From 135b11234146f4e44d2597c679c326c42af6e1f6 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Mon, 26 Mar 2018 14:34:14 -0700 Subject: Fixed drag to remove favorite contacts on a few devices. There were 2 issues at play here: 1) views not being able to leave the list view bounds 2) RemoveView not getting drag events. Their resolutions are: 1) add a drag drop listener to the root layout of the activity, now the view can be dragged anywhere. 2) Drag events are only sent to views that are visible, so we no longer set the remove view visibility to GONE and instead set it's contents to GONE. Bug: 76086197 Test: manual PiperOrigin-RevId: 190526568 Change-Id: I3360015f65a134a896601d6298d07163844e302c --- .../dialer/main/impl/OldMainActivityPeer.java | 22 +++++++++++++----- .../dialer/main/impl/res/layout/stub_fragment.xml | 27 ---------------------- .../impl/toolbar/res/layout/toolbar_layout.xml | 6 +++-- 3 files changed, 20 insertions(+), 35 deletions(-) delete mode 100644 java/com/android/dialer/main/impl/res/layout/stub_fragment.xml diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index 70444bd8c..9e8bd1ad6 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -43,6 +43,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telephony.TelephonyManager; import android.text.TextUtils; +import android.view.DragEvent; import android.view.View; import android.widget.ImageView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; @@ -246,6 +247,7 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen oldSpeedDialFragmentHost = new MainOldSpeedDialFragmentHost( activity, + activity.findViewById(R.id.root_layout), bottomNav, activity.findViewById(R.id.contact_tile_drag_shadow_overlay), activity.findViewById(R.id.remove_view), @@ -1024,34 +1026,42 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen implements OldSpeedDialFragment.HostInterface, OnDragDropListener { private final Context context; + private final View rootLayout; private final BottomNavBar bottomNavBar; private final ImageView dragShadowOverlay; private final RemoveView removeView; + private final View removeViewContent; private final View searchViewContainer; private final MainToolbar toolbar; - // TODO(calderwoodra): Use this for drag and drop - @SuppressWarnings("unused") - private DragDropController dragDropController; - MainOldSpeedDialFragmentHost( Context context, + View rootLayout, BottomNavBar bottomNavBar, ImageView dragShadowOverlay, RemoveView removeView, View searchViewContainer, MainToolbar toolbar) { this.context = context; + this.rootLayout = rootLayout; this.bottomNavBar = bottomNavBar; this.dragShadowOverlay = dragShadowOverlay; this.removeView = removeView; this.searchViewContainer = searchViewContainer; this.toolbar = toolbar; + removeViewContent = removeView.findViewById(R.id.remove_view_content); } @Override public void setDragDropController(DragDropController dragDropController) { removeView.setDragDropController(dragDropController); + rootLayout.setOnDragListener( + (v, event) -> { + if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) { + dragDropController.handleDragHovered(v, (int) event.getX(), (int) event.getY()); + } + return true; + }); } @Override @@ -1088,9 +1098,9 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private void showRemoveView(boolean show) { if (show) { - AnimUtils.crossFadeViews(removeView, searchViewContainer, 300); + AnimUtils.crossFadeViews(removeViewContent, searchViewContainer, 300); } else { - AnimUtils.crossFadeViews(searchViewContainer, removeView, 300); + AnimUtils.crossFadeViews(searchViewContainer, removeViewContent, 300); } } } diff --git a/java/com/android/dialer/main/impl/res/layout/stub_fragment.xml b/java/com/android/dialer/main/impl/res/layout/stub_fragment.xml deleted file mode 100644 index 3bb744fbd..000000000 --- a/java/com/android/dialer/main/impl/res/layout/stub_fragment.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - \ No newline at end of file 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 3ab20c1cf..c7c37d0ac 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 @@ -100,16 +100,18 @@ android:layout_gravity="center_vertical" android:layout_margin="@dimen/search_bar_margin" android:contentDescription="@string/main_remove_contact" - android:visibility="gone" android:importantForAccessibility="no"> + + android:orientation="horizontal" + android:visibility="gone">