diff options
author | Jo De Boeck <deboeck.jo@gmail.com> | 2013-06-23 23:11:33 +0200 |
---|---|---|
committer | Jo De Boeck <deboeck.jo@gmail.com> | 2013-06-26 19:21:14 +0200 |
commit | 57d7aa3a69b8e48d99d8e7c8589d93c1cfbbeb96 (patch) | |
tree | b6ce0450ed5ec9975028a3b984f776e0d7bd1b16 | |
parent | a6eafbbe45a934131d5faf8d68134205c6929c91 (diff) | |
download | packages_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
-rw-r--r-- | res/values/cm_arrays.xml | 8 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 5 | ||||
-rw-r--r-- | src/com/android/settings/profiles/ProfileConfig.java | 17 | ||||
-rw-r--r-- | src/com/android/settings/profiles/ProfileConnectionPreference.java | 6 |
4 files changed, 31 insertions, 5 deletions
diff --git a/res/values/cm_arrays.xml b/res/values/cm_arrays.xml index 74fc542..bc0ec04 100644 --- a/res/values/cm_arrays.xml +++ b/res/values/cm_arrays.xml @@ -213,10 +213,18 @@ <item>Enable</item> </string-array> + <!-- Profile 2G-3G mode options. --> + <string-array name="profile_networkmode_entries" translatable="false"> + <item>@string/profile_networkmode_2g</item> + <item>@string/profile_networkmode_3g</item> + <item>@string/profile_networkmode_2g3g</item> + </string-array> + <!-- Values for profile connections. Do not translate. --> <string-array name="profile_connection_values" translatable="false"> <item>0</item> <item>1</item> + <item>2</item> </string-array> <!-- Values for profile Wi-Fi triggers --> diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 9396d75..a481723 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -215,6 +215,11 @@ <string name="profile_app_delete_confirm">Remove this application?</string> <string name="profile_cannot_delete">An active profile cannot be deleted</string> + <!-- Profile network mode --> + <string name="profile_networkmode_2g">2G</string> + <string name="profile_networkmode_3g">3G</string> + <string name="profile_networkmode_2g3g">2G/3G</string> + <!-- Profile Config screen PreferenceGroup titles --> <string name="profile_connectionoverrides_title">Connection overrides</string> <string name="profile_volumeoverrides_title">Volume overrides</string> 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]); } } }); |