Merge "Refine the homepage app bar layout" into tm-dev am: 44aab7c55f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18332035

Change-Id: Idaef98b8499f40d355a1ae5762f9987c874057e4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jason Chiu
2022-05-16 03:18:08 +00:00
committed by Automerger Merge Worker
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_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_marginEnd="@dimen/search_bar_margin" android:layout_marginEnd="@dimen/search_bar_margin">
android:layout_marginVertical="@dimen/search_bar_margin">
<Toolbar <Toolbar
android:id="@+id/search_action_bar_two_pane" android:id="@+id/search_action_bar_two_pane"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -17,20 +17,13 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/app_bar_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:layout_marginHorizontal="@dimen/homepage_app_bar_margin_horizontal_two_pane"
android:background="@color/settings_two_pane_background_color"> android:padding="@dimen/homepage_app_bar_padding_two_pane"
android:orientation="horizontal"
<FrameLayout android:background="@drawable/homepage_app_bar_background">
android:id="@+id/two_pane_suggestion_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<include layout="@layout/search_bar_two_pane_version"/> <include layout="@layout/search_bar_two_pane_version"/>
@@ -40,6 +33,5 @@
android:layout_height="@dimen/avatar_length" android:layout_height="@dimen/avatar_length"
android:layout_gravity="center" android:layout_gravity="center"
android:contentDescription="@string/search_bar_account_avatar_content_description"/> android:contentDescription="@string/search_bar_account_avatar_content_description"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View File

@@ -34,6 +34,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<include
android:id="@+id/suggestion_container_two_pane"
layout="@layout/suggestion_container_two_pane"
android:visibility="gone"/>
<FrameLayout <FrameLayout
android:id="@+id/contextual_cards_content" android:id="@+id/contextual_cards_content"
android:layout_width="match_parent" 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_icon_padding_start_two_pane">8dp</dimen>
<dimen name="homepage_preference_text_padding_start">16dp</dimen> <dimen name="homepage_preference_text_padding_start">16dp</dimen>
<dimen name="homepage_preference_text_padding_start_two_pane">24dp</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 --> <!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen> <dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>

View File

@@ -89,7 +89,6 @@ public class SettingsHomepageActivity extends FragmentActivity implements
private TopLevelSettings mMainFragment; private TopLevelSettings mMainFragment;
private View mHomepageView; private View mHomepageView;
private View mAppBar;
private View mSuggestionView; private View mSuggestionView;
private View mTwoPaneSuggestionView; private View mTwoPaneSuggestionView;
private CategoryMixin mCategoryMixin; private CategoryMixin mCategoryMixin;
@@ -174,8 +173,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
mSplitController = SplitController.getInstance(); mSplitController = SplitController.getInstance();
mIsTwoPane = mSplitController.isActivityEmbedded(this); mIsTwoPane = mSplitController.isActivityEmbedded(this);
mAppBar = findViewById(R.id.app_bar_container); updateAppBarMinHeight();
mAppBar.setMinimumHeight(getSearchBoxHeight());
initHomepageContainer(); initHomepageContainer();
updateHomepageAppBar(); updateHomepageAppBar();
updateHomepageBackground(); updateHomepageBackground();
@@ -491,12 +489,15 @@ public class SettingsHomepageActivity extends FragmentActivity implements
if (!mIsEmbeddingActivityEnabled) { if (!mIsEmbeddingActivityEnabled) {
return; return;
} }
updateAppBarMinHeight();
if (mIsTwoPane) { if (mIsTwoPane) {
findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.GONE); 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.homepage_app_bar_two_pane_view).setVisibility(View.VISIBLE);
findViewById(R.id.suggestion_container_two_pane).setVisibility(View.VISIBLE);
} else { } else {
findViewById(R.id.homepage_app_bar_regular_phone_view).setVisibility(View.VISIBLE); 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.homepage_app_bar_two_pane_view).setVisibility(View.GONE);
findViewById(R.id.suggestion_container_two_pane).setVisibility(View.GONE);
} }
} }
@@ -507,19 +508,20 @@ public class SettingsHomepageActivity extends FragmentActivity implements
if (mIsTwoPane) { if (mIsTwoPane) {
int padding = getResources().getDimensionPixelSize( int padding = getResources().getDimensionPixelSize(
R.dimen.homepage_padding_horizontal_two_pane); R.dimen.homepage_padding_horizontal_two_pane);
mAppBar.setPaddingRelative(padding, 0, padding, 0);
mMainFragment.setPaddingHorizontal(padding); mMainFragment.setPaddingHorizontal(padding);
} else { } else {
mAppBar.setPaddingRelative(0, 0, 0, 0);
mMainFragment.setPaddingHorizontal(0); mMainFragment.setPaddingHorizontal(0);
} }
mMainFragment.updatePreferencePadding(mIsTwoPane); mMainFragment.updatePreferencePadding(mIsTwoPane);
} }
private int getSearchBoxHeight() { private void updateAppBarMinHeight() {
final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height); final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height);
final int searchBarMargin = getResources().getDimensionPixelSize(R.dimen.search_bar_margin); final int margin = getResources().getDimensionPixelSize(
return searchBarHeight + searchBarMargin * 2; 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 { private static class SuggestionFragCreator implements FragmentCreator {