Cherish:Add 3 New Themes - ChocoX & BakedGreen and DU's PitchBlack [3/3]
And fix all bugs in ThemeSettings
This commit is contained in:
committed by
Hung Phan
parent
362adb0b25
commit
9bb8517d45
@@ -5,10 +5,13 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import static android.os.UserHandle.USER_SYSTEM;
|
||||
import android.app.UiModeManager;
|
||||
import android.os.Bundle;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.content.om.IOverlayManager;
|
||||
import android.os.RemoteException;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.res.Resources;
|
||||
import androidx.preference.ListPreference;
|
||||
@@ -30,7 +33,7 @@ import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.android.internal.util.cherish.ThemesUtils;
|
||||
import com.android.internal.util.cherish.Utils;
|
||||
import com.android.internal.util.cherish.CherishUtils;
|
||||
|
||||
public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
OnPreferenceChangeListener {
|
||||
@@ -38,7 +41,7 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
private static final String PREF_THEME_SWITCH = "theme_switch";
|
||||
|
||||
private UiModeManager mUiModeManager;
|
||||
|
||||
private IOverlayManager mOverlayService;
|
||||
private ListPreference mThemeSwitch;
|
||||
|
||||
@Override
|
||||
@@ -61,12 +64,39 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
switch (theme_switch) {
|
||||
case "1":
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_NO, ThemesUtils.SOLARIZED_DARK);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_NO, ThemesUtils.BAKED_GREEN);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_NO, ThemesUtils.CHOCO_X);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_NO, ThemesUtils.PITCH_BLACK);
|
||||
break;
|
||||
case "2":
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.BAKED_GREEN);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.CHOCO_X);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.PITCH_BLACK);
|
||||
break;
|
||||
case "3":
|
||||
handleBackgrounds(true, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.BAKED_GREEN);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.CHOCO_X);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.PITCH_BLACK);
|
||||
break;
|
||||
case "4":
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK);
|
||||
handleBackgrounds(true, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.BAKED_GREEN);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.CHOCO_X);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.PITCH_BLACK);
|
||||
break;
|
||||
case "5":
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.BAKED_GREEN);
|
||||
handleBackgrounds(true, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.CHOCO_X);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.PITCH_BLACK);
|
||||
break;
|
||||
case "6":
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.BAKED_GREEN);
|
||||
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.CHOCO_X);
|
||||
handleBackgrounds(true, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.PITCH_BLACK);
|
||||
break;
|
||||
}
|
||||
try {
|
||||
@@ -82,7 +112,13 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
private void setupThemeSwitchPref() {
|
||||
mThemeSwitch = (ListPreference) findPreference(PREF_THEME_SWITCH);
|
||||
mThemeSwitch.setOnPreferenceChangeListener(this);
|
||||
if (Utils.isThemeEnabled("com.android.theme.solarizeddark.system")) {
|
||||
if (CherishUtils.isThemeEnabled("com.android.theme.pitchblack.system")) {
|
||||
mThemeSwitch.setValue("6");
|
||||
} else if (CherishUtils.isThemeEnabled("com.android.theme.chocox.system")) {
|
||||
mThemeSwitch.setValue("5");
|
||||
} else if (CherishUtils.isThemeEnabled("com.android.theme.bakedgreen.system")) {
|
||||
mThemeSwitch.setValue("4");
|
||||
} else if (CherishUtils.isThemeEnabled("com.android.theme.solarizeddark.system")) {
|
||||
mThemeSwitch.setValue("3");
|
||||
} else if (mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES) {
|
||||
mThemeSwitch.setValue("2");
|
||||
@@ -111,4 +147,4 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user