From 35ecd12f1617f36d8d22fecdabf9c63cbf92599d Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Sat, 24 Feb 2018 11:37:28 -0800 Subject: Cancel Old SpeedDial contact loaders when they are reset. This prevents to many loaders running at the same time and crashing the application for using too many threads at once. Also made a few UI changes: - Change Android nav bar color to #FFF - Move badges down 2dp - Limit badges to 9+ (instead of 99+, added flag to configure this) - search bar no longer has rounded corners when expanded Bug: 72525324 Test: MainActivityOldPeerTest PiperOrigin-RevId: 186894920 Change-Id: I36fc5d8794440b707184d54de427db5910ec5b8e --- .../dialer/app/list/PhoneFavoriteTileView.java | 19 +++++++------------ .../dialer/main/impl/bottomnav/BottomNavItem.java | 13 ++++++++++++- .../impl/bottomnav/res/layout/bottom_nav_item.xml | 2 +- .../main/impl/bottomnav/res/values/strings.xml | 6 ++++++ .../dialer/main/impl/res/values-v27/styles.xml | 2 +- .../dialer/main/impl/toolbar/SearchBarView.java | 2 ++ .../impl/toolbar/res/drawable/rounded_corner.xml | 21 --------------------- .../toolbar/res/drawable/search_bar_background.xml | 20 ++++++++++++++++++++ .../search_bar_background_rounded_corners.xml | 21 +++++++++++++++++++++ .../main/impl/toolbar/res/layout/toolbar_layout.xml | 2 +- 10 files changed, 71 insertions(+), 37 deletions(-) delete mode 100644 java/com/android/dialer/main/impl/toolbar/res/drawable/rounded_corner.xml create mode 100644 java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml create mode 100644 java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml (limited to 'java') diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java index 3b27d3118..3739588ea 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java @@ -32,7 +32,6 @@ import com.android.dialer.app.R; import com.android.dialer.callintent.CallInitiationType; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.callintent.SpeedDialContactType; -import com.android.dialer.common.LogUtil; import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest; import com.android.dialer.lettertile.LetterTileDrawable; import com.android.dialer.logging.InteractionEvent; @@ -192,21 +191,17 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { this.position = position; } + private ContactLoader loader; + /** * Send a notification using a {@link ContactLoader} to inform the sync adapter that we are * viewing a particular contact, so that it can download the high-res photo. */ - private static void sendViewNotification(Context context, Uri contactUri) { - ContactLoader loader = new ContactLoader(context, contactUri, true /* postViewNotification */); - loader.registerListener( - 0, - (loader1, contact) -> { - try { - loader1.reset(); - } catch (RuntimeException e) { - LogUtil.e("PhoneFavoriteTileView.onLoadComplete", "error resetting loader", e); - } - }); + private void sendViewNotification(Context context, Uri contactUri) { + if (loader != null) { + loader.cancelLoad(); + } + loader = new ContactLoader(context, contactUri, true /* postViewNotification */); loader.startLoading(); } } diff --git a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java index 2c1b4f5d7..2519d23cb 100644 --- a/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java +++ b/java/com/android/dialer/main/impl/bottomnav/BottomNavItem.java @@ -29,6 +29,7 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import com.android.dialer.common.Assert; +import com.android.dialer.configprovider.ConfigProviderBindings; /** Navigation item in a bottom nav. */ final class BottomNavItem extends LinearLayout { @@ -68,7 +69,17 @@ final class BottomNavItem extends LinearLayout { if (count == 0) { notificationBadge.setVisibility(View.INVISIBLE); } else { - String countString = count > 99 ? "99+" : String.format(Integer.toString(count)); + String countString = String.format(Integer.toString(count)); + + boolean use99PlusCount = + ConfigProviderBindings.get(getContext()).getBoolean("use_99_plus", false); + boolean use9Plus = !use99PlusCount; + + if (use99PlusCount && count > 99) { + countString = getContext().getString(R.string.bottom_nav_count_99_plus); + } else if (use9Plus && count > 9) { + countString = getContext().getString(R.string.bottom_nav_count_9_plus); + } notificationBadge.setVisibility(View.VISIBLE); notificationBadge.setText(countString); diff --git a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml index 5dddd3de5..d319b2ed9 100644 --- a/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml +++ b/java/com/android/dialer/main/impl/bottomnav/res/layout/bottom_nav_item.xml @@ -32,7 +32,7 @@ android:id="@+id/bottom_nav_item_image" android:layout_width="24dp" android:layout_height="24dp" - android:layout_marginTop="7dp"/> + android:layout_marginTop="4dp"/> Voicemail Contacts + + + 9+ + + + 99+ \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/res/values-v27/styles.xml b/java/com/android/dialer/main/impl/res/values-v27/styles.xml index c91cba245..86e6f28a6 100644 --- a/java/com/android/dialer/main/impl/res/values-v27/styles.xml +++ b/java/com/android/dialer/main/impl/res/values-v27/styles.xml @@ -20,7 +20,7 @@ \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java index 37ffb9778..78cabf733 100644 --- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java +++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java @@ -133,6 +133,7 @@ final class SearchBarView extends FrameLayout { searchBox.setText(text.get()); } searchBox.requestFocus(); + setBackgroundResource(R.drawable.search_bar_background); } }); animator.start(); @@ -164,6 +165,7 @@ final class SearchBarView extends FrameLayout { super.onAnimationEnd(animation); searchBox.setText(""); searchBoxExpanded.setVisibility(INVISIBLE); + setBackgroundResource(R.drawable.search_bar_background_rounded_corners); } }); animator.start(); diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/rounded_corner.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/rounded_corner.xml deleted file mode 100644 index 58cdabe8b..000000000 --- a/java/com/android/dialer/main/impl/toolbar/res/drawable/rounded_corner.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml new file mode 100644 index 000000000..8767057a5 --- /dev/null +++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml new file mode 100644 index 000000000..58cdabe8b --- /dev/null +++ b/java/com/android/dialer/main/impl/toolbar/res/drawable/search_bar_background_rounded_corners.xml @@ -0,0 +1,21 @@ + + + + + + diff --git a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml index 378b20f47..3ab20c1cf 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml @@ -28,7 +28,7 @@ android:layout_height="wrap_content" android:layout_margin="@dimen/search_bar_margin" android:minHeight="@dimen/collapsed_search_bar_height" - android:background="@drawable/rounded_corner" + android:background="@drawable/search_bar_background_rounded_corners" android:elevation="4dp">