Cherish:Add Quick Settings Pulldown options [2/2]

This commit is contained in:
Roman Birg
2016-01-12 21:21:18 +07:00
committed by Hung Phan
parent 8149d23826
commit e4a1bff5cb
4 changed files with 64 additions and 1 deletions

View File

@@ -326,4 +326,19 @@
<item>0</item>
<item>1</item>
</string-array>
<!-- Quick Pulldown -->
<string-array name="quick_pulldown_entries" translatable="false">
<item>@string/quick_pulldown_off</item>
<item>@string/quick_pulldown_right</item>
<item>@string/quick_pulldown_left</item>
<item>@string/quick_pulldown_always</item>
</string-array>
<string-array name="quick_pulldown_values" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>
</resources>

View File

@@ -422,4 +422,13 @@
<string name="lockscreen_qs_disabled_title">Disable quick settings when locked</string>
<string name="lockscreen_qs_disabled_summary">Disable expanding quick settings on secure lock screens</string>
<!-- Quick pull down-->
<string name="quick_pulldown_title">Quick pulldown</string>
<string name="quick_pulldown_summary">%1$s edge of the status bar pulls down Quick Settings</string>
<string name="quick_pulldown_summary_always">Always show Quick Settings on status bar pulldown</string>
<string name="quick_pulldown_off">Off</string>
<string name="quick_pulldown_left">Left</string>
<string name="quick_pulldown_right">Right</string>
<string name="quick_pulldown_always">Always</string>
</resources>

View File

@@ -66,6 +66,13 @@
<PreferenceCategory
android:title="@string/qs_title">
<ListPreference
android:key="quick_pulldown"
android:title="@string/quick_pulldown_title"
android:entries="@array/quick_pulldown_entries"
android:entryValues="@array/quick_pulldown_values"
android:persistent="false" />
<com.cherish.settings.preferences.SecureSettingSwitchPreference
android:key="status_bar_locked_on_secure_keyguard"
android:title="@string/lockscreen_qs_disabled_title"

View File

@@ -29,7 +29,9 @@ public class QuickSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener {
private static final String QS_BLUR_ALPHA = "qs_blur_alpha";
private static final String QS_BLUR_INTENSITY = "qs_blur_intensity";
private static final String QUICK_PULLDOWN = "quick_pulldown";
private ListPreference mQuickPulldown;
private CustomSeekBarPreference mQSBlurAlpha;
private CustomSeekBarPreference mQSBlurIntensity;
@@ -53,10 +55,18 @@ public class QuickSettings extends SettingsPreferenceFragment implements
mQSBlurIntensity.setValue(qsBlurIntensity);
mQSBlurIntensity.setOnPreferenceChangeListener(this);
mQuickPulldown = (ListPreference) findPreference(QUICK_PULLDOWN);
mQuickPulldown.setOnPreferenceChangeListener(this);
int quickPulldownValue = Settings.System.getIntForUser(resolver,
Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 0, UserHandle.USER_CURRENT);
mQuickPulldown.setValue(String.valueOf(quickPulldownValue));
updatePulldownSummary(quickPulldownValue);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ContentResolver resolver = getActivity().getContentResolver();
if (preference == mQSBlurAlpha) {
int value = (Integer) newValue;
Settings.System.putInt(getContentResolver(),
@@ -67,10 +77,32 @@ public class QuickSettings extends SettingsPreferenceFragment implements
Settings.System.putInt(getContentResolver(),
Settings.System.QS_BLUR_INTENSITY, value);
return true;
} else if (preference == mQuickPulldown) {
int quickPulldownValue = Integer.valueOf((String) newValue);
Settings.System.putIntForUser(resolver, Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN,
quickPulldownValue, UserHandle.USER_CURRENT);
updatePulldownSummary(quickPulldownValue);
return true;
}
return false;
}
private void updatePulldownSummary(int value) {
Resources res = getResources();
if (value == 0) {
// quick pulldown deactivated
mQuickPulldown.setSummary(res.getString(R.string.quick_pulldown_off));
} else if (value == 3) {
// quick pulldown always
mQuickPulldown.setSummary(res.getString(R.string.quick_pulldown_summary_always));
} else {
String direction = res.getString(value == 2
? R.string.quick_pulldown_left
: R.string.quick_pulldown_right);
mQuickPulldown.setSummary(res.getString(R.string.quick_pulldown_summary, direction));
}
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;