Redesign homepage IA icon
- remove the outer circle of the icons - tint the icons including injected ones Test: robotest, visual Bug: 182870640 Change-Id: If72c37152f4f0d68e25149b11d497eef1c7ece91
This commit is contained in:
@@ -1211,6 +1211,14 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return roundedBitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of homepage preference icons.
|
||||
*/
|
||||
@ColorInt
|
||||
public static int getHomepageIconColor(Context context) {
|
||||
return getColorAttrDefaultColor(context, android.R.attr.textColorPrimary);
|
||||
}
|
||||
|
||||
public static boolean isProviderModelEnabled(Context context) {
|
||||
return FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_PROVIDER_MODEL);
|
||||
}
|
||||
|
@@ -59,6 +59,7 @@ import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.dashboard.profileselector.ProfileSelectDialog;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -401,12 +402,12 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
private void setPreferenceIcon(Preference preference, Tile tile, boolean forceRoundedIcon,
|
||||
String iconPackage, Icon icon) {
|
||||
Drawable iconDrawable = icon.loadDrawable(preference.getContext());
|
||||
if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
|
||||
&& TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
|
||||
iconDrawable.setTint(Utils.getHomepageIconColor(preference.getContext()));
|
||||
} else if (forceRoundedIcon && !TextUtils.equals(mContext.getPackageName(), iconPackage)) {
|
||||
iconDrawable = new AdaptiveIcon(mContext, iconDrawable,
|
||||
FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)
|
||||
&& TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)
|
||||
? R.dimen.homepage_foreground_image_inset
|
||||
: R.dimen.dashboard_tile_foreground_image_inset);
|
||||
R.dimen.dashboard_tile_foreground_image_inset);
|
||||
((AdaptiveIcon) iconDrawable).setBackgroundColor(mContext, tile);
|
||||
}
|
||||
preference.setIcon(iconDrawable);
|
||||
|
@@ -39,13 +39,11 @@ import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.PreferenceControllerListHelper;
|
||||
import com.android.settings.core.SettingsBaseActivity;
|
||||
import com.android.settings.homepage.HomepagePreference;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settings.widget.PrimarySwitchPreference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.drawer.CategoryKey;
|
||||
import com.android.settingslib.drawer.DashboardCategory;
|
||||
import com.android.settingslib.drawer.ProviderTile;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
@@ -538,10 +536,6 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
|
||||
@VisibleForTesting
|
||||
Preference createPreference(Tile tile) {
|
||||
if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)
|
||||
&& TextUtils.equals(tile.getCategory(), CategoryKey.CATEGORY_HOMEPAGE)) {
|
||||
return new HomepagePreference(getPrefContext());
|
||||
}
|
||||
return tile instanceof ProviderTile
|
||||
? new SwitchPreference(getPrefContext())
|
||||
: tile.hasSwitch()
|
||||
|
@@ -25,7 +25,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.FeatureFlagUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
@@ -33,8 +32,6 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.homepage.RestrictedHomepagePreference;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.RestrictedTopLevelPreference;
|
||||
|
||||
@@ -92,11 +89,7 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (FeatureFlagUtils.isEnabled(mContext, FeatureFlags.SILKY_HOME)) {
|
||||
disablePreferenceIfManaged((RestrictedHomepagePreference) preference);
|
||||
} else {
|
||||
disablePreferenceIfManaged((RestrictedTopLevelPreference) preference);
|
||||
}
|
||||
disablePreferenceIfManaged((RestrictedTopLevelPreference) preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,18 +133,4 @@ public class TopLevelWallpaperPreferenceController extends BasePreferenceControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disablePreferenceIfManaged(RestrictedHomepagePreference pref) {
|
||||
final String restriction = DISALLOW_SET_WALLPAPER;
|
||||
if (pref != null) {
|
||||
pref.setDisabledByAdmin(null);
|
||||
if (RestrictedLockUtilsInternal.hasBaseUserRestriction(mContext,
|
||||
restriction, UserHandle.myUserId())) {
|
||||
// Do not show the admin dialog for system restriction.
|
||||
pref.setEnabled(false);
|
||||
} else {
|
||||
pref.checkRestrictionAndSetDisabled(restriction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* 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.homepage;
|
||||
|
||||
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) {
|
||||
super(context);
|
||||
setLayoutResource(R.layout.homepage_preference);
|
||||
}
|
||||
|
||||
public HomepagePreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setLayoutResource(R.layout.homepage_preference);
|
||||
}
|
||||
|
||||
public HomepagePreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
this(context, attrs, defStyleAttr, /* defStyleRes= */ 0);
|
||||
setLayoutResource(R.layout.homepage_preference);
|
||||
}
|
||||
|
||||
public HomepagePreference(Context context, AttributeSet attrs,
|
||||
int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
setLayoutResource(R.layout.homepage_preference);
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* 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.homepage;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
|
||||
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) {
|
||||
this(context, attrs, defStyleAttr, /* defStyleRes= */ 0);
|
||||
}
|
||||
|
||||
public RestrictedHomepagePreference(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.preferenceStyle,
|
||||
android.R.attr.preferenceStyle));
|
||||
}
|
||||
|
||||
public RestrictedHomepagePreference(Context context) {
|
||||
this(context, /* attrs= */ null);
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import static com.android.settingslib.search.SearchIndexable.MOBILE;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.util.FeatureFlagUtils;
|
||||
@@ -28,8 +29,10 @@ import android.util.FeatureFlagUtils;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.core.FeatureFlags;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
@@ -102,6 +105,31 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
super.onCreatePreferences(savedInstanceState, rootKey);
|
||||
if (!FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.SILKY_HOME)) {
|
||||
return;
|
||||
}
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen == null) {
|
||||
return;
|
||||
}
|
||||
// Tint the homepage icons
|
||||
final int tintColor = Utils.getHomepageIconColor(getContext());
|
||||
final int count = screen.getPreferenceCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final Preference preference = screen.getPreference(i);
|
||||
if (preference == null) {
|
||||
break;
|
||||
}
|
||||
final Drawable icon = preference.getIcon();
|
||||
if (icon != null) {
|
||||
icon.setTint(tintColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldForceRoundedIcon() {
|
||||
return getContext().getResources()
|
||||
|
Reference in New Issue
Block a user