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

Commit aa793ff2 authored by Hyunyoung Song's avatar Hyunyoung Song Committed by Android (Google) Code Review
Browse files

Merge "Support shorter height row layout / Disable ICON_SLICE" into sc-dev

parents 351aea72 7239df72
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -20,10 +20,10 @@
    android:padding="@dimen/dynamic_grid_edge_margin">

    <com.android.launcher3.search.SearchResultIcon
        android:layout_width="wrap_content"
        android:id="@+id/icon"
        launcher:iconDisplay="hero_app"
        android:layout_height="wrap_content" />
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        launcher:iconDisplay="hero_app" />

    <LinearLayout
        android:layout_width="0dp"
@@ -34,8 +34,8 @@
        android:layout_gravity="center_vertical">

        <TextView
            android:layout_width="wrap_content"
            android:id="@id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="start|center_vertical"
            android:maxLines="1"
+73 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 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.
-->
<com.android.launcher3.search.SearchResultSmallIconRow
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/dynamic_grid_edge_margin">

    <com.android.launcher3.search.SearchResultIcon
        android:id="@+id/icon"
        style="@style/BaseIcon"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding"
        android:drawableTint="?android:attr/textColorPrimary"
        android:padding="@dimen/dynamic_grid_edge_margin"
        launcher:iconDisplay="hero_app"
        launcher:iconSizeOverride="48dp"
        launcher:matchTextInsetWithQuery="true"
        launcher:layoutHorizontal="true" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:orientation="horizontal"
        android:padding="@dimen/dynamic_grid_edge_margin" >

        <TextView
            android:id="@id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="start|center_vertical"
            android:maxLines="1"
            android:paddingEnd="4dp"
            android:textAlignment="viewStart"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="@dimen/search_hero_title_size" />
        <TextView
            android:id="@+id/delimeter"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="start|center_vertical"
            android:maxLines="1"
            android:text="\u2022"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="@dimen/search_hero_subtitle_size" />
        <TextView
            android:id="@+id/subtitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="1"
            android:paddingStart="4dp"
            android:textColor="?android:attr/textColorTertiary"
            android:textSize="@dimen/search_hero_subtitle_size" />
    </LinearLayout>
</com.android.launcher3.search.SearchResultSmallIconRow>
 No newline at end of file
+16 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.launcher3.search;

import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ALL_APPS_DIVIDER;
import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ICON;

import android.app.search.SearchTarget;
@@ -31,6 +32,7 @@ import com.android.launcher3.R;
import com.android.launcher3.allapps.AllAppsContainerView;
import com.android.launcher3.allapps.AllAppsGridAdapter;
import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.config.FeatureFlags;

/**
 * Provides views for on-device search results
@@ -41,11 +43,12 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
    public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 7;
    public static final int VIEW_TYPE_SEARCH_ICON = (1 << 8) | VIEW_TYPE_ICON;
    public static final int VIEW_TYPE_SEARCH_ICON_ROW = (1 << 9);
    public static final int VIEW_TYPE_SEARCH_SMALL_ICON_ROW = (1 << 10);
    public static final int VIEW_TYPE_SEARCH_THUMBNAIL = 1 << 12;
    public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15;
    public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16;

    private static final String TAG = "SearchServiceAdapterProvider";
    private static final String TAG = "SearchServiceAdapter";

    private final AllAppsContainerView mAppsView;
    private final SparseIntArray mViewTypeToLayoutMap = new SparseIntArray();
@@ -57,11 +60,13 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_CORPUS_TITLE, R.layout.search_section_title);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON, R.layout.search_result_icon);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON_ROW, R.layout.search_result_icon_row);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SMALL_ICON_ROW, R.layout.search_result_small_icon_row);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SLICE, R.layout.search_result_slice);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_THUMBNAIL, R.layout.search_result_thumbnail);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_LIVE, R.layout.search_result_widget_live);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_WIDGET_PREVIEW,
                R.layout.search_result_widget_preview);
        mViewTypeToLayoutMap.put(VIEW_TYPE_ALL_APPS_DIVIDER, R.layout.all_apps_divider);
    }

    @Override
@@ -116,25 +121,33 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
            case LayoutType.ICON_SINGLE_VERTICAL_TEXT:
                return VIEW_TYPE_SEARCH_ICON;
            case LayoutType.ICON_SLICE:
                if (FeatureFlags.DISABLE_SLICE_IN_ALLAPPS.get()) {
                    return -1;
                }
                if (t.getSliceUri() != null) {
                    return VIEW_TYPE_SEARCH_SLICE;
                }
                Log.w(TAG, "Dropping as LayoutType.ICON_SLICE target doesn't contain sliceUri.");
                Log.w(TAG, "LayoutType.ICON_SLICE target doesn't contain sliceUri.");
                break;
            case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
            case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
            case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
            case LayoutType.ICON_HORIZONTAL_TEXT:
                return VIEW_TYPE_SEARCH_ICON_ROW;
            case LayoutType.SMALL_ICON_HORIZONTAL_TEXT:
                return VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
            case LayoutType.THUMBNAIL:
                if (t.getSearchAction() != null) {
                    return VIEW_TYPE_SEARCH_THUMBNAIL;
                }
                Log.w(TAG, "Dropping as LayoutType.THUMBNAIL target doesn't contain searchAction.");
                Log.w(TAG, "LayoutType.THUMBNAIL target doesn't contain searchAction.");
                break;
            case LayoutType.WIDGET_PREVIEW:
                return VIEW_TYPE_SEARCH_WIDGET_PREVIEW;
            case LayoutType.WIDGET_LIVE:
                return VIEW_TYPE_SEARCH_WIDGET_LIVE;
            case LayoutType.DIVIDER:
                return VIEW_TYPE_ALL_APPS_DIVIDER;
        }

        return -1;
+8 −16
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.launcher3.search;

import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON;
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_ICON_ROW;
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SMALL_ICON_ROW;
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_SLICE;
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_THUMBNAIL;
import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE_SEARCH_WIDGET_LIVE;
@@ -26,7 +27,6 @@ import static com.android.launcher3.search.DeviceSearchAdapterProvider.VIEW_TYPE
import android.app.search.SearchTarget;

import com.android.launcher3.allapps.AllAppsGridAdapter;
import com.android.systemui.plugins.shared.SearchTargetLegacy;

import java.util.ArrayList;
import java.util.List;
@@ -35,31 +35,23 @@ import java.util.List;
 * Extension of AdapterItem that contains an extra payload specific to item
 */
