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:
@@ -267,11 +267,13 @@ 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.
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the state of background data.
|
* Gets the state of background data.
|
||||||
@@ -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.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user