Skip to content

Commit 2780811

Browse files
alperozturk96tobiasKaminsky
authored andcommitted
Add static BrandingUtil instance
Signed-off-by: alperozturk <[email protected]>
1 parent 30a0fd8 commit 2780811

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

app/src/main/java/it/niedermann/owncloud/notes/NotesApplication.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import androidx.appcompat.app.AppCompatDelegate;
2222

23+
import it.niedermann.owncloud.notes.branding.BrandingUtil;
2324
import it.niedermann.owncloud.notes.preferences.DarkModeSetting;
2425

2526
public class NotesApplication extends Application {
@@ -31,6 +32,7 @@ public class NotesApplication extends Application {
3132
private static long lastInteraction = 0;
3233
private static String PREF_KEY_THEME;
3334
private static boolean isGridViewEnabled = false;
35+
private static BrandingUtil brandingUtil;
3436

3537
@Override
3638
public void onCreate() {
@@ -40,11 +42,16 @@ public void onCreate() {
4042
lockedPreference = prefs.getBoolean(getString(R.string.pref_key_lock), false);
4143
isGridViewEnabled = getDefaultSharedPreferences(this).getBoolean(getString(R.string.pref_key_gridview), false);
4244
super.onCreate();
45+
brandingUtil = BrandingUtil.getInstance(this);
4346
if (BuildConfig.DEBUG) {
4447
WebView.setWebContentsDebuggingEnabled(true);
4548
}
4649
}
4750

51+
public static BrandingUtil brandingUtil() {
52+
return brandingUtil;
53+
}
54+
4855
public static void setAppTheme(DarkModeSetting setting) {
4956
AppCompatDelegate.setDefaultNightMode(setting.getModeId());
5057
}

app/src/main/java/it/niedermann/owncloud/notes/branding/BrandingUtil.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ private BrandingUtil(
5454
this.notes = new NotesViewThemeUtils(schemes);
5555
}
5656

57+
public static BrandingUtil getInstance(@NonNull Context context) {
58+
int color = BrandingUtil.readBrandMainColor(context);
59+
return new BrandingUtil(
60+
MaterialSchemes.Companion.fromColor(color),
61+
new com.nextcloud.android.common.ui.color.ColorUtil(context)
62+
);
63+
}
64+
5765
public static BrandingUtil of(@ColorInt int color, @NonNull Context context) {
5866
return CACHE.computeIfAbsent(color, c -> new BrandingUtil(
5967
MaterialSchemes.Companion.fromColor(c),

0 commit comments

Comments
 (0)