From b4b4b08f2232c686f93e899bacdbfd8600ff78e4 Mon Sep 17 00:00:00 2001 From: roldenburg Date: Tue, 11 Jul 2017 17:23:21 -0700 Subject: Fix Call button text alignment in expanded call log item The Call button may have two lines of text. We were not properly setting the second to GONE in all cases. Note: We don't need to require Google Dialer being the default Dialer for the Duo integration to work. I added this check so removing it doesn't go against any previous well-considered decision. It also enables the Espresso test work without needing a flag to override. Before: https://screenshot.googleplex.com/3YXaZdbQk7k After: https://drive.google.com/open?id=0B7uuA4cyYX0xNThETTJWdTVQQWM Bug: 63062360 Test: GoogleDialtactsActivityTest PiperOrigin-RevId: 161606497 Change-Id: I7526a4fc60b84906cc04563b635eaad9f348415e --- .../database/NoNullCursorAsyncQueryHandler.java | 31 ++++++++++++++++++++++ .../app/calllog/CallLogListItemViewHolder.java | 9 ++++--- .../app/res/layout/call_log_list_item_actions.xml | 3 +-- 3 files changed, 37 insertions(+), 6 deletions(-) (limited to 'java/com/android') diff --git a/java/com/android/contacts/common/database/NoNullCursorAsyncQueryHandler.java b/java/com/android/contacts/common/database/NoNullCursorAsyncQueryHandler.java index d5e61354a..5d10720b5 100644 --- a/java/com/android/contacts/common/database/NoNullCursorAsyncQueryHandler.java +++ b/java/com/android/contacts/common/database/NoNullCursorAsyncQueryHandler.java @@ -20,6 +20,9 @@ import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; +import java.util.concurrent.atomic.AtomicInteger; /** * An {@AsyncQueryHandler} that will never return a null cursor. @@ -27,6 +30,8 @@ import android.net.Uri; *

Instead, will return a {@link Cursor} with 0 records. */ public abstract class NoNullCursorAsyncQueryHandler extends AsyncQueryHandler { + private static final AtomicInteger pendingQueryCount = new AtomicInteger(); + @Nullable private static PendingQueryCountChangedListener pendingQueryCountChangedListener; public NoNullCursorAsyncQueryHandler(ContentResolver cr) { super(cr); @@ -41,6 +46,11 @@ public abstract class NoNullCursorAsyncQueryHandler extends AsyncQueryHandler { String selection, String[] selectionArgs, String orderBy) { + pendingQueryCount.getAndIncrement(); + if (pendingQueryCountChangedListener != null) { + pendingQueryCountChangedListener.onPendingQueryCountChanged(); + } + final CookieWithProjection projectionCookie = new CookieWithProjection(cookie, projection); super.startQuery(token, projectionCookie, uri, projection, selection, selectionArgs, orderBy); } @@ -55,10 +65,31 @@ public abstract class NoNullCursorAsyncQueryHandler extends AsyncQueryHandler { cursor = new EmptyCursor(projectionCookie.projection); } onNotNullableQueryComplete(token, projectionCookie.originalCookie, cursor); + + pendingQueryCount.getAndDecrement(); + if (pendingQueryCountChangedListener != null) { + pendingQueryCountChangedListener.onPendingQueryCountChanged(); + } } protected abstract void onNotNullableQueryComplete(int token, Object cookie, Cursor cursor); + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + public static void setPendingQueryCountChangedListener( + @Nullable PendingQueryCountChangedListener listener) { + pendingQueryCountChangedListener = listener; + } + + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + public static int getPendingQueryCount() { + return pendingQueryCount.get(); + } + + /** Callback to listen for changes in the number of queries that have not completed. */ + public interface PendingQueryCountChangedListener { + void onPendingQueryCountChanged(); + } + /** Class to add projection to an existing cookie. */ private static class CookieWithProjection { diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index 884d07d50..6b97bd694 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -581,12 +581,16 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder return; } + TextView callTypeOrLocationView = + ((TextView) callButtonView.findViewById(R.id.call_type_or_location_text)); + if (canPlaceCallToNumber) { // Set up the call button but hide it by default (the primary action is to call so it is // redundant). We then set it to be visible when appropriate below. This saves us having to // remember to set it to GONE in multiple places. callButtonView.setTag(IntentProvider.getReturnCallIntentProvider(number)); callButtonView.setVisibility(View.GONE); + callTypeOrLocationView.setVisibility(View.GONE); } if (!TextUtils.isEmpty(voicemailUri) && canPlaceCallToNumber) { @@ -595,13 +599,10 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder TextUtils.expandTemplate( mContext.getString(R.string.call_log_action_call), nameOrNumber == null ? "" : nameOrNumber)); - TextView callTypeOrLocationView = - ((TextView) callButtonView.findViewById(R.id.call_type_or_location_text)); + if (callType == Calls.VOICEMAIL_TYPE && !TextUtils.isEmpty(callTypeOrLocation)) { callTypeOrLocationView.setText(callTypeOrLocation); callTypeOrLocationView.setVisibility(View.VISIBLE); - } else { - callTypeOrLocationView.setVisibility(View.GONE); } callButtonView.setVisibility(View.VISIBLE); } diff --git a/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml b/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml index 504638348..ec9e5a00e 100644 --- a/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml +++ b/java/com/android/dialer/app/res/layout/call_log_list_item_actions.xml @@ -35,8 +35,7 @@ + style="@style/CallLogActionStyle">