Commit 0aa4d5d6 by zhengnw@sobot.com

widget 1.0.8 baseactivity 修改国际化语言

parent fedd3d93
...@@ -6,7 +6,7 @@ android { ...@@ -6,7 +6,7 @@ android {
compileSdkVersion 33 compileSdkVersion 33
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 17
} }
} }
......
...@@ -13,7 +13,7 @@ ext { ...@@ -13,7 +13,7 @@ ext {
PUBLISH_GROUP_ID = "com.sobot.library" //项目包名 PUBLISH_GROUP_ID = "com.sobot.library" //项目包名
PUBLISH_ARTIFACT_ID = 'widget' //项目名 PUBLISH_ARTIFACT_ID = 'widget' //项目名
// PUBLISH_ARTIFACT_ID = 'widget_x' //项目名 // PUBLISH_ARTIFACT_ID = 'widget_x' //项目名
PUBLISH_VERSION = '1.0.8' //版本号 PUBLISH_VERSION = '1.0.9' //版本号
} }
......
...@@ -26,7 +26,6 @@ import android.widget.LinearLayout; ...@@ -26,7 +26,6 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import com.sobot.utils.SobotLogUtils;
import com.sobot.utils.SobotSharedPreferencesUtil; import com.sobot.utils.SobotSharedPreferencesUtil;
import com.sobot.utils.SobotSystemUtils; import com.sobot.utils.SobotSystemUtils;
import com.sobot.widget.R; import com.sobot.widget.R;
...@@ -56,6 +55,7 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -56,6 +55,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
protected File cameraFile; protected File cameraFile;
//权限回调 //权限回调
public SobotPermissionListener permissionListener; public SobotPermissionListener permissionListener;
private int initMode;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
...@@ -63,6 +63,7 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -63,6 +63,7 @@ public abstract class SobotBaseActivity extends FragmentActivity {
//修改国际化语言 //修改国际化语言
changeAppLanguage(); changeAppLanguage();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
initMode = getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
if (!SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) { if (!SobotWidgetApi.getSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);//竖屏 setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);//竖屏
...@@ -174,6 +175,10 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -174,6 +175,10 @@ public abstract class SobotBaseActivity extends FragmentActivity {
public void changeAppLanguage() { public void changeAppLanguage() {
try { try {
Locale locale = (Locale) SobotSharedPreferencesUtil.getInstance(getSobotBaseContext()).get("SobotLanguage", Locale.class); Locale locale = (Locale) SobotSharedPreferencesUtil.getInstance(getSobotBaseContext()).get("SobotLanguage", Locale.class);
if (locale == null) {
//获取系统语言
locale = getSysPreferredLocale();
}
updateLanguage(locale); updateLanguage(locale);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -486,17 +491,9 @@ public abstract class SobotBaseActivity extends FragmentActivity { ...@@ -486,17 +491,9 @@ public abstract class SobotBaseActivity extends FragmentActivity {
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
int currentNightMode = newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK; int currentNightMode = newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
switch (currentNightMode) { if (initMode != currentNightMode) {
case Configuration.UI_MODE_NIGHT_NO: initMode = currentNightMode;
SobotLogUtils.i("=====关闭夜间模式===="); recreate();
recreate();
break;
case Configuration.UI_MODE_NIGHT_YES:
SobotLogUtils.i("=====开启夜间模式====");
recreate();
break;
default:
break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment