Add Wi-Fi calling options to Call Settings
Change-Id: Id2b7e0acfb5804d34afa4cdd02dba38aad87de69
diff --git a/res/values/array.xml b/res/values/array.xml
index 245c09b..5a360f2 100644
--- a/res/values/array.xml
+++ b/res/values/array.xml
@@ -39,6 +39,19 @@
<item>@string/sip_ask_me_each_time</item>
</string-array>
+ <string-array translatable="true" name="wifi_calling_choice_entries">
+ <item>@string/wifi_calling_choice_entry_always_use</item>
+ <item>@string/wifi_calling_choice_entry_ask_every_time</item>
+ <item>@string/wifi_calling_choice_entry_never_use</item>
+ </string-array>
+
+ <!-- android.telephony.TelephonyManager.WifiCallingChoices -->
+ <string-array name="wifi_calling_choice_values">
+ <item>@string/wifi_calling_choices_always_use</item>
+ <item>@string/wifi_calling_choices_never_use</item>
+ <item>@string/wifi_calling_choices_ask_every_time</item>
+ </string-array>
+
<string-array translatable="false" name="phone_type_values">
<item>@string/pstn_phone</item>
<item>@string/internet_phone</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8e92006..40b8198 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1149,6 +1149,27 @@
<!-- Item of the Internet call (Wi-Fi only) option dialog: for routing all outgoing calls via SIP. [CHAR LIMIT=NONE] -->
<string name="sip_call_options_wifi_only_entry_1">For all calls</string>
+ <!-- Start of Wi-Fi calling related strings. -->
+
+ <!-- Title of the Wi-Fi settings section [CHAR LIMIT=NONE] -->
+ <string name="wifi_settings">Wi-Fi call settings</string>
+ <!-- Title of option allowing user to pick when to make Wi-Fi calls [CHAR LIMIT=NONE] -->
+ <string name="when_to_make_wifi_calls_title">When to make Wi-Fi calls</string>
+ <!-- Item of Wi-Fi settings: For always using Wi-Fi to make calls. [CHAR LIMIT=NONE] -->
+ <string name="wifi_calling_choice_entry_always_use">Always use Wi-Fi to make calls</string>
+ <!-- Item of Wi-Fi settings: For never using Wi-Fi to make calls. [CHAR LIMIT=NONE] -->
+ <string name="wifi_calling_choice_entry_never_use">Never use Wi-Fi to make calls</string>
+ <!-- Item of Wi-Fi settings: For asking each time whether to use Wi-Fi. [CHAR LIMIT=NONE] -->
+ <string name="wifi_calling_choice_entry_ask_every_time">Always ask</string>
+
+ <!-- Keep values in sync with android.telephony.TelephonyManager.WifiCallingChoices -->
+ <!-- android.telephony.TelephonyManager.WifiCallingChoices.ALWAYS_USE -->
+ <string translatable="false" name="wifi_calling_choices_always_use">0</string>
+ <!-- android.telephony.TelephonyManager.WifiCallingChoices.NEVER_USE -->
+ <string translatable="false" name="wifi_calling_choices_never_use">1</string>
+ <!-- android.telephony.TelephonyManager.WifiCallingChoices.ASK_EVERY_TIME -->
+ <string translatable="false" name="wifi_calling_choices_ask_every_time">2</string>
+
<!-- Title of the dialog to select the phone type for the outgoing call. [CHAR LIMIT=NONE] -->
<string name ="pick_outgoing_call_phone_type">Place call</string>
diff --git a/res/xml/wifi_settings_category.xml b/res/xml/wifi_settings_category.xml
new file mode 100644
index 0000000..91041fd
--- /dev/null
+++ b/res/xml/wifi_settings_category.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2013 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:phone="http://schemas.android.com/apk/res/com.android.phone">
+ <PreferenceCategory
+ android:key="wifi_settings_category_key"
+ android:title="@string/wifi_settings"
+ android:persistent="false">
+
+ <ListPreference
+ android:key="when_to_make_wifi_calls_key"
+ android:title="@string/when_to_make_wifi_calls_title"
+ android:persistent="true"
+ android:entries="@array/wifi_calling_choice_entries"
+ android:entryValues="@array/wifi_calling_choice_values"/>
+
+ </PreferenceCategory>
+</PreferenceScreen>
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index 5cc3aa3..11dc35c 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -52,12 +52,9 @@
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.MediaStore;
import android.provider.Settings;
-import android.provider.Settings.SettingNotFoundException;
import android.telephony.PhoneNumberUtils;
-import android.text.Spannable;
-import android.text.SpannableString;
+import android.telephony.TelephonyManager;
import android.text.TextUtils;
-import android.text.style.TypefaceSpan;
import android.util.Log;
import android.view.MenuItem;
import android.view.WindowManager;
@@ -194,6 +191,9 @@
private static final String SIP_SETTINGS_CATEGORY_KEY =
"sip_settings_category_key";
+ private static final String WHEN_TO_MAKE_WIFI_CALLS_KEY =
+ "when_to_make_wifi_calls_key";
+
private Intent mContactListIntent;
/** Event for Async voicemail change call */
@@ -273,6 +273,7 @@
private ListPreference mButtonDTMF;
private ListPreference mButtonTTY;
private ListPreference mButtonSipCallOptions;
+ private ListPreference mWifiCallOptionsPreference;
private ListPreference mVoicemailProviders;
private PreferenceScreen mVoicemailSettings;
private Preference mVoicemailNotificationRingtone;
@@ -591,6 +592,8 @@
}
} else if (preference == mButtonSipCallOptions) {
handleSipCallOptionsChange(objValue);
+ } else if (preference == mWifiCallOptionsPreference) {
+ handleWifiCallSettingsChange(objValue);
}
// always let the preference setting proceed.
return true;
@@ -1638,6 +1641,7 @@
updateVoiceNumberField();
mVMProviderSettingsForced = false;
createSipCallSettings();
+ createWifiCallSettings();
mRingtoneLookupRunnable = new Runnable() {
@Override
@@ -1736,6 +1740,38 @@
}
}
+ private void createWifiCallSettings() {
+ addPreferencesFromResource(R.xml.wifi_settings_category);
+ mWifiCallOptionsPreference = (ListPreference) findPreference(WHEN_TO_MAKE_WIFI_CALLS_KEY);
+ mWifiCallOptionsPreference.setOnPreferenceChangeListener(this);
+ mWifiCallOptionsPreference.setValueIndex(
+ mWifiCallOptionsPreference.findIndexOfValue(
+ getWhenToMakeWifiCalls()));
+ mWifiCallOptionsPreference.setSummary(mWifiCallOptionsPreference.getEntry());
+ }
+
+ /**
+ * @see android.telephony.TelephonyManager.WifiCallingChoices
+ */
+ private String getWhenToMakeWifiCalls() {
+ int setting;
+ try {
+ setting = Settings.System.getInt(mPhone.getContext().getContentResolver(),
+ Settings.System.WHEN_TO_MAKE_WIFI_CALLS);
+ } catch (Settings.SettingNotFoundException e) {
+ setting = TelephonyManager.WifiCallingChoices.NEVER_USE;
+ }
+ return Integer.toString(setting);
+ }
+
+ /**
+ * @see android.telephony.TelephonyManager.WifiCallingChoices
+ */
+ public void setWhenToMakeWifiCalls(String value) {
+ Settings.System.putInt(mPhone.getContext().getContentResolver(),
+ Settings.System.WHEN_TO_MAKE_WIFI_CALLS, Integer.valueOf(value));
+ }
+
// 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() {
@@ -1893,6 +1929,14 @@
mButtonSipCallOptions.setSummary(mButtonSipCallOptions.getEntry());
}
+ private void handleWifiCallSettingsChange(Object objValue) {
+ String option = objValue.toString();
+ setWhenToMakeWifiCalls(option);
+ mWifiCallOptionsPreference.setValueIndex(
+ mWifiCallOptionsPreference.findIndexOfValue(option));
+ mWifiCallOptionsPreference.setSummary(mWifiCallOptionsPreference.getEntry());
+ }
+
private void updatePreferredTtyModeSummary(int TtyMode) {
String [] txts = getResources().getStringArray(R.array.tty_mode_entries);
switch(TtyMode) {