Merge changes I53ea81ce,I84505033,I4bd5c343 into main
* changes: Apply round corner group background for large screen Update suggestion card padding in Homepage Update Search Bar layout in Homepage
This commit is contained in:
@@ -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.
|
||||
-->
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@*android:color/ripple_material_light">
|
||||
<item
|
||||
android:left="?android:attr/listPreferredItemPaddingStart"
|
||||
android:right="?android:attr/listPreferredItemPaddingEnd">
|
||||
<shape android:shape="rectangle">
|
||||
<solid
|
||||
android:color="@color/settingslib_materialColorPrimaryContainer" />
|
||||
<corners
|
||||
android:radius="?android:attr/dialogCornerRadius" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
@@ -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.
|
||||
-->
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item android:id="@android:id/mask"
|
||||
android:left="?android:attr/listPreferredItemPaddingStart"
|
||||
android:right="?android:attr/listPreferredItemPaddingEnd">
|
||||
<shape android:shape="rectangle">
|
||||
<solid
|
||||
android:color="@android:color/white" />
|
||||
<corners
|
||||
android:radius="?android:attr/dialogCornerRadius" />
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
@@ -17,28 +17,34 @@
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
style="@style/SearchBarStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1">
|
||||
<Toolbar
|
||||
android:id="@+id/search_action_bar_unified"
|
||||
style="@style/SearchBarStyle_v2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/search_action_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/search_bar_height"
|
||||
android:paddingStart="8dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="72dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="24dp"
|
||||
android:paddingEnd="24dp"
|
||||
android:background="@drawable/search_bar_selected_background"
|
||||
android:touchscreenBlocksFocus="false"
|
||||
android:nextFocusForward="@+id/homepage_container"
|
||||
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
|
||||
android:navigationIcon="@drawable/ic_homepage_search">
|
||||
android:background="@drawable/search_bar_selected_background">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/ic_homepage_search" />
|
||||
<TextView
|
||||
android:id="@+id/search_bar_title"
|
||||
style="@style/TextAppearance.SearchBar"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:layout_gravity="start"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/search_settings"/>
|
||||
</Toolbar>
|
||||
</LinearLayout>
|
||||
</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>
|
@@ -38,7 +38,6 @@
|
||||
android:id="@+id/suggestion_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="?android:attr/listPreferredItemPaddingStart"
|
||||
android:layout_marginEnd="?android:attr/listPreferredItemPaddingEnd" />
|
||||
|
||||
@@ -62,19 +61,21 @@
|
||||
android:id="@+id/app_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:elevation="0dp"
|
||||
android:touchscreenBlocksFocus="false"
|
||||
android:keyboardNavigationCluster="false">
|
||||
<LinearLayout
|
||||
android:id="@+id/app_bar_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:minHeight="76dp"
|
||||
app:layout_scrollFlags="scroll|exitUntilCollapsed">
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="8dp"
|
||||
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>
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@@ -459,6 +459,13 @@
|
||||
<item name="cardElevation">0dp</item>
|
||||
</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"
|
||||
parent="android:Widget.DeviceDefault.Button.Borderless">
|
||||
<item name="android:textColor">?android:attr/colorAccent</item>
|
||||
|
@@ -185,6 +185,7 @@
|
||||
<style name="Theme.Settings.HomeBase" parent="Theme.Settings.NoActionBar">
|
||||
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
|
||||
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
||||
<item name="android:listPreferredItemPaddingStart">16dp</item>
|
||||
<item name="preferenceTheme">@style/SettingsPreferenceTheme</item>
|
||||
|
||||
<!-- action bar, needed for search bar icon tinting -->
|
||||
|
@@ -20,6 +20,7 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
@@ -27,6 +28,7 @@ import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceGroupAdapter;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.widget.theme.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -68,14 +70,47 @@ public class RoundCornerPreferenceAdapter extends PreferenceGroupAdapter {
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull PreferenceViewHolder holder, int position) {
|
||||
super.onBindViewHolder(holder, position);
|
||||
updateBackground(holder, position);
|
||||
if (Flags.homepageRevamp()) {
|
||||
updateBackground(holder, position);
|
||||
}
|
||||
}
|
||||
|
||||
protected @DrawableRes int getRoundCornerDrawableRes(int position, boolean isSelected) {
|
||||
int CornerType = mRoundCornerMappingList.get(position);
|
||||
|
||||
if ((CornerType & ROUND_CORNER_CENTER) == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (((CornerType & ROUND_CORNER_TOP) != 0) && ((CornerType & ROUND_CORNER_BOTTOM) == 0)) {
|
||||
// the first
|
||||
return isSelected ? R.drawable.settingslib_round_background_top_selected
|
||||
: R.drawable.settingslib_round_background_top;
|
||||
} else if (((CornerType & ROUND_CORNER_BOTTOM) != 0)
|
||||
&& ((CornerType & ROUND_CORNER_TOP) == 0)) {
|
||||
// the last
|
||||
return isSelected ? R.drawable.settingslib_round_background_bottom_selected
|
||||
: R.drawable.settingslib_round_background_bottom;
|
||||
} else if (((CornerType & ROUND_CORNER_TOP) != 0)
|
||||
&& ((CornerType & ROUND_CORNER_BOTTOM) != 0)) {
|
||||
// the only one preference
|
||||
return isSelected ? R.drawable.settingslib_round_background_selected
|
||||
: R.drawable.settingslib_round_background;
|
||||
} else {
|
||||
// in the center
|
||||
return isSelected ? R.drawable.settingslib_round_background_center_selected
|
||||
: R.drawable.settingslib_round_background_center;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("WeakerAccess") /* synthetic access */
|
||||
private void updatePreferences() {
|
||||
mRoundCornerMappingList = new ArrayList<>();
|
||||
mappingPreferenceGroup(mRoundCornerMappingList, mPreferenceGroup);
|
||||
if (Flags.homepageRevamp()) {
|
||||
mRoundCornerMappingList = new ArrayList<>();
|
||||
mappingPreferenceGroup(mRoundCornerMappingList, mPreferenceGroup);
|
||||
}
|
||||
}
|
||||
|
||||
private void mappingPreferenceGroup(List<Integer> visibleList, PreferenceGroup group) {
|
||||
int groupSize = group.getPreferenceCount();
|
||||
int firstVisible = 0;
|
||||
@@ -125,27 +160,9 @@ public class RoundCornerPreferenceAdapter extends PreferenceGroupAdapter {
|
||||
|
||||
/** handle roundCorner background */
|
||||
private void updateBackground(PreferenceViewHolder holder, int position) {
|
||||
int CornerType = mRoundCornerMappingList.get(position);
|
||||
|
||||
if ((CornerType & ROUND_CORNER_CENTER) == 0) {
|
||||
return;
|
||||
}
|
||||
@DrawableRes int backgroundRes = getRoundCornerDrawableRes(position, false /* isSelected*/);
|
||||
|
||||
View v = holder.itemView;
|
||||
if (((CornerType & ROUND_CORNER_TOP) != 0) && ((CornerType & ROUND_CORNER_BOTTOM) == 0)) {
|
||||
// the first
|
||||
v.setBackgroundResource(R.drawable.settingslib_round_background_top);
|
||||
} else if (((CornerType & ROUND_CORNER_BOTTOM) != 0)
|
||||
&& ((CornerType & ROUND_CORNER_TOP) == 0)) {
|
||||
// the last
|
||||
v.setBackgroundResource(R.drawable.settingslib_round_background_bottom);
|
||||
} else if (((CornerType & ROUND_CORNER_TOP) != 0)
|
||||
&& ((CornerType & ROUND_CORNER_BOTTOM) != 0)) {
|
||||
// the only one preference
|
||||
v.setBackgroundResource(R.drawable.settingslib_round_background);
|
||||
} else {
|
||||
// in the center
|
||||
v.setBackgroundResource(R.drawable.settingslib_round_background_center);
|
||||
}
|
||||
v.setBackgroundResource(backgroundRes);
|
||||
}
|
||||
}
|
||||
|
@@ -406,7 +406,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
||||
|
||||
private void initSearchBarView() {
|
||||
if (Flags.homepageRevamp()) {
|
||||
Toolbar toolbar = findViewById(R.id.search_action_bar_unified);
|
||||
View toolbar = findViewById(R.id.search_action_bar);
|
||||
FeatureFactory.getFeatureFactory().getSearchFeatureProvider()
|
||||
.initSearchToolbar(this /* activity */, toolbar,
|
||||
SettingsEnums.SETTINGS_HOMEPAGE);
|
||||
@@ -469,6 +469,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
||||
window.setStatusBarColor(color);
|
||||
// Update content background.
|
||||
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) {
|
||||
|
@@ -30,6 +30,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.Toolbar;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settings.R;
|
||||
@@ -80,8 +81,9 @@ public interface SearchFeatureProvider {
|
||||
/**
|
||||
* Initializes the search toolbar.
|
||||
*/
|
||||
default void initSearchToolbar(FragmentActivity activity, Toolbar toolbar, int pageId) {
|
||||
if (activity == null || toolbar == null) {
|
||||
default void initSearchToolbar(@NonNull FragmentActivity activity, @Nullable View toolbar,
|
||||
int pageId) {
|
||||
if (toolbar == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,11 +100,13 @@ public interface SearchFeatureProvider {
|
||||
//
|
||||
// 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.setFocusable(false);
|
||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
navView.setBackground(null);
|
||||
if (toolbar instanceof Toolbar) {
|
||||
final View navView = ((Toolbar) toolbar).getNavigationView();
|
||||
navView.setClickable(false);
|
||||
navView.setFocusable(false);
|
||||
navView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
navView.setBackground(null);
|
||||
}
|
||||
|
||||
final Context context = activity.getApplicationContext();
|
||||
final Intent intent = buildSearchIntent(context, pageId)
|
||||
|
@@ -25,35 +25,32 @@ import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.preference.PreferenceGroup;
|
||||
import androidx.preference.PreferenceGroupAdapter;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.window.embedding.ActivityEmbeddingController;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.RoundCornerPreferenceAdapter;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
|
||||
/**
|
||||
* Adapter for highlighting top level preferences
|
||||
*/
|
||||
public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapter implements
|
||||
public class HighlightableTopLevelPreferenceAdapter extends RoundCornerPreferenceAdapter implements
|
||||
SettingsHomepageActivity.HomepageLoadedListener {
|
||||
|
||||
private static final String TAG = "HighlightableTopLevelAdapter";
|
||||
|
||||
static final long DELAY_HIGHLIGHT_DURATION_MILLIS = 100L;
|
||||
private static final int RES_NORMAL_BACKGROUND =
|
||||
Flags.homepageRevamp()
|
||||
? R.drawable.homepage_selectable_item_background_v2
|
||||
: R.drawable.homepage_selectable_item_background;
|
||||
R.drawable.homepage_selectable_item_background;
|
||||
private static final int RES_HIGHLIGHTED_BACKGROUND =
|
||||
Flags.homepageRevamp()
|
||||
? R.drawable.homepage_highlighted_item_background_v2
|
||||
: R.drawable.homepage_highlighted_item_background;
|
||||
R.drawable.homepage_highlighted_item_background;
|
||||
|
||||
private final int mTitleColorNormal;
|
||||
private final int mTitleColorHighlight;
|
||||
@@ -101,7 +98,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
||||
@VisibleForTesting
|
||||
void updateBackground(PreferenceViewHolder holder, int position) {
|
||||
if (!isHighlightNeeded()) {
|
||||
removeHighlightBackground(holder);
|
||||
removeHighlightBackground(holder, position);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -109,9 +106,9 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
||||
&& mHighlightKey != null
|
||||
&& TextUtils.equals(mHighlightKey, getItem(position).getKey())) {
|
||||
// This position should be highlighted.
|
||||
addHighlightBackground(holder);
|
||||
addHighlightBackground(holder, position);
|
||||
} else {
|
||||
removeHighlightBackground(holder);
|
||||
removeHighlightBackground(holder, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,31 +223,41 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
|
||||
// De-highlight the existing preference view holder at an early stage
|
||||
final PreferenceViewHolder holder = mViewHolders.get(position);
|
||||
if (holder != null) {
|
||||
removeHighlightBackground(holder);
|
||||
removeHighlightBackground(holder, position);
|
||||
}
|
||||
notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
|
||||
private void addHighlightBackground(PreferenceViewHolder holder) {
|
||||
private void addHighlightBackground(PreferenceViewHolder holder, int position) {
|
||||
final View v = holder.itemView;
|
||||
v.setBackgroundResource(RES_HIGHLIGHTED_BACKGROUND);
|
||||
((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorHighlight);
|
||||
((TextView) v.findViewById(android.R.id.summary)).setTextColor(mSummaryColorHighlight);
|
||||
final Drawable drawable = ((ImageView) v.findViewById(android.R.id.icon)).getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable.setTint(mIconColorHighlight);
|
||||
if (Flags.homepageRevamp()) {
|
||||
@DrawableRes int bgRes = getRoundCornerDrawableRes(position, true /*isSelected*/);
|
||||
v.setBackgroundResource(bgRes);
|
||||
} else {
|
||||
v.setBackgroundResource(RES_HIGHLIGHTED_BACKGROUND);
|
||||
((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorHighlight);
|
||||
((TextView) v.findViewById(android.R.id.summary)).setTextColor(mSummaryColorHighlight);
|
||||
final Drawable drawable = ((ImageView) v.findViewById(android.R.id.icon)).getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable.setTint(mIconColorHighlight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeHighlightBackground(PreferenceViewHolder holder) {
|
||||
private void removeHighlightBackground(PreferenceViewHolder holder, int position) {
|
||||
final View v = holder.itemView;
|
||||
v.setBackgroundResource(RES_NORMAL_BACKGROUND);
|
||||
((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorNormal);
|
||||
((TextView) v.findViewById(android.R.id.summary)).setTextColor(mSummaryColorNormal);
|
||||
final Drawable drawable = ((ImageView) v.findViewById(android.R.id.icon)).getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable.setTint(mIconColorNormal);
|
||||
if (Flags.homepageRevamp()) {
|
||||
@DrawableRes int bgRes = getRoundCornerDrawableRes(position, false /*isSelected*/);
|
||||
v.setBackgroundResource(bgRes);
|
||||
} else {
|
||||
v.setBackgroundResource(RES_NORMAL_BACKGROUND);
|
||||
((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorNormal);
|
||||
((TextView) v.findViewById(android.R.id.summary)).setTextColor(mSummaryColorNormal);
|
||||
final Drawable drawable = ((ImageView) v.findViewById(android.R.id.icon)).getDrawable();
|
||||
if (drawable != null) {
|
||||
drawable.setTint(mIconColorNormal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user