Merge "UI refinement of highlighted menu entry for large screen" into sc-v2-dev am: aee951dcb0 am: 517c9ead5e

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

Change-Id: I21d8dab4ebc3292bf49a50e518531f3c07098a5b
This commit is contained in:
TreeHugger Robot
2021-11-24 18:44:52 +00:00
committed by Automerger Merge Worker
9 changed files with 243 additions and 31 deletions

View File

@@ -31,6 +31,7 @@ import androidx.preference.PreferenceGroupAdapter;
import androidx.preference.PreferenceViewHolder;
import androidx.recyclerview.widget.RecyclerView;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.activityembedding.ActivityEmbeddingUtils;
import com.android.settings.homepage.SettingsHomepageActivity;
@@ -45,19 +46,18 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
static final long DELAY_HIGHLIGHT_DURATION_MILLIS = 100L;
@VisibleForTesting
final int mHighlightColor;
final int mTitleColorNormal;
final int mTitleColorHighlight;
final int mSummaryColorNormal;
final int mSummaryColorHighlight;
final int mIconColorNormal;
final int mIconColorHighlight;
private final int mTitleColorNormal;
private final int mTitleColorHighlight;
private final int mSummaryColorNormal;
private final int mSummaryColorHighlight;
private final int mIconColorNormal;
private final int mIconColorHighlight;
private final Context mContext;
private final SettingsHomepageActivity mHomepageActivity;
private final RecyclerView mRecyclerView;
private final int mNormalBackgroundRes;
private final int mHighlightBackgroundRes;
private String mHighlightKey;
private String mPreviousHighlightKey;
private int mHighlightPosition = RecyclerView.NO_POSITION;
@@ -76,8 +76,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
mContext.getTheme().resolveAttribute(android.R.attr.selectableItemBackground,
outValue, true /* resolveRefs */);
mNormalBackgroundRes = outValue.resourceId;
mHighlightColor = Utils.getColorAttrDefaultColor(mContext,
com.android.internal.R.attr.colorAccentSecondaryVariant);
mHighlightBackgroundRes = R.drawable.homepage_highlighted_item_background;
mTitleColorNormal = Utils.getColorAttrDefaultColor(mContext,
android.R.attr.textColorPrimary);
mTitleColorHighlight = Utils.getColorAttrDefaultColor(mContext,
@@ -227,7 +226,7 @@ public class HighlightableTopLevelPreferenceAdapter extends PreferenceGroupAdapt
private void addHighlightBackground(PreferenceViewHolder holder) {
final View v = holder.itemView;
v.setBackgroundColor(mHighlightColor);
v.setBackgroundResource(mHighlightBackgroundRes);
((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();

View File

@@ -0,0 +1,48 @@
/*
* Copyright (C) 2021 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.
*/
package com.android.settings.widget;
import android.content.Context;
import android.util.AttributeSet;
import androidx.preference.Preference;
import com.android.settings.R;
/** A customized layout for homepage preference. */
public class HomepagePreference extends Preference {
public HomepagePreference(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.homepage_preference);
}
public HomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayoutResource(R.layout.homepage_preference);
}
public HomepagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.homepage_preference);
}
public HomepagePreference(Context context) {
super(context);
setLayoutResource(R.layout.homepage_preference);
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2021 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.
*/
package com.android.settings.widget;
import android.content.Context;
import android.util.AttributeSet;
import com.android.settings.R;
import com.android.settingslib.RestrictedTopLevelPreference;
/** Homepage preference that can be disabled by a device admin using a user restriction. */
public class RestrictedHomepagePreference extends RestrictedTopLevelPreference {
public RestrictedHomepagePreference(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.homepage_preference);
}
public RestrictedHomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setLayoutResource(R.layout.homepage_preference);
}
public RestrictedHomepagePreference(Context context, AttributeSet attrs) {
super(context, attrs);
setLayoutResource(R.layout.homepage_preference);
}
public RestrictedHomepagePreference(Context context) {
super(context);
setLayoutResource(R.layout.homepage_preference);
}
}