Merge "Apply different text style to highlighted homepage titles" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
cba1fbacd1
@@ -29,6 +29,7 @@ import androidx.preference.PreferenceGroupAdapter;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settingslib.widget.SettingsThemeHelper;
|
||||
import com.android.settingslib.widget.theme.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -84,21 +85,33 @@ public class RoundCornerPreferenceAdapter extends PreferenceGroupAdapter {
|
||||
|
||||
if (((CornerType & ROUND_CORNER_TOP) != 0) && ((CornerType & ROUND_CORNER_BOTTOM) == 0)) {
|
||||
// the first
|
||||
return isSelected ? R.drawable.settingslib_round_background_top_selected
|
||||
return isSelected
|
||||
? SettingsThemeHelper.isExpressiveTheme(mPreferenceGroup.getContext())
|
||||
? R.drawable.settingslib_round_background_top_selected
|
||||
: com.android.settings.R.drawable.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
|
||||
return isSelected
|
||||
? SettingsThemeHelper.isExpressiveTheme(mPreferenceGroup.getContext())
|
||||
? R.drawable.settingslib_round_background_bottom_selected
|
||||
: com.android.settings.R.drawable.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
|
||||
return isSelected
|
||||
? SettingsThemeHelper.isExpressiveTheme(mPreferenceGroup.getContext())
|
||||
? R.drawable.settingslib_round_background_selected
|
||||
: com.android.settings.R.drawable.round_background_selected
|
||||
: R.drawable.settingslib_round_background;
|
||||
} else {
|
||||
// in the center
|
||||
return isSelected ? R.drawable.settingslib_round_background_center_selected
|
||||
return isSelected
|
||||
? SettingsThemeHelper.isExpressiveTheme(mPreferenceGroup.getContext())
|
||||
? R.drawable.settingslib_round_background_center_selected
|
||||
: com.android.settings.R.drawable.round_background_center_selected
|
||||
: R.drawable.settingslib_round_background_center;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.android.settings.Utils;
|
||||
import com.android.settings.core.RoundCornerPreferenceAdapter;
|
||||
import com.android.settings.flags.Flags;
|
||||
import com.android.settings.homepage.SettingsHomepageActivity;
|
||||
import com.android.settingslib.widget.SettingsThemeHelper;
|
||||
|
||||
/**
|
||||
* Adapter for highlighting top level preferences
|
||||
@@ -243,6 +244,14 @@ public class HighlightableTopLevelPreferenceAdapter extends RoundCornerPreferenc
|
||||
if (Flags.homepageRevamp()) {
|
||||
@DrawableRes int bgRes = getRoundCornerDrawableRes(position, true /*isSelected*/);
|
||||
v.setBackgroundResource(bgRes);
|
||||
Context context = v.getContext();
|
||||
if (SettingsThemeHelper.isExpressiveTheme(context)) {
|
||||
TextView title = v.findViewById(android.R.id.title);
|
||||
if (title != null) {
|
||||
title.setTextAppearance(context, com.android.settingslib.widget.theme.R.style
|
||||
.TextAppearance_SettingsLib_TitleMedium_Emphasized);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
v.setBackgroundResource(RES_HIGHLIGHTED_BACKGROUND);
|
||||
((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorHighlight);
|
||||
@@ -259,6 +268,14 @@ public class HighlightableTopLevelPreferenceAdapter extends RoundCornerPreferenc
|
||||
if (Flags.homepageRevamp()) {
|
||||
@DrawableRes int bgRes = getRoundCornerDrawableRes(position, false /*isSelected*/);
|
||||
v.setBackgroundResource(bgRes);
|
||||
Context context = v.getContext();
|
||||
if (SettingsThemeHelper.isExpressiveTheme(context)) {
|
||||
TextView title = v.findViewById(android.R.id.title);
|
||||
if (title != null) {
|
||||
title.setTextAppearance(context, com.android.settingslib.widget.theme.R.style
|
||||
.TextAppearance_SettingsLib_TitleMedium);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
v.setBackgroundResource(RES_NORMAL_BACKGROUND);
|
||||
((TextView) v.findViewById(android.R.id.title)).setTextColor(mTitleColorNormal);
|
||||
|
||||
Reference in New Issue
Block a user