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

Commit c2820187 authored by Samuel Fufa's avatar Samuel Fufa
Browse files

Consolidate Search result UIs

- Allow SearchAction to be represented by SearchResultIcon and SearchResultIconRow
- Fix tap enter to launch regression
- Remove Plugin Pipeline

Bug: 177223401
Test: Manual
Change-Id: Id1d445f6af3f80f840d567165051188c78230ed0
parent 867b62a2
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -45,14 +45,14 @@

        <TextView
            android:layout_width="wrap_content"
            android:id="@+id/desc"
            android:id="@+id/subtitle"
            android:maxLines="1"
            android:textColor="?android:attr/textColorTertiary"
            android:textSize="@dimen/search_hero_subtitle_size"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <com.android.launcher3.BubbleTextView
    <com.android.launcher3.search.SearchResultIcon
        android:id="@+id/shortcut_0"
        style="@style/BaseIcon"
        android:layout_width="@dimen/deep_shortcut_icon_size"
@@ -63,7 +63,7 @@
        launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
        launcher:layoutHorizontal="false" />

    <com.android.launcher3.BubbleTextView
    <com.android.launcher3.search.SearchResultIcon
        android:id="@+id/shortcut_1"
        style="@style/BaseIcon"
        android:layout_width="@dimen/deep_shortcut_icon_size"
@@ -72,5 +72,4 @@
        android:textSize="@dimen/search_hero_inline_button_size"
        launcher:iconSizeOverride="@dimen/deep_shortcut_icon_size"
        launcher:layoutHorizontal="false" />

</com.android.launcher3.search.SearchResultIconRow>
 No newline at end of file
+0 −79
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2020 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.SearchResultPlayItem xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="4dp"
    android:orientation="horizontal">
    <View
        android:id="@+id/icon"
        android:layout_width="@dimen/deep_shortcut_icon_size"
        android:layout_height="@dimen/deep_shortcut_icon_size"
        android:layout_gravity="start|center_vertical"
        android:background="@drawable/ic_deepshortcut_placeholder" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_gravity="start|center_vertical"
        android:layout_weight="1"
        android:orientation="vertical"
        android:paddingTop="4dp"
        android:paddingBottom="4dp"
        android:paddingStart="8dp"
        android:paddingEnd="8dp">

        <TextView
            android:id="@+id/title_view"
            style="@style/TextHeadline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxLines="1"
            android:ellipsize="end"
            android:textAlignment="viewStart"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp" />

        <TextView
            android:id="@+id/detail_0"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="?android:attr/textColorPrimary" />

        <TextView
            android:id="@+id/detail_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="?android:attr/textColorPrimary"
            android:visibility="gone" />

        <TextView
            android:id="@+id/detail_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="?android:attr/textColorPrimary"
            android:visibility="gone" />
    </LinearLayout>
    <Button
        android:id="@+id/try_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="start|center_vertical"
        android:text="@string/search_action_try_now">
    </Button>


</com.android.launcher3.search.SearchResultPlayItem>
+0 −60
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2020 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.SearchSettingsRowView xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/TextHeadline"
    android:id="@+id/section_title"
    android:background="?android:attr/selectableItemBackground"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:padding="@dimen/dynamic_grid_cell_padding_x"
    android:textColor="?android:attr/textColorPrimary">

    <View
        android:layout_width="@dimen/search_settings_icon_size"
        android:src="@drawable/ic_setting"
        android:id="@+id/icon"
        android:layout_height="@dimen/search_settings_icon_size" />

    <LinearLayout
        android:layout_width="0dp"
        android:orientation="vertical"
        android:paddingRight="@dimen/dynamic_grid_cell_padding_x"
        android:paddingLeft="@dimen/dynamic_grid_cell_padding_x"
        android:layout_height="wrap_content"
        android:layout_weight="1">


        <TextView
            android:id="@+id/title"
            style="@style/TextTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/search_line_spacing"
            android:maxLines="1"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="@dimen/search_hero_title_size" />

        <TextView
            android:id="@+id/breadcrumbs"
            style="@style/TextTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:visibility="gone"
            android:textColor="?android:attr/textColorSecondary"
            android:textSize="@dimen/search_hero_subtitle_size" />
    </LinearLayout>
</com.android.launcher3.search.SearchSettingsRowView>
 No newline at end of file
+8 −8
Original line number Diff line number Diff line
@@ -12,21 +12,21 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<com.android.launcher3.search.SearchResultSettingsSlice xmlns:android="http://schemas.android.com/apk/res/android"
    android:paddingHorizontal="@dimen/dynamic_grid_cell_padding_x"
<com.android.launcher3.search.SearchResultIconSlice xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res-auto"
    android:padding="@dimen/dynamic_grid_edge_margin"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <FrameLayout
        android:layout_width="wrap_content"
        android:paddingTop="@dimen/search_settings_icon_vertical_offset"
        android:layout_height="wrap_content">

        <View
            android:layout_width="@dimen/search_settings_icon_size"
            android:src="@drawable/ic_setting"
        <com.android.launcher3.search.SearchResultIcon
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/icon"
            android:layout_height="@dimen/search_settings_icon_size" />
            launcher:iconDisplay="hero_app" />
    </FrameLayout>

    <androidx.slice.widget.SliceView
