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

Commit e8c57790 authored by Erfan Norozi's avatar Erfan Norozi
Browse files

Searchbar in toolbar large screen.

On large screen (desktop/tablet), display the searchbar inside the
toolbar.

The SearchViewManager is altered to treat focus on the "docked"
searchbar the same as expanding the iconified searchbar.

Bug: 391232269
Flag: com.android.documentsui.flags.use_material3
Test: Manual testing && atest DocumentsUIGoogleTests:com.android.documentsui.SearchViewUiTest

Change-Id: I1b5e5ca974fd3cf2bfbe80f2f1bcf4ed4a04d201
parent a21d71df
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 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.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="?attr/colorSurfaceContainerHigh" />
    <!-- The docked searchbar is a pill shape so we set the corner radius to a very high number. -->
    <corners android:radius="999dp" />
</shape>
 No newline at end of file
+3 −2
Original line number Diff line number Diff line
@@ -17,8 +17,9 @@
    android:width="24dp"
    android:height="24dp"
    android:viewportHeight="960"
    android:viewportWidth="960">
    android:viewportWidth="960"
    android:tint="?attr/colorOnSurface">
    <path
        android:fillColor="?attr/colorOnSurface"
        android:fillColor="@android:color/white"
        android:pathData="M256,760L200,704L424,480L200,256L256,200L480,424L704,200L760,256L536,480L760,704L704,760L480,536L256,760Z" />
</vector>
+3 −2
Original line number Diff line number Diff line
@@ -18,8 +18,9 @@
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24"
        android:viewportHeight="24">
        android:viewportHeight="24"
        android:tint="?attr/colorControlNormal">
    <path
        android:fillColor="?android:attr/colorControlNormal"
        android:fillColor="@android:color/white"
        android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z"/>
</vector>
 No newline at end of file
+58 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2025 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.google.android.material.appbar.MaterialToolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/docked_search_toolbar"
    android:layout_width="wrap_content"
    android:layout_height="@dimen/docked_searchbar_height"
    android:paddingStart="@dimen/docked_searchbar_padding"
    android:paddingEnd="@dimen/docked_searchbar_padding"
    android:background="@drawable/docked_search_bar_background">

    <ImageView
        android:layout_width="@dimen/docked_searchbar_height"
        android:layout_height="@dimen/docked_searchbar_height"
        android:src="@drawable/ic_menu_search_m3"
        android:tint="?attr/colorOnSurfaceVariant"
        android:padding="@dimen/docked_searchbar_icon_padding"
        android:importantForAccessibility="no" />

    <EditText
        android:id="@+id/docked_search_text"
        android:layout_width="@dimen/docked_searchbar_text_width"
        android:layout_height="match_parent"
        android:background="@null"
        android:hint="@string/search_bar_hint"
        android:singleLine="true"
        android:textAppearance="@style/TextAppearance.DocumentsUI.SearchBar"
        android:textColorHint="@null"
        android:inputType="textFilter|textNoSuggestions"
        android:importantForAutofill="no"
        android:imeOptions="actionSearch">
    </EditText>

    <ImageView
        android:id="@+id/docked_search_clear"
        android:layout_width="@dimen/docked_searchbar_height"
        android:layout_height="@dimen/docked_searchbar_height"
        android:src="@drawable/ic_cancel"
        android:tint="?attr/colorOnSurfaceVariant"
        android:padding="@dimen/docked_searchbar_icon_padding"
        android:visibility="invisible"
        android:contentDescription="@string/search_bar_clear" />

</com.google.android.material.appbar.MaterialToolbar>
+9 −0
Original line number Diff line number Diff line
@@ -17,6 +17,15 @@
<menu
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
<!-- The docked search bar is only visible on larger screens. -->
    <item
        android:id="@+id/option_menu_docked_search"
        android:title="@string/menu_search"
        android:icon="@drawable/ic_menu_search"
        android:imeOptions="actionSearch"
        android:visible="false"
        app:showAsAction="always"
        app:actionLayout="@layout/docked_search_bar" />
<!-- showAsAction flag impacts the behavior of SearchView.
     When set to collapseActionView, collapsing SearchView to icon is the
     default behavior. It would fit UX, however after expanding SearchView is
Loading