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_pitch_black</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 name="theme_type_values">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
</string-array>
</resources>

View File

@@ -267,5 +267,8 @@
<string name="theme_type_light">Light</string>
<string name="theme_type_pitch_black">Google 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>

View File

@@ -27,7 +27,7 @@
android:key="theme_switch"
android:icon="@drawable/ic_system_theme"
android:title="@string/theme_type_title"
android:summary="@string/theme_type_summary"
android:summary="%s"
android:dialogTitle="@string/theme_type_summary"
android:entries="@array/theme_type_titles"
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 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;
}
}
}