Update Search Bar layout in Homepage
Bug: 340513864 Bug: 340773713 Bug: 340799397 Bug: 340759836 Test: visual Change-Id: I4bd5c3438aa55ca764f61b180a37c10206ee78be
This commit is contained in:
@@ -17,28 +17,34 @@
|
|||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
style="@style/SearchBarStyle"
|
style="@style/SearchBarStyle_v2"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:layout_weight="1">
|
|
||||||
<Toolbar
|
<LinearLayout
|
||||||
android:id="@+id/search_action_bar_unified"
|
android:id="@+id/search_action_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/search_bar_height"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="8dp"
|
android:minHeight="72dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingStart="24dp"
|
||||||
android:paddingEnd="24dp"
|
android:paddingEnd="24dp"
|
||||||
android:background="@drawable/search_bar_selected_background"
|
android:background="@drawable/search_bar_selected_background">
|
||||||
android:touchscreenBlocksFocus="false"
|
|
||||||
android:nextFocusForward="@+id/homepage_container"
|
<ImageView
|
||||||
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
|
android:id="@+id/imageView"
|
||||||
android:navigationIcon="@drawable/ic_homepage_search">
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:src="@drawable/ic_homepage_search" />
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_bar_title"
|
android:id="@+id/search_bar_title"
|
||||||
style="@style/TextAppearance.SearchBar"
|
style="@style/TextAppearance.SearchBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="8dp"
|
android:paddingStart="8dp"
|
||||||
android:layout_gravity="start"
|
android:paddingEnd="8dp"
|
||||||
android:text="@string/search_settings"/>
|
android:text="@string/search_settings"/>
|
||||||
</Toolbar>
|
</LinearLayout>
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
Copyright (C) 2024 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/app_bar_content"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:padding="6dp"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<include layout="@layout/search_bar_unified_version"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
@@ -62,19 +62,21 @@
|
|||||||
android:id="@+id/app_bar"
|
android:id="@+id/app_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:elevation="0dp"
|
||||||
android:touchscreenBlocksFocus="false"
|
android:touchscreenBlocksFocus="false"
|
||||||
android:keyboardNavigationCluster="false">
|
android:keyboardNavigationCluster="false">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/app_bar_container"
|
android:id="@+id/app_bar_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="horizontal"
|
||||||
android:minHeight="76dp"
|
android:paddingTop="8dp"
|
||||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
android:paddingBottom="24dp"
|
||||||
|
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
|
||||||
|
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
|
||||||
|
|
||||||
|
<include layout="@layout/search_bar_unified_version"/>
|
||||||
|
|
||||||
<include
|
|
||||||
android:id="@+id/homepage_app_bar_unified_view"
|
|
||||||
layout="@layout/settings_homepage_app_bar_unified_layout"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|||||||
@@ -459,6 +459,13 @@
|
|||||||
<item name="cardElevation">0dp</item>
|
<item name="cardElevation">0dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="SearchBarStyle_v2">
|
||||||
|
<item name="cardCornerRadius">40dp</item>
|
||||||
|
<item name="cardElevation">0dp</item>
|
||||||
|
<item name="strokeWidth">1dp</item>
|
||||||
|
<item name="strokeColor">@color/settingslib_materialColorOutlineVariant</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="ConditionCardBorderlessButton"
|
<style name="ConditionCardBorderlessButton"
|
||||||
parent="android:Widget.DeviceDefault.Button.Borderless">
|
parent="android:Widget.DeviceDefault.Button.Borderless">
|
||||||
<item name="android:textColor">?android:attr/colorAccent</item>
|
<item name="android:textColor">?android:attr/colorAccent</item>
|
||||||
|
|||||||
@@ -185,6 +185,7 @@
|
|||||||
<style name="Theme.Settings.HomeBase" parent="Theme.Settings.NoActionBar">
|
<style name="Theme.Settings.HomeBase" parent="Theme.Settings.NoActionBar">
|
||||||
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
|
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
|
||||||
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
||||||
|
<item name="android:listPreferredItemPaddingStart">16dp</item>
|
||||||
<item name="preferenceTheme">@style/SettingsPreferenceTheme</item>
|
<item name="preferenceTheme">@style/SettingsPreferenceTheme</item>
|
||||||
|
|
||||||
<!-- action bar, needed for search bar icon tinting -->
|
<!-- action bar, needed for search bar icon tinting -->
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
|
|
||||||
private void initSearchBarView() {
|
private void initSearchBarView() {
|
||||||
if (Flags.homepageRevamp()) {
|
if (Flags.homepageRevamp()) {
|
||||||
Toolbar toolbar = findViewById(R.id.search_action_bar_unified);
|
View toolbar = findViewById(R.id.search_action_bar);
|
||||||
FeatureFactory.getFeatureFactory().getSearchFeatureProvider()
|
FeatureFactory.getFeatureFactory().getSearchFeatureProvider()
|
||||||
.initSearchToolbar(this /* activity */, toolbar,
|
.initSearchToolbar(this /* activity */, toolbar,
|
||||||
SettingsEnums.SETTINGS_HOMEPAGE);
|
SettingsEnums.SETTINGS_HOMEPAGE);
|
||||||
@@ -469,6 +469,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
|||||||
window.setStatusBarColor(color);
|
window.setStatusBarColor(color);
|
||||||
// Update content background.
|
// Update content background.
|
||||||
findViewById(android.R.id.content).setBackgroundColor(color);
|
findViewById(android.R.id.content).setBackgroundColor(color);
|
||||||
|
if (Flags.homepageRevamp()) {
|
||||||
|
//Update search bar background
|
||||||
|
findViewById(R.id.app_bar_container).setBackgroundColor(color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSuggestionFragment(boolean scrollNeeded) {
|
private void showSuggestionFragment(boolean scrollNeeded) {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.Toolbar;
|
import android.widget.Toolbar;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
@@ -80,8 +81,9 @@ public interface SearchFeatureProvider {
|
|||||||
/**
|
/**
|
||||||
* Initializes the search toolbar.
|
* Initializes the search toolbar.
|
||||||
*/
|
*/
|
||||||
default void initSearchToolbar(FragmentActivity activity, Toolbar toolbar, int pageId) {
|
default void initSearchToolbar(@NonNull FragmentActivity activity, @Nullable View toolbar,
|
||||||
if (activity == null || toolbar == null) {
|
int pageId) {
|
||||||
|
if (toolbar == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,11 +100,13 @@ public interface SearchFeatureProvider {
|
|||||||
//
|
//
|
||||||
// Need to make the navigation icon non-clickable so that the entire card is clickable
|
// Need to make the navigation icon non-clickable so that the entire card is clickable
|
||||||
// and goes to the search UI. Also set the background to null so there's no ripple.
|
// and goes to the search UI. Also set the background to null so there's no ripple.
|
||||||
final View navView = toolbar.getNavigationView();
|
if (toolbar instanceof Toolbar) {
|
||||||
navView.setClickable(false);
|
final View navView = ((Toolbar) toolbar).getNavigationView();
|
||||||
navView.setFocusable(false);
|
navView.setClickable(false);
|
||||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
navView.setFocusable(false);
|
||||||
navView.setBackground(null);
|
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||||
|
navView.setBackground(null);
|
||||||
|
}
|
||||||
|
|
||||||
final Context context = activity.getApplicationContext();
|
final Context context = activity.getApplicationContext();
|
||||||
final Intent intent = buildSearchIntent(context, pageId)
|
final Intent intent = buildSearchIntent(context, pageId)
|
||||||
|
|||||||
Reference in New Issue
Block a user