<string name="gadget_title">Power control</string>
<string name="gadget_toggle_wifi">Updating Wi-Fi setting</string>
<string name="gadget_toggle_bluetooth">Updating Bluetooth setting</string>
+ <!-- Template for gadget toggle button description. Populated examples are "Wi-Fi off" or "Wi-Fi turning on". -->
+ <string name="gadget_state_template"><xliff:g name="feature" example="Wi-Fi">%1$s</xliff:g> <xliff:g name="state" example="off">%2$s</xliff:g></string>
+ <!-- Gadget value used to describe on state. -->
+ <string name="gadget_state_on">on</string>
+ <!-- Gadget value used to describe off state. -->
+ <string name="gadget_state_off">off</string>
+ <!-- Gadget value used to describe turning on state. -->
+ <string name="gadget_state_turning_on">turning on</string>
+ <!-- Gadget value used to describe turning off state. -->
+ <string name="gadget_state_turning_off">turning off</string>
+ <!-- Spoken description for the Wi-Fi power control gadget. -->
+ <string name="gadget_wifi">Wi-Fi</string>
+ <!-- Spoken description for the Bluetooth power control gadget. -->
+ <string name="gadget_bluetooth">Bluetooth</string>
+ <!-- Spoken description for the GPS power control gadget. -->
+ <string name="gadget_gps">GPS</string>
+ <!-- Spoken description for the data synchronization gadget. -->
+ <string name="gadget_sync">Sync</string>
+ <!-- Template for brightness gadget toggle button description. -->
+ <string name="gadget_brightness_template">Brightness <xliff:g name="state" example="half">%1$s</xliff:g></string>
+ <!-- Brightness gadget value used to describe automatic brightness state. -->
+ <string name="gadget_brightness_state_auto">auto</string>
+ <!-- Brightness gadget value used to describe maximum brightness state. -->
+ <string name="gadget_brightness_state_full">full</string>
+ <!-- Brightness gadget value used to describe half brightness state. -->
+ <string name="gadget_brightness_state_half">half</string>
+ <!-- Brightness gadget value used to describe minimum brightness state. -->
+ <string name="gadget_brightness_state_off">off</string>
<!-- Title of preference to enter the VPN settings activity -->
<string name="vpn_settings_title">VPN</string>
}
/**
+ * Return the ID of the clickable container for the setting.
+ */
+ public abstract int getContainerId();
+
+ /**
* Return the ID of the main large image button for the setting.
*/
public abstract int getButtonId();
public abstract int getIndicatorId();
/**
+ * Returns the resource ID of the setting's content description.
+ */
+ public abstract int getButtonDescription();
+
+ /**
* Returns the resource ID of the image to show as a function of
* the on-vs-off state.
*/
* turning off, turning on) of the setting.
*/
public final void setImageViewResources(Context context, RemoteViews views) {
+ int containerId = getContainerId();
int buttonId = getButtonId();
int indicatorId = getIndicatorId();
int pos = getPosition();
switch (getTriState(context)) {
case STATE_DISABLED:
+ views.setContentDescription(containerId,
+ getContentDescription(context, R.string.gadget_state_off));
views.setImageViewResource(buttonId, getButtonImageId(false));
views.setImageViewResource(
indicatorId, IND_DRAWABLE_OFF[pos]);
break;
case STATE_ENABLED:
+ views.setContentDescription(containerId,
+ getContentDescription(context, R.string.gadget_state_on));
views.setImageViewResource(buttonId, getButtonImageId(true));
views.setImageViewResource(
indicatorId, IND_DRAWABLE_ON[pos]);
// user's intent. This is much easier to see in
// sunlight.
if (isTurningOn()) {
+ views.setContentDescription(containerId,
+ getContentDescription(context, R.string.gadget_state_turning_on));
views.setImageViewResource(buttonId, getButtonImageId(true));
views.setImageViewResource(
indicatorId, IND_DRAWABLE_MID[pos]);
} else {
+ views.setContentDescription(containerId,
+ getContentDescription(context, R.string.gadget_state_turning_off));
views.setImageViewResource(buttonId, getButtonImageId(false));
views.setImageViewResource(
indicatorId, IND_DRAWABLE_OFF[pos]);
}
/**
+ * Returns the gadget state template populated with the gadget
+ * description and state.
+ */
+ private final String getContentDescription(Context context, int stateResId) {
+ final String gadget = context.getString(getButtonDescription());
+ final String state = context.getString(stateResId);
+ return context.getString(R.string.gadget_state_template, gadget, state);
+ }
+
+ /**
* Update internal state from a broadcast state change.
*/
public abstract void onActualStateChange(Context context, Intent intent);
* Subclass of StateTracker to get/set Wifi state.
*/
private static final class WifiStateTracker extends StateTracker {
+ public int getContainerId() { return R.id.btn_wifi; }
public int getButtonId() { return R.id.img_wifi; }
public int getIndicatorId() { return R.id.ind_wifi; }
+ public int getButtonDescription() { return R.string.gadget_wifi; }
public int getButtonImageId(boolean on) {
return on ? R.drawable.ic_appwidget_settings_wifi_on_holo
: R.drawable.ic_appwidget_settings_wifi_off_holo;
* Subclass of StateTracker to get/set Bluetooth state.
*/
private static final class BluetoothStateTracker extends StateTracker {
+ public int getContainerId() { return R.id.btn_bluetooth; }
public int getButtonId() { return R.id.img_bluetooth; }
public int getIndicatorId() { return R.id.ind_bluetooth; }
+ public int getButtonDescription() { return R.string.gadget_bluetooth; }
public int getButtonImageId(boolean on) {
return on ? R.drawable.ic_appwidget_settings_bluetooth_on_holo
: R.drawable.ic_appwidget_settings_bluetooth_off_holo;
* Subclass of StateTracker for GPS state.
*/
private static final class GpsStateTracker extends StateTracker {
+ public int getContainerId() { return R.id.btn_gps; }
public int getButtonId() { return R.id.img_gps; }
public int getIndicatorId() { return R.id.ind_gps; }
+ public int getButtonDescription() { return R.string.gadget_gps; }
public int getButtonImageId(boolean on) {
return on ? R.drawable.ic_appwidget_settings_gps_on_holo
: R.drawable.ic_appwidget_settings_gps_off_holo;
* Subclass of StateTracker for sync state.
*/
private static final class SyncStateTracker extends StateTracker {
+ public int getContainerId() { return R.id.btn_sync; }
public int getButtonId() { return R.id.img_sync; }
public int getIndicatorId() { return R.id.ind_sync; }
+ public int getButtonDescription() { return R.string.gadget_sync; }
public int getButtonImageId(boolean on) {
return on ? R.drawable.ic_appwidget_settings_sync_on_holo
: R.drawable.ic_appwidget_settings_sync_off_holo;
sSyncState.setImageViewResources(context, views);
if (getBrightnessMode(context)) {
+ views.setContentDescription(R.id.btn_brightness,
+ context.getString(R.string.gadget_brightness_template,
+ context.getString(R.string.gadget_brightness_state_auto)));
views.setImageViewResource(R.id.img_brightness,
R.drawable.ic_appwidget_settings_brightness_auto_holo);
views.setImageViewResource(R.id.ind_brightness,
final int half = (int)(pm.getMaximumScreenBrightnessSetting()
* HALF_BRIGHTNESS_THRESHOLD);
if (brightness > full) {
+ views.setContentDescription(R.id.btn_brightness,
+ context.getString(R.string.gadget_brightness_template,
+ context.getString(R.string.gadget_brightness_state_full)));
views.setImageViewResource(R.id.img_brightness,
R.drawable.ic_appwidget_settings_brightness_full_holo);
} else if (brightness > half) {
+ views.setContentDescription(R.id.btn_brightness,
+ context.getString(R.string.gadget_brightness_template,
+ context.getString(R.string.gadget_brightness_state_half)));
views.setImageViewResource(R.id.img_brightness,
R.drawable.ic_appwidget_settings_brightness_half_holo);
} else {
+ views.setContentDescription(R.id.btn_brightness,
+ context.getString(R.string.gadget_brightness_template,
+ context.getString(R.string.gadget_brightness_state_off)));
views.setImageViewResource(R.id.img_brightness,
R.drawable.ic_appwidget_settings_brightness_off_holo);
}