Power Widget: don't display toast in intermediate state

If bluetooth or wifi is in an intermediate state, the widget can't modify
the state, so it shouldn't pop up a toast.
This commit is contained in:
Ken Shirriff
2010-02-24 12:31:36 -08:00
parent effc754719
commit 8ab15b32f4

View File

@@ -267,10 +267,12 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
int wifiState = getWifiState(context); int wifiState = getWifiState(context);
if (wifiState == STATE_ENABLED) { if (wifiState == STATE_ENABLED) {
wifiManager.setWifiEnabled(false); wifiManager.setWifiEnabled(false);
Toast.makeText(context, R.string.gadget_toggle_wifi, Toast.LENGTH_SHORT).show();
} else if (wifiState == STATE_DISABLED) { } else if (wifiState == STATE_DISABLED) {
wifiManager.setWifiEnabled(true); wifiManager.setWifiEnabled(true);
Toast.makeText(context, R.string.gadget_toggle_wifi, Toast.LENGTH_SHORT).show();
} }
Toast.makeText(context, R.string.gadget_toggle_wifi, Toast.LENGTH_SHORT).show(); // If wifi is in intermediate state, don't do anything.
} }
/** /**
@@ -450,9 +452,11 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
int state = getBluetoothState(context); int state = getBluetoothState(context);
if (state == STATE_ENABLED) { if (state == STATE_ENABLED) {
mLocalBluetoothManager.setBluetoothEnabled(false); mLocalBluetoothManager.setBluetoothEnabled(false);
Toast.makeText(context, R.string.gadget_toggle_bluetooth, Toast.LENGTH_SHORT).show();
} else if (state == STATE_DISABLED) { } else if (state == STATE_DISABLED) {
mLocalBluetoothManager.setBluetoothEnabled(true); mLocalBluetoothManager.setBluetoothEnabled(true);
Toast.makeText(context, R.string.gadget_toggle_bluetooth, Toast.LENGTH_SHORT).show();
} }
Toast.makeText(context, R.string.gadget_toggle_bluetooth, Toast.LENGTH_SHORT).show(); // If bluetooth is in intermediate state, don't do anything.
} }
} }