Cherish: Add quick settings pull down with one finger [2/2]

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Roman Birg
2018-10-16 22:02:55 +05:30
committed by Hưng Phan
parent 0aadfb1c94
commit 2a091387f9
4 changed files with 52 additions and 2 deletions

View File

@@ -12,4 +12,19 @@
limitations under the License.
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Quick QS pulldown -->
<string-array name="quick_pulldown_entries">
<item>@string/quick_pulldown_none</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

@@ -157,5 +157,11 @@
<string name="battery_light_medium_color">Medium battery</string>
<string name="battery_light_full_color">Almost full battery</string>
<string name="battery_light_reallyfull_color">Full (100) battery</string>
<string name="status_bar_quick_qs_pulldown">Quick QS pulldown</string>
<string name="quick_pulldown_none">Disabled</string>
<string name="quick_pulldown_right">Pulldown status bar from right side</string>
<string name="quick_pulldown_left">Pulldown status bar from left side</string>
<string name="quick_pulldown_always">Always show quick settings on status bar pull down</string>
</resources>

View File

@@ -20,6 +20,13 @@
<PreferenceCategory
android:title="@string/qs_category">
<ListPreference
android:key="status_bar_quick_qs_pulldown"
android:title="@string/status_bar_quick_qs_pulldown"
android:entries="@array/quick_pulldown_entries"
android:entryValues="@array/quick_pulldown_values"
android:defaultValue="0" />
</PreferenceCategory>

View File

@@ -36,22 +36,44 @@ import java.util.ArrayList;
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class QuickSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener {
private ListPreference mQuickPulldown;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
addPreferencesFromResource(R.xml.cherish_settings_quicksettings);
PreferenceScreen prefScreen = getPreferenceScreen();
ContentResolver resolver = getActivity().getContentResolver();
final Context mContext = getActivity().getApplicationContext();
final ContentResolver resolver = mContext.getContentResolver();
final PreferenceScreen prefSet = getPreferenceScreen();
int qpmode = Settings.System.getIntForUser(getContentResolver(),
Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN, 0, UserHandle.USER_CURRENT);
mQuickPulldown = (ListPreference) findPreference("status_bar_quick_qs_pulldown");
mQuickPulldown.setValue(String.valueOf(qpmode));
mQuickPulldown.setSummary(mQuickPulldown.getEntry());
mQuickPulldown.setOnPreferenceChangeListener(this);
}
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
ContentResolver resolver = getActivity().getContentResolver();
if (preference == mQuickPulldown) {
int value = Integer.parseInt((String) newValue);
Settings.System.putIntForUser(resolver,
Settings.System.STATUS_BAR_QUICK_QS_PULLDOWN, value,
UserHandle.USER_CURRENT);
int index = mQuickPulldown.findIndexOfValue((String) newValue);
mQuickPulldown.setSummary(
mQuickPulldown.getEntries()[index]);
return true;
}
return false;
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;