Commit 0aa4d5d6 by zhengnw@sobot.com

widget 1.0.8 baseactivity 修改国际化语言

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