Refine the homepage app bar layout

- Polish the app bar mask on homepage
- Move the Suggestion card to the position below the search box

Fix: 224435133
Fix: 230284145
Test: robotest, visual

Change-Id: I0a4fd86230fb773a28ca1d9799f3c631a81a11cb
This commit is contained in:
Jason Chiu
2022-05-12 16:21:21 +08:00
parent 56c7f91cea
commit 8847c3186a
7 changed files with 89 additions and 31 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2022 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="@color/settings_two_pane_background_color" />
<corners
android:bottomLeftRadius="@dimen/homepage_app_bar_corner_radius"
android:bottomRightRadius="@dimen/homepage_app_bar_corner_radius" />
</shape>

View File

@@ -21,8 +21,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="@dimen/search_bar_margin"
android:layout_marginVertical="@dimen/search_bar_margin">
android:layout_marginEnd="@dimen/search_bar_margin">
<Toolbar
android:id="@+id/search_action_bar_two_pane"
android:layout_width="match_parent"

View File

@@ -17,29 +17,21 @@
<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:orientation="vertical"
android:background="@color/settings_two_pane_background_color">
android:layout_marginHorizontal="@dimen/homepage_app_bar_margin_horizontal_two_pane"
android:padding="@dimen/homepage_app_bar_padding_two_pane"
android:orientation="horizontal"
android:background="@drawable/homepage_app_bar_background">
<FrameLayout
android:id="@+id/two_pane_suggestion_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<include layout="@layout/search_bar_two_pane_version"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<include layout="@layout/search_bar_two_pane_version"/>
<ImageView
android:id="@+id/account_avatar_two_pane_version"
android:layout_width="@dimen/avatar_length"
android:layout_height="@dimen/avatar_length"
android:layout_gravity="center"
android:contentDescription="@string/search_bar_account_avatar_content_description"/>
</LinearLayout>
<ImageView
android:id="@+id/account_avatar_two_pane_version"
android:layout_width="@dimen/avatar_length"
android:layout_height="@dimen/avatar_length"
android:layout_gravity="center"
android:contentDescription="@string/search_bar_account_avatar_content_description"/>
</LinearLayout>

View File

@@ -34,6 +34,11 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/suggestion_container_two_pane"
layout="@layout/suggestion_container_two_pane"
android:visibility="gone"/>
<FrameLayout
android:id="@+id/contextual_cards_content"
android:layout_width="match_parent"

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2022 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.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/homepage_app_bar_margin_bottom_two_pane"
android:layout_marginHorizontal="@dimen/homepage_padding_horizontal_two_pane">
<FrameLayout
android:id="@+id/two_pane_suggestion_content"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>

View File

@@ -152,6 +152,12 @@
<dimen name="homepage_preference_icon_padding_start_two_pane">8dp</dimen>
<dimen name="homepage_preference_text_padding_start">16dp</dimen>
<dimen name="homepage_preference_text_padding_start_two_pane">24dp</dimen>
<dimen name="homepage_app_bar_corner_radius">32dp</dimen>
<dimen name="homepage_app_bar_padding_two_pane">6dp</dimen>
<!-- bottom: search_bar_margin - homepage_app_bar_padding_two_pane -->
<dimen name="homepage_app_bar_margin_bottom_two_pane">10dp</dimen>
<!-- horizontal: homepage_padding_horizontal_two_pane - homepage_app_bar_padding_two_pane -->
<dimen name="homepage_app_bar_margin_horizontal_two_pane">18dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>

View File

@@ -86,7 +86,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
private TopLevelSettings mMainFragment;
private View mHomepageView;
private View mAppBar;
private View mSuggestionView;
private View mTwoPaneSuggestionView;
private CategoryMixin mCategoryMixin;
@@ -171,8 +170,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
mSplitController = SplitController.getInstance();
mIsTwoPane = mSplitController.isActivityEmbedded(this);
mAppBar = findViewById(R.id.app_bar_container);
mAppBar.setMinimumHeight(getSearchBoxHeight());
updateAppBarMinHeight();
initHomepageContainer();
updateHomepageAppBar();
updateHomepageBackground();
@@ -482,12 +480,15 @@ public class SettingsHomepageActivity extends FragmentActivity implements
if (!mIsEmbeddingActivityEnabled) {
return;
}
updateAppBarMinHeight();
if (mIsTwoPane) {
findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.GONE);
findViewById(R.id.homepage_app_bar_two_pane_view).setVisibility(View.VISIBLE);
findViewById(R.id.suggestion_container_two_pane).setVisibility(View.VISIBLE);
} else {
findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.VISIBLE);
findViewById(R.id.homepage_app_bar_two_pane_view).setVisibility(View.GONE);
findViewById(R.id.suggestion_container_two_pane).setVisibility(View.GONE);
}
}
@@ -498,19 +499,20 @@ public class SettingsHomepageActivity extends FragmentActivity implements
if (mIsTwoPane) {
int padding = getResources().getDimensionPixelSize(
R.dimen.homepage_padding_horizontal_two_pane);
mAppBar.setPaddingRelative(padding, 0, padding, 0);
mMainFragment.setPaddingHorizontal(padding);
} else {
mAppBar.setPaddingRelative(0, 0, 0, 0);
mMainFragment.setPaddingHorizontal(0);
}
mMainFragment.updatePreferencePadding(mIsTwoPane);
}
private int getSearchBoxHeight() {
private void updateAppBarMinHeight() {
final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height);
final int searchBarMargin = getResources().getDimensionPixelSize(R.dimen.search_bar_margin);
return searchBarHeight + searchBarMargin * 2;
final int margin = getResources().getDimensionPixelSize(
mIsEmbeddingActivityEnabled && mIsTwoPane
? R.dimen.homepage_app_bar_padding_two_pane
: R.dimen.search_bar_margin);
findViewById(R.id.app_bar_container).setMinimumHeight(searchBarHeight + margin * 2);
}
private static class SuggestionFragCreator implements FragmentCreator {