UI refinement of highlighted menu entry for large screen
- Add a new highlight background drawable - Add two homepage specific preferences for the new layout design Fix: 207079684 Test: visual Change-Id: I20c80da090a03129bffa845d443ee5d1ad13b97b
This commit is contained in:
27
res/drawable/homepage_highlighted_item_background.xml
Normal file
27
res/drawable/homepage_highlighted_item_background.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:insetLeft="@dimen/homepage_menu_entry_padding_horizontal"
|
||||
android:insetRight="@dimen/homepage_menu_entry_padding_horizontal">
|
||||
<shape android:shape="rectangle">
|
||||
<solid
|
||||
android:color="?androidprv:attr/colorAccentSecondaryVariant" />
|
||||
<corners
|
||||
android:radius="@dimen/homepage_menu_entry_corner_radius" />
|
||||
</shape>
|
||||
</inset>
|
81
res/layout/homepage_preference.xml
Normal file
81
res/layout/homepage_preference.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="@dimen/homepage_menu_entry_padding_horizontal"
|
||||
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:clipToPadding="false"
|
||||
android:baselineAligned="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/icon_frame"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="56dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp">
|
||||
|
||||
<androidx.preference.internal.PreferenceImageView
|
||||
android:id="@android:id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:maxWidth="40dp"
|
||||
app:maxHeight="40dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="?android:attr/textAppearanceListItem"
|
||||
android:ellipsize="marquee"/>
|
||||
|
||||
<TextView
|
||||
android:id="@android:id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@android:id/title"
|
||||
android:layout_alignStart="@android:id/title"
|
||||
android:layout_gravity="start"
|
||||
android:textAlignment="viewStart"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:maxLines="4"
|
||||
style="@style/PreferenceSummaryTextStyle"/>
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
@@ -141,6 +141,10 @@
|
||||
<dimen name="homepage_title_margin_bottom">8dp</dimen>
|
||||
<dimen name="homepage_title_margin_horizontal">24dp</dimen>
|
||||
|
||||
<!-- Homepage menu entry -->
|
||||
<dimen name="homepage_menu_entry_padding_horizontal">16dp</dimen>
|
||||
<dimen name="homepage_menu_entry_corner_radius">28dp</dimen>
|
||||
|
||||
<!-- Dimensions for Wifi Assistant Card -->
|
||||
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
|
||||
<dimen name="wifi_assistant_padding_start_end">16dp</dimen>
|
||||
|
@@ -20,7 +20,7 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="top_level_settings">
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.network.NetworkDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_wireless"
|
||||
android:key="top_level_network"
|
||||
@@ -30,7 +30,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_network"
|
||||
settings:controller="com.android.settings.network.TopLevelNetworkEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.connecteddevice.ConnectedDeviceDashboardFragment"
|
||||
android:icon="@drawable/ic_devices_other"
|
||||
android:key="top_level_connected_devices"
|
||||
@@ -40,7 +40,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_connected_devices"
|
||||
settings:controller="com.android.settings.connecteddevice.TopLevelConnectedDevicesPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.applications.AppDashboardFragment"
|
||||
android:icon="@drawable/ic_apps"
|
||||
android:key="top_level_apps"
|
||||
@@ -49,7 +49,7 @@
|
||||
android:summary="@string/app_and_notification_dashboard_summary"
|
||||
settings:highlightableMenuKey="@string/menu_key_apps"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.notification.ConfigureNotificationSettings"
|
||||
android:icon="@drawable/ic_notifications"
|
||||
android:key="top_level_notifications"
|
||||
@@ -58,7 +58,7 @@
|
||||
android:summary="@string/notification_dashboard_summary"
|
||||
settings:highlightableMenuKey="@string/menu_key_notifications"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
|
||||
android:icon="@drawable/ic_settings_battery_white"
|
||||
android:key="top_level_battery"
|
||||
@@ -68,7 +68,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_battery"
|
||||
settings:controller="com.android.settings.fuelgauge.TopLevelBatteryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.deviceinfo.StorageDashboardFragment"
|
||||
android:icon="@drawable/ic_storage_white"
|
||||
android:key="top_level_storage"
|
||||
@@ -78,7 +78,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_storage"
|
||||
settings:controller="com.android.settings.deviceinfo.TopLevelStoragePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.notification.SoundSettings"
|
||||
android:icon="@drawable/ic_volume_up_24dp"
|
||||
android:key="top_level_sound"
|
||||
@@ -87,7 +87,7 @@
|
||||
android:summary="@string/sound_dashboard_summary"
|
||||
settings:highlightableMenuKey="@string/menu_key_sound"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.DisplaySettings"
|
||||
android:icon="@drawable/ic_settings_display_white"
|
||||
android:key="top_level_display"
|
||||
@@ -97,7 +97,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_display"
|
||||
settings:controller="com.android.settings.display.TopLevelDisplayPreferenceController"/>
|
||||
|
||||
<com.android.settingslib.RestrictedTopLevelPreference
|
||||
<com.android.settings.widget.RestrictedHomepagePreference
|
||||
android:icon="@drawable/ic_settings_wallpaper_white"
|
||||
android:key="top_level_wallpaper"
|
||||
android:order="-70"
|
||||
@@ -106,7 +106,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_wallpaper"
|
||||
settings:controller="com.android.settings.display.TopLevelWallpaperPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.accessibility.AccessibilitySettings"
|
||||
android:icon="@drawable/ic_settings_accessibility"
|
||||
android:key="top_level_accessibility"
|
||||
@@ -116,7 +116,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_accessibility"
|
||||
settings:controller="com.android.settings.accessibility.TopLevelAccessibilityPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.security.SecuritySettings"
|
||||
android:icon="@drawable/ic_settings_security_white"
|
||||
android:key="top_level_security"
|
||||
@@ -126,7 +126,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_security"
|
||||
settings:controller="com.android.settings.security.TopLevelSecurityEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.privacy.PrivacyDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_privacy"
|
||||
android:key="top_level_privacy"
|
||||
@@ -135,7 +135,7 @@
|
||||
android:summary="@string/privacy_dashboard_summary"
|
||||
settings:highlightableMenuKey="@string/menu_key_privacy"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.location.LocationSettings"
|
||||
android:icon="@drawable/ic_settings_location"
|
||||
android:key="top_level_location"
|
||||
@@ -145,7 +145,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_location"
|
||||
settings:controller="com.android.settings.location.TopLevelLocationPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:key="top_level_emergency"
|
||||
android:title="@string/emergency_settings_preference_title"
|
||||
android:summary="@string/emergency_dashboard_summary"
|
||||
@@ -154,7 +154,7 @@
|
||||
android:fragment="com.android.settings.emergency.EmergencyDashboardFragment"
|
||||
settings:highlightableMenuKey="@string/menu_key_emergency"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.accounts.AccountDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_accounts"
|
||||
android:key="top_level_accounts"
|
||||
@@ -164,7 +164,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_accounts"
|
||||
settings:controller="com.android.settings.accounts.TopLevelAccountEntryPreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.system.SystemDashboardFragment"
|
||||
android:icon="@drawable/ic_settings_system_dashboard_white"
|
||||
android:key="top_level_system"
|
||||
@@ -173,7 +173,7 @@
|
||||
android:summary="@string/system_dashboard_summary"
|
||||
settings:highlightableMenuKey="@string/menu_key_system"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:fragment="com.android.settings.deviceinfo.aboutphone.MyDeviceInfoFragment"
|
||||
android:icon="@drawable/ic_phone_info"
|
||||
android:key="top_level_about_device"
|
||||
@@ -183,7 +183,7 @@
|
||||
settings:highlightableMenuKey="@string/menu_key_about_device"
|
||||
settings:controller="com.android.settings.deviceinfo.aboutphone.TopLevelAboutDevicePreferenceController"/>
|
||||
|
||||
<Preference
|
||||
<com.android.settings.widget.HomepagePreference
|
||||
android:icon="@drawable/ic_help"
|
||||
android:key="top_level_support"
|
||||
android:order="100"
|
||||
|
@@ -529,8 +529,7 @@ public abstract class DashboardFragment extends SettingsPreferenceFragment
|
||||
mBlockerController.countDown(controller.getPreferenceKey());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
Preference createPreference(Tile tile) {
|
||||
protected Preference createPreference(Tile tile) {
|
||||
return tile instanceof ProviderTile
|
||||
? new SwitchPreference(getPrefContext())
|
||||
: tile.hasSwitch()
|
||||
|
@@ -43,7 +43,9 @@ import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.support.SupportPreferenceController;
|
||||
import com.android.settings.widget.HighlightableTopLevelPreferenceAdapter;
|
||||
import com.android.settings.widget.HomepagePreference;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.drawer.Tile;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
@SearchIndexable(forTarget = MOBILE)
|
||||
@@ -247,6 +249,11 @@ public class TopLevelSettings extends DashboardFragment implements
|
||||
return mTopLevelAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Preference createPreference(Tile tile) {
|
||||
return new HomepagePreference(getPrefContext());
|
||||
}
|
||||
|
||||
void reloadHighlightMenuKey() {
|
||||
if (mTopLevelAdapter == null) {
|
||||
return;
|
||||
|
@@ -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();
|
||||
|
48
src/com/android/settings/widget/HomepagePreference.java
Normal file
48
src/com/android/settings/widget/HomepagePreference.java
Normal 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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user