Cherish:Switch styles [2/3]
This commit is contained in:
9
res/drawable/ic_switch_theme.xml
Normal file
9
res/drawable/ic_switch_theme.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?android:attr/colorControlNormal"
|
||||
android:pathData="M17,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h10c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5zM17,15c-1.66,0 -3,-1.34 -3,-3s1.34,-3 3,-3 3,1.34 3,3 -1.34,3 -3,3z"/>
|
||||
</vector>
|
||||
@@ -353,4 +353,16 @@
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Switch styles -->
|
||||
<string-array name="switch_style_entries" translatable="false">
|
||||
<item>@string/switch_default</item>
|
||||
<item>@string/switch_md2</item>
|
||||
<item>@string/switch_oneplus</item>
|
||||
</string-array>
|
||||
<string-array name="switch_style_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -440,5 +440,11 @@
|
||||
<!-- Force expanded notifications -->
|
||||
<string name="force_expanded_notifications_title">Force expanded notifications</string>
|
||||
<string name="force_expanded_notifications_summary">Force apps that support expanded notifications</string>
|
||||
|
||||
<!-- Switch styles -->
|
||||
<string name="switch_style_title">Switch appearance</string>
|
||||
<string name="switch_default">Default</string>
|
||||
<string name="switch_md2">Material Design 2</string>
|
||||
<string name="switch_oneplus">OnePlus</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -32,6 +32,14 @@
|
||||
android:entries="@array/theme_type_titles"
|
||||
android:entryValues="@array/theme_type_values"
|
||||
android:defaultValue="1"/>
|
||||
|
||||
<ListPreference
|
||||
android:key="switch_style"
|
||||
android:icon="@drawable/ic_switch_theme"
|
||||
android:title="@string/switch_style_title"
|
||||
android:persistent="false"
|
||||
android:entries="@array/switch_style_entries"
|
||||
android:entryValues="@array/switch_style_values" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
private static final String SYSUI_ROUNDED_CONTENT_PADDING = "sysui_rounded_content_padding";
|
||||
private static final String SYSUI_STATUS_BAR_PADDING = "sysui_status_bar_padding";
|
||||
private static final String SYSUI_ROUNDED_FWVALS = "sysui_rounded_fwvals";
|
||||
private static final String SWITCH_STYLE = "switch_style";
|
||||
|
||||
private ColorPickerPreference mThemeColor;
|
||||
private ColorPickerPreference mGradientColor;
|
||||
@@ -62,6 +63,7 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
private CustomSeekBarPreference mContentPadding;
|
||||
private CustomSeekBarPreference mSBPadding;
|
||||
private SwitchPreference mRoundedFwvals;
|
||||
private ListPreference mSwitchStyle;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
@@ -114,6 +116,14 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
mRoundedFwvals = (SwitchPreference) findPreference(SYSUI_ROUNDED_FWVALS);
|
||||
mRoundedFwvals.setOnPreferenceChangeListener(this);
|
||||
|
||||
mSwitchStyle = (ListPreference) findPreference(SWITCH_STYLE);
|
||||
int switchStyle = Settings.System.getInt(resolver,
|
||||
Settings.System.SWITCH_STYLE, 1);
|
||||
int switchValueIndex = mSwitchStyle.findIndexOfValue(String.valueOf(switchStyle));
|
||||
mSwitchStyle.setValueIndex(switchValueIndex >= 0 ? switchValueIndex : 0);
|
||||
mSwitchStyle.setSummary(mSwitchStyle.getEntry());
|
||||
mSwitchStyle.setOnPreferenceChangeListener(this);
|
||||
|
||||
mOverlayService = IOverlayManager.Stub
|
||||
.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
|
||||
mUiModeManager = getContext().getSystemService(UiModeManager.class);
|
||||
@@ -230,6 +240,11 @@ public class ThemeSettings extends SettingsPreferenceFragment implements
|
||||
(int) objValue, UserHandle.USER_CURRENT);
|
||||
} else if (preference == mRoundedFwvals) {
|
||||
restoreCorners();
|
||||
} else if (preference == mSwitchStyle) {
|
||||
String value = (String) objValue;
|
||||
Settings.System.putInt(resolver, Settings.System.SWITCH_STYLE, Integer.valueOf(value));
|
||||
int valueIndex = mSwitchStyle.findIndexOfValue(value);
|
||||
mSwitchStyle.setSummary(mSwitchStyle.getEntries()[valueIndex]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user