Merge "Modify Power Widget Gps Icon To Represent Location. Instead of directly controlling gps on/off, it will control master location switch on/off." into klp-dev

This commit is contained in:
David Christie
2013-08-08 20:19:05 +00:00
committed by Android (Google) Code Review
9 changed files with 26 additions and 31 deletions

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 750 B

After

Width:  |  Height:  |  Size: 750 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -95,7 +95,7 @@
/> />
<LinearLayout <LinearLayout
android:id="@+id/btn_gps" android:id="@+id/btn_location"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -106,7 +106,7 @@
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
android:id="@+id/img_gps" android:id="@+id/img_location"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1" android:layout_weight="1"
@@ -115,7 +115,7 @@
/> />
<ImageView <ImageView
android:id="@+id/ind_gps" android:id="@+id/ind_location"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:scaleType="fitXY" android:scaleType="fitXY"

View File

@@ -3698,8 +3698,8 @@
<string name="gadget_wifi">Wi\u2011Fi</string> <string name="gadget_wifi">Wi\u2011Fi</string>
<!-- Spoken description for the Bluetooth power control gadget. --> <!-- Spoken description for the Bluetooth power control gadget. -->
<string name="gadget_bluetooth">Bluetooth</string> <string name="gadget_bluetooth">Bluetooth</string>
<!-- Spoken description for the GPS power control gadget. --> <!-- Spoken description for the Location power control gadget. -->
<string name="gadget_gps">GPS</string> <string name="gadget_location">Location</string>
<!-- Spoken description for the data synchronization gadget. --> <!-- Spoken description for the data synchronization gadget. -->
<string name="gadget_sync">Sync</string> <string name="gadget_sync">Sync</string>
<!-- Template for brightness gadget toggle button description. --> <!-- Template for brightness gadget toggle button description. -->

View File

