mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Merge pull request #500 from wulkanat/master
feat: "real" Material You implementation
This commit is contained in:
commit
ef870f93fc
@ -48,7 +48,93 @@ public class MaterialYouUtils {
|
||||
SharedPreferences amoledThemeSharedPreferences,
|
||||
@Nullable MaterialYouListener materialYouListener) {
|
||||
executor.execute(() -> {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
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_300);
|
||||
lightTheme.colorPrimaryDark = context.getColor(android.R.color.system_accent1_500);
|
||||
lightTheme.colorAccent = context.getColor(android.R.color.system_accent3_300);
|
||||
lightTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_200);
|
||||
lightTheme.backgroundColor = context.getColor(android.R.color.system_neutral1_10);
|
||||
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_100);
|
||||
lightTheme.bottomAppBarBackgroundColor = context.getColor(android.R.color.system_accent2_100);
|
||||
lightTheme.navBarColor = context.getColor(android.R.color.system_neutral2_100);
|
||||
lightTheme.primaryTextColor = context.getColor(android.R.color.system_neutral1_900);
|
||||
lightTheme.secondaryTextColor = context.getColor(android.R.color.system_neutral1_900);
|
||||
lightTheme.bottomAppBarIconColor = context.getColor(android.R.color.system_accent1_400);;
|
||||
lightTheme.primaryIconColor = context.getColor(android.R.color.system_accent1_400);
|
||||
lightTheme.fabIconColor = context.getColor(android.R.color.system_neutral1_10);
|
||||
lightTheme.toolbarPrimaryTextAndIconColor = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.toolbarSecondaryTextColor = context.getColor(android.R.color.system_accent3_50);
|
||||
lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_50);
|
||||
lightTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_10);
|
||||
lightTheme.dividerColor = context.getColor(android.R.color.system_neutral1_100);
|
||||
lightTheme.isLightStatusBar = false;
|
||||
lightTheme.isChangeStatusBarIconColorAfterToolbarCollapsedInImmersiveInterface = true;
|
||||
lightTheme.name = "Material You";
|
||||
|
||||
darkTheme.colorPrimary = context.getColor(android.R.color.system_accent1_100);
|
||||
darkTheme.colorPrimaryDark = context.getColor(android.R.color.system_accent1_300);
|
||||
darkTheme.colorAccent = context.getColor(android.R.color.system_accent3_100);
|
||||
darkTheme.colorPrimaryLightTheme = context.getColor(android.R.color.system_accent1_100);
|
||||
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 = context.getColor(android.R.color.system_neutral2_800);
|
||||
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_accent1_900);
|
||||
darkTheme.toolbarSecondaryTextColor = context.getColor(android.R.color.system_accent3_900);
|
||||
darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_800);
|
||||
darkTheme.tabLayoutWithCollapsedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_800);
|
||||
darkTheme.tabLayoutWithCollapsedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_800);
|
||||
darkTheme.tabLayoutWithExpandedCollapsingToolbarTabBackground = context.getColor(android.R.color.system_accent1_800);
|
||||
darkTheme.tabLayoutWithExpandedCollapsingToolbarTabIndicator = context.getColor(android.R.color.system_accent1_800);
|
||||
darkTheme.tabLayoutWithExpandedCollapsingToolbarTextColor = context.getColor(android.R.color.system_accent1_800);
|
||||
darkTheme.circularProgressBarBackground = context.getColor(android.R.color.system_accent1_900);
|
||||
darkTheme.dividerColor = context.getColor(android.R.color.system_neutral1_600);
|
||||
darkTheme.isLightStatusBar = true;
|
||||
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_accent3_100);
|
||||
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());
|
||||
});
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
|
||||
WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
|
||||
WallpaperColors wallpaperColors = wallpaperManager.getWallpaperColors(WallpaperManager.FLAG_SYSTEM);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user