Add strings for WIFI only SIP call options.
To simplify the code, I created two list preferences in
sip_settings_category.xml and the code makes one of them invisible based on the
WIFI-only config flag.
http://b/issue?id=3093602
Change-Id: I26381815724b4e5f01833fcaac3752280ba01c51
diff --git a/res/values/array.xml b/res/values/array.xml
index 5318923..2ce65a2 100644
--- a/res/values/array.xml
+++ b/res/values/array.xml
@@ -22,11 +22,20 @@
<string-array translatable="true" name="sip_call_options_entries">
<!-- Item for routing all outgoing calls via SIP. [CHAR LIMIT=NONE] -->
- <item>For all calls when data network available</item>
+ <item>For all calls when data network is available</item>
<!-- Item for routing a outgoing call via SIP if the destination is a SIP URI. [CHAR LIMIT=NONE] -->
- <item>Only for Internet numbers</item>
+ <item>Only for Internet calls</item>
<!-- Item for asking user to select the way for each outgoing call. [CHAR LIMIT=NONE] -->
- <item>Ask every time I make a call</item>
+ <item>Ask for each call</item>
+ </string-array>
+
+ <string-array translatable="true" name="sip_call_options_wifi_only_entries">
+ <!-- Item for routing all outgoing calls via SIP. [CHAR LIMIT=NONE] -->
+ <item>For all calls</item>
+ <!-- Item for routing a outgoing call via SIP if the destination is a SIP URI. [CHAR LIMIT=NONE] -->
+ <item>Only for Internet calls</item>
+ <!-- Item for asking user to select the way for each outgoing call. [CHAR LIMIT=NONE] -->
+ <item>Ask for each call</item>
</string-array>
<string-array translatable="false" name="sip_call_options_values">
diff --git a/res/values/strings.xml b/res/values/strings.xml
index f26c2ee..60cbb50 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1236,6 +1236,8 @@
<string name="sip_call_options">Configure call options</string>
<!-- Title for the dialog of selecting the way we handle an outgoing call. [CHAR LIMIT=NONE] -->
<string name="sip_call_options_title">Use Internet calling</string>
+ <!-- Title for the dialog of selecting the way we handle an outgoing call (Wi-Fi only). [CHAR LIMIT=NONE] -->
+ <string name="sip_call_options_wifi_only_title">Use Internet calling (Wi-Fi only)</string>
<!-- Title for enabling the auto registration for all sip accounts. [CHAR LIMIT=NONE] -->
<string name="auto_reg">Auto-registration</string>
diff --git a/res/xml/sip_settings_category.xml b/res/xml/sip_settings_category.xml
index c8c37fc..e857be6 100644
--- a/res/xml/sip_settings_category.xml
+++ b/res/xml/sip_settings_category.xml
@@ -36,5 +36,13 @@
android:persistent="true"
android:entries="@array/sip_call_options_entries"
android:entryValues="@array/sip_call_options_values"/>
+
+ <ListPreference
+ android:key="sip_call_options_wifi_only_key"
+ android:title="@string/sip_call_options_title"
+ android:dialogTitle="@string/sip_call_options_wifi_only_title"
+ android:persistent="true"
+ android:entries="@array/sip_call_options_wifi_only_entries"
+ android:entryValues="@array/sip_call_options_values"/>
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 8c05031..3c75973 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -39,6 +39,7 @@
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
+import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.provider.ContactsContract.CommonDataKinds;
@@ -134,6 +135,8 @@
private static final String BUTTON_SIP_CALL_OPTIONS =
"sip_call_options_key";
+ private static final String BUTTON_SIP_CALL_OPTIONS_WIFI_ONLY =
+ "sip_call_options_wifi_only_key";
private static final String SIP_SETTINGS_CATEGORY_KEY =
"sip_settings_category_key";
@@ -1433,8 +1436,7 @@
mSipManager = SipManager.newInstance(this);
mSipSharedPreferences = new SipSharedPreferences(this);
addPreferencesFromResource(R.xml.sip_settings_category);
- mButtonSipCallOptions = (ListPreference) findPreference
- (BUTTON_SIP_CALL_OPTIONS);
+ mButtonSipCallOptions = getSipCallOptionPreference();
mButtonSipCallOptions.setOnPreferenceChangeListener(this);
mButtonSipCallOptions.setValueIndex(
mButtonSipCallOptions.findIndexOfValue(
@@ -1443,6 +1445,24 @@
}
}
+ // Gets the call options for SIP depending on whether SIP is allowed only
+ // on Wi-Fi only; also make the other options preference invisible.
+ private ListPreference getSipCallOptionPreference() {
+ ListPreference wifiAnd3G = (ListPreference)
+ findPreference(BUTTON_SIP_CALL_OPTIONS);
+ ListPreference wifiOnly = (ListPreference)
+ findPreference(BUTTON_SIP_CALL_OPTIONS_WIFI_ONLY);
+ PreferenceGroup sipSettings = (PreferenceGroup)
+ findPreference(SIP_SETTINGS_CATEGORY_KEY);
+ if (SipManager.isSipWifiOnly(this)) {
+ sipSettings.removePreference(wifiAnd3G);
+ return wifiOnly;
+ } else {
+ sipSettings.removePreference(wifiOnly);
+ return wifiAnd3G;
+ }
+ }
+
@Override
protected void onResume() {
super.onResume();