diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.gitignore b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.gitignore new file mode 100644 index 00000000..37a4eb8b --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +/entry/.preview +.cxx diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/.gitignore b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/compiler.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/compiler.xml new file mode 100644 index 00000000..61a9130c --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/gradle.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/gradle.xml new file mode 100644 index 00000000..b9090f42 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/gradle.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/jarRepositories.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/jarRepositories.xml new file mode 100644 index 00000000..1dfcd020 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/jarRepositories.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/misc.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/misc.xml new file mode 100644 index 00000000..58918f50 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/phone/phoneSettingConfig_-925978332.json b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/phone/phoneSettingConfig_-925978332.json new file mode 100644 index 00000000..f505e6b9 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/phone/phoneSettingConfig_-925978332.json @@ -0,0 +1,25 @@ +{ + "setting": { + "1.0.1": { + "Language": { + "args": { + "Language": "zh-CN" + } + } + } + }, + "frontend": { + "1.0.0": { + "Resolution": { + "args": { + "Resolution": "360*780" + } + }, + "DeviceType": { + "args": { + "DeviceType": "phone" + } + } + } + } +} \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/phone/phoneSettingConfig_1789527875.json b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/phone/phoneSettingConfig_1789527875.json new file mode 100644 index 00000000..f505e6b9 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/phone/phoneSettingConfig_1789527875.json @@ -0,0 +1,25 @@ +{ + "setting": { + "1.0.1": { + "Language": { + "args": { + "Language": "zh-CN" + } + } + } + }, + "frontend": { + "1.0.0": { + "Resolution": { + "args": { + "Resolution": "360*780" + } + }, + "DeviceType": { + "args": { + "DeviceType": "phone" + } + } + } + } +} \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/previewConfig.json b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/previewConfig.json new file mode 100644 index 00000000..3e83069d --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/previewer/previewConfig.json @@ -0,0 +1,12 @@ +{ + "1.0.0": { + "LastPreviewDevice": { + "C:\\Users\\lucifer\\DevEcoStudioProjects\\assignment_app\\entry": [ + "phone" + ], + "C:\\Users\\lucifer\\Desktop\\alpesh_assignment\\assessment\\HarmonyOS\\Day2 Assingment\\Alpesh\\assignment_app\\entry": [ + "phone" + ] + } + } +} \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/vcs.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/vcs.xml new file mode 100644 index 00000000..4fce1d86 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/build.gradle b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/build.gradle new file mode 100644 index 00000000..9ec29b00 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/build.gradle @@ -0,0 +1,37 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +ohos { + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 4 + } +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } + dependencies { + classpath 'com.huawei.ohos:hap:2.4.2.7' + classpath 'com.huawei.ohos:decctest:1.0.0.7' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + jcenter() + } +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/.gitignore b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/.gitignore new file mode 100644 index 00000000..796b96d1 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/.gitignore @@ -0,0 +1 @@ +/build diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/build.gradle b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/build.gradle new file mode 100644 index 00000000..30c5f30b --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.huawei.ohos.hap' +apply plugin: 'com.huawei.ohos.decctest' +ohos { + compileSdkVersion 5 + defaultConfig { + compatibleSdkVersion 4 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13' + ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' +} +decc { + supportType = ['html','xml'] +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/proguard-rules.pro b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/proguard-rules.pro new file mode 100644 index 00000000..f7666e47 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/proguard-rules.pro @@ -0,0 +1 @@ +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/config.json b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/config.json new file mode 100644 index 00000000..1375b2a7 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/config.json @@ -0,0 +1,49 @@ +{ + "app": { + "bundleName": "com.example.assignment_app", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Release" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.assignment_app", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": "com.example.assignment_app.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ] + } +} \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/MainAbility.java b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/MainAbility.java new file mode 100644 index 00000000..8346e010 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/MainAbility.java @@ -0,0 +1,13 @@ +package com.example.assignment_app; + +import com.example.assignment_app.slice.MainAbilitySlice; +import ohos.aafwk.ability.Ability; +import ohos.aafwk.content.Intent; + +public class MainAbility extends Ability { + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setMainRoute(MainAbilitySlice.class.getName()); + } +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/MyApplication.java b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/MyApplication.java new file mode 100644 index 00000000..d9b5646c --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/MyApplication.java @@ -0,0 +1,10 @@ +package com.example.assignment_app; + +import ohos.aafwk.ability.AbilityPackage; + +public class MyApplication extends AbilityPackage { + @Override + public void onInitialize() { + super.onInitialize(); + } +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/Login.java b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/Login.java new file mode 100644 index 00000000..4806f1bb --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/Login.java @@ -0,0 +1,13 @@ +package com.example.assignment_app.slice; + +import com.example.assignment_app.ResourceTable; +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; + +public class Login extends AbilitySlice { + @Override + protected void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_login); + } +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/MainAbilitySlice.java b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/MainAbilitySlice.java new file mode 100644 index 00000000..7e518788 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/MainAbilitySlice.java @@ -0,0 +1,28 @@ +package com.example.assignment_app.slice; + +import com.example.assignment_app.ResourceTable; +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.agp.components.Button; + +public class MainAbilitySlice extends AbilitySlice { + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_ability_main); + Button login = (Button) findComponentById(ResourceTable.Id_login_btn); + Button signup = (Button) findComponentById(ResourceTable.Id_signup_btn); + login.setClickedListener(List -> present(new Login(),new Intent())); + signup.setClickedListener(List -> present(new Signup(),new Intent())); + } + + @Override + public void onActive() { + super.onActive(); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/Signup.java b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/Signup.java new file mode 100644 index 00000000..e24189ee --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/java/com/example/assignment_app/slice/Signup.java @@ -0,0 +1,213 @@ +package com.example.assignment_app.slice; + +import com.example.assignment_app.ResourceTable; +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.agp.components.*; +import ohos.agp.window.dialog.ToastDialog; + + +public class Signup extends AbilitySlice { + @Override + protected void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_signup); + TextField firstname = (TextField) findComponentById(ResourceTable.Id_firstname); + TextField lastname = (TextField) findComponentById(ResourceTable.Id_lastname); + TextField email = (TextField) findComponentById(ResourceTable.Id_email); + TextField password = (TextField) findComponentById(ResourceTable.Id_password); + TextField mobile = (TextField) findComponentById(ResourceTable.Id_mobile); + RadioButton male = (RadioButton) findComponentById(ResourceTable.Id_gender_male); + RadioButton female = (RadioButton) findComponentById(ResourceTable.Id_gender_female); + Button signup = (Button) findComponentById(ResourceTable.Id_signup_btn); + Text er1 = (Text) findComponentById(ResourceTable.Id_er1); + Text er2 = (Text) findComponentById(ResourceTable.Id_er2); + Text er3 = (Text) findComponentById(ResourceTable.Id_er3); + Text er4 = (Text) findComponentById(ResourceTable.Id_er4); + Text er5 = (Text) findComponentById(ResourceTable.Id_er5); + Text er6 = (Text) findComponentById(ResourceTable.Id_er6); + + // All field cleared + firstname.setText(""); + lastname.setText(""); + email.setText(""); + password.setText(""); + mobile.setText(""); + male.setChecked(false); + female.setChecked(false); + er1.setVisibility(Component.INVISIBLE); + er2.setVisibility(Component.INVISIBLE); + er3.setVisibility(Component.INVISIBLE); + er4.setVisibility(Component.INVISIBLE); + er5.setVisibility(Component.INVISIBLE); + er6.setVisibility(Component.INVISIBLE); + + firstname.setFocusChangedListener((component, isFocused) -> { + String name = firstname.getText(); + if (!isFocused) { + if (!name.matches(getString(ResourceTable.String_name_regex))) { + + er1.setVisibility(Component.VISIBLE); + } + else + { + er1.setVisibility(Component.INVISIBLE); + } + + } + }); + + male.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + female.setChecked(false); + } + }); + + female.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + male.setChecked(false); + } + }); + + lastname.setFocusChangedListener((component, isFocused) -> { + String name = lastname.getText(); + if (!isFocused) { + if (!name.matches(getString(ResourceTable.String_name_regex))) { + + + er2.setVisibility(Component.VISIBLE); + } + else + { + + er2.setVisibility(Component.INVISIBLE); + } + + } + }); + + + email.setFocusChangedListener((component, isFocused) -> { + String name = email.getText(); + if (!isFocused) { + if (!name.matches(getString(ResourceTable.String_email_regex))) { + + er3.setVisibility(Component.VISIBLE); + } + else + { + + er3.setVisibility(Component.INVISIBLE); + } + + } + }); + + password.setFocusChangedListener((component, isFocused) -> { + String name = password.getText(); + if (!isFocused) { + if (!name.matches(getString(ResourceTable.String_pass_regex))) { + + er4.setVisibility(Component.VISIBLE); + } + else + { + + er4.setVisibility(Component.INVISIBLE); + } + + } + }); + + mobile.setFocusChangedListener((component, isFocused) -> { + String name = mobile.getText(); + if (!isFocused) { + if (!name.matches(getString(ResourceTable.String_mobile_regex))) { + + + er5.setVisibility(Component.VISIBLE); + } + else + { + + er5.setVisibility(Component.INVISIBLE); + } + + } + }); + + + signup.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + if ((!male.isChecked()) && (!female.isChecked()) ) + { + er6.setVisibility(Component.VISIBLE); + } + else + { + er6.setVisibility(Component.INVISIBLE); + } + + // checking if focus was on some feild and signup btn pressed, verifying that data format + // + if (firstname.getText().matches(getString(ResourceTable.String_name_regex))) { + er1.setVisibility(Component.INVISIBLE); + } + else + { + er1.setVisibility(Component.VISIBLE); + } + if (lastname.getText().matches(getString(ResourceTable.String_name_regex))) { + + er2.setVisibility(Component.INVISIBLE); + }else + { + er2.setVisibility(Component.VISIBLE); + } + if (email.getText().matches(getString(ResourceTable.String_email_regex))) { + + er3.setVisibility(Component.INVISIBLE); + }else + { + er3.setVisibility(Component.VISIBLE); + } + if (password.getText().matches(getString(ResourceTable.String_pass_regex))) { + + er4.setVisibility(Component.INVISIBLE); + }else + { + er4.setVisibility(Component.VISIBLE); + } + if (mobile.getText().matches(getString(ResourceTable.String_mobile_regex))) { + + er5.setVisibility(Component.INVISIBLE); + }else + { + er5.setVisibility(Component.VISIBLE); + } + + + // Checking If anything empty + + if(email.getText().equals("") || password.getText().equals("") || firstname.getText().equals("") || lastname.getText().equals("") || mobile.getText().equals("")) + { + new ToastDialog(getContext()).setText("Enter All Data").show(); + //present(new Signup(), new Intent()); + } + else if(er1.getVisibility()==0 || er2.getVisibility()==0 || er3.getVisibility()==0 || er4.getVisibility()==0 || er5.getVisibility()==0 || er6.getVisibility()==0) + { + new ToastDialog(getContext()).setText("Enter Correct data and gender").show(); + } + + else { + new ToastDialog(getContext()).setText("Verified").show(); + present(new MainAbilitySlice(), new Intent()); + } + } + }); + } + +} diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/element/string.json b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/element/string.json new file mode 100644 index 00000000..18fcdf58 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/element/string.json @@ -0,0 +1,52 @@ +{ + "string": [ + { + "name": "app_name", + "value": "assignment_app" + }, + { + "name": "mainability_description", + "value": "Java_Phone_Empty Feature Ability" + }, + { + "name": "mainability_HelloWorld", + "value": "Hello World" + }, + { + "name": "persondataability_description", + "value": "hap sample empty provider" + }, + { + "name": "pass_regex", + "value": "^.{5,}$" + }, + { + "name": "name_regex", + "value":"^[a-zA-Z]+$" + }, + { + "name": "email_regex", + "value": "^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$" + }, + { + "name": "mobile_regex", + "value": "^[0-9]{10}$" + }, + { + "name": "alias", + "value": "Data" + }, + { + "name": "db_name", + "value": "Data.db" + }, + { + "name": "male", + "value": "Male" + }, + { + "name": "female", + "value": "Female" + } + ] +} \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/graphic/background_ability_main.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/graphic/background_ability_main.xml new file mode 100644 index 00000000..c0c0a3df --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/graphic/background_ability_main.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/layout/ability_main.xml b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/layout/ability_main.xml new file mode 100644 index 00000000..8dc72320 --- /dev/null +++ b/HarmonyOS/Day2 Assingment/Alpesh/assignment_app/entry/src/main/resources/base/layout/ability_main.xml @@ -0,0 +1,53 @@ + + + + + + +