summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-01-25 17:48:37 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-01-25 17:48:37 +0000
commit5eac337bda898cfa20fe3b6a1f6f4dc9ae96eed2 (patch)
tree7ad31b4039ec4267df816b130601803ab87baa8a
parent05b5e8912f5dbf357c123665be8944caf043a4e8 (diff)
parent0e5473caae596c08932e96eedd1cdb34adb60af7 (diff)
Merge "Reset invalid selected countries to the default value."
-rw-r--r--java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java
index 932cc6d6c..f1ea4c9dc 100644
--- a/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java
+++ b/java/com/android/dialer/assisteddialing/ui/AssistedDialingSettingFragment.java
@@ -140,6 +140,28 @@ public class AssistedDialingSettingFragment extends PreferenceFragment {
countryChooserPref.setEntries(newKeys.toArray(new CharSequence[newKeys.size()]));
countryChooserPref.setEntryValues(newValues.toArray(new CharSequence[newValues.size()]));
+
+ if (!newValues.contains(countryChooserPref.getValue())) {
+ ameliorateInvalidSelectedValue(countryChooserPref);
+ }
+ }
+
+ /**
+ * Restore an invalid user selected value to the default value.
+ *
+ * <p>In the Assisted Dialing settings in Dialer, this state is possible when a user selected a
+ * country code, and then that country code was removed from our filtered list, typically via a
+ * change in the available countries provided by a server side flag.
+ *
+ * @param countryChooserPref The list preference to restore to default when an invalid value is
+ * detected.
+ */
+ private void ameliorateInvalidSelectedValue(ListPreference countryChooserPref) {
+ // Reset the preference value to the default value.
+ countryChooserPref.setValue(countryChooserPref.getEntryValues()[0].toString());
+ LogUtil.i(
+ "AssistedDialingSettingFragment.ameliorateInvalidSelectedValue",
+ "Reset the country chooser preference to the default value.");
}
private List<DisplayNameAndCountryCodeTuple> buildDefaultCountryChooserKeysAndValues(