@@ -59,7 +59,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
private static final int BUTTON_WIFI = 0; private static final int BUTTON_WIFI = 0;
private static final int BUTTON_BRIGHTNESS = 1; private static final int BUTTON_BRIGHTNESS = 1;
private static final int BUTTON_SYNC = 2; private static final int BUTTON_SYNC = 2;
private static final int BUTTON_GPS = 3; private static final int BUTTON_LOCATION = 3;
private static final int BUTTON_BLUETOOTH = 4; private static final int BUTTON_BLUETOOTH = 4;
// This widget keeps track of two sets of states: // This widget keeps track of two sets of states:
@@ -102,7 +102,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
private static final StateTracker sWifiState = new WifiStateTracker(); private static final StateTracker sWifiState = new WifiStateTracker();
private static final StateTracker sBluetoothState = new BluetoothStateTracker(); private static final StateTracker sBluetoothState = new BluetoothStateTracker();
private static final StateTracker sGpsState = new GpsStateTracker(); private static final StateTracker sLocationState = new LocationStateTracker();
private static final StateTracker sSyncState = new SyncStateTracker(); private static final StateTracker sSyncState = new SyncStateTracker();
private static SettingsObserver sSettingsObserver; private static SettingsObserver sSettingsObserver;
@@ -506,24 +506,23 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
} }
/** /**
* Subclass of StateTracker for GPS state. * Subclass of StateTracker for location state.
*/ */
private static final class GpsStateTracker extends StateTracker { private static final class LocationStateTracker extends StateTracker {
public int getContainerId() { return R.id.btn_gps; } public int getContainerId() { return R.id.btn_location; }
public int getButtonId() { return R.id.img_gps; } public int getButtonId() { return R.id.img_location; }
public int getIndicatorId() { return R.id.ind_gps; } public int getIndicatorId() { return R.id.ind_location; }
public int getButtonDescription() { return R.string.gadget_gps; } public int getButtonDescription() { return R.string.gadget_location; }
public int getButtonImageId(boolean on) { public int getButtonImageId(boolean on) {
return on ? R.drawable.ic_appwidget_settings_gps_on_holo return on ? R.drawable.ic_appwidget_settings_location_on_holo
: R.drawable.ic_appwidget_settings_gps_off_holo; : R.drawable.ic_appwidget_settings_location_off_holo;
} }
@Override @Override
public int getActualState(Context context) { public int getActualState(Context context) {
ContentResolver resolver = context.getContentResolver(); ContentResolver resolver = context.getContentResolver();
boolean on = Settings.Secure.isLocationProviderEnabled( return Settings.Secure.isLocationMasterSwitchEnabled(resolver)
resolver, LocationManager.GPS_PROVIDER); ? STATE_ENABLED : STATE_DISABLED;
return on ? STATE_ENABLED : STATE_DISABLED;
} }
@Override @Override
@@ -542,15 +541,11 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
final UserManager um = final UserManager um =
(UserManager) context.getSystemService(Context.USER_SERVICE); (UserManager) context.getSystemService(Context.USER_SERVICE);
if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) { if (!um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
Settings.Secure.setLocationProviderEnabled( Settings.Secure.setLocationMasterSwitchEnabled(resolver, desiredState);
resolver,
LocationManager.GPS_PROVIDER,
desiredState);
return desiredState; return desiredState;
} }
return Settings.Secure.isLocationProviderEnabled(
resolver, return Settings.Secure.isLocationMasterSwitchEnabled(resolver);
LocationManager.GPS_PROVIDER);
} }
@Override @Override
@@ -669,8 +664,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
views.setOnClickPendingIntent(R.id.btn_sync, views.setOnClickPendingIntent(R.id.btn_sync,
getLaunchPendingIntent(context, getLaunchPendingIntent(context,
BUTTON_SYNC)); BUTTON_SYNC));
views.setOnClickPendingIntent(R.id.btn_gps, views.setOnClickPendingIntent(R.id.btn_location,
getLaunchPendingIntent(context, BUTTON_GPS)); getLaunchPendingIntent(context, BUTTON_LOCATION));
views.setOnClickPendingIntent(R.id.btn_bluetooth, views.setOnClickPendingIntent(R.id.btn_bluetooth,
getLaunchPendingIntent(context, getLaunchPendingIntent(context,
BUTTON_BLUETOOTH)); BUTTON_BLUETOOTH));
@@ -701,7 +696,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
private static void updateButtons(RemoteViews views, Context context) { private static void updateButtons(RemoteViews views, Context context) {
sWifiState.setImageViewResources(context, views); sWifiState.setImageViewResources(context, views);
sBluetoothState.setImageViewResources(context, views); sBluetoothState.setImageViewResources(context, views);
sGpsState.setImageViewResources(context, views); sLocationState.setImageViewResources(context, views);
sSyncState.setImageViewResources(context, views); sSyncState.setImageViewResources(context, views);
if (getBrightnessMode(context)) { if (getBrightnessMode(context)) {
@@ -782,7 +777,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
} else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) { } else if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
sBluetoothState.onActualStateChange(context, intent); sBluetoothState.onActualStateChange(context, intent);
} else if (LocationManager.PROVIDERS_CHANGED_ACTION.equals(action)) { } else if (LocationManager.PROVIDERS_CHANGED_ACTION.equals(action)) {
sGpsState.onActualStateChange(context, intent); sLocationState.onActualStateChange(context, intent);
} else if (ContentResolver.ACTION_SYNC_CONN_STATUS_CHANGED.equals(action)) { } else if (ContentResolver.ACTION_SYNC_CONN_STATUS_CHANGED.equals(action)) {
sSyncState.onActualStateChange(context, intent); sSyncState.onActualStateChange(context, intent);
} else if (intent.hasCategory(Intent.CATEGORY_ALTERNATIVE)) { } else if (intent.hasCategory(Intent.CATEGORY_ALTERNATIVE)) {
@@ -794,8 +789,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
toggleBrightness(context); toggleBrightness(context);
} else if (buttonId == BUTTON_SYNC) { } else if (buttonId == BUTTON_SYNC) {
sSyncState.toggleState(context); sSyncState.toggleState(context);
} else if (buttonId == BUTTON_GPS) { } else if (buttonId == BUTTON_LOCATION) {
sGpsState.toggleState(context); sLocationState.toggleState(context);
} else if (buttonId == BUTTON_BLUETOOTH) { } else if (buttonId == BUTTON_BLUETOOTH) {
sBluetoothState.toggleState(context); sBluetoothState.toggleState(context);
} }