summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/main
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-03-26 14:34:14 -0700
committerCopybara-Service <copybara-piper@google.com>2018-03-26 22:26:41 -0700
commit135b11234146f4e44d2597c679c326c42af6e1f6 (patch)
tree9ce9c069aec759853531e0556e9325698ef9bc1c /java/com/android/dialer/main
parent0a8163fde93716a0a7ae2d7b536851f59da15a38 (diff)
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
Diffstat (limited to 'java/com/android/dialer/main')
-rw-r--r--java/com/android/dialer/main/impl/OldMainActivityPeer.java22
-rw-r--r--java/com/android/dialer/main/impl/res/layout/stub_fragment.xml27
-rw-r--r--java/com/android/dialer/main/impl/toolbar/res/layout/toolbar_layout.xml6
3 files changed, 20 insertions, 35 deletions
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 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ 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
- -->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <TextView
- android:text="hello world!"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
-</FrameLayout> \ 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">
+ <!-- We set this view's visibility to gone instead of the parent because if we hide remove
+ view, it won't receive drag and accessibility events. -->
<LinearLayout
android:id="@+id/remove_view_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/dialer_theme_color"
android:gravity="center"
- android:orientation="horizontal">
+ android:orientation="horizontal"
+ android:visibility="gone">
<ImageView
android:id="@+id/remove_view_icon"