Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b99e36d authored by yueg's avatar yueg Committed by Copybara-Service
Browse files

Fix scroll for new favorites

Test: SpeedDialAdapterTest
PiperOrigin-RevId: 202543795
Change-Id: I1eec7a7328da3037b4d1cbacc7d9b211305e3eb0
parent 9af4b65f
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -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);
    }
  }

  /**
+4 −10
Original line number Diff line number Diff line
@@ -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"
+7 −1
Original line number Diff line number Diff line
@@ -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;
+8 −1
Original line number Diff line number Diff line
@@ -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);
  }
}
+1 −3
Original line number Diff line number Diff line
@@ -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"