diff options
author | Yorke Lee <yorkelee@google.com> | 2014-10-06 19:56:00 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-10-06 19:56:00 +0000 |
commit | cc905070716384be515de6f8410612ecb4495a4a (patch) | |
tree | e385fa8f93b9db58015bbaaa33aa0db12fb4a006 | |
parent | 20347611513c1b3e5a129797f32c091d1a0e91ce (diff) | |
parent | 8ab775e5660b716081f1edd267dad2459f204150 (diff) |
am 8ab775e5: Merge "Fix IllegalStateException in Dialer" into lmp-dev
* commit '8ab775e5660b716081f1edd267dad2459f204150':
Fix IllegalStateException in Dialer
3 files changed, 19 insertions, 6 deletions
diff --git a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java index 9fb223903..da4f4a4c9 100644 --- a/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java +++ b/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java @@ -159,8 +159,13 @@ public class DialerPhoneNumberListAdapter extends PhoneNumberListAdapter { v.setAdjustSelectionBoundsEnabled(false); } - public void setShortcutEnabled(int shortcutType, boolean visible) { + /** + * @return True if the shortcut state (disabled vs enabled) was changed by this operation + */ + public boolean setShortcutEnabled(int shortcutType, boolean visible) { + final boolean changed = mShortcutEnabled[shortcutType] != visible; mShortcutEnabled[shortcutType] = visible; + return changed; } public String getFormattedQueryString() { diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java index 3ce4bea72..f1f2ae039 100644 --- a/src/com/android/dialer/list/RegularSearchListAdapter.java +++ b/src/com/android/dialer/list/RegularSearchListAdapter.java @@ -69,13 +69,17 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { @Override public void setQueryString(String queryString) { final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()); - setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts); + boolean changed = false; + changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts); // Either one of the add contacts options should be enabled. If the user entered // a dialable number, then clicking add to contact should add it as a number. // Otherwise, it should add it to a new contact as a name. - setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts); - setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL, + changed |= setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts); + changed |= setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL, showNumberShortcuts && CallUtil.isVideoEnabled(getContext())); + if (changed) { + notifyDataSetChanged(); + } super.setQueryString(queryString); } } diff --git a/src/com/android/dialer/list/SmartDialNumberListAdapter.java b/src/com/android/dialer/list/SmartDialNumberListAdapter.java index b2e031074..04c0d620d 100644 --- a/src/com/android/dialer/list/SmartDialNumberListAdapter.java +++ b/src/com/android/dialer/list/SmartDialNumberListAdapter.java @@ -118,9 +118,13 @@ public class SmartDialNumberListAdapter extends DialerPhoneNumberListAdapter { @Override public void setQueryString(String queryString) { final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()); - setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts); - setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL, + boolean changed = false; + changed |= setShortcutEnabled(SHORTCUT_ADD_NUMBER_TO_CONTACTS, showNumberShortcuts); + changed |= setShortcutEnabled(SHORTCUT_MAKE_VIDEO_CALL, showNumberShortcuts && CallUtil.isVideoEnabled(getContext())); + if (changed) { + notifyDataSetChanged(); + } super.setQueryString(queryString); } } |