summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/profiles
diff options
context:
space:
mode:
authorAdnan <adnan@cyngn.com>2014-07-17 15:35:37 -0700
committerAdnan Begovic <adnan@cyngn.com>2015-10-26 16:11:14 -0700
commitaeca4295807a848a424db7cbb88e96d80bd528b7 (patch)
treeaec9d2e5202b0c77cb5d6468ee9ca01de92b3de7 /src/com/android/settings/profiles
parent460f7bf8321f38c14eaf44058d1d1cd6faf23f11 (diff)
downloadpackages_apps_Settings-aeca4295807a848a424db7cbb88e96d80bd528b7.zip
packages_apps_Settings-aeca4295807a848a424db7cbb88e96d80bd528b7.tar.gz
packages_apps_Settings-aeca4295807a848a424db7cbb88e96d80bd528b7.tar.bz2
Profiles: Add 4g as connection options for profiles (2/2)
Change-Id: Iadf2493266162df238f6fc013a5d60631cc289e7
Diffstat (limited to 'src/com/android/settings/profiles')
-rw-r--r--src/com/android/settings/profiles/SetupActionsFragment.java89
-rw-r--r--src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java39
2 files changed, 99 insertions, 29 deletions
diff --git a/src/com/android/settings/profiles/SetupActionsFragment.java b/src/com/android/settings/profiles/SetupActionsFragment.java
index 6b9c962..485981a 100644
--- a/src/com/android/settings/profiles/SetupActionsFragment.java
+++ b/src/com/android/settings/profiles/SetupActionsFragment.java
@@ -74,7 +74,7 @@ import com.android.settings.profiles.actions.item.VolumeStreamItem;
import java.util.ArrayList;
import java.util.List;
-import static android.app.ConnectionSettings.PROFILE_CONNECTION_2G3G;
+import static android.app.ConnectionSettings.PROFILE_CONNECTION_2G3G4G;
import static android.app.ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH;
import static android.app.ConnectionSettings.PROFILE_CONNECTION_GPS;
import static android.app.ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA;
@@ -169,7 +169,7 @@ public class SetupActionsFragment extends SettingsPreferenceFragment
final TelephonyManager tm =
(TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
- mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_2G3G));
+ mItems.add(generateConnectionOverrideItem(PROFILE_CONNECTION_2G3G4G));
}
}
if (WimaxHelper.isWimaxSupported(getActivity())) {
@@ -585,27 +585,64 @@ public class SetupActionsFragment extends SettingsPreferenceFragment
builder.setTitle(ConnectionOverrideItem.getConnectionTitle(setting.getConnectionId()));
builder.setSingleChoiceItems(connectionNames, defaultIndex,
new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int item) {
- switch (item) {
- case 0: // disable override
- setting.setOverride(false);
- break;
- case 1: // enable override, disable
- setting.setOverride(true);
- setting.setValue(0);
- break;
- case 2: // enable override, enable
- setting.setOverride(true);
- setting.setValue(1);
- break;
- }
- mProfile.setConnectionSettings(setting);
- mAdapter.notifyDataSetChanged();
- updateProfile();
- dialog.dismiss();
- }
- });
+ @Override
+ public void onClick(DialogInterface dialog, int item) {
+ switch (item) {
+ case 0: // disable override
+ setting.setOverride(false);
+ break;
+ case 1: // enable override, disable
+ setting.setOverride(true);
+ setting.setValue(0);
+ break;
+ case 2: // enable override, enable
+ setting.setOverride(true);
+ setting.setValue(1);
+ break;
+ }
+ mProfile.setConnectionSettings(setting);
+ mAdapter.notifyDataSetChanged();
+ updateProfile();
+ dialog.dismiss();
+ }
+ });
+
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.show();
+ }
+
+ private void requestMobileConnectionOverrideDialog(final ConnectionSettings setting) {
+ if (setting == null) {
+ throw new UnsupportedOperationException("connection setting cannot be null yo");
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ final String[] connectionNames =
+ getResources().getStringArray(R.array.profile_networkmode_entries_4g);
+
+ int defaultIndex = ConnectionOverrideItem.CM_MODE_UNCHANGED; // no action
+ if (setting.isOverride()) {
+ defaultIndex = setting.getValue();
+ }
+
+ builder.setTitle(ConnectionOverrideItem.getConnectionTitle(setting.getConnectionId()));
+ builder.setSingleChoiceItems(connectionNames, defaultIndex,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int item) {
+ switch (item) {
+ case ConnectionOverrideItem.CM_MODE_UNCHANGED:
+ setting.setOverride(false);
+ break;
+ default:
+ setting.setOverride(true);
+ setting.setValue(item);
+ }
+ mProfile.setConnectionSettings(setting);
+ mAdapter.notifyDataSetChanged();
+ updateProfile();
+ dialog.dismiss();
+ }
+ });
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
@@ -726,7 +763,11 @@ public class SetupActionsFragment extends SettingsPreferenceFragment
requestRingModeDialog(item.getSettings());
} else if (itemAtPosition instanceof ConnectionOverrideItem) {
ConnectionOverrideItem item = (ConnectionOverrideItem) itemAtPosition;
- requestConnectionOverrideDialog(item.getSettings());
+ if (item.getConnectionType() == ConnectionSettings.PROFILE_CONNECTION_2G3G4G) {
+ requestMobileConnectionOverrideDialog(item.getSettings());
+ } else {
+ requestConnectionOverrideDialog(item.getSettings());
+ }
} else if (itemAtPosition instanceof VolumeStreamItem) {
VolumeStreamItem item = (VolumeStreamItem) itemAtPosition;
requestVolumeDialog(item.getStreamType(), item.getSettings());
diff --git a/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java b/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
index 74efd27..7ec5553 100644
--- a/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
+++ b/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
@@ -28,6 +28,13 @@ public class ConnectionOverrideItem implements Item {
int mConnectionId;
ConnectionSettings mConnectionSettings;
+ public static final int CM_MODE_2G = 0;
+ public static final int CM_MODE_3G = 1;
+ public static final int CM_MODE_4G = 2;
+ public static final int CM_MODE_2G3G = 3;
+ public static final int CM_MODE_ALL = 4;
+ public static final int CM_MODE_UNCHANGED = 5;
+
public ConnectionOverrideItem(int connectionId, ConnectionSettings settings) {
mConnectionId = connectionId;
if (settings == null) {
@@ -71,8 +78,8 @@ public class ConnectionOverrideItem implements Item {
return R.string.toggleBluetooth;
case ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA:
return R.string.toggleData;
- case ConnectionSettings.PROFILE_CONNECTION_2G3G:
- return R.string.toggle2g3g;
+ case ConnectionSettings.PROFILE_CONNECTION_2G3G4G:
+ return R.string.toggle2g3g4g;
case ConnectionSettings.PROFILE_CONNECTION_GPS:
return R.string.toggleGPS;
case ConnectionSettings.PROFILE_CONNECTION_NFC:
@@ -89,9 +96,31 @@ public class ConnectionOverrideItem implements Item {
}
public int getSummary() {
- if (mConnectionSettings != null && mConnectionSettings.isOverride()) {
- if (mConnectionSettings.getValue() == 1) {
- return R.string.profile_action_enable;
+ if (mConnectionSettings != null) {
+ if (mConnectionId == ConnectionSettings.PROFILE_CONNECTION_2G3G4G) { // different options
+ if (mConnectionSettings.isOverride()) {
+ switch (mConnectionSettings.getValue()) {
+ case CM_MODE_2G:
+ return R.string.profile_networkmode_2g;
+ case CM_MODE_3G:
+ return R.string.profile_networkmode_3g;
+ case CM_MODE_4G:
+ return R.string.profile_networkmode_4g;
+ case CM_MODE_2G3G:
+ return R.string.profile_networkmode_2g3g;
+ default:
+ case CM_MODE_ALL:
+ return R.string.profile_networkmode_2g3g4g;
+ }
+ } else {
+ return R.string.profile_action_none;
+ }
+ } else if (mConnectionSettings.isOverride()) { // enabled, disabled, or none
+ if (mConnectionSettings.getValue() == 1) {
+ return R.string.profile_action_enable;
+ } else {
+ return R.string.profile_action_disable;
+ }
} else {
return R.string.profile_action_disable;
}