diff options
author | calderwoodra <calderwoodra@google.com> | 2018-05-17 16:15:40 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-17 17:31:53 -0700 |
commit | 29b95403e0997f58e0030e638dcdaf209319f282 (patch) | |
tree | f62cec766780b6c943f49e3ffc56315e359a046c | |
parent | 147e86270e70bf090cfc8ebb4bc5903a17a9ef10 (diff) |
Fixed various speed dial issues.
X. Pinned contacts are now saved onPause
4. Large display size no longer crops images
14. If ViLTE is disabled, IMS_VIDEO channels won't be added.
Bug: 78491298,79876391,79876661
Test: manual
PiperOrigin-RevId: 197068627
Change-Id: I642a11d684c648b7f6579792313b09eabb09a9fa
5 files changed, 43 insertions, 45 deletions
diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index fc80d23da..c118f9601 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -183,6 +183,7 @@ public class SpeedDialFragment extends Fragment { super.onPause(); favoritesListener.hideMenu(); suggestedListener.onPause(); + onHidden(); } @Override diff --git a/java/com/android/dialer/speeddial/SquareImageView.java b/java/com/android/dialer/speeddial/SquareImageView.java deleted file mode 100644 index a12f4d426..000000000 --- a/java/com/android/dialer/speeddial/SquareImageView.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -package com.android.dialer.speeddial; - -import android.content.Context; -import android.support.annotation.Nullable; -import android.util.AttributeSet; -import android.widget.QuickContactBadge; - -/** A square {@link android.widget.ImageView} constrained on width. */ -public class SquareImageView extends QuickContactBadge { - - public SquareImageView(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - setClickable(false); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, widthMeasureSpec); - } -} diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java index 2b056bbfc..9e227553b 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java @@ -18,6 +18,7 @@ package com.android.dialer.speeddial.loader; import android.content.res.Resources; import android.database.Cursor; +import android.os.Trace; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Data; @@ -105,7 +106,9 @@ public abstract class SpeedDialUiItem { * <p>If the cursor started at row X, this method will advance to row Y s.t. rows X, X + 1, ... Y * - 1 all belong to the same contact (that is, share the same contact id and lookup key). */ - public static SpeedDialUiItem fromCursor(Resources resources, Cursor cursor) { + public static SpeedDialUiItem fromCursor( + Resources resources, Cursor cursor, boolean isImsEnabled) { + Trace.beginSection("fromCursor"); Assert.checkArgument(cursor != null); Assert.checkArgument(cursor.getCount() != 0); String lookupKey = cursor.getString(LOOKUP_KEY); @@ -141,7 +144,8 @@ public abstract class SpeedDialUiItem { .build(); channels.add(channel); - if ((cursor.getInt(CARRIER_PRESENCE) & Data.CARRIER_PRESENCE_VT_CAPABLE) == 1) { + if (isImsEnabled + && (cursor.getInt(CARRIER_PRESENCE) & Data.CARRIER_PRESENCE_VT_CAPABLE) == 1) { // Add another channel if the number is ViLTE reachable channels.add(channel.toBuilder().setTechnology(Channel.IMS_VIDEO).build()); } @@ -149,6 +153,7 @@ public abstract class SpeedDialUiItem { } while (cursor.moveToNext() && Objects.equals(lookupKey, cursor.getString(LOOKUP_KEY))); builder.setChannels(ImmutableList.copyOf(channels)); + Trace.endSection(); return builder.build(); } diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java index 1ad37dc2a..998793e6e 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java @@ -25,6 +25,7 @@ import android.database.Cursor; import android.net.Uri; import android.os.Build.VERSION_CODES; import android.os.RemoteException; +import android.os.Trace; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; @@ -46,6 +47,7 @@ import com.android.dialer.speeddial.database.SpeedDialEntry; import com.android.dialer.speeddial.database.SpeedDialEntry.Channel; import com.android.dialer.speeddial.database.SpeedDialEntryDao; import com.android.dialer.speeddial.database.SpeedDialEntryDatabaseHelper; +import com.android.dialer.util.CallUtil; import com.google.common.base.Optional; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -205,7 +207,9 @@ public final class SpeedDialUiItemMutator { return loadSpeedDialUiItemsInternal(); } Assert.checkArgument(cursor.moveToFirst(), "Cursor should never be empty"); - SpeedDialUiItem item = SpeedDialUiItem.fromCursor(appContext.getResources(), cursor); + SpeedDialUiItem item = + SpeedDialUiItem.fromCursor( + appContext.getResources(), cursor, CallUtil.isVideoEnabled(appContext)); // Star the contact if it isn't starred already, then return. if (!item.isStarred()) { @@ -228,9 +232,12 @@ public final class SpeedDialUiItemMutator { @WorkerThread private ImmutableList<SpeedDialUiItem> loadSpeedDialUiItemsInternal() { + Trace.beginSection("loadSpeedDialUiItemsInternal"); Assert.isWorkerThread(); contactsPreferences.refreshValue(ContactsPreferences.DISPLAY_ORDER_KEY); + Trace.beginSection("getAllEntries"); SpeedDialEntryDao db = getSpeedDialEntryDao(); + Trace.endSection(); // getAllEntries // This is the list of contacts that we will display to the user List<SpeedDialUiItem> speedDialUiItems = new ArrayList<>(); @@ -251,6 +258,7 @@ public final class SpeedDialUiItemMutator { "Updated entries are incomplete: " + entries.size() + " != " + entriesToUiItems.size()); // Mark the SpeedDialEntries to be updated or deleted + Trace.beginSection("updateOrDeleteEntries"); for (SpeedDialEntry entry : entries) { SpeedDialUiItem contact = entriesToUiItems.get(entry); // Remove contacts that no longer exist or are no longer starred @@ -271,12 +279,14 @@ public final class SpeedDialUiItemMutator { // These are our existing starred entries speedDialUiItems.add(contact); } + Trace.endSection(); // updateOrDeleteEntries // Get all Strequent Contacts List<SpeedDialUiItem> strequentContacts = getStrequentContacts(); // For each contact, if it isn't starred, add it as a suggestion. // If it is starred and not already accounted for above, then insert into the SpeedDialEntry DB. + Trace.beginSection("addSuggestions"); for (SpeedDialUiItem contact : strequentContacts) { if (!contact.isStarred()) { // Add this contact as a suggestion @@ -291,12 +301,16 @@ public final class SpeedDialUiItemMutator { speedDialUiItems.add(contact); } } + Trace.endSection(); // addSuggestions + Trace.beginSection("insertUpdateAndDelete"); ImmutableMap<SpeedDialEntry, Long> insertedEntriesToIdsMap = db.insertUpdateAndDelete( ImmutableList.copyOf(entriesToInsert), ImmutableList.copyOf(entriesToUpdate), ImmutableList.copyOf(entriesToDelete)); + Trace.endSection(); // insertUpdateAndDelete + Trace.endSection(); // loadSpeedDialUiItemsInternal return speedDialUiItemsWithUpdatedIds(speedDialUiItems, insertedEntriesToIdsMap); } @@ -388,11 +402,13 @@ public final class SpeedDialUiItemMutator { @WorkerThread private Map<SpeedDialEntry, SpeedDialUiItem> getSpeedDialUiItemsFromEntries( List<SpeedDialEntry> entries) { + Trace.beginSection("getSpeedDialUiItemsFromEntries"); Assert.isWorkerThread(); // Fetch the contact ids from the SpeedDialEntries Set<String> contactIds = new ArraySet<>(); entries.forEach(entry -> contactIds.add(Long.toString(entry.contactId()))); if (contactIds.isEmpty()) { + Trace.endSection(); return new ArrayMap<>(); } @@ -410,7 +426,9 @@ public final class SpeedDialUiItemMutator { null)) { Map<SpeedDialEntry, SpeedDialUiItem> map = new ArrayMap<>(); for (cursor.moveToFirst(); !cursor.isAfterLast(); /* Iterate in the loop */ ) { - SpeedDialUiItem item = SpeedDialUiItem.fromCursor(appContext.getResources(), cursor); + SpeedDialUiItem item = + SpeedDialUiItem.fromCursor( + appContext.getResources(), cursor, CallUtil.isVideoEnabled(appContext)); for (SpeedDialEntry entry : entries) { if (entry.contactId() == item.contactId()) { // Update the id and pinned position to match it's corresponding SpeedDialEntry. @@ -442,6 +460,7 @@ public final class SpeedDialUiItemMutator { for (SpeedDialEntry entry : entries) { map.putIfAbsent(entry, null); } + Trace.endSection(); return map; } } @@ -467,6 +486,7 @@ public final class SpeedDialUiItemMutator { @WorkerThread private List<SpeedDialUiItem> getStrequentContacts() { + Trace.beginSection("getStrequentContacts"); Assert.isWorkerThread(); Set<String> contactIds = new ArraySet<>(); @@ -482,9 +502,11 @@ public final class SpeedDialUiItemMutator { .query(strequentUri, new String[] {Phone.CONTACT_ID}, null, null, null)) { if (cursor == null) { LogUtil.e("SpeedDialUiItemMutator.getStrequentContacts", "null cursor"); + Trace.endSection(); return new ArrayList<>(); } if (cursor.getCount() == 0) { + Trace.endSection(); return new ArrayList<>(); } for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { @@ -507,14 +529,19 @@ public final class SpeedDialUiItemMutator { List<SpeedDialUiItem> contacts = new ArrayList<>(); if (cursor == null) { LogUtil.e("SpeedDialUiItemMutator.getStrequentContacts", "null cursor"); + Trace.endSection(); return new ArrayList<>(); } if (cursor.getCount() == 0) { + Trace.endSection(); return contacts; } for (cursor.moveToFirst(); !cursor.isAfterLast(); /* Iterate in the loop */ ) { - contacts.add(SpeedDialUiItem.fromCursor(appContext.getResources(), cursor)); + contacts.add( + SpeedDialUiItem.fromCursor( + appContext.getResources(), cursor, CallUtil.isVideoEnabled(appContext))); } + Trace.endSection(); return contacts; } } diff --git a/java/com/android/dialer/speeddial/res/layout/favorite_item_layout.xml b/java/com/android/dialer/speeddial/res/layout/favorite_item_layout.xml index 134196da7..a0bbfbd36 100644 --- a/java/com/android/dialer/speeddial/res/layout/favorite_item_layout.xml +++ b/java/com/android/dialer/speeddial/res/layout/favorite_item_layout.xml @@ -27,14 +27,15 @@ android:layout_width="wrap_content" android:layout_height="104dp" android:layout_gravity="center_horizontal" - android:layout_marginBottom="8dp"> + android:layout_marginBottom="8dp" + android:minWidth="128dp"> - <com.android.dialer.speeddial.SquareImageView + <QuickContactBadge android:id="@+id/avatar" android:layout_width="104dp" android:layout_height="104dp" - android:layout_marginStart="12dp" - android:layout_marginEnd="12dp"/> + android:layout_gravity="center_horizontal" + android:clickable="false"/> <FrameLayout android:id="@+id/video_call_container" |