summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorJo De Boeck <deboeck.jo@gmail.com>2013-06-23 23:11:33 +0200
committerJo De Boeck <deboeck.jo@gmail.com>2013-06-26 19:21:14 +0200
commit57d7aa3a69b8e48d99d8e7c8589d93c1cfbbeb96 (patch)
treeb6ce0450ed5ec9975028a3b984f776e0d7bd1b16 /src/com
parenta6eafbbe45a934131d5faf8d68134205c6929c91 (diff)
downloadpackages_apps_settings-57d7aa3a69b8e48d99d8e7c8589d93c1cfbbeb96.zip
packages_apps_settings-57d7aa3a69b8e48d99d8e7c8589d93c1cfbbeb96.tar.gz
packages_apps_settings-57d7aa3a69b8e48d99d8e7c8589d93c1cfbbeb96.tar.bz2
Add 2G/3G option to profile connections (2/2)
Only show option when network type is GSM not CDMA Change-Id: Ib225366c63ae928f23afd5bbe8b5f68818a4976b
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/settings/profiles/ProfileConfig.java17
-rw-r--r--src/com/android/settings/profiles/ProfileConnectionPreference.java6
2 files changed, 18 insertions, 5 deletions
diff --git a/src/com/android/settings/profiles/ProfileConfig.java b/src/com/android/settings/profiles/ProfileConfig.java
index 1a7a53e..da9aedf 100644
--- a/src/com/android/settings/profiles/ProfileConfig.java
+++ b/src/com/android/settings/profiles/ProfileConfig.java
@@ -41,6 +41,7 @@ import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
+import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@@ -103,6 +104,10 @@ public class ProfileConfig extends SettingsPreferenceFragment
if (deviceSupportsMobileData(getActivity())) {
mConnections.add(new ConnectionItem(ConnectionSettings.PROFILE_CONNECTION_MOBILEDATA, getString(R.string.toggleData)));
mConnections.add(new ConnectionItem(ConnectionSettings.PROFILE_CONNECTION_WIFIAP, getString(R.string.toggleWifiAp)));
+ final TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
+ if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
+ mConnections.add(new ConnectionItem(ConnectionSettings.PROFILE_CONNECTION_2G3G, getString(R.string.toggle2g3g), R.array.profile_networkmode_entries));
+ }
}
if (WimaxHelper.isWimaxSupported(getActivity())) {
mConnections.add(new ConnectionItem(ConnectionSettings.PROFILE_CONNECTION_WIMAX, getString(R.string.toggleWimax)));
@@ -299,6 +304,7 @@ public class ProfileConfig extends SettingsPreferenceFragment
if (connectionList != null) {
connectionList.removeAll();
for (ConnectionItem connection : mConnections) {
+ String[] connectionstrings = getResources().getStringArray(connection.mChoices);
ConnectionSettings settings = mProfile.getSettingsForConnection(connection.mConnectionId);
if (settings == null) {
settings = new ConnectionSettings(connection.mConnectionId);
@@ -308,8 +314,7 @@ public class ProfileConfig extends SettingsPreferenceFragment
ProfileConnectionPreference pref = new ProfileConnectionPreference(getActivity());
pref.setKey("connection_" + connection.mConnectionId);
pref.setTitle(connection.mLabel);
- pref.setSummary(settings.getValue() == 1 ? getString(R.string.connection_state_enabled)
- : getString(R.string.connection_state_disabled));
+ pref.setSummary(connectionstrings[settings.getValue()]);
pref.setPersistent(false);
pref.setConnectionItem(connection);
connection.mCheckbox = pref;
@@ -439,10 +444,18 @@ public class ProfileConfig extends SettingsPreferenceFragment
String mLabel;
ConnectionSettings mSettings;
ProfileConnectionPreference mCheckbox;
+ int mChoices;
public ConnectionItem(int connectionId, String label) {
mConnectionId = connectionId;
+ mChoices = R.array.profile_connection_entries;
+ mLabel = label;
+ }
+
+ public ConnectionItem(int connectionId, String label, int choices) {
+ mConnectionId = connectionId;
mLabel = label;
+ mChoices = choices;
}
}
diff --git a/src/com/android/settings/profiles/ProfileConnectionPreference.java b/src/com/android/settings/profiles/ProfileConnectionPreference.java
index 352c707..a5fc986 100644
--- a/src/com/android/settings/profiles/ProfileConnectionPreference.java
+++ b/src/com/android/settings/profiles/ProfileConnectionPreference.java
@@ -123,11 +123,12 @@ public class ProfileConnectionPreference extends Preference implements
protected Dialog createConnectionDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
final String[] ConnectionValues = getContext().getResources().getStringArray(R.array.profile_connection_values);
+ final String[] connectionNames = getContext().getResources().getStringArray(mConnectionItem.mChoices);
currentChoice = mConnectionItem.mSettings.getValue();
builder.setTitle(mConnectionItem.mLabel);
- builder.setSingleChoiceItems(R.array.profile_connection_entries, currentChoice, new DialogInterface.OnClickListener() {
+ builder.setSingleChoiceItems(mConnectionItem.mChoices, currentChoice, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int item) {
currentChoice = item;
@@ -140,8 +141,7 @@ public class ProfileConnectionPreference extends Preference implements
if (currentChoice != defaultChoice) {
int value = Integer.parseInt(ConnectionValues[currentChoice]);
mConnectionItem.mSettings.setValue(value);
- setSummary(value == 1 ? getContext().getString(R.string.connection_state_enabled)
- : getContext().getString(R.string.connection_state_disabled));
+ setSummary(connectionNames[value]);
}
}
});