From ae8144b6905143e0a8e5a6920b6ed8f60cf8b00e Mon Sep 17 00:00:00 2001 From: uabdullah Date: Fri, 2 Feb 2018 15:28:40 -0800 Subject: NUI VM Transcribed by Google UI Support Shows the "Transcribed by Google" logo for voicemails transcribed by Google Bug: 72491920 Test: Unit Tests PiperOrigin-RevId: 184343786 Change-Id: I9d662860e218ff555c65f667f4ee15015df47ab2 --- .../dialer/voicemail/listui/NewVoicemailViewHolder.java | 16 ++++++++++++++++ .../voicemail/listui/res/layout/new_voicemail_entry.xml | 10 ++++++++++ .../dialer/voicemail/listui/res/values/strings.xml | 3 +++ 3 files changed, 29 insertions(+) diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java index 71c98031a..b0c07df66 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java @@ -43,6 +43,7 @@ import com.android.dialer.common.LogUtil; import com.android.dialer.common.concurrent.DialerExecutor.SuccessListener; import com.android.dialer.common.concurrent.DialerExecutor.Worker; import com.android.dialer.common.concurrent.DialerExecutorComponent; +import com.android.dialer.compat.android.provider.VoicemailCompat; import com.android.dialer.contactphoto.ContactPhotoManager; import com.android.dialer.contactphoto.NumberAttributeConverter; import com.android.dialer.lettertile.LetterTileDrawable; @@ -58,6 +59,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On private final TextView primaryTextView; private final TextView secondaryTextView; private final TextView transcriptionTextView; + private final TextView transcriptionBrandingTextView; private final QuickContactBadge quickContactBadge; private final NewVoicemailMediaPlayerView mediaPlayerView; private final ImageView menuButton; @@ -76,6 +78,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On primaryTextView = view.findViewById(R.id.primary_text); secondaryTextView = view.findViewById(R.id.secondary_text); transcriptionTextView = view.findViewById(R.id.transcription_text); + transcriptionBrandingTextView = view.findViewById(R.id.transcription_branding); quickContactBadge = view.findViewById(R.id.quick_contact_photo); mediaPlayerView = view.findViewById(R.id.new_voicemail_media_player); menuButton = view.findViewById(R.id.menu_button); @@ -226,6 +229,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On String.valueOf(mediaPlayerView.getVoicemailUri()), String.valueOf(viewHolderVoicemailUri)); transcriptionTextView.setMaxLines(1); + transcriptionBrandingTextView.setVisibility(GONE); isViewHolderExpanded = false; mediaPlayerView.reset(); @@ -251,6 +255,8 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On secondaryTextView.setTypeface(null, Typeface.NORMAL); transcriptionTextView.setTypeface(null, Typeface.NORMAL); + transcriptionBrandingTextView.setVisibility(GONE); + mediaPlayerView.reset(); LogUtil.i( @@ -319,6 +325,7 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On transcriptionTextView.setMaxLines(999); isViewHolderExpanded = true; + updateBrandingText(voicemailEntry); // Once the media player is visible update its state mediaPlayerView.setVisibility(View.VISIBLE); mediaPlayerView.bindValuesFromAdapterOfExpandedViewHolderMediaPlayerView( @@ -333,6 +340,15 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On String.valueOf(mediaPlayerView.getVoicemailUri())); } + private void updateBrandingText(VoicemailEntry voicemailEntry) { + if (voicemailEntry.transcriptionState() == VoicemailCompat.TRANSCRIPTION_AVAILABLE + && !TextUtils.isEmpty(voicemailEntry.transcription())) { + transcriptionBrandingTextView.setVisibility(VISIBLE); + } else { + transcriptionBrandingTextView.setVisibility(GONE); + } + } + @WorkerThread private Integer markVoicemailAsRead(Pair contextUriPair) { Assert.isWorkerThread(); diff --git a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml index 95769fe32..6900627dd 100644 --- a/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml +++ b/java/com/android/dialer/voicemail/listui/res/layout/new_voicemail_entry.xml @@ -82,6 +82,16 @@ android:layout_gravity="center_vertical" android:visibility="gone"/> + + Turn On + + Transcribed by Google + -- cgit v1.2.3 From 1579e1c993ecef391a1a828cb2ac13d2985d893d Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Fri, 2 Feb 2018 15:52:26 -0800 Subject: Implemented drag to remove in NUI with old favorites. This change moves the remove button to overlap the search bar instead of reside underneath it since we no longer have top tabs. Bug: 72722364 Test: manual PiperOrigin-RevId: 184347110 Change-Id: I5bfa70fec9dd7ee6ee0b7270039931f9277291f4 --- .../dialer/app/list/PhoneFavoritesTileAdapter.java | 29 ++++++---- .../dialer/main/impl/OldMainActivityPeer.java | 65 ++++++++++++++-------- .../impl/toolbar/res/layout/toolbar_layout.xml | 44 ++++++++++++++- .../main/impl/toolbar/res/values/strings.xml | 3 + 4 files changed, 106 insertions(+), 35 deletions(-) diff --git a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java index ed64f7a52..a20185989 100644 --- a/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java +++ b/java/com/android/dialer/app/list/PhoneFavoritesTileAdapter.java @@ -46,6 +46,7 @@ import com.android.dialer.duo.DuoComponent; import com.android.dialer.logging.InteractionEvent; import com.android.dialer.logging.Logger; import com.android.dialer.shortcuts.ShortcutRefresher; +import com.android.dialer.strictmode.StrictModeUtils; import com.google.common.collect.ComparisonChain; import java.util.ArrayList; import java.util.Comparator; @@ -519,22 +520,27 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop } if (changed && dropEntryIndex < PIN_LIMIT) { - final ArrayList operations = + ArrayList operations = getReflowedPinningOperations(contactEntries, draggedEntryIndex, dropEntryIndex); - if (!operations.isEmpty()) { - // update the database here with the new pinned positions - try { - context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); - Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT); - } catch (RemoteException | OperationApplicationException e) { - LogUtil.e(TAG, "Exception thrown when pinning contacts", e); - } - } + StrictModeUtils.bypass(() -> updateDatabaseWithPinnedPositions(operations)); } draggedEntry = null; } } + private void updateDatabaseWithPinnedPositions(ArrayList operations) { + if (operations.isEmpty()) { + // Nothing to update + return; + } + try { + context.getContentResolver().applyBatch(ContactsContract.AUTHORITY, operations); + Logger.get(context).logInteraction(InteractionEvent.Type.SPEED_DIAL_PIN_CONTACT); + } catch (RemoteException | OperationApplicationException e) { + LogUtil.e(TAG, "Exception thrown when pinning contacts", e); + } + } + /** * Used when a contact is removed from speeddial. This will both unstar and set pinned position of * the contact to PinnedPosition.DEMOTED so that it doesn't show up anymore in the favorites list. @@ -543,7 +549,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements OnDragDrop final ContentValues values = new ContentValues(2); values.put(Contacts.STARRED, false); values.put(Contacts.PINNED, PinnedPositions.DEMOTED); - context.getContentResolver().update(contactUri, values, null, null); + StrictModeUtils.bypass( + () -> context.getContentResolver().update(contactUri, values, null, null)); } /** diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index c7410d541..16b74d5ff 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -34,6 +34,7 @@ import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.ImageView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; +import com.android.dialer.animation.AnimUtils; import com.android.dialer.app.calllog.CallLogAdapter; import com.android.dialer.app.calllog.CallLogFragment; import com.android.dialer.app.calllog.CallLogFragment.CallLogFragmentListener; @@ -44,6 +45,7 @@ import com.android.dialer.app.list.OldSpeedDialFragment; import com.android.dialer.app.list.OnDragDropListener; import com.android.dialer.app.list.OnListFragmentScrolledListener; import com.android.dialer.app.list.PhoneFavoriteSquareTileView; +import com.android.dialer.app.list.RemoveView; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.FragmentUtils.FragmentUtilListener; @@ -112,8 +114,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen // Speed Dial private MainOnPhoneNumberPickerActionListener onPhoneNumberPickerActionListener; - private MainOldSpeedDialFragmentHostInterface oldSpeedDialFragmentHostInterface; - private MainOnDragDropListener onDragDropListener; + private MainOldSpeedDialFragmentHost oldSpeedDialFragmentHost; /** Language the device was in last time {@link #onSaveInstanceState(Bundle)} was called. */ private String savedLanguageCode; @@ -177,10 +178,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen onListFragmentScrolledListener = new MainOnListFragmentScrolledListener(snackbarContainer); onPhoneNumberPickerActionListener = new MainOnPhoneNumberPickerActionListener(mainActivity); - oldSpeedDialFragmentHostInterface = - new MainOldSpeedDialFragmentHostInterface( - bottomNav, mainActivity.findViewById(R.id.contact_tile_drag_shadow_overlay)); - onDragDropListener = new MainOnDragDropListener(); + oldSpeedDialFragmentHost = + new MainOldSpeedDialFragmentHost( + bottomNav, + mainActivity.findViewById(R.id.contact_tile_drag_shadow_overlay), + mainActivity.findViewById(R.id.remove_view), + mainActivity.findViewById(R.id.search_view_container)); lastTabController = new LastTabController(mainActivity, bottomNav); @@ -283,10 +286,8 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen return (T) onListFragmentScrolledListener; } else if (callbackInterface.isInstance(onPhoneNumberPickerActionListener)) { return (T) onPhoneNumberPickerActionListener; - } else if (callbackInterface.isInstance(oldSpeedDialFragmentHostInterface)) { - return (T) oldSpeedDialFragmentHostInterface; - } else if (callbackInterface.isInstance(onDragDropListener)) { - return (T) onDragDropListener; + } else if (callbackInterface.isInstance(oldSpeedDialFragmentHost)) { + return (T) oldSpeedDialFragmentHost; } else { return null; } @@ -644,25 +645,38 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen } } - /** @see OldSpeedDialFragment.HostInterface */ - private static final class MainOldSpeedDialFragmentHostInterface - implements OldSpeedDialFragment.HostInterface { + /** + * Handles the callbacks for {@link OldSpeedDialFragment} and drag/drop logic for drag to remove. + * + * @see OldSpeedDialFragment.HostInterface + * @see OnDragDropListener + */ + private static final class MainOldSpeedDialFragmentHost + implements OldSpeedDialFragment.HostInterface, OnDragDropListener { private final BottomNavBar bottomNavBar; private final ImageView dragShadowOverlay; + private final RemoveView removeView; + private final View searchViewContainer; // TODO(calderwoodra): Use this for drag and drop @SuppressWarnings("unused") private DragDropController dragDropController; - MainOldSpeedDialFragmentHostInterface(BottomNavBar bottomNavBar, ImageView dragShadowOverlay) { + MainOldSpeedDialFragmentHost( + BottomNavBar bottomNavBar, + ImageView dragShadowOverlay, + RemoveView removeView, + View searchViewContainer) { this.bottomNavBar = bottomNavBar; this.dragShadowOverlay = dragShadowOverlay; + this.removeView = removeView; + this.searchViewContainer = searchViewContainer; } @Override public void setDragDropController(DragDropController dragDropController) { - this.dragDropController = dragDropController; + removeView.setDragDropController(dragDropController); } @Override @@ -674,23 +688,30 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen public ImageView getDragShadowOverlay() { return dragShadowOverlay; } - } - - /** @see com.android.dialer.app.list.OnDragDropListener */ - // TODO(calderwoodra): implement drag and drop - private static final class MainOnDragDropListener implements OnDragDropListener { @Override - public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) {} + public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) { + showRemoveView(true); + } @Override public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView view) {} @Override - public void onDragFinished(int x, int y) {} + public void onDragFinished(int x, int y) { + showRemoveView(false); + } @Override public void onDroppedOnRemove() {} + + private void showRemoveView(boolean show) { + if (show) { + AnimUtils.crossFadeViews(removeView, searchViewContainer, 300); + } else { + AnimUtils.crossFadeViews(searchViewContainer, removeView, 300); + } + } } /** 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 9b0086b38..7c4cee2b3 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 @@ -18,8 +18,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="?attr/actionBarSize" + android:layout_height="?attr/actionBarSize" android:background="@color/dialer_theme_color" app:contentInsetStart="0dp" app:contentInsetEnd="0dp"> @@ -89,4 +88,45 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml b/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml index c1d153f1f..6af235b81 100644 --- a/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml +++ b/java/com/android/dialer/main/impl/toolbar/res/values/strings.xml @@ -39,4 +39,7 @@ Settings Send feedback + + + Remove \ No newline at end of file -- cgit v1.2.3