Permalink
Browse files

SystemUI: fix data toggle

- required double tap to work previously

- also changed the long press intent to open
    network settings instead of general wireless
    settings, as it is more appropriate for this
    toggle

Change-Id: I808bd886e11de217cee1a37193ac1ff529856468
  • Loading branch information...
1 parent e3efa41 commit a75d61141fc5e8b06fb1c6f250bd40b28cae3af2 @travp624 committed Jun 9, 2012
@@ -16,23 +16,22 @@
package com.android.systemui.statusbar.policy.toggles;
-import android.bluetooth.BluetoothAdapter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
-import android.util.AttributeSet;
-import android.widget.CompoundButton;
-import android.widget.TextView;
import com.android.systemui.R;
public class NetworkToggle extends Toggle {
+ boolean mDataEnabled;
+
public NetworkToggle(Context context) {
super(context);
setLabel(R.string.toggle_data);
+ mDataEnabled = isMobileDataEnabled();
context.registerReceiver(getBroadcastReceiver(), getIntentFilter());
updateState();
}
@@ -44,6 +43,7 @@ private boolean isMobileDataEnabled() {
}
private void setMobileDataEnabled(boolean on) {
+ mDataEnabled = on;
ConnectivityManager cm = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
cm.setMobileDataEnabled(on);
@@ -63,6 +63,7 @@ public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
+ mDataEnabled = isMobileDataEnabled();
updateState();
}
}
@@ -77,7 +78,7 @@ protected IntentFilter getIntentFilter() {
@Override
protected boolean updateInternalToggleState() {
- mToggle.setChecked(isMobileDataEnabled());
+ mToggle.setChecked(mDataEnabled);
if (mToggle.isChecked()) {
setIcon(R.drawable.toggle_data);
} else {
@@ -89,7 +90,7 @@ protected boolean updateInternalToggleState() {
@Override
protected boolean onLongPress() {
Intent intent = new Intent(
- android.provider.Settings.ACTION_WIRELESS_SETTINGS);
+ android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
return true;

0 comments on commit a75d611

Please sign in to comment.