diff --git a/ability/Preferences/README_zh.md b/ability/Preferences/README_zh.md deleted file mode 100644 index 6f20da4954b183d0edcdbcdce874247012ca3119..0000000000000000000000000000000000000000 --- a/ability/Preferences/README_zh.md +++ /dev/null @@ -1,7 +0,0 @@ -# 偏好设置(JS) - -- 轻量级偏好数据库(Preference)提供偏好型数据库的操作类,应用通过这些操作类完成数据库操作。 - - 本示例通过 Preferences 保存偏好设置项,来演示如何创建、删除、更新和查询应用程序偏好数据。 - - 主要实现了登录偏好数据存取及主页面背景色偏好数据存取。 diff --git a/ability/Preferences/entry/src/main/js/default/i18n/en-US.json b/ability/Preferences/entry/src/main/js/default/i18n/en-US.json deleted file mode 100644 index 92f4d8c85384ad6d9be6fba21309757eeb5bb149..0000000000000000000000000000000000000000 --- a/ability/Preferences/entry/src/main/js/default/i18n/en-US.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Strings": { - "login_screen_uri" : "pages/login/login", - "main_screen_uri" : "pages/main/main" - }, - "Files": { - } -} \ No newline at end of file diff --git a/ability/Preferences/screenshots/device/background_color_from_preference.png b/ability/Preferences/screenshots/device/background_color_from_preference.png deleted file mode 100644 index 7ec4b07bb0c557df86e90be28ddc0d5f20e2d987..0000000000000000000000000000000000000000 Binary files a/ability/Preferences/screenshots/device/background_color_from_preference.png and /dev/null differ diff --git a/ability/Preferences/screenshots/device/default_background.png b/ability/Preferences/screenshots/device/default_background.png deleted file mode 100644 index feb19c427e322a0a5f1daf098ea3383881e0b614..0000000000000000000000000000000000000000 Binary files a/ability/Preferences/screenshots/device/default_background.png and /dev/null differ diff --git a/ability/Preferences/screenshots/device/login_screen.png b/ability/Preferences/screenshots/device/login_screen.png deleted file mode 100644 index 54f9914b7cc40eb85d3dd7e49bc1c060f5729acb..0000000000000000000000000000000000000000 Binary files a/ability/Preferences/screenshots/device/login_screen.png and /dev/null differ diff --git a/ability/Preferences/screenshots/device/splash_screen.png b/ability/Preferences/screenshots/device/splash_screen.png deleted file mode 100644 index 697593f4a8ab540e8e4a42389dd7ef7e43a62a4d..0000000000000000000000000000000000000000 Binary files a/ability/Preferences/screenshots/device/splash_screen.png and /dev/null differ diff --git a/data/Preferences/README.md b/data/Preferences/README.md new file mode 100644 index 0000000000000000000000000000000000000000..3bc1460974563b54f79762d4265c281d0bab6a71 --- /dev/null +++ b/data/Preferences/README.md @@ -0,0 +1,16 @@ +# Lightweight Preferences Database + +### Introduction + +The lightweight **Preferences** database supports lightweight key-value operations and allows local apps to store a small amount of data. This sample shows how to create, delete, update, and query preferences data in an app by using **Preferences**. It mainly covers the preferences data for the login and home screen background color. + +### Usage + +1. On the startup screen of your app, choose not to display this screen again. After this preference setting is saved, the app should skip the startup screen and directly display the simulated login screen the next time it starts up. +2. On the simulated login screen, enter the user name and password to log in. The app will automatically remember the login status so that no login is required in future. +3. On the home screen, apply a background color by selecting the corresponding color. Clear preferences settings to clear the saved background color. + +### Constraints + +This sample can only be run on large-system devices. + diff --git a/data/Preferences/README_zh.md b/data/Preferences/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..6f6623c5e1cd14916d692f35d7992aadb9ed50dc --- /dev/null +++ b/data/Preferences/README_zh.md @@ -0,0 +1,16 @@ +# 轻量级偏好数据库 + +### 简介 + +轻量级偏好数据库主要提供轻量级Key-Value操作,支持本地应用存储少量数据。本示例通过 Preferences 创建、删除、更新和查询应用程序偏好数据,主要实现了登录页面偏好数据存取及主页面背景色偏好数据存取。 + +### 使用说明 + +1. 启动页面勾选不再显示,保存该偏好数据,下次启动应用不再显示该页面,直接进入模拟登录页面。 +2. 模拟登录页面输入用户名和密码,点击登录跳转到主页面,自动保存登录状态,下次不再显示模拟登录页面。 +3. 主页面点击应用背景色后,再点击对应颜色可保存背景色,点击清除偏好设置,清除已保存的背景色。 + +### 约束与限制 + +本示例支持在大型系统上运行。 + diff --git a/ability/Preferences/build.gradle b/data/Preferences/build.gradle similarity index 100% rename from ability/Preferences/build.gradle rename to data/Preferences/build.gradle diff --git a/ability/Preferences/entry/build.gradle b/data/Preferences/entry/build.gradle similarity index 100% rename from ability/Preferences/entry/build.gradle rename to data/Preferences/entry/build.gradle diff --git a/ability/Preferences/entry/package.json b/data/Preferences/entry/package.json similarity index 100% rename from ability/Preferences/entry/package.json rename to data/Preferences/entry/package.json diff --git a/ability/Preferences/entry/src/main/config.json b/data/Preferences/entry/src/main/config.json similarity index 100% rename from ability/Preferences/entry/src/main/config.json rename to data/Preferences/entry/src/main/config.json diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/MainAbility.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/MainAbility.java similarity index 100% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/MainAbility.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/MainAbility.java diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/PreferencesInternalAbility.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/PreferencesInternalAbility.java similarity index 89% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/PreferencesInternalAbility.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/PreferencesInternalAbility.java index 5679b599d62c2ad31d3861879c369565b488be87..701f3f044c2d018065e8309992b28e1791c05b89 100644 --- a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/PreferencesInternalAbility.java +++ b/data/Preferences/entry/src/main/java/ohos/samples/preferences/PreferencesInternalAbility.java @@ -73,8 +73,6 @@ public class PreferencesInternalAbility extends AceInternalAbility { private Preferences preferences; - private Set remoteObjectHandlers = new HashSet(); - /** * bundleName,abilityName */ @@ -127,14 +125,14 @@ public class PreferencesInternalAbility extends AceInternalAbility { private void saveSplashState(MessageParcel data, MessageParcel reply) { SplashEntry entry = ZSONObject.stringToClass(data.readString(), SplashEntry.class); saveSplashShowState(entry.getCheckState()); - Map saveResult = new HashMap(); + Map saveResult = new HashMap<>(); saveResult.put(Constants.CODE, SUCCESS); saveResult.put(Constants.DATA, Constants.SUCCESS); reply.writeString(ZSONObject.toZSONString(saveResult)); } private void getSplashState(MessageParcel reply) { - Map clearResult = new HashMap(); + Map clearResult = new HashMap<>(); clearResult.put(Constants.CODE, SUCCESS); clearResult.put(Constants.DATA, getSplashStateFromPref()); reply.writeString(ZSONObject.toZSONString(clearResult)); @@ -142,21 +140,21 @@ public class PreferencesInternalAbility extends AceInternalAbility { private void clearPreferences(MessageParcel reply) { clear(); - Map clearResult = new HashMap(); + Map clearResult = new HashMap<>(); clearResult.put(Constants.CODE, SUCCESS); clearResult.put(Constants.DATA, getBackgroundColorFromPref()); reply.writeString(ZSONObject.toZSONString(clearResult)); } private void checkLoginStatus(MessageParcel reply) { - Map loginResult = new HashMap(); + Map loginResult = new HashMap<>(); loginResult.put(Constants.CODE, SUCCESS); loginResult.put(Constants.DATA, getLoginStatus()); reply.writeString(ZSONObject.toZSONString(loginResult)); } private void getBackgroundColor(MessageParcel reply) { - Map bgResult = new HashMap(); + Map bgResult = new HashMap<>(); bgResult.put(Constants.CODE, SUCCESS); bgResult.put(Constants.DATA, getBackgroundColorFromPref()); reply.writeString(ZSONObject.toZSONString(bgResult)); @@ -165,15 +163,16 @@ public class PreferencesInternalAbility extends AceInternalAbility { private void saveLogin(MessageParcel data, MessageParcel reply) { LoginEntry entry = ZSONObject.stringToClass(data.readString(), LoginEntry.class); saveLoginStatus(entry.getLoginState()); - Map saveResult = new HashMap(); + Map saveResult = new HashMap<>(); saveResult.put(Constants.CODE, getLoginStatus() == 1 ? SUCCESS : ERROR); saveResult.put(Constants.DATA, getLoginStatus()); reply.writeString(ZSONObject.toZSONString(saveResult)); } private void subscribe(MessageParcel data, MessageParcel reply, MessageOption option) { + Set remoteObjectHandlers = new HashSet<>(); remoteObjectHandlers.add(data.readRemoteObject()); - Map subscribeResult = new HashMap(); + Map subscribeResult = new HashMap<>(); subscribeResult.put(Constants.CODE, SUCCESS); subscribeResult.put(Constants.DATA, Constants.SUCCESS); if (option.getFlags() == MessageOption.TF_SYNC) { @@ -202,7 +201,7 @@ public class PreferencesInternalAbility extends AceInternalAbility { private void saveBgColor(MessageParcel data, MessageParcel reply) { ColorEntry colorEntry = ZSONObject.stringToClass(data.readString(), ColorEntry.class); saveBackgroundColorInPref(colorEntry.getAppliedColor()); - Map colorResult = new HashMap(); + Map colorResult = new HashMap<>(); colorResult.put(Constants.CODE, getBackgroundColorFromPref() != null ? SUCCESS : ERROR); colorResult.put(Constants.DATA, getBackgroundColorFromPref()); reply.writeString(ZSONObject.toZSONString(colorResult)); @@ -260,13 +259,9 @@ public class PreferencesInternalAbility extends AceInternalAbility { private void onRegister(AceAbility abilityContext) { this.mContext = abilityContext; - AceInternalAbilityHandler abilityHandler = new AceInternalAbilityHandler() { - @Override - public boolean onRemoteRequest(int code, MessageParcel data, MessageParcel reply, MessageOption option) - throws RemoteException { - LogUtil.debug(TAG, "onRemoteRequest received request"); - return remoteRequest(code, data, reply, option); - } + AceInternalAbilityHandler abilityHandler = (code, data, reply, option) -> { + LogUtil.debug(TAG, "onRemoteRequest received request"); + return remoteRequest(code, data, reply, option); }; this.setInternalAbilityHandler(abilityHandler, abilityContext); } diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/entities/ColorEntry.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/entities/ColorEntry.java similarity index 100% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/entities/ColorEntry.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/entities/ColorEntry.java diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/entities/LoginEntry.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/entities/LoginEntry.java similarity index 100% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/entities/LoginEntry.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/entities/LoginEntry.java diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/entities/SplashEntry.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/entities/SplashEntry.java similarity index 100% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/entities/SplashEntry.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/entities/SplashEntry.java diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/utils/Constants.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/utils/Constants.java similarity index 100% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/utils/Constants.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/utils/Constants.java diff --git a/ability/Preferences/entry/src/main/java/ohos/samples/preferences/utils/LogUtil.java b/data/Preferences/entry/src/main/java/ohos/samples/preferences/utils/LogUtil.java similarity index 100% rename from ability/Preferences/entry/src/main/java/ohos/samples/preferences/utils/LogUtil.java rename to data/Preferences/entry/src/main/java/ohos/samples/preferences/utils/LogUtil.java diff --git a/ability/Preferences/entry/src/main/js/default/app.js b/data/Preferences/entry/src/main/js/default/app.js similarity index 100% rename from ability/Preferences/entry/src/main/js/default/app.js rename to data/Preferences/entry/src/main/js/default/app.js diff --git a/ability/Preferences/entry/src/main/js/default/common/icon.png b/data/Preferences/entry/src/main/js/default/common/icon.png similarity index 100% rename from ability/Preferences/entry/src/main/js/default/common/icon.png rename to data/Preferences/entry/src/main/js/default/common/icon.png diff --git a/data/Preferences/entry/src/main/js/default/common/login.png b/data/Preferences/entry/src/main/js/default/common/login.png new file mode 100644 index 0000000000000000000000000000000000000000..0bc8cb27e9efc965f2a82bc16172bb6606b0e3fe Binary files /dev/null and b/data/Preferences/entry/src/main/js/default/common/login.png differ diff --git a/ability/Preferences/entry/src/main/js/default/common/logo.png b/data/Preferences/entry/src/main/js/default/common/logo.png similarity index 100% rename from ability/Preferences/entry/src/main/js/default/common/logo.png rename to data/Preferences/entry/src/main/js/default/common/logo.png diff --git a/data/Preferences/entry/src/main/js/default/common/splash.png b/data/Preferences/entry/src/main/js/default/common/splash.png new file mode 100644 index 0000000000000000000000000000000000000000..327b890126dc9e7d20e49082deaa4422c809b916 Binary files /dev/null and b/data/Preferences/entry/src/main/js/default/common/splash.png differ diff --git a/data/Preferences/entry/src/main/js/default/i18n/en-US.json b/data/Preferences/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..ccd823cb12c7b3043209def153d3353d908c7980 --- /dev/null +++ b/data/Preferences/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,17 @@ +{ + "Strings": { + "login_screen_uri": "pages/login/login", + "main_screen_uri": "pages/main/main", + "no_show_again": "Don't show again", + "user_name": "User Name", + "password": "Password", + "login": "Login", + "apply_background_color": "Apply Background Color", + "clear_preferences": "Clear Preferences", + "red": "Red", + "green": "Green", + "blue": "Blue", + "pink": "Pink", + "orange": "Orange" + } +} \ No newline at end of file diff --git a/data/Preferences/entry/src/main/js/default/i18n/zh-CN.json b/data/Preferences/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..1bdc64995ef0a18755c7b0a94f6ea674578bf3db --- /dev/null +++ b/data/Preferences/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,17 @@ +{ + "Strings": { + "login_screen_uri": "pages/login/login", + "main_screen_uri": "pages/main/main", + "no_show_again": "不再显示", + "user_name": "用户名", + "password": "密码", + "login": "登录", + "apply_background_color": "应用背景色", + "clear_preferences": "清除偏好设置", + "red": "红色", + "green": "绿色", + "blue": "蓝色", + "pink": "粉红色", + "orange": "橙色" + } +} diff --git a/ability/Preferences/entry/src/main/js/default/pages/login/login.css b/data/Preferences/entry/src/main/js/default/pages/login/login.css similarity index 81% rename from ability/Preferences/entry/src/main/js/default/pages/login/login.css rename to data/Preferences/entry/src/main/js/default/pages/login/login.css index bd577a91c33e33566a69cdc867fb0cbe279b250c..f838a6e445e2a9e4f1f2eecb932780b995d49a44 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/login/login.css +++ b/data/Preferences/entry/src/main/js/default/pages/login/login.css @@ -23,20 +23,18 @@ .input-text { width: 80%; - margin-left: 50px; - margin-bottom: 20px; + height: 80px; + margin-top: 16px; + margin-bottom: 16px; placeholder-color: #b3b3b3; - height: 100px; } .btn { - width: 60%; - margin-left: 50px; - height: 100px; - background-color: #ff3366; + width: 80%; + height: 80px; text-color: white; - margin-top: 30px; - margin-bottom: 200px; + margin-top: 16px; + margin-bottom: 16px; } .img { diff --git a/ability/Preferences/entry/src/main/js/default/pages/login/login.hml b/data/Preferences/entry/src/main/js/default/pages/login/login.hml similarity index 59% rename from ability/Preferences/entry/src/main/js/default/pages/login/login.hml rename to data/Preferences/entry/src/main/js/default/pages/login/login.hml index b95aeea989184aae60ac3299546f089a021c3113..a42b375bfb88cd3e5143203e645d0f36a7e949d1 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/login/login.hml +++ b/data/Preferences/entry/src/main/js/default/pages/login/login.hml @@ -14,8 +14,10 @@ -->
- - - - + + + + +
\ No newline at end of file diff --git a/ability/Preferences/entry/src/main/js/default/pages/login/login.js b/data/Preferences/entry/src/main/js/default/pages/login/login.js similarity index 31% rename from ability/Preferences/entry/src/main/js/default/pages/login/login.js rename to data/Preferences/entry/src/main/js/default/pages/login/login.js index f53d166eb21abe7c6d167cd39d8ec1c74c93fcc6..d51e3f120aa77e0aac9057d1492a3e800c48f39d 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/login/login.js +++ b/data/Preferences/entry/src/main/js/default/pages/login/login.js @@ -17,79 +17,75 @@ import prompt from "@system.prompt"; import router from "@system.router"; const injectRef = Object.getPrototypeOf(global) || global; + injectRef.regeneratorRuntime = require("@babel/runtime/regenerator"); export default { - data: { - userID: "", - password: "" - }, - - updateUserID: function(e) { - var that = this; - that.userID = e.value; - }, + data: { + userID: "", + password: "" + }, + updateUserID: function (e) { + var that = this; + that.userID = e.value; + }, + updatePassword: function (e) { + var that = this; + that.password = e.value; + }, + login: function () { + var that = this; + if (that.userID && that.password) { + that.saveLoginStatus(); + } else { + console.info("Login : Invalid userID and Password"); + that.showToast("Please enter a valid userID and Password"); + } + }, + showToast: function (msg) { + prompt.showToast({ + message: msg, + duration: "3000" + }); + }, - updatePassword: function(e) { - var that = this; - that.password = e.value; - }, - - login: function() { - var that = this; - if(that.userID && that.password){ - that.saveLoginStatus(); - }else{ - console.info("Login : Invalid userID and Password"); - that.showToast("Please enter a valid userID and Password"); - } - }, - - showToast: function(msg) { - prompt.showToast({ - message: msg, - duration: "3000" - }); - }, - - /** +/** * save the login status in preference */ - saveLoginStatus: async function() { - try { - var that = this; - var actionData = {}; - actionData.userId = that.userID; - actionData.password = that.password; - actionData.loginState = 1; + saveLoginStatus: async function() { + try { + var that = this; + var actionData = {}; + actionData.userId = that.userID; + actionData.password = that.password; + actionData.loginState = 1; - var action = {}; - action.bundleName = "ohos.samples.preferences"; - action.abilityName = "PreferencesInternalAbility"; - action.messageCode = 1004; - action.data = actionData; - action.abilityType = 1; - action.syncOption = 0; - var result = await FeatureAbility.callAbility(action); - console.info("Login : result for login : " + result); - var resultJson = JSON.parse(result); - if (resultJson.code == 0) { - that.gotoMain(); - } else { - console.error("Login : error while login"); - that.showToast( - "Something went wrong. Please try again." - ); - } - } catch (pluginError) { - console.error("Login : Plugin Error : " + pluginError); + var action = {}; + action.bundleName = "ohos.samples.preferences"; + action.abilityName = "PreferencesInternalAbility"; + action.messageCode = 1004; + action.data = actionData; + action.abilityType = 1; + action.syncOption = 0; + var result = await FeatureAbility.callAbility(action); + console.info("Login : result for login : " + result); + var resultJson = JSON.parse(result); + if (resultJson.code == 0) { + that.gotoMain(); + } else { + console.error("Login : error while login"); + that.showToast( + "Something went wrong. Please try again." + ); + } + } catch (pluginError) { + console.error("Login : Plugin Error : " + pluginError); + } + }, + gotoMain: function () { + var that = this; + router.replace({ + uri: that.$t("Strings.main_screen_uri") + }); } - }, - - gotoMain: function() { - var that = this; - router.replace({ - uri: that.$t("Strings.main_screen_uri") - }); - } }; diff --git a/ability/Preferences/entry/src/main/js/default/pages/main/main.css b/data/Preferences/entry/src/main/js/default/pages/main/main.css similarity index 79% rename from ability/Preferences/entry/src/main/js/default/pages/main/main.css rename to data/Preferences/entry/src/main/js/default/pages/main/main.css index 913927d80a9d2bac2b8741e09174954fd86c6644..7b8b2313350179d70ed11c5013853634c2f3f089 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/main/main.css +++ b/data/Preferences/entry/src/main/js/default/pages/main/main.css @@ -20,7 +20,7 @@ } .list-container { - height: 40%; + height: 45%; } .list { @@ -29,31 +29,30 @@ .list-item { align-items: center; - margin-top: 10px; - margin-bottom: 10px; - margin-left: 30px; - margin-right: 30px; + margin-top: 16px; + margin-bottom: 16px; + margin-left: 50px; + margin-right: 50px; padding: 20px; flex-direction: column; background-color: #ffffff; - border-radius: 10px; + border-radius: 40px; border: 1px solid; border-color: black; } .btn { - font-size: 30px; color: white; font-size: 30px; text-align: center; } .btn-container { - background-color: #1976D2; - margin-top: 20px; - height: 120px; + background-color: #0000ff; + margin-top: 16px; + margin-bottom: 16px; + height: 80px; width: 80%; - padding-top: 20px; - padding-bottom: 20px; + border-radius: 40px; justify-content: center; } \ No newline at end of file diff --git a/ability/Preferences/entry/src/main/js/default/pages/main/main.hml b/data/Preferences/entry/src/main/js/default/pages/main/main.hml similarity index 46% rename from ability/Preferences/entry/src/main/js/default/pages/main/main.hml rename to data/Preferences/entry/src/main/js/default/pages/main/main.hml index 82806df4abe76dd74f97c786802de0e754e1cf0f..d76f039cc94c6a51ad219ddd2c041e5fae8d186c 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/main/main.hml +++ b/data/Preferences/entry/src/main/js/default/pages/main/main.hml @@ -13,21 +13,22 @@ limitations under the License. --> -
+
-
- - - {{$item.colorName}} - - -
+
+ + + {{ $item.colorName }} + + +
-
- Apply Background Color -
-
- Clear Preferences +
+ {{ $t('Strings.apply_background_color') }} +
+
+ {{ $t('Strings.clear_preferences') }}
diff --git a/ability/Preferences/entry/src/main/js/default/pages/main/main.js b/data/Preferences/entry/src/main/js/default/pages/main/main.js similarity index 90% rename from ability/Preferences/entry/src/main/js/default/pages/main/main.js rename to data/Preferences/entry/src/main/js/default/pages/main/main.js index a78c63ed5603ec25984237da622390c3f9258b3b..cd7fe330e8dc7d47c0d532ffcf89c95d753817c5 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/main/main.js +++ b/data/Preferences/entry/src/main/js/default/pages/main/main.js @@ -14,7 +14,6 @@ */ import prompt from "@system.prompt"; -import router from "@system.router"; const injectRef = Object.getPrototypeOf(global) || global; @@ -27,27 +26,27 @@ export default { tempVar: true, colorsList: [ { - colorName: "Red", + colorName: "", backgroundcolor: "#ff6666", textColor: "#ff0000" }, { - colorName: "Green", + colorName: "", backgroundcolor: "#c1ff80", textColor: "#336600" }, { - colorName: "Blue", + colorName: "", backgroundcolor: "#9999ff", textColor: "#1a1aff" }, { - colorName: "Pink", + colorName: "", backgroundcolor: "#ff99ff", textColor: "#e600e6" }, { - colorName: "Orange", + colorName: "", backgroundcolor: "#ffcc80", textColor: "#ff9900" } @@ -55,6 +54,10 @@ export default { }, onInit() { var that = this; + var arr = [that.$t('Strings.red'), that.$t('Strings.green'), that.$t('Strings.blue'), that.$t('Strings.pink'), that.$t('Strings.orange')]; + for (var k = 0; k < this.colorsList.length; k++) { + this.colorsList[k].colorName = arr[k]; + } if (that.lastSelectedColor) { that.appliedColor = that.lastSelectedColor; console.info("Main : onInit : backgroundColor updated to " + that.lastSelectedColor); @@ -131,7 +134,7 @@ export default { result); var resultJson = JSON.parse(result); if (resultJson.code == 0) { - that.appliedColor = resultJson.data; + that.appliedColor = resultJson.data; that.showToast("Clear Preferences Success"); } else { console.error("Main : Clear Preferences Error "); diff --git a/ability/Preferences/entry/src/main/js/default/pages/splash/splash.css b/data/Preferences/entry/src/main/js/default/pages/splash/splash.css similarity index 100% rename from ability/Preferences/entry/src/main/js/default/pages/splash/splash.css rename to data/Preferences/entry/src/main/js/default/pages/splash/splash.css diff --git a/ability/Preferences/entry/src/main/js/default/pages/splash/splash.hml b/data/Preferences/entry/src/main/js/default/pages/splash/splash.hml similarity index 79% rename from ability/Preferences/entry/src/main/js/default/pages/splash/splash.hml rename to data/Preferences/entry/src/main/js/default/pages/splash/splash.hml index 2798cfe2815ca41762b03b95dae0b9a428659fcc..87551b416e54b353983c6097e52680fb96b2adcd 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/splash/splash.hml +++ b/data/Preferences/entry/src/main/js/default/pages/splash/splash.hml @@ -15,10 +15,10 @@
- +
- - Don't show again + + {{ $t('Strings.no_show_again') }}
\ No newline at end of file diff --git a/ability/Preferences/entry/src/main/js/default/pages/splash/splash.js b/data/Preferences/entry/src/main/js/default/pages/splash/splash.js similarity index 97% rename from ability/Preferences/entry/src/main/js/default/pages/splash/splash.js rename to data/Preferences/entry/src/main/js/default/pages/splash/splash.js index 0db8ea871cf1d0f1f52b938cdfccfe02cf4b6837..a1ef85c2b015e99d45810c3035885c06a64313c6 100644 --- a/ability/Preferences/entry/src/main/js/default/pages/splash/splash.js +++ b/data/Preferences/entry/src/main/js/default/pages/splash/splash.js @@ -13,7 +13,6 @@ * limitations under the License. */ -import prompt from "@system.prompt"; import router from "@system.router"; const injectRef = Object.getPrototypeOf(global) || global; @@ -84,7 +83,7 @@ export default { try { console.info("Splash : Timer started"); var action = that.setAction(1002); - var result = await FeatureAbility.subscribeAbilityEvent(action,function (timerResult) { + var result = await FeatureAbility.subscribeAbilityEvent(action, function (timerResult) { console.info("Splash : Timer completed timerResult = " + timerResult); this.eventData = JSON.stringify(timerResult.data); }); @@ -161,7 +160,7 @@ export default { setTimeout(function () { //your codes that.startTimer(); - },3000); + }, 3000); } } else { console.error("Splash : error while getting login status"); @@ -170,11 +169,11 @@ export default { console.error("Splash : checkShowSplash Plugin Error" + pluginError); } }, - onChanged: async function (obj) { + onChanged: async function (checked) { try { var that = this; var actionData = {}; - actionData.checkState = obj.checked ? 1: 0; + actionData.checkState = checked ? 1 : 0; var action = {}; action.bundleName = "ohos.samples.preferences"; action.abilityName = "PreferencesInternalAbility"; @@ -194,6 +193,4 @@ export default { console.error("Splash : onChanged Plugin Error" + pluginError); } } -} - -; +}; diff --git a/ability/Preferences/entry/src/main/resources/base/element/string.json b/data/Preferences/entry/src/main/resources/base/element/string.json similarity index 100% rename from ability/Preferences/entry/src/main/resources/base/element/string.json rename to data/Preferences/entry/src/main/resources/base/element/string.json diff --git a/ability/Preferences/entry/src/main/resources/base/media/icon.png b/data/Preferences/entry/src/main/resources/base/media/icon.png similarity index 100% rename from ability/Preferences/entry/src/main/resources/base/media/icon.png rename to data/Preferences/entry/src/main/resources/base/media/icon.png diff --git a/data/Preferences/screenshots/device/apply_background_color.png b/data/Preferences/screenshots/device/apply_background_color.png new file mode 100644 index 0000000000000000000000000000000000000000..55c7a44c333151807b2838e4d3a7e29f31743da8 Binary files /dev/null and b/data/Preferences/screenshots/device/apply_background_color.png differ diff --git a/data/Preferences/screenshots/device/login.png b/data/Preferences/screenshots/device/login.png new file mode 100644 index 0000000000000000000000000000000000000000..b707d10528803fba7d2cff3b235dfc591efacec0 Binary files /dev/null and b/data/Preferences/screenshots/device/login.png differ diff --git a/data/Preferences/screenshots/device/main.png b/data/Preferences/screenshots/device/main.png new file mode 100644 index 0000000000000000000000000000000000000000..4022eb02e75cb54379d6c21a23fe50bbb152205f Binary files /dev/null and b/data/Preferences/screenshots/device/main.png differ diff --git a/data/Preferences/screenshots/device/splash.png b/data/Preferences/screenshots/device/splash.png new file mode 100644 index 0000000000000000000000000000000000000000..e02d8793c4b15261a3566b28604a7bb7601b2a99 Binary files /dev/null and b/data/Preferences/screenshots/device/splash.png differ diff --git a/ability/Preferences/settings.gradle b/data/Preferences/settings.gradle similarity index 100% rename from ability/Preferences/settings.gradle rename to data/Preferences/settings.gradle