Skip to content
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 @@ -38,6 +38,7 @@ public class NotesApplication extends Application {
private static boolean isGridViewEnabled = false;
private static boolean isSwipeEnabled = true;
private static BrandingUtil brandingUtil;
private static NotesApplication instance;

@Override
public void onCreate() {
Expand All @@ -48,7 +49,8 @@ public void onCreate() {
isGridViewEnabled = getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_key_gridview), false);
isSwipeEnabled = getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_key_swipe_actions), true);
super.onCreate();
brandingUtil = BrandingUtil.getInstance(this);
instance = this;
resetBrandingUtil();
if (BuildConfig.DEBUG) {
WebView.setWebContentsDebuggingEnabled(true);
}
Expand All @@ -70,6 +72,10 @@ public static BrandingUtil brandingUtil() {
return brandingUtil;
}

public static void resetBrandingUtil() {
brandingUtil = BrandingUtil.getInstance(instance);
}

public static void setAppTheme(DarkModeSetting setting) {
AppCompatDelegate.setDefaultNightMode(setting.getModeId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.concurrent.ConcurrentMap;

import it.niedermann.android.sharedpreferences.SharedPreferenceIntLiveData;
import it.niedermann.owncloud.notes.NotesApplication;
import it.niedermann.owncloud.notes.R;

public class BrandingUtil extends ViewThemeUtilsBase {
Expand Down Expand Up @@ -88,9 +89,9 @@ public static void saveBrandColor(@NonNull Context context, @ColorInt int color)
Log.v(TAG, "--- Write: shared_preference_theme_main" + " | " + color);
editor.putInt(pref_key_branding_main, color);
editor.apply();
if (context instanceof BrandedActivity) {
if (color != previousMainColor) {
final var activity = (BrandedActivity) context;
if (color != previousMainColor) {
NotesApplication.resetBrandingUtil();
if (context instanceof BrandedActivity activity) {
activity.runOnUiThread(() -> ActivityCompat.recreate(activity));
}
}
Expand Down