Update locations where chevrons are shown (when enabled)
Bug: 186131786
Test: manual
Change-Id: I44bdef14d6ffba686ebefc2aed566a70890c974e
diff --git a/res/values-w1400dp/config.xml b/res/values-w1400dp/config.xml
index 3ab6c0f..d13c504 100644
--- a/res/values-w1400dp/config.xml
+++ b/res/values-w1400dp/config.xml
@@ -16,8 +16,7 @@
-->
<resources>
- <!-- Whether all activities should be single pane views or not. -->
<bool name="config_global_force_single_pane">false</bool>
- <!-- Fully qualified class name for the homepage fragment. -->
<string name="config_homepage_fragment_class" translatable="false">com.android.car.settings.bluetooth.BluetoothSettingsFragment</string>
+ <bool name="config_top_level_enable_chevrons">false</bool>
</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 441d50c..0a34a34 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -65,6 +65,10 @@
<attr name="searchable" format="boolean" />
</declare-styleable>
+ <declare-styleable name="PreferenceGroup">
+ <attr name="showChevron" format="boolean"/>
+ </declare-styleable>
+
<declare-styleable name="ProgressBarPreference">
<attr name="min" format="integer"/>
<attr name="max" format="integer"/>
diff --git a/res/values/config.xml b/res/values/config.xml
index 11a2a04..76d3620 100644
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -104,6 +104,11 @@
<item>@string/pk_bluetooth_paired_devices</item>
</string-array>
+ <!--
+ Whether to allow chevrons on top-level preferences when enabled for
+ car-ui-lib preferences.
+ -->
+ <bool name="config_top_level_enable_chevrons">true</bool>
<!-- The shape for top-level icons: 0=RECTANGLE, 1=OVAL -->
<integer name="config_top_level_icon_shape" translatable="false">1</integer>
<!--
diff --git a/res/values/overlayable.xml b/res/values/overlayable.xml
index 476e30a..b3bedbc 100644
--- a/res/values/overlayable.xml
+++ b/res/values/overlayable.xml
@@ -62,6 +62,7 @@
<item type="bool" name="config_show_settings_root_exit_icon"/>
<item type="bool" name="config_show_system_update_settings"/>
<item type="bool" name="config_show_wifi_mac_address"/>
+ <item type="bool" name="config_top_level_enable_chevrons"/>
<item type="bool" name="config_top_level_injection_background_always_use_default"/>
<item type="bool" name="config_top_level_injection_enable_summaries"/>
<item type="color" name="brightness_thumb_inner_ring_color"/>
diff --git a/res/xml/add_wifi_fragment.xml b/res/xml/add_wifi_fragment.xml
index b1e8ff7..ad35e91 100644
--- a/res/xml/add_wifi_fragment.xml
+++ b/res/xml/add_wifi_fragment.xml
@@ -20,11 +20,12 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/wifi_setup_add_network"
android:key="@string/psk_add_wifi">
- <EditTextPreference
+ <com.android.car.ui.preference.CarUiEditTextPreference
android:key="@string/pk_add_wifi_network_name"
android:persistent="false"
android:title="@string/wifi_ssid"
- settings:controller="com.android.car.settings.wifi.NetworkNamePreferenceController"/>
+ settings:controller="com.android.car.settings.wifi.NetworkNamePreferenceController"
+ settings:showChevron="false"/>
<ListPreference
android:dialogTitle="@string/wifi_security"
android:key="@string/pk_add_wifi_security"
@@ -37,5 +38,6 @@
android:persistent="false"
android:summary="@string/default_password_summary"
android:title="@string/wifi_password"
- settings:controller="com.android.car.settings.wifi.NetworkPasswordPreferenceController"/>
+ settings:controller="com.android.car.settings.wifi.NetworkPasswordPreferenceController"
+ settings:showChevron="false"/>
</PreferenceScreen>
diff --git a/res/xml/application_launch_settings_fragment.xml b/res/xml/application_launch_settings_fragment.xml
index 55d5de9..92816eb 100644
--- a/res/xml/application_launch_settings_fragment.xml
+++ b/res/xml/application_launch_settings_fragment.xml
@@ -20,20 +20,22 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/app_launch_title"
android:key="@string/psk_application_launch_settings">
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_opening_links_app_details"
- settings:controller="com.android.car.settings.applications.managedomainurls.ApplicationWithVersionPreferenceController"/>
+ settings:controller="com.android.car.settings.applications.managedomainurls.ApplicationWithVersionPreferenceController"
+ settings:showChevron="false"/>
<PreferenceCategory android:title="@string/app_launch_domain_links_title">
<ListPreference
android:key="@string/pk_opening_links_app_details_state"
android:title="@string/app_launch_open_domain_urls_title"
android:summary="%s"
settings:controller="com.android.car.settings.applications.managedomainurls.AppLinkStatePreferenceController"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_opening_links_app_details_urls"
android:title="@string/app_launch_supported_domain_urls_title"
android:dependency="@string/pk_opening_links_app_details_state"
- settings:controller="com.android.car.settings.applications.managedomainurls.DomainUrlsPreferenceController"/>
+ settings:controller="com.android.car.settings.applications.managedomainurls.DomainUrlsPreferenceController"
+ settings:showChevron="false"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/app_launch_other_defaults_title">
<Preference
diff --git a/res/xml/bluetooth_pairing_selection_fragment.xml b/res/xml/bluetooth_pairing_selection_fragment.xml
index 56e02ed..917fe1d 100644
--- a/res/xml/bluetooth_pairing_selection_fragment.xml
+++ b/res/xml/bluetooth_pairing_selection_fragment.xml
@@ -20,17 +20,20 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/bluetooth_pair_new_device"
android:key="@string/psk_bluetooth_pairing_selection">
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_bluetooth_name"
android:title="@string/bluetooth_name"
- settings:controller="com.android.car.settings.bluetooth.BluetoothNamePreferenceController"/>
- <PreferenceCategory
+ settings:controller="com.android.car.settings.bluetooth.BluetoothNamePreferenceController"
+ settings:showChevron="false"/>
+ <com.android.car.settings.common.SettingsPreferenceCategory
android:key="@string/pk_bluetooth_available_devices"
android:title="@string/bluetooth_available_devices"
- settings:controller="com.android.car.settings.bluetooth.BluetoothUnbondedDevicesPreferenceController"/>
- <Preference
+ settings:controller="com.android.car.settings.bluetooth.BluetoothUnbondedDevicesPreferenceController"
+ settings:showChevron="false"/>
+ <com.android.car.ui.preference.CarUiPreference
android:icon="@drawable/ic_settings_about"
android:key="@string/pk_bluetooth_address"
android:selectable="false"
- settings:controller="com.android.car.settings.bluetooth.BluetoothAddressPreferenceController"/>
+ settings:controller="com.android.car.settings.bluetooth.BluetoothAddressPreferenceController"
+ settings:showChevron="false"/>
</PreferenceScreen>
diff --git a/res/xml/bluetooth_settings_fragment.xml b/res/xml/bluetooth_settings_fragment.xml
index b586d69..578ab7c 100644
--- a/res/xml/bluetooth_settings_fragment.xml
+++ b/res/xml/bluetooth_settings_fragment.xml
@@ -30,10 +30,11 @@
android:key="@string/pk_bluetooth_paired_devices"
android:title="@string/bluetooth_paired_devices"
settings:controller="com.android.car.settings.bluetooth.BluetoothBondedDevicesPreferenceController"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:fragment="com.android.car.settings.bluetooth.BluetoothPairingSelectionFragment"
android:icon="@drawable/ic_add"
android:key="@string/pk_bluetooth_pair_new_device"
android:title="@string/bluetooth_pair_new_device"
- settings:controller="com.android.car.settings.bluetooth.PairNewDevicePreferenceController"/>
+ settings:controller="com.android.car.settings.bluetooth.PairNewDevicePreferenceController"
+ settings:showChevron="false"/>
</PreferenceScreen>
diff --git a/res/xml/security_settings_fragment.xml b/res/xml/security_settings_fragment.xml
index f5b3bc4..b2c158b 100644
--- a/res/xml/security_settings_fragment.xml
+++ b/res/xml/security_settings_fragment.xml
@@ -25,15 +25,16 @@
android:key="@string/pk_choose_lock_type"
android:title="@string/lock_settings_picker_title"
settings:controller="com.android.car.settings.security.ChooseLockTypePreferenceController"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_credentials_reset"
android:summary="@string/credentials_reset_summary"
android:title="@string/credentials_reset"
- settings:controller="com.android.car.settings.security.CredentialsResetPreferenceController">
+ settings:controller="com.android.car.settings.security.CredentialsResetPreferenceController"
+ settings:showChevron="false">
<intent
android:action="com.android.credentials.RESET"
android:targetPackage="com.android.car.settings"/>
- </Preference>
+ </com.android.car.ui.preference.CarUiPreference>
<com.android.car.settings.common.LogicalPreferenceGroup
android:key="@string/pk_system_extra_settings"
settings:controller="com.android.car.settings.common.ExtraSettingsPreferenceController">
diff --git a/res/xml/user_details_fragment.xml b/res/xml/user_details_fragment.xml
index 3bb65b9..160dab5 100644
--- a/res/xml/user_details_fragment.xml
+++ b/res/xml/user_details_fragment.xml
@@ -34,11 +34,12 @@
android:title="@string/account_list_title"
settings:controller="com.android.car.settings.accounts.AccountListPreferenceController"
settings:searchable="false"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_account_settings_add"
android:title="@string/user_add_account_menu"
android:icon="@drawable/ic_add"
- settings:controller="com.android.car.settings.accounts.AddAccountPreferenceController"/>
+ settings:controller="com.android.car.settings.accounts.AddAccountPreferenceController"
+ settings:showChevron="false"/>
<com.android.car.settings.common.DividerPreference/>
<SwitchPreference
android:key="@string/pk_account_auto_sync"
@@ -55,8 +56,9 @@
</intent>
</com.android.car.settings.common.LogicalPreferenceGroup>
</com.android.car.settings.common.LogicalPreferenceGroup>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_profile_details_delete"
android:title="@string/delete_this_profile_text"
- settings:controller="com.android.car.settings.users.ProfileDetailsDeletePreferenceController"/>
+ settings:controller="com.android.car.settings.users.ProfileDetailsDeletePreferenceController"
+ settings:showChevron="false"/>
</PreferenceScreen>
diff --git a/res/xml/users_list_fragment.xml b/res/xml/users_list_fragment.xml
index 4dbd0ec..b8fb9c5 100644
--- a/res/xml/users_list_fragment.xml
+++ b/res/xml/users_list_fragment.xml
@@ -23,7 +23,8 @@
<com.android.car.settings.common.LogicalPreferenceGroup
android:key="@string/pk_users_list"
settings:controller="com.android.car.settings.users.UsersListPreferenceController"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_add_user"
- settings:controller="com.android.car.settings.users.AddUserPreferenceController"/>
+ settings:controller="com.android.car.settings.users.AddUserPreferenceController"
+ settings:showChevron="false"/>
</PreferenceScreen>
diff --git a/res/xml/wifi_detail_fragment.xml b/res/xml/wifi_detail_fragment.xml
index bfab9cb..465773b 100644
--- a/res/xml/wifi_detail_fragment.xml
+++ b/res/xml/wifi_detail_fragment.xml
@@ -86,7 +86,7 @@
<PreferenceCategory
android:selectable="false"
android:title="@string/wifi_details_ipv6_address_header">
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:key="@string/pk_wifi_ipv6"
android:selectable="false"
settings:controller="com.android.car.settings.wifi.details.WifiIpv6AddressPreferenceController"
diff --git a/res/xml/wifi_list_fragment.xml b/res/xml/wifi_list_fragment.xml
index 45abaa4..e1be990 100644
--- a/res/xml/wifi_list_fragment.xml
+++ b/res/xml/wifi_list_fragment.xml
@@ -32,10 +32,11 @@
<com.android.car.settings.common.LogicalPreferenceGroup
android:key="@string/pk_wifi_list"
settings:controller="com.android.car.settings.wifi.WifiEntryListPreferenceController"/>
- <Preference
+ <com.android.car.ui.preference.CarUiPreference
android:fragment="com.android.car.settings.wifi.AddWifiFragment"
android:icon="@drawable/ic_add"
android:key="@string/pk_add_wifi"
android:title="@string/wifi_setup_add_network"
- settings:controller="com.android.car.settings.wifi.AddWifiPreferenceController"/>
+ settings:controller="com.android.car.settings.wifi.AddWifiPreferenceController"
+ settings:showChevron="false"/>
</PreferenceScreen>
diff --git a/res/xml/wifi_tether_fragment.xml b/res/xml/wifi_tether_fragment.xml
index feaf891..98e8721 100644
--- a/res/xml/wifi_tether_fragment.xml
+++ b/res/xml/wifi_tether_fragment.xml
@@ -27,7 +27,8 @@
<com.android.car.settings.common.ValidatedEditTextPreference
android:key="@string/pk_wifi_tether_name"
android:title="@string/wifi_hotspot_name_title"
- settings:controller="com.android.car.settings.wifi.WifiTetherNamePreferenceController"/>
+ settings:controller="com.android.car.settings.wifi.WifiTetherNamePreferenceController"
+ settings:showChevron="false"/>
<ListPreference
android:key="@string/pk_wifi_tether_security"
android:title="@string/wifi_hotspot_security_title"
@@ -38,7 +39,8 @@
android:key="@string/pk_wifi_tether_password"
android:title="@string/wifi_hotspot_password_title"
android:persistent="false"
- settings:controller="com.android.car.settings.wifi.WifiTetherPasswordPreferenceController"/>
+ settings:controller="com.android.car.settings.wifi.WifiTetherPasswordPreferenceController"
+ settings:showChevron="false"/>
<SwitchPreference
android:key="@string/pk_wifi_tether_auto_off"
android:title="@string/wifi_hotspot_auto_off_title"
diff --git a/src/com/android/car/settings/common/LogicalPreferenceGroup.java b/src/com/android/car/settings/common/LogicalPreferenceGroup.java
index 6c5e63c..0570647 100644
--- a/src/com/android/car/settings/common/LogicalPreferenceGroup.java
+++ b/src/com/android/car/settings/common/LogicalPreferenceGroup.java
@@ -17,11 +17,15 @@
package com.android.car.settings.common;
import android.content.Context;
+import android.content.res.TypedArray;
import android.util.AttributeSet;
+import androidx.preference.Preference;
import androidx.preference.PreferenceGroup;
-import com.android.car.settings.R;
+import com.android.car.ui.R;
+import com.android.car.ui.preference.CarUiEditTextPreference;
+import com.android.car.ui.preference.CarUiPreference;
/**
* {@link PreferenceGroup} which does not display a title, icon, or summary. This allows for
@@ -29,10 +33,20 @@
*/
public class LogicalPreferenceGroup extends PreferenceGroup {
+ private final boolean mShouldShowChevron;
+
public LogicalPreferenceGroup(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setLayoutResource(R.layout.logical_preference_group);
+ TypedArray a = context.obtainStyledAttributes(
+ attrs,
+ R.styleable.PreferenceGroup,
+ defStyleAttr,
+ defStyleRes);
+
+ mShouldShowChevron = a.getBoolean(R.styleable.PreferenceGroup_showChevron, true);
+ a.recycle();
}
public LogicalPreferenceGroup(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -46,4 +60,13 @@
public LogicalPreferenceGroup(Context context) {
this(context, null);
}
+
+ @Override
+ public boolean addPreference(Preference preference) {
+ if (!mShouldShowChevron && (preference instanceof CarUiPreference
+ || preference instanceof CarUiEditTextPreference)) {
+ ((CarUiPreference) preference).setShowChevron(false);
+ }
+ return super.addPreference(preference);
+ }
}
diff --git a/src/com/android/car/settings/common/PreferenceXmlParser.java b/src/com/android/car/settings/common/PreferenceXmlParser.java
index 0deeeea..9312508 100644
--- a/src/com/android/car/settings/common/PreferenceXmlParser.java
+++ b/src/com/android/car/settings/common/PreferenceXmlParser.java
@@ -49,6 +49,7 @@
private static final String PREF_TAG_ENDS_WITH = "Preference";
private static final String PREF_GROUP_TAG_ENDS_WITH = "PreferenceGroup";
+ private static final String PREF_CATEGORY_TAG_ENDS_WITH = "PreferenceCategory";
private static final List<String> SUPPORTED_PREF_TYPES = Arrays.asList("Preference",
"PreferenceCategory", "PreferenceScreen");
@@ -102,7 +103,8 @@
}
final String nodeName = parser.getName();
if (!SUPPORTED_PREF_TYPES.contains(nodeName) && !nodeName.endsWith(PREF_TAG_ENDS_WITH)
- && !nodeName.endsWith(PREF_GROUP_TAG_ENDS_WITH)) {
+ && !nodeName.endsWith(PREF_GROUP_TAG_ENDS_WITH)
+ && !nodeName.endsWith(PREF_CATEGORY_TAG_ENDS_WITH)) {
continue;
}
final Bundle preferenceMetadata = new Bundle();
diff --git a/src/com/android/car/settings/common/SettingsPreferenceCategory.java b/src/com/android/car/settings/common/SettingsPreferenceCategory.java
new file mode 100644
index 0000000..99dd02c
--- /dev/null
+++ b/src/com/android/car/settings/common/SettingsPreferenceCategory.java
@@ -0,0 +1,74 @@
+/*
+ * 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.car.settings.common;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+
+import androidx.core.content.res.TypedArrayUtils;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
+
+import com.android.car.ui.R;
+import com.android.car.ui.preference.CarUiEditTextPreference;
+import com.android.car.ui.preference.CarUiPreference;
+
+/**
+ * {@link PreferenceCategory} which allows for CarUiPreference chevrons to be hidden for the entire
+ * category with {@link R.styleable.PreferenceGroup_showChevron}
+ */
+public class SettingsPreferenceCategory extends PreferenceCategory {
+
+ private final boolean mShouldShowChevron;
+
+ public SettingsPreferenceCategory(Context context, AttributeSet attrs,
+ int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+
+ TypedArray a = context.obtainStyledAttributes(
+ attrs,
+ R.styleable.PreferenceGroup,
+ defStyleAttr,
+ defStyleRes);
+
+ mShouldShowChevron = a.getBoolean(R.styleable.PreferenceGroup_showChevron, true);
+ a.recycle();
+ }
+
+ public SettingsPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0);
+ }
+
+ public SettingsPreferenceCategory(Context context, AttributeSet attrs) {
+ this(context, attrs, TypedArrayUtils.getAttr(context, R.attr.preferenceCategoryStyle,
+ android.R.attr.preferenceCategoryStyle));
+ }
+
+ public SettingsPreferenceCategory(Context context) {
+ this(context, null);
+ }
+
+ @Override
+ public boolean addPreference(Preference preference) {
+ if (!mShouldShowChevron && (preference instanceof CarUiPreference
+ || preference instanceof CarUiEditTextPreference)) {
+ ((CarUiPreference) preference).setShowChevron(false);
+ }
+ return super.addPreference(preference);
+ }
+}
diff --git a/src/com/android/car/settings/common/TopLevelPreference.java b/src/com/android/car/settings/common/TopLevelPreference.java
index 106335c..0c621d7 100644
--- a/src/com/android/car/settings/common/TopLevelPreference.java
+++ b/src/com/android/car/settings/common/TopLevelPreference.java
@@ -29,25 +29,26 @@
public TopLevelPreference(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- init();
+ init(context);
}
public TopLevelPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- init();
+ init(context);
}
public TopLevelPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- init();
+ init(context);
}
public TopLevelPreference(Context context) {
super(context);
- init();
+ init(context);
}
- private void init() {
+ private void init(Context context) {
setLayoutResource(R.layout.top_level_preference);
+ setShowChevron(context.getResources().getBoolean(R.bool.config_top_level_enable_chevrons));
}
}