From 95ccf9ae7911393cbf4b91c6677983d800a2d20b Mon Sep 17 00:00:00 2001 From: bowenxu Date: Sat, 21 Mar 2020 16:23:18 -0700 Subject: [PATCH] add cn language support --- app/build.gradle | 4 ++-- .../main/java/com/example/oplifttowake/DozeService.java | 2 +- .../main/java/com/example/oplifttowake/MainActivity.java | 2 +- app/src/main/java/com/example/oplifttowake/Utils.java | 4 ++-- app/src/main/res/values-zh-rCN/strings.xml | 9 +++++++++ app/src/main/res/values/strings.xml | 3 +++ 6 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/values-zh-rCN/strings.xml diff --git a/app/build.gradle b/app/build.gradle index f5d92be..74fc551 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.example.oplifttowake" minSdkVersion 26 targetSdkVersion 29 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/example/oplifttowake/DozeService.java b/app/src/main/java/com/example/oplifttowake/DozeService.java index 005c496..c4a0c48 100644 --- a/app/src/main/java/com/example/oplifttowake/DozeService.java +++ b/app/src/main/java/com/example/oplifttowake/DozeService.java @@ -39,7 +39,7 @@ public void onCreate() { //如果API在26以上即版本为O则调用startForefround()方法启动服务 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (DEBUG) Log.d(TAG, "Android O detected, starting foreground"); - setForegroundService("LiftToWake", "Lift to Wake Active", + setForegroundService(this.getString(R.string.switch_lift), this.getString(R.string.lift_active), "Lift to Wake Active Channel"); } } diff --git a/app/src/main/java/com/example/oplifttowake/MainActivity.java b/app/src/main/java/com/example/oplifttowake/MainActivity.java index f4d2d8f..ef88a64 100644 --- a/app/src/main/java/com/example/oplifttowake/MainActivity.java +++ b/app/src/main/java/com/example/oplifttowake/MainActivity.java @@ -41,7 +41,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean b) { } else { Utils.stopService(this); } - Toast.makeText(this,"Lift to Wake: "+state,Toast.LENGTH_SHORT).show(); + Toast.makeText(this, this.getString(R.string.switch_lift) + " "+ state,Toast.LENGTH_SHORT).show(); } } diff --git a/app/src/main/java/com/example/oplifttowake/Utils.java b/app/src/main/java/com/example/oplifttowake/Utils.java index 0b271ed..55cee02 100644 --- a/app/src/main/java/com/example/oplifttowake/Utils.java +++ b/app/src/main/java/com/example/oplifttowake/Utils.java @@ -25,12 +25,12 @@ protected static Sensor getSensor(Context context, SensorManager sm, String type for (Sensor sensor : sm.getSensorList(Sensor.TYPE_ALL)) { if (type.equals(sensor.getStringType())) { if (DEBUG) Log.d(TAG, "SENSOR FOUND"); - Toast.makeText(context,"Sensor found, service ready!",Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(R.string.sensor_found),Toast.LENGTH_SHORT).show(); return sensor; } } if (DEBUG) Log.d(TAG, "SENSOR NOT FOUND"); - Toast.makeText(context,"Sensor NOT found",Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(R.string.sensor_not_found),Toast.LENGTH_SHORT).show(); return null; } diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml new file mode 100644 index 0000000..97f8859 --- /dev/null +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -0,0 +1,9 @@ + + + 一加抬腕亮屏 + OPLiftToWakeChannelName + 抬腕亮屏 + 抬腕亮屏已开启 + 传感器已匹配,服务就绪 + 传感器匹配失败 + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4efe925..b046a82 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2,4 +2,7 @@ OPLiftToWake OPLiftToWakeChannelName Lift To Wake + Lift to Wake Active + Sensor found, service ready! + Sensor NOT found!