Add toast to settings widget.
When the settings widget updates bluetooth or wifi, display a toast since they are slow to update. Also fix some long lines. bug=1918321
This commit is contained in:
@@ -1820,6 +1820,8 @@ found in the list of installed applications.</string>
|
|||||||
|
|
||||||
<!-- Power Control Widget -->
|
<!-- Power Control Widget -->
|
||||||
<string name="gadget_title">Power Control</string>
|
<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>
|
||||||
|
|
||||||
<string name="vpn_settings_activity_title">VPN settings</string>
|
<string name="vpn_settings_activity_title">VPN settings</string>
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@ import android.os.ServiceManager;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.RemoteViews;
|
import android.widget.RemoteViews;
|
||||||
|
import android.widget.Toast;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.bluetooth.LocalBluetoothManager;
|
import com.android.settings.bluetooth.LocalBluetoothManager;
|
||||||
|
|
||||||
@@ -175,7 +176,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
views.setImageViewResource(R.id.btn_bluetooth, R.drawable.widget_btn_bluetooth);
|
views.setImageViewResource(R.id.btn_bluetooth, R.drawable.widget_btn_bluetooth);
|
||||||
break;
|
break;
|
||||||
case STATE_INTERMEDIATE:
|
case STATE_INTERMEDIATE:
|
||||||
views.setImageViewResource(R.id.btn_bluetooth, R.drawable.widget_btn_bluetooth_gray);
|
views.setImageViewResource(R.id.btn_bluetooth,
|
||||||
|
R.drawable.widget_btn_bluetooth_gray);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -187,7 +189,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
* @param appWidgetId
|
* @param appWidgetId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static PendingIntent getLaunchPendingIntent(Context context, int appWidgetId, int buttonId) {
|
private static PendingIntent getLaunchPendingIntent(Context context, int appWidgetId,
|
||||||
|
int buttonId) {
|
||||||
Intent launchIntent = new Intent();
|
Intent launchIntent = new Intent();
|
||||||
launchIntent.setClass(context, SettingsAppWidgetProvider.class);
|
launchIntent.setClass(context, SettingsAppWidgetProvider.class);
|
||||||
launchIntent.addCategory(Intent.CATEGORY_ALTERNATIVE);
|
launchIntent.addCategory(Intent.CATEGORY_ALTERNATIVE);
|
||||||
@@ -256,6 +259,7 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
} 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -265,7 +269,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
* @return true if enabled
|
* @return true if enabled
|
||||||
*/
|
*/
|
||||||
private static boolean getBackgroundDataState(Context context) {
|
private static boolean getBackgroundDataState(Context context) {
|
||||||
ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager connManager =
|
||||||
|
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
return connManager.getBackgroundDataSetting();
|
return connManager.getBackgroundDataSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +280,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
private void toggleBackgroundData(Context context) {
|
private void toggleBackgroundData(Context context) {
|
||||||
ConnectivityManager connManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager connManager =
|
||||||
|
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
boolean sync = getBackgroundDataState(context);
|
boolean sync = getBackgroundDataState(context);
|
||||||
connManager.setBackgroundDataSetting(!sync);
|
connManager.setBackgroundDataSetting(!sync);
|
||||||
ContentResolver.setMasterSyncAutomatically(!sync);
|
ContentResolver.setMasterSyncAutomatically(!sync);
|
||||||
@@ -300,7 +306,8 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
private void toggleGps(Context context) {
|
private void toggleGps(Context context) {
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
boolean enabled = getGpsState(context);
|
boolean enabled = getGpsState(context);
|
||||||
Settings.Secure.setLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER, !enabled);
|
Settings.Secure.setLocationProviderEnabled(resolver, LocationManager.GPS_PROVIDER,
|
||||||
|
!enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,5 +400,6 @@ public class SettingsAppWidgetProvider extends AppWidgetProvider {
|
|||||||
} 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user