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

Commit 4112ae6a authored by Samuel Fufa's avatar Samuel Fufa Committed by Android (Google) Code Review
Browse files

Merge "[Search] Show search suggestions with in Recyclerview" into sc-v2-dev

parents 04d52b48 6cf7b319
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -43,15 +43,6 @@

        <include layout="@layout/all_apps_personal_work_tabs" />

        <Button
            android:id="@+id/all_apps_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:text="@string/all_apps_label"
            android:background="@drawable/padded_rounded_action_button"
            android:visibility="gone"/>

    </com.android.launcher3.allapps.FloatingHeaderView>

    <include layout="@layout/search_container_all_apps" />
+11 −8
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.util.PackageManagerHelper;

import java.util.Arrays;
@@ -95,16 +96,15 @@ public class AllAppsGridAdapter extends
        // The type of this item
        public int viewType;

        /** App-only properties */
        // The section name of this app.  Note that there can be multiple items with different
        // The section name of this item.  Note that there can be multiple items with different
        // sectionNames in the same section
        public String sectionName = null;
        // The row that this item shows up on
        public int rowIndex;
        // The index of this app in the row
        public int rowAppIndex;
        // The associated AppInfo for the app
        public AppInfo appInfo = null;
        // The associated ItemInfoWithIcon for the item
        public ItemInfoWithIcon itemInfo = null;
        // The index of this app not including sections
        public int appIndex = -1;
        // Search section associated to result
@@ -119,7 +119,7 @@ public class AllAppsGridAdapter extends
            item.viewType = VIEW_TYPE_ICON;
            item.position = pos;
            item.sectionName = sectionName;
            item.appInfo = appInfo;
            item.itemInfo = appInfo;
            item.appIndex = appIndex;
            return item;
        }
@@ -373,7 +373,7 @@ public class AllAppsGridAdapter extends
                if (adapterProvider != null) {
                    return adapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType);
                }
                throw new RuntimeException("Unexpected view type");
                throw new RuntimeException("Unexpected view type" + viewType);
        }
    }

@@ -382,10 +382,13 @@ public class AllAppsGridAdapter extends
        switch (holder.getItemViewType()) {
            case VIEW_TYPE_ICON:
                AdapterItem adapterItem = mApps.getAdapterItems().get(position);
                AppInfo info = adapterItem.appInfo;
                BubbleTextView icon = (BubbleTextView) holder.itemView;
                icon.reset();
                icon.applyFromApplicationInfo(info);
                if (adapterItem.itemInfo instanceof AppInfo) {
                    icon.applyFromApplicationInfo((AppInfo) adapterItem.itemInfo);
                } else {
                    icon.applyFromItemInfoWithIcon(adapterItem.itemInfo);
                }
                break;
            case VIEW_TYPE_EMPTY_SEARCH:
                TextView emptyViewText = (TextView) holder.itemView;
+0 −50
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ public class FloatingHeaderView extends LinearLayout implements
        ValueAnimator.AnimatorUpdateListener, PluginListener<AllAppsRow>, Insettable,
        OnHeightUpdatedListener {

    private static final long ALL_APPS_CONTENT_ANIM_DURATION = 150;
    private final Rect mRVClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
    private final Rect mHeaderClip = new Rect(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
    private final ValueAnimator mAnimator = ValueAnimator.ofInt(0, 0);
@@ -110,13 +109,6 @@ public class FloatingHeaderView extends LinearLayout implements
    private FloatingHeaderRow[] mAllRows = FloatingHeaderRow.NO_ROWS;


    // members for handling suggestion state
    private final ValueAnimator mAllAppsContentAnimator = ValueAnimator.ofFloat(0, 0);
    private View mAllAppsButton;
    private int mAllAppsContentFadeInOffset;
    private boolean mInSuggestionMode = false;


    public FloatingHeaderView(@NonNull Context context) {
        this(context, null);
    }
@@ -127,20 +119,12 @@ public class FloatingHeaderView extends LinearLayout implements
                .getDimensionPixelSize(R.dimen.all_apps_header_top_padding);
        mHeaderProtectionSupported = context.getResources().getBoolean(
                R.bool.config_header_protection_supported);
        mAllAppsContentFadeInOffset = context.getResources()
                .getDimensionPixelSize(R.dimen.all_apps_content_fade_in_offset);
        mAllAppsContentAnimator.setDuration(ALL_APPS_CONTENT_ANIM_DURATION);
        mAllAppsContentAnimator.addUpdateListener(this::onAllAppsContentAnimationUpdate);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mTabLayout = findViewById(R.id.tabs);
        mAllAppsButton = findViewById(R.id.all_apps_button);
        if (mAllAppsButton != null) {
            mAllAppsButton.setOnClickListener(this::onAllAppsButtonClicked);
        }

        // Find all floating header rows.
        ArrayList<FloatingHeaderRow> rows = new ArrayList<>();
@@ -329,7 +313,6 @@ public class FloatingHeaderView extends LinearLayout implements
        }

        mTabLayout.setTranslationY(mTranslationY);
        setSuggestionMode(false);

        int clipHeight = mHeaderTopPadding - getPaddingBottom();
        mRVClip.top = mTabsHidden ? clipHeight : 0;
@@ -365,7 +348,6 @@ public class FloatingHeaderView extends LinearLayout implements
            mTranslationY = 0;
            applyVerticalMove();
        }
        setSuggestionMode(false);
        mHeaderCollapsed = false;
        mSnappedScrolledY = -mMaxTranslation;
        mCurrentRV.scrollToTop();
@@ -461,38 +443,6 @@ public class FloatingHeaderView extends LinearLayout implements
        }
        return Math.max(getHeight() - getPaddingTop() + mTranslationY, 0);
    }

    /**
     * When suggestion mode is enabled, hides AllApps content view and shows AllApps button.
     */
    public void setSuggestionMode(boolean isSuggestMode) {
        if (mInSuggestionMode == isSuggestMode || mAllAppsButton == null) return;
        if (!FeatureFlags.ENABLE_ONE_SEARCH.get()) return;
        AllAppsContainerView allApps = (AllAppsContainerView) getParent();
        mInSuggestionMode = isSuggestMode;
        if (isSuggestMode) {
            mTabLayout.setVisibility(GONE);
            mAllAppsButton.setVisibility(VISIBLE);
            allApps.getContentView().setVisibility(GONE);
        } else {
            mTabLayout.setVisibility(mTabsHidden ? GONE : VISIBLE);
            mAllAppsButton.setVisibility(GONE);
            allApps.getContentView().setVisibility(VISIBLE);
        }
    }

    private void onAllAppsButtonClicked(View view) {
        setSuggestionMode(false);
        mAllAppsContentAnimator.start();
    }

    private void onAllAppsContentAnimationUpdate(ValueAnimator valueAnimator) {
        float prog = valueAnimator.getAnimatedFraction();
        View allAppsList = ((AllAppsContainerView) getParent()).getContentView();
        allAppsList.setAlpha(255 * prog);
        allAppsList.setTranslationY((1 - prog) * mAllAppsContentFadeInOffset);
    }

}