am 59b56305: am f211f688: Merge "Hide call assistant configure item if necessary" into lmp-mr1-dev
* commit '59b5630581db18cd56c91ba563dcfd7c07ba82d9':
Hide call assistant configure item if necessary
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 274d74c..9095828 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -166,8 +166,6 @@
<string name="wifi_calling_use_call_assistant_summary">Let apps or services manage networks used for calls</string>
<!-- Label for setting to configure the selected call assistant. -->
<string name="wifi_calling_call_assistant_configure">Configure</string>
- <!-- Label for setting to configure the selected call assistant when no call assistant is chosen. -->
- <string name="wifi_calling_call_assistant_configure_no_selection">Call assistant off</string>
<!-- Built-in label for the default connection service setting. -->
<string name="connection_service_default_label">Built-in connection service</string>
diff --git a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
index 3869294..19e4786 100644
--- a/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
+++ b/src/com/android/phone/settings/PhoneAccountSettingsFragment.java
@@ -140,7 +140,7 @@
mConfigureCallAssistant =
getPreferenceScreen().findPreference(CONFIGURE_CALL_ASSISTANT_PREF_KEY);
mConfigureCallAssistant.setOnPreferenceClickListener(this);
- updateConfigureCallAssistantSummary();
+ updateConfigureCallAssistant();
}
if (SipUtil.isVoipSupported(getActivity())) {
@@ -208,7 +208,7 @@
} else {
mTelecomManager.setSimCallManager(null);
}
- updateConfigureCallAssistantSummary();
+ updateConfigureCallAssistant();
} else {
Log.w(LOG_TAG, "Single call assistant expected but " + simCallManagers.size()
+ " found. Ignoring preference change.");
@@ -221,15 +221,8 @@
@Override
public boolean onPreferenceClick(Preference pref) {
if (pref == mConfigureCallAssistant) {
- String packageName = null;
- PhoneAccountHandle handle = mTelecomManager.getSimCallManager();
- if (handle != null) {
- packageName = handle.getComponentName().getPackageName();
- }
- if (packageName != null) {
- Intent intent = new Intent(TelecomManager.ACTION_CONNECTION_SERVICE_CONFIGURE)
- .addCategory(Intent.CATEGORY_DEFAULT)
- .setPackage(packageName);
+ Intent intent = getConfigureCallAssistantIntent();
+ if (intent != null) {
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
@@ -271,7 +264,7 @@
updateDefaultOutgoingAccountsModel();
} else if (pref == mSelectCallAssistant) {
updateCallAssistantModel();
- updateConfigureCallAssistantSummary();
+ updateConfigureCallAssistant();
}
}
@@ -281,7 +274,7 @@
@Override
public void onAccountChanged(AccountSelectionPreference pref) {
if (pref == mSelectCallAssistant) {
- updateConfigureCallAssistantSummary();
+ updateConfigureCallAssistant();
}
}
@@ -327,16 +320,19 @@
}
/**
- * Updates the summary on the "configure call assistant" preference.
+ * Shows or hides the "configure call assistant" preference.
*/
- private void updateConfigureCallAssistantSummary() {
- if (mTelecomManager.getSimCallManager() == null) {
- mConfigureCallAssistant.setSummary(
- R.string.wifi_calling_call_assistant_configure_no_selection);
- mConfigureCallAssistant.setEnabled(false);
+ private void updateConfigureCallAssistant() {
+ Intent intent = getConfigureCallAssistantIntent();
+ boolean shouldShow = intent != null && !mApplicationContext.getPackageManager()
+ .queryIntentActivities(intent, 0).isEmpty();
+
+ PreferenceCategory callAssistantCategory = (PreferenceCategory)
+ getPreferenceScreen().findPreference(CALL_ASSISTANT_CATEGORY_PREF_KEY);
+ if (shouldShow) {
+ callAssistantCategory.addPreference(mConfigureCallAssistant);
} else {
- mConfigureCallAssistant.setSummary(null);
- mConfigureCallAssistant.setEnabled(true);
+ callAssistantCategory.removePreference(mConfigureCallAssistant);
}
}
@@ -357,4 +353,17 @@
mAccountList.addPreference(accountPreference);
}
}
+
+ private Intent getConfigureCallAssistantIntent() {
+ PhoneAccountHandle handle = mTelecomManager.getSimCallManager();
+ if (handle != null) {
+ String packageName = handle.getComponentName().getPackageName();
+ if (packageName != null) {
+ return new Intent(TelecomManager.ACTION_CONNECTION_SERVICE_CONFIGURE)
+ .addCategory(Intent.CATEGORY_DEFAULT)
+ .setPackage(packageName);
+ }
+ }
+ return null;
+ }
}