Skip to content

Commit

Permalink
actionBar title follow app language
Browse files Browse the repository at this point in the history
  • Loading branch information
RikkaW committed Jul 8, 2019
1 parent 29ad1ab commit 4180c76
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions manager/src/main/java/moe/shizuku/manager/app/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package moe.shizuku.manager.app;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
Expand Down Expand Up @@ -41,6 +42,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getLocaleDelegate().onCreate(this);
mTheme = ThemeHelper.getTheme(this);

resetTitle();

super.onCreate(savedInstanceState);

if (getActionBar() != null) {
Expand Down Expand Up @@ -124,4 +127,23 @@ private DayNightDelegate getDayNightDelegate(Context context) {
}
return mDayNightDelegate;
}

/**
* Fix titles don't change when current locale is changed
*/
private void resetTitle() {
try {
int label = getPackageManager().getActivityInfo(
getComponentName(), PackageManager.GET_META_DATA).labelRes;
if (label == 0) {
label = getPackageManager().getApplicationInfo(
getPackageName(), PackageManager.GET_META_DATA).labelRes;
}
if (label != 0) {
setTitle(label);
}
} catch (PackageManager.NameNotFoundException ignored) {

}
}
}

0 comments on commit 4180c76

Please sign in to comment.