Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix night mode bug #1060

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (theme.equals("black")) {
setTheme(R.style.TuskyBlackTheme);
}
ThemeUtils.setAppNightMode(theme, this);
ThemeUtils.setAppNightMode(theme);

/* set the taskdescription programmatically, the theme would turn it blue */
String appName = getString(R.string.app_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
"appTheme" -> {
val theme = sharedPreferences.getNonNullString("appTheme", ThemeUtils.APP_THEME_DEFAULT)
Log.d("activeTheme", theme)
ThemeUtils.setAppNightMode(theme, this)
ThemeUtils.setAppNightMode(theme)
restartActivitiesOnExit = true

// recreate() could be used instead, but it doesn't have an animation B).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void setDrawableTint(Context context, Drawable drawable, @AttrRes
drawable.setColorFilter(getColor(context, attribute), PorterDuff.Mode.SRC_IN);
}

public static void setAppNightMode(String flavor, Context context) {
public static void setAppNightMode(String flavor) {
int mode;
switch (flavor) {
default:
Expand All @@ -121,12 +121,7 @@ public static void setAppNightMode(String flavor, Context context) {
break;
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
UiModeManager uiModeManager = (UiModeManager)context.getApplicationContext().getSystemService(Context.UI_MODE_SERVICE);
uiModeManager.setNightMode(mode);
} else {
AppCompatDelegate.setDefaultNightMode(mode);
}
AppCompatDelegate.setDefaultNightMode(mode);

}
}