Loading core/java/android/provider/Settings.java +9 −3 Original line number Diff line number Diff line Loading @@ -3092,6 +3092,12 @@ public final class Settings { */ public static final String EXPANDED_RING_MODE = "expanded_ring_mode"; /** * Notification Power Widget - Custom Location Mode * @hide */ public static final String EXPANDED_LOCATION_MODE = "expanded_location_mode"; /** * Notification Power Widget - Custom Torch Mode * @hide Loading packages/SystemUI/src/com/android/systemui/quicksettings/GPSTile.java +51 −23 Original line number Diff line number Diff line Loading @@ -16,22 +16,33 @@ package com.android.systemui.quicksettings; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.UserHandle; import android.provider.Settings; import android.view.View; import com.android.systemui.R; import com.android.systemui.statusbar.phone.QuickSettingsContainerView; import com.android.systemui.statusbar.phone.QuickSettingsController; import com.android.systemui.statusbar.policy.LocationController; import com.android.systemui.statusbar.policy.LocationController.LocationSettingsChangeCallback; import java.util.Arrays; public class GPSTile extends QuickSettingsTile implements LocationSettingsChangeCallback { private LocationController mLocationController; private int mCurrentMode; private int mLocatorsMode; private int mLocatorsIndex; private static final int[] LOCATORS = new int[]{ Settings.Secure.LOCATION_MODE_OFF, Settings.Secure.LOCATION_MODE_BATTERY_SAVING, Settings.Secure.LOCATION_MODE_SENSORS_ONLY, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY }; public GPSTile(Context context, QuickSettingsController qsc, LocationController lc) { super(context, qsc); Loading @@ -41,7 +52,8 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange mOnClick = new View.OnClickListener() { @Override public void onClick(View v) { changeLocationMode(); toggleState(); updateResources(); } }; mOnLongClick = new View.OnLongClickListener() { Loading @@ -51,10 +63,13 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange return true; } }; qsc.registerObservedContent( Settings.System.getUriFor(Settings.System.EXPANDED_LOCATION_MODE), this); } @Override void onPostCreate() { updateSettings(); onLocationSettingsChanged(false); updateTile(); super.onPostCreate(); Loading @@ -78,32 +93,45 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange mCurrentMode = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, UserHandle.USER_CURRENT); mLocatorsIndex = currentModeToLocatorIndex(mCurrentMode); updateResources(); } private void changeLocationMode() { int newMode; switch (mCurrentMode) { case Settings.Secure.LOCATION_MODE_BATTERY_SAVING: newMode = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; break; case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY: newMode = Settings.Secure.LOCATION_MODE_BATTERY_SAVING; break; case Settings.Secure.LOCATION_MODE_OFF: newMode = Settings.Secure.LOCATION_MODE_SENSORS_ONLY; break; case Settings.Secure.LOCATION_MODE_SENSORS_ONLY: newMode = Settings.Secure.LOCATION_MODE_OFF; break; default: newMode = Settings.Secure.LOCATION_MODE_OFF; break; private void toggleState() { int locatorIndex = mLocatorsIndex; int mask = 0; do { locatorIndex++; if (locatorIndex >= LOCATORS.length) { locatorIndex = 0; } mask = (int) Math.pow(2, locatorIndex); } while (mLocatorsMode > 1 && (mLocatorsMode & mask) != mask); // Off is always preset // Set the desired state Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, newMode, UserHandle.USER_CURRENT); Settings.Secure.LOCATION_MODE, LOCATORS[locatorIndex], UserHandle.USER_CURRENT); } private int currentModeToLocatorIndex(int mode) { int count = LOCATORS.length; for (int i = 0; i < count; i++) { if (LOCATORS[i] == mode) { return i; } } return 0; } private void updateSettings() { mLocatorsMode = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.EXPANDED_LOCATION_MODE, 0, UserHandle.USER_CURRENT); } @Override public void onChangeUri(ContentResolver resolver, Uri uri) { updateSettings(); updateResources(); } private synchronized void updateTile() { Loading packages/SystemUI/src/com/android/systemui/quicksettings/RingerModeTile.java +2 −2 Original line number Diff line number Diff line Loading @@ -160,8 +160,8 @@ public class RingerModeTile extends QuickSettingsTile { } } } else { for (int i = 0; i < modes.length; i++) { int index = Integer.valueOf(modes[i]); for (String mode : modes) { int index = Integer.valueOf(mode); Ringer r = index < RINGERS.length ? RINGERS[index] : null; if (r != null && (hasVibrator || !r.mVibrateWhenRinging)) { Loading Loading
core/java/android/provider/Settings.java +9 −3 Original line number Diff line number Diff line Loading @@ -3092,6 +3092,12 @@ public final class Settings { */ public static final String EXPANDED_RING_MODE = "expanded_ring_mode"; /** * Notification Power Widget - Custom Location Mode * @hide */ public static final String EXPANDED_LOCATION_MODE = "expanded_location_mode"; /** * Notification Power Widget - Custom Torch Mode * @hide Loading
packages/SystemUI/src/com/android/systemui/quicksettings/GPSTile.java +51 −23 Original line number Diff line number Diff line Loading @@ -16,22 +16,33 @@ package com.android.systemui.quicksettings; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.UserHandle; import android.provider.Settings; import android.view.View; import com.android.systemui.R; import com.android.systemui.statusbar.phone.QuickSettingsContainerView; import com.android.systemui.statusbar.phone.QuickSettingsController; import com.android.systemui.statusbar.policy.LocationController; import com.android.systemui.statusbar.policy.LocationController.LocationSettingsChangeCallback; import java.util.Arrays; public class GPSTile extends QuickSettingsTile implements LocationSettingsChangeCallback { private LocationController mLocationController; private int mCurrentMode; private int mLocatorsMode; private int mLocatorsIndex; private static final int[] LOCATORS = new int[]{ Settings.Secure.LOCATION_MODE_OFF, Settings.Secure.LOCATION_MODE_BATTERY_SAVING, Settings.Secure.LOCATION_MODE_SENSORS_ONLY, Settings.Secure.LOCATION_MODE_HIGH_ACCURACY }; public GPSTile(Context context, QuickSettingsController qsc, LocationController lc) { super(context, qsc); Loading @@ -41,7 +52,8 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange mOnClick = new View.OnClickListener() { @Override public void onClick(View v) { changeLocationMode(); toggleState(); updateResources(); } }; mOnLongClick = new View.OnLongClickListener() { Loading @@ -51,10 +63,13 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange return true; } }; qsc.registerObservedContent( Settings.System.getUriFor(Settings.System.EXPANDED_LOCATION_MODE), this); } @Override void onPostCreate() { updateSettings(); onLocationSettingsChanged(false); updateTile(); super.onPostCreate(); Loading @@ -78,32 +93,45 @@ public class GPSTile extends QuickSettingsTile implements LocationSettingsChange mCurrentMode = Settings.Secure.getIntForUser(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF, UserHandle.USER_CURRENT); mLocatorsIndex = currentModeToLocatorIndex(mCurrentMode); updateResources(); } private void changeLocationMode() { int newMode; switch (mCurrentMode) { case Settings.Secure.LOCATION_MODE_BATTERY_SAVING: newMode = Settings.Secure.LOCATION_MODE_HIGH_ACCURACY; break; case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY: newMode = Settings.Secure.LOCATION_MODE_BATTERY_SAVING; break; case Settings.Secure.LOCATION_MODE_OFF: newMode = Settings.Secure.LOCATION_MODE_SENSORS_ONLY; break; case Settings.Secure.LOCATION_MODE_SENSORS_ONLY: newMode = Settings.Secure.LOCATION_MODE_OFF; break; default: newMode = Settings.Secure.LOCATION_MODE_OFF; break; private void toggleState() { int locatorIndex = mLocatorsIndex; int mask = 0; do { locatorIndex++; if (locatorIndex >= LOCATORS.length) { locatorIndex = 0; } mask = (int) Math.pow(2, locatorIndex); } while (mLocatorsMode > 1 && (mLocatorsMode & mask) != mask); // Off is always preset // Set the desired state Settings.Secure.putIntForUser(mContext.getContentResolver(), Settings.Secure.LOCATION_MODE, newMode, UserHandle.USER_CURRENT); Settings.Secure.LOCATION_MODE, LOCATORS[locatorIndex], UserHandle.USER_CURRENT); } private int currentModeToLocatorIndex(int mode) { int count = LOCATORS.length; for (int i = 0; i < count; i++) { if (LOCATORS[i] == mode) { return i; } } return 0; } private void updateSettings() { mLocatorsMode = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.EXPANDED_LOCATION_MODE, 0, UserHandle.USER_CURRENT); } @Override public void onChangeUri(ContentResolver resolver, Uri uri) { updateSettings(); updateResources(); } private synchronized void updateTile() { Loading
packages/SystemUI/src/com/android/systemui/quicksettings/RingerModeTile.java +2 −2 Original line number Diff line number Diff line Loading @@ -160,8 +160,8 @@ public class RingerModeTile extends QuickSettingsTile { } } } else { for (int i = 0; i < modes.length; i++) { int index = Integer.valueOf(modes[i]); for (String mode : modes) { int index = Integer.valueOf(mode); Ringer r = index < RINGERS.length ? RINGERS[index] : null; if (r != null && (hasVibrator || !r.mVibrateWhenRinging)) { Loading