summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/widget
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-09-26 15:58:00 -0700
committerAmith Yamasani <yamasani@google.com>2010-09-27 11:20:00 -0700
commit740edeaa42d276bca21ea7e077412badecc0eea3 (patch)
tree901c53dc9037f407f8f8868a22246e58e400043b /src/com/android/settings/widget
parentdd79a33ba53fec530094f4d2fe37f0538530d9f8 (diff)
downloadpackages_apps_settings-740edeaa42d276bca21ea7e077412badecc0eea3.zip
packages_apps_settings-740edeaa42d276bca21ea7e077412badecc0eea3.tar.gz
packages_apps_settings-740edeaa42d276bca21ea7e077412badecc0eea3.tar.bz2
Fix the indicators in the button bar. The middle ones were showing the left indicators incorrectly.
Earlier refactoring seems to have messed it up. Added a position value to the state trackers. Bug: 2980926 Change-Id: I31df4b1ae0b835d801d67747154594299498c4cf
Diffstat (limited to 'src/com/android/settings/widget')
-rw-r--r--src/com/android/settings/widget/SettingsAppWidgetProvider.java39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/com/android/settings/widget/SettingsAppWidgetProvider.java b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
index 444b8d4..533b5e4 100644
--- a/src/com/android/settings/widget/SettingsAppWidgetProvider.java
+++ b/src/com/android/settings/widget/SettingsAppWidgetProvider.java
@@ -68,6 +68,28 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
private static final int STATE_UNKNOWN = 4;
private static final int STATE_INTERMEDIATE = 5;
+ // Position in the widget bar, to enable different graphics for left, center and right buttons
+ private static final int POS_LEFT = 0;
+ private static final int POS_CENTER = 1;
+ private static final int POS_RIGHT = 2;
+
+ private static final int[] IND_DRAWABLE_OFF = {
+ R.drawable.appwidget_settings_ind_off_l,
+ R.drawable.appwidget_settings_ind_off_c,
+ R.drawable.appwidget_settings_ind_off_r
+ };
+
+ private static final int[] IND_DRAWABLE_MID = {
+ R.drawable.appwidget_settings_ind_mid_l,
+ R.drawable.appwidget_settings_ind_mid_c,
+ R.drawable.appwidget_settings_ind_mid_r
+ };
+
+ private static final int[] IND_DRAWABLE_ON = {
+ R.drawable.appwidget_settings_ind_on_l,
+ R.drawable.appwidget_settings_ind_on_c,
+ R.drawable.appwidget_settings_ind_on_r
+ };
/**
* Minimum and maximum brightnesses. Don't go to 0 since that makes the display unusable
@@ -152,22 +174,28 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
public abstract int getButtonImageId(boolean on);
/**
+ * Returns the position in the button bar - either POS_LEFT, POS_RIGHT or POS_CENTER.
+ */
+ public int getPosition() { return POS_CENTER; }
+
+ /**
* Updates the remote views depending on the state (off, on,
* turning off, turning on) of the setting.
*/
public final void setImageViewResources(Context context, RemoteViews views) {
int buttonId = getButtonId();
int indicatorId = getIndicatorId();
+ int pos = getPosition();
switch (getTriState(context)) {
case STATE_DISABLED:
views.setImageViewResource(buttonId, getButtonImageId(false));
views.setImageViewResource(
- indicatorId, R.drawable.appwidget_settings_ind_off_l);
+ indicatorId, IND_DRAWABLE_OFF[pos]);
break;
case STATE_ENABLED:
views.setImageViewResource(buttonId, getButtonImageId(true));
views.setImageViewResource(
- indicatorId, R.drawable.appwidget_settings_ind_on_l);
+ indicatorId, IND_DRAWABLE_ON[pos]);
break;
case STATE_INTERMEDIATE:
// In the transitional state, the bottom green bar
@@ -178,11 +206,11 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
if (isTurningOn()) {
views.setImageViewResource(buttonId, getButtonImageId(true));
views.setImageViewResource(
- indicatorId, R.drawable.appwidget_settings_ind_mid_l);
+ indicatorId, IND_DRAWABLE_MID[pos]);
} else {
views.setImageViewResource(buttonId, getButtonImageId(false));
views.setImageViewResource(
- indicatorId, R.drawable.appwidget_settings_ind_off_l);
+ indicatorId, IND_DRAWABLE_OFF[pos]);
}
break;
}
@@ -299,6 +327,9 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
}
@Override
+ public int getPosition() { return POS_LEFT; }
+
+ @Override
public int getActualState(Context context) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (wifiManager != null) {