diff --git a/app/build.gradle b/app/build.gradle
index 79edb565..51ac3203 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -181,7 +181,7 @@ dependencies {
implementation 'com.nex3z:flow-layout:1.3.3'
// RecyclerView fast scrolling
- implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
+ implementation 'me.zhanghai.android.fastscroll:library:1.1.8'
implementation 'com.otaliastudios:zoomlayout:1.9.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 654a9708..d343bfe6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -438,9 +438,6 @@
android:name=".services.SubmitPostService"
android:enabled="true"
android:exported="false" />
-
{
- stopService();
- });
- } else {
- stopService();
- }
-
- return START_NOT_STICKY;
- }
-
- private void stopService() {
- stopForeground(true);
- stopSelf();
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
index cb0c759b..65bea6ef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/ThemePreferenceFragment.java
@@ -179,7 +179,7 @@ public class ThemePreferenceFragment extends CustomFontPreferenceFragmentCompat
enableMaterialYouSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> {
if ((Boolean) newValue) {
- MaterialYouUtils.changeTheme(activity, executor, new Handler(),
+ MaterialYouUtils.changeThemeASync(activity, executor, new Handler(),
redditDataRoomDatabase, customThemeWrapper,
lightThemeSharedPreferences, darkThemeSharedPreferences,
amoledThemeSharedPreferences, null);
@@ -191,7 +191,7 @@ public class ThemePreferenceFragment extends CustomFontPreferenceFragmentCompat
});
applyMaterialYouPreference.setOnPreferenceClickListener(preference -> {
- MaterialYouUtils.changeTheme(activity, executor, new Handler(),
+ MaterialYouUtils.changeThemeASync(activity, executor, new Handler(),
redditDataRoomDatabase, customThemeWrapper,
lightThemeSharedPreferences, darkThemeSharedPreferences,
amoledThemeSharedPreferences, null);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
index 9d5f27cb..7268cb2b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/MaterialYouUtils.java
@@ -40,83 +40,185 @@ public class MaterialYouUtils {
});
}
- public static void changeTheme(Context context, Executor executor, Handler handler,
- RedditDataRoomDatabase redditDataRoomDatabase,
- CustomThemeWrapper customThemeWrapper,
- SharedPreferences lightThemeSharedPreferences,
- SharedPreferences darkThemeSharedPreferences,
- SharedPreferences amoledThemeSharedPreferences,
- @Nullable MaterialYouListener materialYouListener) {
+ public static void changeThemeSync(Context context,
+ RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
+ SharedPreferences lightThemeSharedPreferences,
+ SharedPreferences darkThemeSharedPreferences,
+ SharedPreferences amoledThemeSharedPreferences) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ignored) { }
+ if (changeTheme(context, redditDataRoomDatabase, customThemeWrapper, lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences)) {
+ EventBus.getDefault().post(new RecreateActivityEvent());
+ }
+ }
+
+ public static void changeThemeASync(Context context, Executor executor, Handler handler,
+ RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
+ SharedPreferences lightThemeSharedPreferences,
+ SharedPreferences darkThemeSharedPreferences,
+ SharedPreferences amoledThemeSharedPreferences,
+ @Nullable MaterialYouListener materialYouListener) {
executor.execute(() -> {
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) { }
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ if (changeTheme(context, redditDataRoomDatabase, customThemeWrapper, lightThemeSharedPreferences, darkThemeSharedPreferences, amoledThemeSharedPreferences)) {
+ handler.post(() -> {
+ if (materialYouListener != null) {
+ materialYouListener.applied();
+ }
+ EventBus.getDefault().post(new RecreateActivityEvent());
+ });
+ }
+ });
+ }
+
+ private static boolean changeTheme(Context context,
+ RedditDataRoomDatabase redditDataRoomDatabase,
+ CustomThemeWrapper customThemeWrapper,
+ SharedPreferences lightThemeSharedPreferences,
+ SharedPreferences darkThemeSharedPreferences,
+ SharedPreferences amoledThemeSharedPreferences) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
+ CustomTheme lightTheme = CustomThemeWrapper.getIndigo(context);
+ CustomTheme darkTheme = CustomThemeWrapper.getIndigoDark(context);
+ CustomTheme amoledTheme = CustomThemeWrapper.getIndigoAmoled(context);
+
+ lightTheme.colorPrimary = context.getColor(android.R.color.system_accent1_100);
+ lightTheme.colorPrimaryDark = lightTheme.colorPrimary;
+ lightTheme.colorAccent = context.getColor(android.R.color.system_accent3_300);
+ lightTheme.colorPrimaryLightTheme = lightTheme.colorPrimary;
+ lightTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_100);
+ lightTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
+ lightTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
+ lightTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
+ lightTheme.bottomAppBarBackgroundColor = lightTheme.colorPrimary;
+ lightTheme.navBarColor = lightTheme.colorPrimary;
+ lightTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_900);
+ lightTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_700);
+ lightTheme.buttonTextColor = context.getColor(android.R.color.system_accent1_800);
+ lightTheme.bottomAppBarIconColor = lightTheme.buttonTextColor;
+ lightTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_400);
+ lightTheme.fabIconColor = lightTheme.buttonTextColor;
+ lightTheme.toolbarPrimaryTextAndIconColor = lightTheme.buttonTextColor;
+ lightTheme.toolbarSecondaryTextColor = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = lightTheme.colorPrimary;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = lightTheme.backgroundColor;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = lightTheme.buttonTextColor;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = lightTheme.buttonTextColor;
+ lightTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_10);
+ lightTheme.dividerColor = context.getColor(android.R.color.system_neutral1_400);
+ lightTheme.isLightStatusBar = true;
+ lightTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
+ lightTheme.name = "Material You";
+
+ darkTheme.colorPrimary = context.getColor(android.R.color.system_accent2_800);
+ darkTheme.colorPrimaryDark = darkTheme.colorPrimary;
+ darkTheme.colorAccent = context.getColor(android.R.color.system_accent3_100);
+ darkTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_300);
+ darkTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_900);
+ darkTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
+ darkTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
+ darkTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
+ darkTheme.bottomAppBarBackgroundColor = context.getColor(android.R.color.system_accent2_800);
+ darkTheme.navBarColor = darkTheme.colorPrimary;
+ darkTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_10);
+ darkTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_10);
+ darkTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_100);;
+ darkTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_100);
+ darkTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
+ darkTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent2_100);
+ darkTheme.toolbarSecondaryTextColor = darkTheme.toolbarPrimaryTextAndIconColor;
+ darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = darkTheme.toolbarPrimaryTextAndIconColor;
+ darkTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = darkTheme.toolbarPrimaryTextAndIconColor;
+ darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = darkTheme.colorPrimary;
+ darkTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = darkTheme.backgroundColor;
+ darkTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = darkTheme.bottomAppBarIconColor;
+ darkTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = darkTheme.bottomAppBarIconColor;
+ darkTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_900);
+ darkTheme.dividerColor = context.getColor(android.R.color.system_neutral1_600);
+ darkTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
+ darkTheme.name = "Material You Dark";
+
+ amoledTheme.colorAccent = context.getColor(android.R.color.system_accent1_100);
+ amoledTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_300);
+ amoledTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
+ amoledTheme.name = "Material You Amoled";
+
+ redditDataRoomDatabase.customThemeDao().unsetLightTheme();
+ redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
+ redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
+
+ redditDataRoomDatabase.customThemeDao().insert(lightTheme);
+ redditDataRoomDatabase.customThemeDao().insert(darkTheme);
+ redditDataRoomDatabase.customThemeDao().insert(amoledTheme);
+
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(lightTheme, lightThemeSharedPreferences);
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(darkTheme, darkThemeSharedPreferences);
+ CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(amoledTheme, amoledThemeSharedPreferences);
+
+ return true;
+ } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
+ WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
+ WallpaperColors wallpaperColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
+
+ if (wallpaperColors != null) {
+ int colorPrimaryInt = lightenColor(wallpaperColors.getPrimaryColor().toArgb(), 0.4);
+ int colorPrimaryDarkInt = darkenColor(colorPrimaryInt, 0.3);
+ int backgroundColor = lightenColor(colorPrimaryInt, 0.2);
+ int cardViewBackgroundColor = lightenColor(colorPrimaryInt, 0.6);
+ Color colorAccent = wallpaperColors.getSecondaryColor();
+ int colorAccentInt = lightenColor(colorAccent == null ? customThemeWrapper.getColorAccent() : colorAccent.toArgb(), 0.4);
+
+ int colorPrimaryAppropriateTextColor = getAppropriateTextColor(colorPrimaryInt);
+ int backgroundColorAppropriateTextColor = getAppropriateTextColor(backgroundColor);
+
CustomTheme lightTheme = CustomThemeWrapper.getIndigo(context);
CustomTheme darkTheme = CustomThemeWrapper.getIndigoDark(context);
CustomTheme amoledTheme = CustomThemeWrapper.getIndigoAmoled(context);
- lightTheme.colorPrimary = context.getColor(android.R.color.system_accent1_100);
- lightTheme.colorPrimaryDark = lightTheme.colorPrimary;
- lightTheme.colorAccent = context.getColor(android.R.color.system_accent3_300);
- lightTheme.colorPrimaryLightTheme = lightTheme.colorPrimary;
- lightTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_100);
- lightTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
- lightTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
- lightTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_50);
- lightTheme.bottomAppBarBackgroundColor = lightTheme.colorPrimary;
- lightTheme.navBarColor = lightTheme.colorPrimary;
- lightTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_900);
- lightTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_700);
- lightTheme.buttonTextColor = context.getColor(android.R.color.system_accent1_800);
- lightTheme.bottomAppBarIconColor = lightTheme.buttonTextColor;
- lightTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_400);
- lightTheme.fabIconColor = lightTheme.buttonTextColor;
- lightTheme.toolbarPrimaryTextAndIconColor = lightTheme.buttonTextColor;
- lightTheme.toolbarSecondaryTextColor = lightTheme.buttonTextColor;
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = lightTheme.buttonTextColor;
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = lightTheme.buttonTextColor;
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = lightTheme.colorPrimary;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = lightTheme.backgroundColor;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = lightTheme.buttonTextColor;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = lightTheme.buttonTextColor;
- lightTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_10);
- lightTheme.dividerColor = context.getColor(android.R.color.system_neutral1_400);
- lightTheme.isLightStatusBar = true;
- lightTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
+ lightTheme.colorPrimary = colorPrimaryInt;
+ lightTheme.colorPrimaryDark = colorPrimaryDarkInt;
+ lightTheme.colorAccent = colorAccentInt;
+ lightTheme.colorPrimaryLightTheme = colorPrimaryInt;
+ lightTheme.backgroundColor = backgroundColor;
+ lightTheme.cardViewBackgroundColor = cardViewBackgroundColor;
+ lightTheme.commentBackgroundColor = cardViewBackgroundColor;
+ lightTheme.awardedCommentBackgroundColor = cardViewBackgroundColor;
+ lightTheme.bottomAppBarBackgroundColor = colorPrimaryInt;
+ lightTheme.navBarColor = colorPrimaryInt;
+ lightTheme.primaryTextColor = backgroundColorAppropriateTextColor;
+ lightTheme.secondaryTextColor = backgroundColorAppropriateTextColor == Color.BLACK ? Color.parseColor("#8A000000") : Color.parseColor("#B3FFFFFF");
+ lightTheme.bottomAppBarIconColor = colorPrimaryAppropriateTextColor;
+ lightTheme.primaryIconColor = backgroundColorAppropriateTextColor;
+ lightTheme.fabIconColor = colorPrimaryAppropriateTextColor;
+ lightTheme.toolbarPrimaryTextAndIconColor = colorPrimaryAppropriateTextColor;
+ lightTheme.toolbarSecondaryTextColor = colorPrimaryAppropriateTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
+ lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = colorPrimaryInt;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = backgroundColor;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
+ lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
+ lightTheme.circularProgressBarBackground = colorPrimaryInt;
+ lightTheme.dividerColor = backgroundColorAppropriateTextColor == Color.BLACK ? Color.parseColor("#E0E0E0") : Color.parseColor("69666C");
+ lightTheme.isLightStatusBar = colorPrimaryAppropriateTextColor == Color.BLACK;
+ lightTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface =
+ (lightTheme.isLightStatusBar && getAppropriateTextColor(cardViewBackgroundColor) == Color.WHITE)
+ || (!lightTheme.isLightStatusBar && getAppropriateTextColor(cardViewBackgroundColor) == Color.BLACK);
lightTheme.name = "Material You";
- darkTheme.colorPrimary = context.getColor(android.R.color.system_accent2_800);
- darkTheme.colorPrimaryDark = darkTheme.colorPrimary;
- darkTheme.colorAccent = context.getColor(android.R.color.system_accent3_100);
- darkTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_300);
- darkTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_900);
- darkTheme.cardViewBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
- darkTheme.commentBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
- darkTheme.awardedCommentBackgroundColor = context.getColor(android.R.color.system_neutral2_800);
- darkTheme.bottomAppBarBackgroundColor = context.getColor(android.R.color.system_accent2_800);
- darkTheme.navBarColor = darkTheme.colorPrimary;
- darkTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_10);
- darkTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_10);
- darkTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_100);;
- darkTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_100);
- darkTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
- darkTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent2_100);
- darkTheme.toolbarSecondaryTextColor = darkTheme.toolbarPrimaryTextAndIconColor;
- darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = darkTheme.toolbarPrimaryTextAndIconColor;
- darkTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = darkTheme.toolbarPrimaryTextAndIconColor;
- darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = darkTheme.colorPrimary;
- darkTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = darkTheme.backgroundColor;
- darkTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = darkTheme.bottomAppBarIconColor;
- darkTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = darkTheme.bottomAppBarIconColor;
- darkTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_900);
- darkTheme.dividerColor = context.getColor(android.R.color.system_neutral1_600);
- darkTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
+ darkTheme.colorAccent = colorPrimaryInt;
+ darkTheme.colorPrimaryLightTheme = colorPrimaryInt;
darkTheme.name = "Material You Dark";
- amoledTheme.colorAccent = context.getColor(android.R.color.system_accent1_100);
- amoledTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_300);
- amoledTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_900);
+ amoledTheme.colorAccent = colorPrimaryInt;
+ amoledTheme.colorPrimaryLightTheme = colorPrimaryInt;
amoledTheme.name = "Material You Amoled";
redditDataRoomDatabase.customThemeDao().unsetLightTheme();
@@ -131,91 +233,11 @@ public class MaterialYouUtils {
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(darkTheme, darkThemeSharedPreferences);
CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(amoledTheme, amoledThemeSharedPreferences);
- handler.post(() -> {
- if (materialYouListener != null) {
- materialYouListener.applied();
- }
- EventBus.getDefault().post(new RecreateActivityEvent());
- });
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
- WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
- WallpaperColors wallpaperColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
-
- if (wallpaperColors != null) {
- int colorPrimaryInt = lightenColor(wallpaperColors.getPrimaryColor().toArgb(), 0.4);
- int colorPrimaryDarkInt = darkenColor(colorPrimaryInt, 0.3);
- int backgroundColor = lightenColor(colorPrimaryInt, 0.2);
- int cardViewBackgroundColor = lightenColor(colorPrimaryInt, 0.6);
- Color colorAccent = wallpaperColors.getSecondaryColor();
- int colorAccentInt = lightenColor(colorAccent == null ? customThemeWrapper.getColorAccent() : colorAccent.toArgb(), 0.4);
-
- int colorPrimaryAppropriateTextColor = getAppropriateTextColor(colorPrimaryInt);
- int backgroundColorAppropriateTextColor = getAppropriateTextColor(backgroundColor);
-
- CustomTheme lightTheme = CustomThemeWrapper.getIndigo(context);
- CustomTheme darkTheme = CustomThemeWrapper.getIndigoDark(context);
- CustomTheme amoledTheme = CustomThemeWrapper.getIndigoAmoled(context);
-
- lightTheme.colorPrimary = colorPrimaryInt;
- lightTheme.colorPrimaryDark = colorPrimaryDarkInt;
- lightTheme.colorAccent = colorAccentInt;
- lightTheme.colorPrimaryLightTheme = colorPrimaryInt;
- lightTheme.backgroundColor = backgroundColor;
- lightTheme.cardViewBackgroundColor = cardViewBackgroundColor;
- lightTheme.commentBackgroundColor = cardViewBackgroundColor;
- lightTheme.awardedCommentBackgroundColor = cardViewBackgroundColor;
- lightTheme.bottomAppBarBackgroundColor = colorPrimaryInt;
- lightTheme.navBarColor = colorPrimaryInt;
- lightTheme.primaryTextColor = backgroundColorAppropriateTextColor;
- lightTheme.secondaryTextColor = backgroundColorAppropriateTextColor == Color.BLACK ? Color.parseColor("#8A000000") : Color.parseColor("#B3FFFFFF");
- lightTheme.bottomAppBarIconColor = colorPrimaryAppropriateTextColor;
- lightTheme.primaryIconColor = backgroundColorAppropriateTextColor;
- lightTheme.fabIconColor = colorPrimaryAppropriateTextColor;
- lightTheme.toolbarPrimaryTextAndIconColor = colorPrimaryAppropriateTextColor;
- lightTheme.toolbarSecondaryTextColor = colorPrimaryAppropriateTextColor;
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
- lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = colorPrimaryInt;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = backgroundColor;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = colorPrimaryAppropriateTextColor;
- lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = colorPrimaryAppropriateTextColor;
- lightTheme.circularProgressBarBackground = colorPrimaryInt;
- lightTheme.dividerColor = backgroundColorAppropriateTextColor == Color.BLACK ? Color.parseColor("#E0E0E0") : Color.parseColor("69666C");
- lightTheme.isLightStatusBar = colorPrimaryAppropriateTextColor == Color.BLACK;
- lightTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface =
- (lightTheme.isLightStatusBar && getAppropriateTextColor(cardViewBackgroundColor) == Color.WHITE)
- || (!lightTheme.isLightStatusBar && getAppropriateTextColor(cardViewBackgroundColor) == Color.BLACK);
- lightTheme.name = "Material You";
-
- darkTheme.colorAccent = colorPrimaryInt;
- darkTheme.colorPrimaryLightTheme = colorPrimaryInt;
- darkTheme.name = "Material You Dark";
-
- amoledTheme.colorAccent = colorPrimaryInt;
- amoledTheme.colorPrimaryLightTheme = colorPrimaryInt;
- amoledTheme.name = "Material You Amoled";
-
- redditDataRoomDatabase.customThemeDao().unsetLightTheme();
- redditDataRoomDatabase.customThemeDao().unsetDarkTheme();
- redditDataRoomDatabase.customThemeDao().unsetAmoledTheme();
-
- redditDataRoomDatabase.customThemeDao().insert(lightTheme);
- redditDataRoomDatabase.customThemeDao().insert(darkTheme);
- redditDataRoomDatabase.customThemeDao().insert(amoledTheme);
-
- CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(lightTheme, lightThemeSharedPreferences);
- CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(darkTheme, darkThemeSharedPreferences);
- CustomThemeSharedPreferencesUtils.insertThemeToSharedPreferences(amoledTheme, amoledThemeSharedPreferences);
-
- handler.post(() -> {
- if (materialYouListener != null) {
- materialYouListener.applied();
- }
- EventBus.getDefault().post(new RecreateActivityEvent());
- });
- }
+ return true;
}
- });
+ }
+
+ return false;
}
private static int lightenColor(int color, double ratio) {