diff options
author | calderwoodra <calderwoodra@google.com> | 2018-05-01 11:01:37 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-02 16:36:45 -0700 |
commit | 3eb6fd18fe64c02f0433de75bec7cfca9d231e62 (patch) | |
tree | 85d192a03bc5d506267c39653866954550a437dc | |
parent | 4a65002a1619ec70157b3c274a501286134cc7d4 (diff) |
Fixed speed dial remove.
App would crash when users attempted to remove a starred contact because we try
to update Phone.CONTENT_URI, which is not allowed. Test assumed that
we could update PHone.CONTENT_URI, which is why this wasn't caught.
Updated the test to verify the contact in Contacts.CONTENT_URI get updated to
starred = 0. Unforunately, since fakeContentProvider doesn't work exactly like
cp2, the update won't propogate to Phone.CONTENT_URI, so out test is less than
ideal, but it should cover our bases.
Also updated the image and text for starring a suggestion.
Bug: 78923466
Test: tap
PiperOrigin-RevId: 194962080
Change-Id: I9f8f71d70ba83510682890917081380a3c51cd7a
3 files changed, 6 insertions, 16 deletions
diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index 17591aa6c..124470617 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -399,7 +399,7 @@ public class SpeedDialFragment extends Fragment { @Override public int getDrawableId() { - return R.drawable.context_menu_contact_icon; + return R.drawable.quantum_ic_star_vd_theme_24; } @Override diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java index e8892c431..0a2a241b3 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java @@ -130,11 +130,8 @@ public final class SpeedDialUiItemMutator { private ImmutableList<SpeedDialUiItem> removeSpeedDialUiItemInternal( SpeedDialUiItem speedDialUiItem) { Assert.isWorkerThread(); - if (speedDialUiItem.isStarred()) { - removeStarredSpeedDialUiItem(speedDialUiItem); - } else { - removeSuggestedSpeedDialUiItem(speedDialUiItem); - } + Assert.checkArgument(speedDialUiItem.isStarred()); + removeStarredSpeedDialUiItem(speedDialUiItem); return loadSpeedDialUiItemsInternal(); } @@ -175,19 +172,12 @@ public final class SpeedDialUiItemMutator { appContext .getContentResolver() .update( - Phone.CONTENT_URI, + Contacts.CONTENT_URI, contentValues, - Phone.CONTACT_ID + " = ?", + Contacts._ID + " = ?", new String[] {Long.toString(speedDialUiItem.contactId())}); } - @WorkerThread - @SuppressWarnings("unused") - private void removeSuggestedSpeedDialUiItem(SpeedDialUiItem speedDialUiItem) { - Assert.isWorkerThread(); - // TODO(calderwoodra): remove strequent contact - } - /** * Takes a contact uri from {@link Phone#CONTENT_URI} and updates {@link Phone#STARRED} to be * true, if it isn't already or Inserts the contact into the {@link SpeedDialEntryDatabaseHelper} diff --git a/java/com/android/dialer/speeddial/res/values/strings.xml b/java/com/android/dialer/speeddial/res/values/strings.xml index 028f6a90c..d2f5371b8 100644 --- a/java/com/android/dialer/speeddial/res/values/strings.xml +++ b/java/com/android/dialer/speeddial/res/values/strings.xml @@ -57,5 +57,5 @@ <string name="contact_menu_contact_info">Contact info</string> <!-- Text shown to the user in a button to prompt them to mark a contact as a favorite contact [CHAR LIMIT=30]. --> - <string name="suggested_contact_bottom_sheet_add_favorite_option">Add to favorites</string> + <string name="suggested_contact_bottom_sheet_add_favorite_option">Add favorite</string> </resources>
\ No newline at end of file |