public class SearchAdapterItem extends AllAppsGridAdapter.AdapterItem {
    private SearchTargetLegacy mSearchTargetLegacy;
    private SearchTarget mSearchTarget;
    private List<SearchTarget> mInlineItems = new ArrayList<>();


    private static final int AVAILABLE_FOR_ACCESSIBILITY =
            VIEW_TYPE_SEARCH_SLICE | VIEW_TYPE_SEARCH_THUMBNAIL | VIEW_TYPE_SEARCH_ICON_ROW
                    | VIEW_TYPE_SEARCH_ICON | VIEW_TYPE_SEARCH_WIDGET_PREVIEW
    private static final int AVAILABLE_FOR_ACCESSIBILITY = VIEW_TYPE_SEARCH_SLICE
            | VIEW_TYPE_SEARCH_THUMBNAIL
            | VIEW_TYPE_SEARCH_ICON_ROW
            | VIEW_TYPE_SEARCH_ICON
            | VIEW_TYPE_SEARCH_SMALL_ICON_ROW
            | VIEW_TYPE_SEARCH_WIDGET_PREVIEW
            | VIEW_TYPE_SEARCH_WIDGET_LIVE;


    public SearchAdapterItem(SearchTargetLegacy searchTargetLegacy, int type) {
        mSearchTargetLegacy = searchTargetLegacy;
        viewType = type;
    }

    public SearchAdapterItem(SearchTarget searchTarget, int type) {
        mSearchTarget = searchTarget;
        viewType = type;
    }

    public SearchTargetLegacy getSearchTargetLegacy() {
        return mSearchTargetLegacy;
    }

    public SearchTarget getSearchTarget() {
        return mSearchTarget;
    }
+8 −6
Original line number Diff line number Diff line
@@ -46,12 +46,12 @@ public class SearchResultIconRow extends LinearLayout implements SearchTargetHan
    public static final int MAX_INLINE_ITEMS = 3;

    protected final Launcher mLauncher;
    private final LauncherAppState mLauncherAppState;
    protected SearchResultIcon mResultIcon;
    protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];
    private SearchResultIcon mResultIcon;

    private final LauncherAppState mLauncherAppState;
    private TextView mTitleView;
    private TextView mSubTitleView;
    protected final SearchResultIcon[] mInlineIcons = new SearchResultIcon[MAX_INLINE_ITEMS];

    private PackageItemInfo mProviderInfo;

@@ -77,13 +77,14 @@ public class SearchResultIconRow extends LinearLayout implements SearchTargetHan
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        int iconSize = getIconSize();

        mResultIcon = findViewById(R.id.icon);

        mTitleView = findViewById(R.id.title);
        mSubTitleView = findViewById(R.id.subtitle);
        mSubTitleView.setVisibility(GONE);

        mResultIcon.getLayoutParams().height = iconSize;
        mResultIcon.getLayoutParams().width = iconSize;
        mResultIcon.setTextVisibility(false);
@@ -94,15 +95,16 @@ public class SearchResultIconRow extends LinearLayout implements SearchTargetHan
        for (SearchResultIcon inlineIcon : mInlineIcons) {
            inlineIcon.getLayoutParams().width = getIconSize();
        }

        setOnClickListener(mResultIcon);
        setOnLongClickListener(mResultIcon);
    }

    @Override
    public void apply(SearchTarget parentTarget, List<SearchTarget> children) {
        showSubtitleIfNeeded(null);
        mResultIcon.apply(parentTarget, children, this::onItemInfoCreated);

        showSubtitleIfNeeded(null);

        if (parentTarget.getShortcutInfo() != null) {
            updateWithShortcutInfo(parentTarget.getShortcutInfo());
        } else if (parentTarget.getSearchAction() != null) {
Loading