Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Niedermann <info@niedermann.it>2023-03-01 14:43:53 +0300
committerStefan Niedermann <info@niedermann.it>2023-03-09 11:53:19 +0300
commit3ea462ca9e2ae18ba9d869125da8d8d07f2c7854 (patch)
tree30257c67768325d5972ec499a6eb41e11017ac6d /app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
parentbfab286b0bc6dbfac1211eec64d74b66b2ce1e6d (diff)
refactor: Unidirectional data flow and single point of truth for current state
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java32
1 files changed, 4 insertions, 28 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
index 3bd6c6bbf..45d4e25c1 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/ThemeUtils.java
@@ -1,13 +1,11 @@
package it.niedermann.nextcloud.deck.ui.theme;
-import static it.niedermann.nextcloud.deck.DeckApplication.isDarkTheme;
+import static com.nextcloud.android.common.ui.util.PlatformThemeUtil.isDarkMode;
import android.content.Context;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
-import androidx.core.content.ContextCompat;
-import androidx.preference.PreferenceManager;
import com.nextcloud.android.common.ui.color.ColorUtil;
import com.nextcloud.android.common.ui.theme.MaterialSchemes;
@@ -20,8 +18,6 @@ import com.nextcloud.android.common.ui.theme.utils.MaterialViewThemeUtils;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import it.niedermann.nextcloud.deck.DeckLog;
-import it.niedermann.nextcloud.deck.R;
import scheme.Scheme;
public class ThemeUtils extends ViewThemeUtilsBase {
@@ -44,7 +40,7 @@ public class ThemeUtils extends ViewThemeUtilsBase {
this.material = new MaterialViewThemeUtils(schemes, colorUtil);
this.androidx = new AndroidXViewThemeUtils(schemes, this.platform);
this.dialog = new DialogViewThemeUtils(schemes);
- this.deck = new DeckViewThemeUtils(schemes, this.material);
+ this.deck = new DeckViewThemeUtils(schemes, this.material, this.platform);
}
public static ThemeUtils of(@ColorInt int color, @NonNull Context context) {
@@ -54,28 +50,8 @@ public class ThemeUtils extends ViewThemeUtilsBase {
));
}
+ @Deprecated
public static Scheme createScheme(@ColorInt int color, @NonNull Context context) {
- return isDarkTheme(context) ? Scheme.dark(color) : Scheme.light(color);
- }
-
- @ColorInt
- public static int readBrandMainColor(@NonNull Context context) {
- final var sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
- DeckLog.log("--- Read:", context.getString(R.string.shared_preference_theme_main));
- return sharedPreferences.getInt(context.getString(R.string.shared_preference_theme_main), ContextCompat.getColor(context, R.color.defaultBrand));
- }
-
- public static void saveBrandColors(@NonNull Context context, @ColorInt int color) {
- final var editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
- DeckLog.log("--- Write:", context.getString(R.string.shared_preference_theme_main), "|", color);
- editor.putInt(context.getString(R.string.shared_preference_theme_main), color);
- editor.apply();
- }
-
- public static void clearBrandColors(@NonNull Context context) {
- final var editor = PreferenceManager.getDefaultSharedPreferences(context).edit();
- DeckLog.log("--- Remove:", context.getString(R.string.shared_preference_theme_main));
- editor.remove(context.getString(R.string.shared_preference_theme_main));
- editor.apply();
+ return isDarkMode(context) ? Scheme.dark(color) : Scheme.light(color);
}
}