summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java')
-rw-r--r--src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java83
1 files changed, 44 insertions, 39 deletions
diff --git a/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java b/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
index ec7530d..00c8542 100644
--- a/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
+++ b/src/com/android/settings/profiles/actions/item/ConnectionOverrideItem.java
@@ -15,6 +15,8 @@
*/
package com.android.settings.profiles.actions.item;
+import android.content.Context;
+import android.telephony.SubscriptionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,16 +27,13 @@ import cyanogenmod.profiles.ConnectionSettings;
import com.android.settings.R;
import com.android.settings.profiles.actions.ItemListAdapter;
+import com.android.settings.utils.TelephonyUtils;
+
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 static final int CM_MODE_SYSTEM_DEFAULT = -1;
public ConnectionOverrideItem(int connectionId, ConnectionSettings settings) {
mConnectionId = connectionId;
@@ -62,8 +61,8 @@ public class ConnectionOverrideItem implements Item {
TextView title = (TextView) view.findViewById(R.id.title);
TextView summary = (TextView) view.findViewById(R.id.summary);
- title.setText(getConnectionTitle(mConnectionId));
- summary.setText(getSummary());
+ title.setText(getConnectionTitle(view.getContext(), mConnectionSettings));
+ summary.setText(getSummary(view.getContext()));
return view;
}
@@ -73,61 +72,67 @@ public class ConnectionOverrideItem implements Item {
return true;
}
- public static int getConnectionTitle(int connectionId) {
- switch (connectionId) {
+ public static String getConnectionTitle(Context context, ConnectionSettings settings) {
+ int r = 0;
+ switch (settings.getConnectionId()) {
case ConnectionSettings.PROFILE_CONNECTION_BLUETOOTH:
- return R.string.toggleBluetooth;
+ r = R.string.toggleBluetooth;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA:
- return R.string.toggleData;
+ r =R.string.toggleData;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_2G3G4G:
- return R.string.toggle2g3g4g;
+ if (settings.getSubId() != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
+ final String displayName = SubscriptionManager.from(context)
+ .getActiveSubscriptionInfo(settings.getSubId())
+ .getDisplayName()
+ .toString();
+ return context.getString(R.string.toggle2g3g4g_msim, displayName);
+ }
+ r = R.string.toggle2g3g4g;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_GPS:
- return R.string.toggleGPS;
+ r = R.string.toggleGPS;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_NFC:
- return R.string.toggleNfc;
+ r = R.string.toggleNfc;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_SYNC:
- return R.string.toggleSync;
+ r = R.string.toggleSync;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_WIFI:
- return R.string.toggleWifi;
+ r = R.string.toggleWifi;
+ break;
case ConnectionSettings.PROFILE_CONNECTION_WIFIAP:
- return R.string.toggleWifiAp;
- default:
- return 0;
+ r = R.string.toggleWifiAp;
+ break;
}
+ return context.getString(r);
}
- public int getSummary() {
+ public CharSequence getSummary(Context context) {
+ int resId = -1;
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;
- }
+ return TelephonyUtils.getNetworkModeString(context,
+ mConnectionSettings.getValue(), SubscriptionManager.getDefaultDataSubId());
} else {
- return R.string.profile_action_none;
+ resId = R.string.profile_action_none;
}
} else if (mConnectionSettings.isOverride()) { // enabled, disabled, or none
if (mConnectionSettings.getValue() == 1) {
- return R.string.profile_action_enable;
+ resId = R.string.profile_action_enable;
} else {
- return R.string.profile_action_disable;
+ resId = R.string.profile_action_disable;
}
} else {
- return R.string.profile_action_none;
+ resId = R.string.profile_action_none;
}
} else {
- return R.string.profile_action_none;
+ resId = R.string.profile_action_none;
}
+ return context.getString(resId);
}
public ConnectionSettings getSettings() {