@@ -36,5 +36,5 @@
        android:layout_marginStart="@dimen/dynamic_grid_cell_padding_x"
        android:layout_width="0dp" />

</com.android.launcher3.search.SearchResultSettingsSlice>
</com.android.launcher3.search.SearchResultIconSlice>
+22 −36
Original line number Diff line number Diff line
@@ -21,17 +21,16 @@ import static com.android.launcher3.allapps.AllAppsGridAdapter.VIEW_TYPE_ICON;
import android.app.search.SearchTarget;
import android.util.SparseIntArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.app.search.LayoutType;
import com.android.app.search.ResultType;
import com.android.launcher3.Launcher;
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;
import com.android.systemui.plugins.shared.SearchTargetLegacy;

/**
 * Provides views for on-device search results
@@ -39,14 +38,12 @@ import com.android.systemui.plugins.shared.SearchTargetLegacy;
public class DeviceSearchAdapterProvider extends SearchAdapterProvider {

    public static final int VIEW_TYPE_SEARCH_CORPUS_TITLE = 1 << 5;
    public static final int VIEW_TYPE_SEARCH_ROW_WITH_BUTTON = 1 << 7;
    public static final int VIEW_TYPE_SEARCH_ROW = 1 << 8;
    public static final int VIEW_TYPE_SEARCH_SLICE = 1 << 9;
    public static final int VIEW_TYPE_SEARCH_ICON_ROW = 1 << 10;
    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_PEOPLE = 1 << 11;
    public static final int VIEW_TYPE_SEARCH_THUMBNAIL = 1 << 12;
    public static final int VIEW_TYPE_SEARCH_SUGGEST = 1 << 13;
    public static final int VIEW_TYPE_SEARCH_ICON = (1 << 14) | VIEW_TYPE_ICON;
    public static final int VIEW_TYPE_SEARCH_WIDGET_LIVE = 1 << 15;
    public static final int VIEW_TYPE_SEARCH_WIDGET_PREVIEW = 1 << 16;

@@ -58,13 +55,10 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
        super(launcher);
        mAppsView = appsView;

        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ICON, R.layout.search_result_icon);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_CORPUS_TITLE, R.layout.search_section_title);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ROW_WITH_BUTTON,
                R.layout.search_result_play_item);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_ROW, R.layout.search_result_settings_row);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SLICE, R.layout.search_result_slice);
        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_SLICE, R.layout.search_result_slice);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_PEOPLE, R.layout.search_result_people_item);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_THUMBNAIL, R.layout.search_result_thumbnail);
        mViewTypeToLayoutMap.put(VIEW_TYPE_SEARCH_SUGGEST, R.layout.search_result_suggest);
@@ -110,12 +104,9 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {


    @Override
    public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem focusedItem) {
        if (focusedItem instanceof SearchTargetHandler) {
            SearchTargetLegacy searchTarget = ((SearchAdapterItem) focusedItem)
                    .getSearchTargetLegacy();
            SearchEventTracker.INSTANCE.get(mLauncher).quickSelect(searchTarget);
            return true;
    public boolean onAdapterItemSelected(AllAppsGridAdapter.AdapterItem adapterItem, View view) {
        if (view instanceof SearchTargetHandler) {
            return ((SearchTargetHandler) view).quickSelect();
        }
        return false;
    }
@@ -125,25 +116,20 @@ public class DeviceSearchAdapterProvider extends SearchAdapterProvider {
     * Returns -1 if viewType is not found
     */
    public int getViewTypeForSearchTarget(SearchTarget t) {
        if (t.getLayoutType().equals(LayoutType.TEXT_HEADER)) {
        switch (t.getLayoutType()) {
            case LayoutType.TEXT_HEADER:
                return VIEW_TYPE_SEARCH_CORPUS_TITLE;
        }
        switch (t.getResultType()) {
            case ResultType.APPLICATION:
                if (t.getLayoutType().equals(LayoutType.ICON_SINGLE_VERTICAL_TEXT)) {
            case LayoutType.ICON_SINGLE_VERTICAL_TEXT:
                return VIEW_TYPE_SEARCH_ICON;
                }
                break;
            case ResultType.SETTING:
                if (t.getLayoutType().equals(LayoutType.ICON_SLICE)) {
            case LayoutType.ICON_SLICE:
                return VIEW_TYPE_SEARCH_SLICE;
                }
                return VIEW_TYPE_SEARCH_ROW;
            case ResultType.SHORTCUT:
            case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT_BUTTON:
            case LayoutType.ICON_DOUBLE_HORIZONTAL_TEXT:
            case LayoutType.ICON_SINGLE_HORIZONTAL_TEXT:
                return VIEW_TYPE_SEARCH_ICON_ROW;
            case ResultType.PLAY:
                return VIEW_TYPE_SEARCH_ROW_WITH_BUTTON;
        }
            default:
                return -1;

        }
    }
}
Loading