Change search fab to search bar.
- Remove search fab from layout xml - Change RelativeLayout to CoordinatorLayout so we can use prebuilt scrolling behavior - Minor update to theme so search bar background works in dark mode for the homepage activity. Change-Id: If7408c12684be65137e04ae3bb4137204c2d77e0 Fixes: 117508596 Test: robotests, visual
This commit is contained in:
@@ -19,4 +19,4 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/card_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="match_parent" />
|
||||
|
@@ -15,11 +15,34 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<RelativeLayout
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/homepage_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:elevation="0dp">
|
||||
|
||||
<include layout="@layout/search_bar"/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
@@ -28,25 +51,8 @@
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_marginStart="0dp"
|
||||
android:background="?android:attr/windowBackground"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:itemIconTint="@color/bottom_navigation_colors"
|
||||
app:itemTextColor="@color/bottom_navigation_colors"
|
||||
app:menu="@menu/home_bottom_navigation" />
|
||||
app:menu="@menu/home_bottom_navigation"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@id/main_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/bottom_nav" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/search_fab"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_search_24dp"
|
||||
android:layout_margin="24dp"
|
||||
android:layout_above="@id/bottom_nav"
|
||||
android:layout_alignParentRight="true"
|
||||
app:backgroundTint="?android:attr/colorAccent"
|
||||
app:tint="@android:color/white" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
@@ -18,6 +18,7 @@
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Settings.Home" parent="Theme.Settings.HomeBase">
|
||||
<item name="colorPrimary">@*android:color/primary_device_default_settings</item>
|
||||
<item name="colorPrimaryDark">@*android:color/primary_dark_device_default_settings</item>
|
||||
</style>
|
||||
|
||||
|
@@ -170,6 +170,9 @@
|
||||
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
|
||||
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
||||
<item name="preferenceTheme">@style/PreferenceTheme</item>
|
||||
|
||||
<!-- action bar, needed for search bar icon tinting -->
|
||||
<item name="android:actionBarTheme">@*android:style/ThemeOverlay.DeviceDefault.ActionBar.Accent</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Settings.Home" parent="Theme.Settings.HomeBase">
|
||||
|
@@ -299,15 +299,6 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
||||
.initSearchToolbar(this, toolbar);
|
||||
setActionBar(toolbar);
|
||||
|
||||
// Please forgive me for what I am about to do.
|
||||
//
|
||||
// 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.
|
||||
View navView = toolbar.getNavigationView();
|
||||
navView.setClickable(false);
|
||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
navView.setBackground(null);
|
||||
}
|
||||
|
||||
ActionBar actionBar = getActionBar();
|
||||
|
@@ -20,6 +20,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@@ -32,7 +33,6 @@ import com.android.settings.core.SettingsBaseActivity;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
public class SettingsHomepageActivity extends SettingsBaseActivity {
|
||||
|
||||
@@ -54,9 +54,9 @@ public class SettingsHomepageActivity extends SettingsBaseActivity {
|
||||
|
||||
setContentView(R.layout.settings_homepage_container);
|
||||
|
||||
final FloatingActionButton searchButton = findViewById(R.id.search_fab);
|
||||
final Toolbar toolbar = findViewById(R.id.search_action_bar);
|
||||
FeatureFactory.getFactory(this).getSearchFeatureProvider()
|
||||
.initSearchToolbar(this, searchButton);
|
||||
.initSearchToolbar(this, toolbar);
|
||||
|
||||
final BottomNavigationView navigation = findViewById(R.id.bottom_nav);
|
||||
navigation.setOnNavigationItemSelectedListener(item -> {
|
||||
|
@@ -16,12 +16,15 @@
|
||||
*/
|
||||
package com.android.settings.search;
|
||||
|
||||
import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.View;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -53,15 +56,23 @@ public interface SearchFeatureProvider {
|
||||
return "com.android.settings.intelligence";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initializes the search toolbar.
|
||||
*/
|
||||
default void initSearchToolbar(Activity activity, View view) {
|
||||
if (activity == null || view == null) {
|
||||
default void initSearchToolbar(Activity activity, Toolbar toolbar) {
|
||||
if (activity == null || toolbar == null) {
|
||||
return;
|
||||
}
|
||||
view.setOnClickListener(tb -> {
|
||||
// Please forgive me for what I am about to do.
|
||||
//
|
||||
// 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.
|
||||
final View navView = toolbar.getNavigationView();
|
||||
navView.setClickable(false);
|
||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
navView.setBackground(null);
|
||||
|
||||
toolbar.setOnClickListener(tb -> {
|
||||
final Intent intent = SEARCH_UI_INTENT;
|
||||
intent.setPackage(getSettingsIntelligencePkgName());
|
||||
final Context context = activity.getApplicationContext();
|
||||
|
@@ -44,7 +44,7 @@ public class SearchFeatureProviderImplTest {
|
||||
@Before
|
||||
public void setUp() {
|
||||
FakeFeatureFactory.setupForTest();
|
||||
mActivity = Robolectric.buildActivity(Activity.class).create().visible().get();
|
||||
mActivity = Robolectric.setupActivity(Activity.class);
|
||||
mProvider = spy(new SearchFeatureProviderImpl());
|
||||
}
|
||||
|
||||
@@ -54,6 +54,8 @@ public class SearchFeatureProviderImplTest {
|
||||
// Should not crash.
|
||||
|
||||
final Toolbar toolbar = new Toolbar(mActivity);
|
||||
// This ensures navigationView is created.
|
||||
toolbar.setNavigationContentDescription("test");
|
||||
mProvider.initSearchToolbar(mActivity, toolbar);
|
||||
|
||||
toolbar.performClick();
|
||||
|
Reference in New Issue
Block a user