diff options
author | yueg <yueg@google.com> | 2018-06-28 14:26:45 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-06-28 16:25:46 -0700 |
commit | 5b99e36d5139a4e6b141af45f4cbcd946d81675e (patch) | |
tree | c883e3adc2497dcb8efeae8a7f5dc0524ba967e6 | |
parent | 9af4b65fa7717a647e3c8996cbbbcc93637aeab4 (diff) |
Fix scroll for new favorites
Test: SpeedDialAdapterTest
PiperOrigin-RevId: 202543795
Change-Id: I1eec7a7328da3037b4d1cbacc7d9b211305e3eb0
5 files changed, 46 insertions, 18 deletions
diff --git a/java/com/android/dialer/main/impl/OldMainActivityPeer.java b/java/com/android/dialer/main/impl/OldMainActivityPeer.java index d790c6814..73bb4f81a 100644 --- a/java/com/android/dialer/main/impl/OldMainActivityPeer.java +++ b/java/com/android/dialer/main/impl/OldMainActivityPeer.java @@ -51,6 +51,7 @@ import android.text.method.LinkMovementMethod; import android.view.ActionMode; import android.view.DragEvent; import android.view.View; +import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; @@ -334,7 +335,12 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen activity.findViewById(R.id.remove_view), activity.findViewById(R.id.search_view_container), toolbar); - speedDialFragmentHost = new MainSpeedDialFragmentHost(toolbar); + speedDialFragmentHost = + new MainSpeedDialFragmentHost( + toolbar, + activity.findViewById(R.id.root_layout), + activity.findViewById(R.id.coordinator_layout), + activity.findViewById(R.id.fragment_container)); lastTabController = new LastTabController(activity, bottomNav, showVoicemailTab); @@ -1255,15 +1261,32 @@ public class OldMainActivityPeer implements MainActivityPeer, FragmentUtilListen private static final class MainSpeedDialFragmentHost implements SpeedDialFragment.HostInterface { private final MainToolbar toolbar; - - MainSpeedDialFragmentHost(MainToolbar toolbar) { + private final ViewGroup rootLayout; + private final ViewGroup coordinatorLayout; + private final ViewGroup fragmentContainer; + + MainSpeedDialFragmentHost( + MainToolbar toolbar, + ViewGroup rootLayout, + ViewGroup coordinatorLayout, + ViewGroup fragmentContainer) { this.toolbar = toolbar; + this.rootLayout = rootLayout; + this.coordinatorLayout = coordinatorLayout; + this.fragmentContainer = fragmentContainer; } @Override public void setHasFrequents(boolean hasFrequents) { toolbar.showClearFrequents(hasFrequents); } + + @Override + public void dragFavorite(boolean start) { + rootLayout.setClipChildren(!start); + coordinatorLayout.setClipChildren(!start); + fragmentContainer.setClipChildren(!start); + } } /** diff --git a/java/com/android/dialer/main/impl/res/layout/main_activity.xml b/java/com/android/dialer/main/impl/res/layout/main_activity.xml index 76d709c16..5fd9bed7b 100644 --- a/java/com/android/dialer/main/impl/res/layout/main_activity.xml +++ b/java/com/android/dialer/main/impl/res/layout/main_activity.xml @@ -19,9 +19,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/root_layout" android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:clipToPadding="false"> + android:layout_height="match_parent"> <!-- MainToolbar --> <include @@ -35,17 +33,13 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar" - android:layout_above="@+id/bottom_nav_bar" - android:clipChildren="false" - android:clipToPadding="false"> + android:layout_above="@+id/bottom_nav_bar"> <!-- Holds SpeedDial, Call Log, Contacts, Voicemail and Search fragments --> <FrameLayout android:id="@+id/fragment_container" android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:clipToPadding="false"/> + android:layout_height="match_parent"/> <FrameLayout android:id="@+id/search_fragment_container" @@ -102,4 +96,4 @@ android:importantForAccessibility="no" android:visibility="gone"/> </FrameLayout> -</RelativeLayout>
\ No newline at end of file +</RelativeLayout> diff --git a/java/com/android/dialer/speeddial/SpeedDialAdapter.java b/java/com/android/dialer/speeddial/SpeedDialAdapter.java index ff52a0745..4a48b6504 100644 --- a/java/com/android/dialer/speeddial/SpeedDialAdapter.java +++ b/java/com/android/dialer/speeddial/SpeedDialAdapter.java @@ -34,6 +34,7 @@ import android.widget.FrameLayout; import com.android.dialer.common.Assert; import com.android.dialer.speeddial.FavoritesViewHolder.FavoriteContactsListener; import com.android.dialer.speeddial.HeaderViewHolder.SpeedDialHeaderListener; +import com.android.dialer.speeddial.SpeedDialFragment.HostInterface; import com.android.dialer.speeddial.SuggestionViewHolder.SuggestedContactsListener; import com.android.dialer.speeddial.draghelper.SpeedDialItemTouchHelperCallback.ItemTouchHelperAdapter; import com.android.dialer.speeddial.loader.SpeedDialUiItem; @@ -81,6 +82,7 @@ public final class SpeedDialAdapter extends RecyclerView.Adapter<RecyclerView.Vi private final FavoriteContactsListener favoritesListener; private final SuggestedContactsListener suggestedListener; private final SpeedDialHeaderListener headerListener; + private final HostInterface hostInterface; private final Map<Integer, Integer> positionToRowTypeMap = new ArrayMap<>(); private List<SpeedDialUiItem> speedDialUiItems; @@ -95,11 +97,13 @@ public final class SpeedDialAdapter extends RecyclerView.Adapter<RecyclerView.Vi Context context, FavoriteContactsListener favoritesListener, SuggestedContactsListener suggestedListener, - SpeedDialHeaderListener headerListener) { + SpeedDialHeaderListener headerListener, + HostInterface hostInterface) { this.context = context; this.favoritesListener = favoritesListener; this.suggestedListener = suggestedListener; this.headerListener = headerListener; + this.hostInterface = hostInterface; } @Override @@ -255,6 +259,7 @@ public final class SpeedDialAdapter extends RecyclerView.Adapter<RecyclerView.Vi if (viewHolder != null) { draggingFavoritesViewHolder = (FavoritesViewHolder) viewHolder; draggingFavoritesViewHolder.onSelectedChanged(true); + hostInterface.dragFavorite(true); removeViewHolder.show(); } break; @@ -263,6 +268,7 @@ public final class SpeedDialAdapter extends RecyclerView.Adapter<RecyclerView.Vi if (draggingFavoritesViewHolder != null) { draggingFavoritesViewHolder.onSelectedChanged(false); draggingFavoritesViewHolder = null; + hostInterface.dragFavorite(false); removeViewHolder.hide(); } break; diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index a958d443a..d4e7a76fa 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -156,7 +156,12 @@ public class SpeedDialFragment extends Fragment { new UpdateSpeedDialAdapterListener(), speedDialLoaderListener); adapter = - new SpeedDialAdapter(getContext(), favoritesListener, suggestedListener, headerListener); + new SpeedDialAdapter( + getContext(), + favoritesListener, + suggestedListener, + headerListener, + FragmentUtils.getParentUnsafe(this, HostInterface.class)); layoutManager.setSpanSizeLookup(adapter.getSpanSizeLookup()); RecyclerView recyclerView = rootLayout.findViewById(R.id.speed_dial_recycler_view); recyclerView.setLayoutManager(layoutManager); @@ -653,5 +658,7 @@ public class SpeedDialFragment extends Fragment { public interface HostInterface { void setHasFrequents(boolean hasFrequents); + + void dragFavorite(boolean start); } } diff --git a/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml b/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml index 472f9e951..e79bc6b2f 100644 --- a/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml +++ b/java/com/android/dialer/speeddial/res/layout/fragment_speed_dial.xml @@ -17,9 +17,7 @@ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/speed_dial_root" android:layout_width="match_parent" - android:layout_height="match_parent" - android:clipChildren="false" - android:clipToPadding="false"> + android:layout_height="match_parent"> <android.support.v7.widget.RecyclerView android:id="@+id/speed_dial_recycler_view" |