Loading res/values/cm_arrays.xml +14 −0 Original line number Diff line number Diff line Loading @@ -356,6 +356,20 @@ <item>3</item> </string-array> <string-array name="entries_location_widget" translatable="false"> <!-- Off is always preset --> <item>@string/cm_location_mode_battery_saving</item> <item>@string/cm_location_mode_device_only</item> <item>@string/cm_location_mode_high_accuracy</item> </string-array> <string-array name="values_location_widget" translatable="false"> <!-- Off is always preset --> <item>1</item> <item>2</item> <item>3</item> </string-array> <!-- Quick pulldown --> <string-array name="quick_pulldown_entries" translatable="false"> <item>@string/quick_pulldown_off</item> Loading res/values/cm_strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -401,6 +401,10 @@ <string name="cm_sound_mode_vibrate">Vibrate</string> <string name="cm_sound_mode_sound">Sound</string> <string name="cm_sound_mode_soundVibrate">Sound & Vibrate</string> <string name="pref_location_mode_title">Location modes</string> <string name="cm_location_mode_battery_saving">Battery saving</string> <string name="cm_location_mode_device_only">Device only</string> <string name="cm_location_mode_high_accuracy">High accuracy</string> <!-- Reset tiles --> <string name="tiles_reset_title">Reset</string> Loading res/xml/quick_settings_panel.xml +7 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,13 @@ android:entries="@array/entries_screentimeout_widget" android:entryValues="@array/values_screentimeout_widget" /> <MultiSelectListPreference android:key="pref_location_mode" android:dialogTitle="@string/pref_location_mode_title" android:title="@string/pref_location_mode_title" android:entries="@array/entries_location_widget" android:entryValues="@array/values_location_widget" /> </PreferenceCategory> <PreferenceCategory Loading src/com/android/settings/quicksettings/QuickSettings.java +33 −1 Original line number Diff line number Diff line /* * Copyright (C) 2011 The CyanogenMod Project * Copyright (C) 2011-2014 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -27,6 +27,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; import android.os.Bundle; import android.os.UserHandle; import android.os.Vibrator; import android.preference.ListPreference; import android.preference.MultiSelectListPreference; Loading @@ -48,6 +49,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements private static final String SEPARATOR = "OV=I=XseparatorX=I=VO"; private static final String EXP_RING_MODE = "pref_ring_mode"; private static final String EXP_LOCATION_MODE = "pref_location_mode"; private static final String EXP_NETWORK_MODE = "pref_network_mode"; private static final String EXP_SCREENTIMEOUT_MODE = "pref_screentimeout_mode"; private static final String QUICK_PULLDOWN = "quick_pulldown"; Loading @@ -57,6 +59,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements private static final String QS_SMALL_ICONS = "qs_small_icons"; private MultiSelectListPreference mRingMode; private MultiSelectListPreference mLocationMode; private ListPreference mNetworkMode; private ListPreference mScreenTimeoutMode; private ListPreference mQuickPulldown; Loading Loading @@ -112,6 +115,23 @@ public class QuickSettings extends SettingsPreferenceFragment implements } } mLocationMode = (MultiSelectListPreference) prefSet.findPreference(EXP_LOCATION_MODE); if (mLocationMode != null) { int currentLocatorMode = Settings.System.getIntForUser(resolver, Settings.System.EXPANDED_LOCATION_MODE, 0, UserHandle.USER_CURRENT); Set<String> currentModes = new HashSet<String>(); String[] modes = getResources().getStringArray(R.array.values_location_widget); int count = modes.length; for (int i = 0; i < count; i++) { int mask = (int) Math.pow(2, i + 1); // Off is always preset if ((currentLocatorMode & mask) == mask) { currentModes.add(modes[i]); } } mLocationMode.setValues(currentModes); mLocationMode.setOnPreferenceChangeListener(this); } // Add the network mode preference mNetworkMode = (ListPreference) prefSet.findPreference(EXP_NETWORK_MODE); if (mNetworkMode != null) { Loading Loading @@ -179,6 +199,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements } } @SuppressWarnings("unchecked") public boolean onPreferenceChange(Preference preference, Object newValue) { ContentResolver resolver = getContentResolver(); if (preference == mRingMode) { Loading @@ -188,6 +209,17 @@ public class QuickSettings extends SettingsPreferenceFragment implements Settings.System.putString(resolver, Settings.System.EXPANDED_RING_MODE, value); updateSummary(value, mRingMode, R.string.pref_ring_mode_summary); return true; } else if (preference == mLocationMode) { int currentLocatorMode = 1; // Off is always preset String[] currentModes = ((Set<String>) newValue).toArray(new String[]{}); int count = currentModes.length; for (int i = 0; i < count; i++) { int index = mLocationMode.findIndexOfValue(currentModes[i]); currentLocatorMode |= (int) Math.pow(2, index + 1); // Off is always preset } Settings.System.putIntForUser(resolver, Settings.System.EXPANDED_LOCATION_MODE, currentLocatorMode, UserHandle.USER_CURRENT); return true; } else if (preference == mNetworkMode) { int value = Integer.valueOf((String) newValue); int index = mNetworkMode.findIndexOfValue((String) newValue); Loading Loading
res/values/cm_arrays.xml +14 −0 Original line number Diff line number Diff line Loading @@ -356,6 +356,20 @@ <item>3</item> </string-array> <string-array name="entries_location_widget" translatable="false"> <!-- Off is always preset --> <item>@string/cm_location_mode_battery_saving</item> <item>@string/cm_location_mode_device_only</item> <item>@string/cm_location_mode_high_accuracy</item> </string-array> <string-array name="values_location_widget" translatable="false"> <!-- Off is always preset --> <item>1</item> <item>2</item> <item>3</item> </string-array> <!-- Quick pulldown --> <string-array name="quick_pulldown_entries" translatable="false"> <item>@string/quick_pulldown_off</item> Loading
res/values/cm_strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -401,6 +401,10 @@ <string name="cm_sound_mode_vibrate">Vibrate</string> <string name="cm_sound_mode_sound">Sound</string> <string name="cm_sound_mode_soundVibrate">Sound & Vibrate</string> <string name="pref_location_mode_title">Location modes</string> <string name="cm_location_mode_battery_saving">Battery saving</string> <string name="cm_location_mode_device_only">Device only</string> <string name="cm_location_mode_high_accuracy">High accuracy</string> <!-- Reset tiles --> <string name="tiles_reset_title">Reset</string> Loading
res/xml/quick_settings_panel.xml +7 −0 Original line number Diff line number Diff line Loading @@ -74,6 +74,13 @@ android:entries="@array/entries_screentimeout_widget" android:entryValues="@array/values_screentimeout_widget" /> <MultiSelectListPreference android:key="pref_location_mode" android:dialogTitle="@string/pref_location_mode_title" android:title="@string/pref_location_mode_title" android:entries="@array/entries_location_widget" android:entryValues="@array/values_location_widget" /> </PreferenceCategory> <PreferenceCategory Loading
src/com/android/settings/quicksettings/QuickSettings.java +33 −1 Original line number Diff line number Diff line /* * Copyright (C) 2011 The CyanogenMod Project * Copyright (C) 2011-2014 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. Loading Loading @@ -27,6 +27,7 @@ import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; import android.os.Bundle; import android.os.UserHandle; import android.os.Vibrator; import android.preference.ListPreference; import android.preference.MultiSelectListPreference; Loading @@ -48,6 +49,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements private static final String SEPARATOR = "OV=I=XseparatorX=I=VO"; private static final String EXP_RING_MODE = "pref_ring_mode"; private static final String EXP_LOCATION_MODE = "pref_location_mode"; private static final String EXP_NETWORK_MODE = "pref_network_mode"; private static final String EXP_SCREENTIMEOUT_MODE = "pref_screentimeout_mode"; private static final String QUICK_PULLDOWN = "quick_pulldown"; Loading @@ -57,6 +59,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements private static final String QS_SMALL_ICONS = "qs_small_icons"; private MultiSelectListPreference mRingMode; private MultiSelectListPreference mLocationMode; private ListPreference mNetworkMode; private ListPreference mScreenTimeoutMode; private ListPreference mQuickPulldown; Loading Loading @@ -112,6 +115,23 @@ public class QuickSettings extends SettingsPreferenceFragment implements } } mLocationMode = (MultiSelectListPreference) prefSet.findPreference(EXP_LOCATION_MODE); if (mLocationMode != null) { int currentLocatorMode = Settings.System.getIntForUser(resolver, Settings.System.EXPANDED_LOCATION_MODE, 0, UserHandle.USER_CURRENT); Set<String> currentModes = new HashSet<String>(); String[] modes = getResources().getStringArray(R.array.values_location_widget); int count = modes.length; for (int i = 0; i < count; i++) { int mask = (int) Math.pow(2, i + 1); // Off is always preset if ((currentLocatorMode & mask) == mask) { currentModes.add(modes[i]); } } mLocationMode.setValues(currentModes); mLocationMode.setOnPreferenceChangeListener(this); } // Add the network mode preference mNetworkMode = (ListPreference) prefSet.findPreference(EXP_NETWORK_MODE); if (mNetworkMode != null) { Loading Loading @@ -179,6 +199,7 @@ public class QuickSettings extends SettingsPreferenceFragment implements } } @SuppressWarnings("unchecked") public boolean onPreferenceChange(Preference preference, Object newValue) { ContentResolver resolver = getContentResolver(); if (preference == mRingMode) { Loading @@ -188,6 +209,17 @@ public class QuickSettings extends SettingsPreferenceFragment implements Settings.System.putString(resolver, Settings.System.EXPANDED_RING_MODE, value); updateSummary(value, mRingMode, R.string.pref_ring_mode_summary); return true; } else if (preference == mLocationMode) { int currentLocatorMode = 1; // Off is always preset String[] currentModes = ((Set<String>) newValue).toArray(new String[]{}); int count = currentModes.length; for (int i = 0; i < count; i++) { int index = mLocationMode.findIndexOfValue(currentModes[i]); currentLocatorMode |= (int) Math.pow(2, index + 1); // Off is always preset } Settings.System.putIntForUser(resolver, Settings.System.EXPANDED_LOCATION_MODE, currentLocatorMode, UserHandle.USER_CURRENT); return true; } else if (preference == mNetworkMode) { int value = Integer.valueOf((String) newValue); int index = mNetworkMode.findIndexOfValue((String) newValue); Loading