Skip to content

Commit

Permalink
add cn language support
Browse files Browse the repository at this point in the history
  • Loading branch information
xubowenhaoren committed Mar 21, 2020
1 parent 8134cb0 commit 95ccf9a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/example/oplifttowake/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">一加抬腕亮屏</string>
<string name="channel_name">OPLiftToWakeChannelName</string>
<string name="switch_lift">抬腕亮屏</string>
<string name="lift_active" >抬腕亮屏已开启</string>
<string name="sensor_found">传感器已匹配,服务就绪</string>
<string name="sensor_not_found">传感器匹配失败</string>
</resources>
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
<string name="app_name">OPLiftToWake</string>
<string name="channel_name">OPLiftToWakeChannelName</string>
<string name="switch_lift">Lift To Wake</string>
<string name="lift_active">Lift to Wake Active</string>
<string name="sensor_found">Sensor found, service ready!</string>
<string name="sensor_not_found">Sensor NOT found!</string>
</resources>

0 comments on commit 95ccf9a

Please sign in to comment.