Cherish:Add 3 New Themes - ChocoX & BakedGreen and DU's PitchBlack [3/3]

And fix all bugs in ThemeSettings
This commit is contained in:
SuperDroidBond
2020-01-23 10:38:14 +07:00
committed by Hung Phan
parent 362adb0b25
commit 9bb8517d45
4 changed files with 50 additions and 5 deletions

View File

@@ -270,11 +270,17 @@
<item>@string/theme_type_light</item> <item>@string/theme_type_light</item>
<item>@string/theme_type_pitch_black</item> <item>@string/theme_type_pitch_black</item>
<item>@string/theme_type_solarized_dark</item> <item>@string/theme_type_solarized_dark</item>
<item>@string/theme_type_baked_green</item>
<item>@string/theme_type_choco_x</item>
<item>@string/theme_type_du_pitchblack</item>
</string-array> </string-array>
<string-array name="theme_type_values"> <string-array name="theme_type_values">
<item>1</item> <item>1</item>
<item>2</item> <item>2</item>
<item>3</item> <item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
</string-array> </string-array>
</resources> </resources>

View File

@@ -267,5 +267,8 @@
<string name="theme_type_light">Light</string> <string name="theme_type_light">Light</string>
<string name="theme_type_pitch_black">Google dark</string> <string name="theme_type_pitch_black">Google dark</string>
<string name="theme_type_solarized_dark">Solarized dark</string> <string name="theme_type_solarized_dark">Solarized dark</string>
<string name="theme_type_baked_green">Baked Green</string>
<string name="theme_type_choco_x">Choco X</string>
<string name="theme_type_du_pitchblack">Pitch black</string>
</resources> </resources>

View File

@@ -27,7 +27,7 @@
android:key="theme_switch" android:key="theme_switch"
android:icon="@drawable/ic_system_theme" android:icon="@drawable/ic_system_theme"
android:title="@string/theme_type_title" android:title="@string/theme_type_title"
android:summary="@string/theme_type_summary" android:summary="%s"
android:dialogTitle="@string/theme_type_summary" android:dialogTitle="@string/theme_type_summary"
android:entries="@array/theme_type_titles" android:entries="@array/theme_type_titles"
android:entryValues="@array/theme_type_values" android:entryValues="@array/theme_type_values"

View File

@@ -5,10 +5,13 @@ import com.android.internal.logging.nano.MetricsProto;
import static android.os.UserHandle.USER_SYSTEM; import static android.os.UserHandle.USER_SYSTEM;
import android.app.UiModeManager; import android.app.UiModeManager;
import android.os.Bundle; import android.os.Bundle;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.UserHandle; import android.os.UserHandle;
import android.content.om.IOverlayManager;
import android.os.RemoteException;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.res.Resources; import android.content.res.Resources;
import androidx.preference.ListPreference; import androidx.preference.ListPreference;
@@ -30,7 +33,7 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import com.android.internal.util.cherish.ThemesUtils; 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 public class ThemeSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener { OnPreferenceChangeListener {
@@ -38,7 +41,7 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
private static final String PREF_THEME_SWITCH = "theme_switch"; private static final String PREF_THEME_SWITCH = "theme_switch";
private UiModeManager mUiModeManager; private UiModeManager mUiModeManager;
private IOverlayManager mOverlayService;
private ListPreference mThemeSwitch; private ListPreference mThemeSwitch;
@Override @Override
@@ -61,12 +64,39 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
switch (theme_switch) { switch (theme_switch) {
case "1": case "1":
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_NO, ThemesUtils.SOLARIZED_DARK); 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; break;
case "2": case "2":
handleBackgrounds(false, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK); 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; break;
case "3": case "3":
handleBackgrounds(true, context, UiModeManager.MODE_NIGHT_YES, ThemesUtils.SOLARIZED_DARK); 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; break;
} }
try { try {
@@ -82,7 +112,13 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
private void setupThemeSwitchPref() { private void setupThemeSwitchPref() {
mThemeSwitch = (ListPreference) findPreference(PREF_THEME_SWITCH); mThemeSwitch = (ListPreference) findPreference(PREF_THEME_SWITCH);
mThemeSwitch.setOnPreferenceChangeListener(this); 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"); mThemeSwitch.setValue("3");
} else if (mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES) { } else if (mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES) {
mThemeSwitch.setValue("2"); mThemeSwitch.setValue("2");
@@ -111,4 +147,4 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
return MetricsProto.MetricsEvent.CHERISH_SETTINGS; return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
} }
} }