Update power widget icons and fix location behavior

Bug: 11242129

Change-Id: I29f5b4cf914ece4b0991229f384012eb66ba3820
This commit is contained in:
David Christie
2013-10-31 11:03:36 -07:00
parent 741bc05424
commit 587e6bf3fc
66 changed files with 17 additions and 11 deletions

View File

@@ -509,27 +509,33 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
* Subclass of StateTracker for location state.
*/
private static final class LocationStateTracker extends StateTracker {
private int mCurrentLocationMode = Settings.Secure.LOCATION_MODE_OFF;
public int getContainerId() { return R.id.btn_location; }
public int getButtonId() { return R.id.img_location; }
public int getIndicatorId() { return R.id.ind_location; }
public int getButtonDescription() { return R.string.gadget_location; }
public int getButtonImageId(boolean on) {
return on ? R.drawable.ic_appwidget_settings_location_on_holo
: R.drawable.ic_appwidget_settings_location_off_holo;
if (on) {
switch (mCurrentLocationMode) {
case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
return R.drawable.ic_appwidget_settings_location_on_holo;
default:
return R.drawable.ic_appwidget_settings_location_saving_holo;
}
}
return R.drawable.ic_appwidget_settings_location_off_holo;
}
@Override
public int getActualState(Context context) {
ContentResolver resolver = context.getContentResolver();
int currentLocationMode = Settings.Secure.getInt(resolver,
mCurrentLocationMode = Settings.Secure.getInt(resolver,
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
switch (currentLocationMode) {
case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
case Settings.Secure.LOCATION_MODE_OFF:
return STATE_DISABLED;
}
return STATE_ENABLED;
return (mCurrentLocationMode == Settings.Secure.LOCATION_MODE_OFF)
? STATE_DISABLED : STATE_ENABLED;
}
@Override
@@ -566,7 +572,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
break;
}
Settings.Secure.putInt(resolver, Settings.Secure.LOCATION_MODE, mode);
return desiredState;
return mode != Settings.Secure.LOCATION_MODE_OFF;
}
return getActualState(context) == STATE_ENABLED;