Snap for 5151423 from 926571dc29 to qt-release
Change-Id: I764d329cc0fa612a27c584a2bad24a636f039a9b
This commit is contained in:
@@ -2959,6 +2959,17 @@
|
||||
android:value="true" />
|
||||
</activity>
|
||||
|
||||
<activity android:name=".panel.SettingsPanelActivity"
|
||||
android:label="@string/settings_panel_title"
|
||||
android:theme="@style/Theme.BottomDialog"
|
||||
android:excludeFromRecents="true"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.settings.SETTINGSPANEL" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider android:name=".slices.SettingsSliceProvider"
|
||||
android:authorities="com.android.settings.slices;android.settings.slices"
|
||||
android:exported="true"
|
||||
|
||||
@@ -1177,7 +1177,7 @@
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" <color name="homepage_accessibility_background">#5011C1</color>"
|
||||
errorLine1=" <color name="homepage_accessibility_background">#783BE5</color>"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
@@ -1209,7 +1209,7 @@
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" <color name="homepage_support_background">#26459C</color>"
|
||||
errorLine1=" <color name="homepage_support_background">#3F5FBD</color>"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/colors.xml"
|
||||
|
||||
22
res/drawable/settings_panel_background.xml
Normal file
22
res/drawable/settings_panel_background.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2018 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" android:inset="4dp">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="?android:attr/colorBackground" />
|
||||
</shape>
|
||||
</inset>
|
||||
@@ -30,8 +30,6 @@
|
||||
android:id="@+id/slice_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/homepage_card_vertical_margin"
|
||||
android:layout_marginTop="@dimen/homepage_card_vertical_margin"
|
||||
android:paddingStart="@dimen/homepage_card_padding_start"
|
||||
android:paddingEnd="@dimen/homepage_card_padding_end"/>
|
||||
|
||||
|
||||
26
res/layout/panel_layout.xml
Normal file
26
res/layout/panel_layout.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 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"
|
||||
android:id="@+id/panel_parent_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:layout_margin="4dp"
|
||||
android:orientation="vertical">
|
||||
</LinearLayout>
|
||||
@@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 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.
|
||||
-->
|
||||
|
||||
<!-- Entity header -->
|
||||
<RelativeLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/entity_header"
|
||||
style="@style/EntityHeader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/entity_header_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/entity_header_icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:scaleType="fitXY"
|
||||
android:antialias="true"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/entity_header_title"
|
||||
style="@style/TextAppearance.EntityHeaderTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="false"
|
||||
android:ellipsize="marquee"
|
||||
android:textDirection="locale"
|
||||
android:layout_marginTop="8dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/install_type"
|
||||
style="@style/TextAppearance.EntityHeaderSummary"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/entity_header_summary"
|
||||
style="@style/TextAppearance.EntityHeaderSummary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/entity_header_second_summary"
|
||||
style="@style/TextAppearance.EntityHeaderSummary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/entity_header_links"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageButton
|
||||
android:id="@android:id/button1"
|
||||
style="?android:attr/actionOverflowButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="0dp"
|
||||
android:minWidth="@dimen/min_tap_target_size"
|
||||
android:src="@null"
|
||||
android:tint="?android:attr/colorAccent" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@android:id/button2"
|
||||
style="?android:attr/actionOverflowButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="0dp"
|
||||
android:minWidth="@dimen/min_tap_target_size"
|
||||
android:src="@null"
|
||||
android:tint="?android:attr/colorAccent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -42,7 +42,9 @@
|
||||
<FrameLayout
|
||||
android:id="@+id/contextual_cards_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/homepage_card_side_margin"
|
||||
android:layout_marginEnd="@dimen/homepage_card_side_margin"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/main_content"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2018 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.
|
||||
@@ -14,5 +14,6 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:id="@+id/main_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"/>
|
||||
@@ -121,9 +121,9 @@
|
||||
<color name="homepage_storage_background">#C14CE6</color>
|
||||
<color name="homepage_security_background">#0F9D58</color>
|
||||
<color name="homepage_accounts_background">#F15B8D</color>
|
||||
<color name="homepage_accessibility_background">#5011C1</color>
|
||||
<color name="homepage_accessibility_background">#783BE5</color>
|
||||
<color name="homepage_system_background">#9E9E9E</color>
|
||||
<color name="homepage_support_background">#26459C</color>
|
||||
<color name="homepage_support_background">#3F5FBD</color>
|
||||
<color name="homepage_generic_icon_background">#1A73E8</color>
|
||||
<color name="homepage_location_background">#2EC7DC</color>
|
||||
<color name="homepage_about_background">#9FA8DA</color>
|
||||
|
||||
@@ -150,4 +150,14 @@
|
||||
<string name="config_settingsintelligence_package_name" translatable="false">
|
||||
com.android.settings.intelligence
|
||||
</string>
|
||||
|
||||
<!-- Emergency app package name -->
|
||||
<string name="config_emergency_package_name" translatable="false">
|
||||
com.android.emergency
|
||||
</string>
|
||||
<!-- Emergency app intent action -->
|
||||
<string name="config_emergency_intent_action" translatable="false">
|
||||
android.settings.EDIT_EMERGENCY_INFO
|
||||
</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -329,8 +329,8 @@
|
||||
<dimen name="homepage_card_icon_size">24dp</dimen>
|
||||
<dimen name="homepage_card_corner_radius">8dp</dimen>
|
||||
<dimen name="homepage_card_elevation">2dp</dimen>
|
||||
<dimen name="homepage_card_vertical_margin">4dp</dimen>
|
||||
<dimen name="homepage_card_side_margin">8dp</dimen>
|
||||
<dimen name="homepage_card_vertical_margin">8dp</dimen>
|
||||
<dimen name="homepage_card_side_margin">4dp</dimen>
|
||||
<dimen name="homepage_card_padding_start">16dp</dimen>
|
||||
<dimen name="homepage_card_padding_end">16dp</dimen>
|
||||
|
||||
|
||||
@@ -4131,7 +4131,6 @@
|
||||
<!-- Manage applications, text for move error messages -->
|
||||
<string name="insufficient_storage">Not enough storage space.</string>
|
||||
<string name="does_not_exist">App doesn\u2019t exist.</string>
|
||||
<string name="app_forward_locked">App is copy-protected.</string>
|
||||
<string name="invalid_location">Install location isn\u2019t valid.</string>
|
||||
<string name="system_package">System updates can\u2019t be installed on external media.</string>
|
||||
<!-- Error message shown when trying to move device administrators to external disks, such as SD card [CHAR_LIMIT=none] -->
|
||||
@@ -4578,22 +4577,24 @@
|
||||
<!-- Summary for the accessibility preference for master mono. [CHAR LIMIT=50] -->
|
||||
<string name="accessibility_toggle_master_mono_summary">Combine channels when playing audio</string>
|
||||
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<!-- Option heading to leave the timeout requirement for accessibility users at its default level. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_timeout_default">Default</string>
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<!-- Option heading to leave the timeout requirement for accessibility users at 10 secs. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_timeout_10secs">10 seconds</string>
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<!-- Option heading to leave the timeout requirement for accessibility users at 30 secs. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_timeout_30secs">30 seconds</string>
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<!-- Option heading to leave the timeout requirement for accessibility users at 1 min. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_timeout_1min">1 minute</string>
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<!-- Option heading to leave the timeout requirement for accessibility users at 2 mins. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_timeout_2mins">2 minutes</string>
|
||||
<!-- Title for accessibility preference to accessibility message_timeout. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_accessibility_content_timeout_preference_title">Content Timeout</string>
|
||||
<!-- Title for accessibility preference to accessibility message_timeout. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_accessibility_control_timeout_preference_title">Control Timeout</string>
|
||||
<!-- Title for accessibility preference to accessibility message_timeout. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_accessibility_timeout_preference_summary">Choose how long it takes before automatically disappearing messages go away.\nSome apps may not support this setting yet.</string>
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_content_timeout_preference_title">Time to read</string>
|
||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
||||
<!-- Descriptive text for accessibility preference to accessibility content timeout. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_content_timeout_preference_summary">Choose how much time you want to read and take action on messages that automatically go away.\n\nSupport for this setting is up to each app.</string>
|
||||
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_control_timeout_preference_summary">Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting.</string>
|
||||
|
||||
<!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
|
||||
<string name="accessibility_long_press_timeout_preference_title">Touch & hold delay</string>
|
||||
@@ -10297,8 +10298,8 @@
|
||||
<!-- Available networks screen, summary when button disallowed due to permanent automatic mode [CHAR LIMIT=NONE] -->
|
||||
<string name="manual_mode_disallowed_summary">Unavailable when connected to <xliff:g id="carrier" example="verizon">%1$s</xliff:g></string>
|
||||
|
||||
<!-- Used for EmergencyInfoSlice slice helper class -->
|
||||
<string name="emergency_info_contextual_card_summary" translatable="false">Medical info, emergency contacts</string>
|
||||
<!-- Used for EmergencyInfoSlice slice helper class [CHAR LIMIT=NONE]-->
|
||||
<string name="emergency_info_contextual_card_summary">Medical info, emergency contacts</string>
|
||||
|
||||
<!-- See more items in contextual homepage [CHAR LIMIT=30]-->
|
||||
<string name="see_more">See more</string>
|
||||
@@ -10320,6 +10321,12 @@
|
||||
<!-- Title for no connected devices in connected device slice. [CHAR LIMIT=NONE] -->
|
||||
<string name="no_connected_devices">No connected devices</string>
|
||||
|
||||
<!-- Default title for the settings panel [CHAR LIMIT=NONE] -->
|
||||
<string name="settings_panel_title">Settings Panel</string>
|
||||
|
||||
<!-- Title for the Internet Connectivity dialog (settings panel) with Internet related settings [CHAR LIMIT=50] -->
|
||||
<string name="internet_connectivity_panel_title">Internet Connectivity</string>
|
||||
|
||||
<!-- UI debug setting: force desktop mode [CHAR LIMIT=50] -->
|
||||
<string name="force_desktop_mode">Force desktop mode</string>
|
||||
<!-- UI debug setting: force desktop mode summary [CHAR LIMIT=NONE] -->
|
||||
|
||||
@@ -331,23 +331,6 @@
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.EntityHeaderTitle"
|
||||
parent="@android:style/TextAppearance.Material.Subhead">
|
||||
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
<item name="android:textSize">20sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.EntityHeaderSummary"
|
||||
parent="@android:style/TextAppearance.Material.Body1">
|
||||
<item name="android:textAlignment">viewStart</item>
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
<item name="android:gravity">start</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">marquee</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.ZenOnboardingButton">
|
||||
<item name="android:fontFamily">sans-serif-medium</item>
|
||||
<item name="android:textSize">14sp</item>
|
||||
@@ -418,13 +401,6 @@
|
||||
<item name="android:progressDrawable">@drawable/ring_progress</item>
|
||||
</style>
|
||||
|
||||
<style name="EntityHeader">
|
||||
<item name="android:background">?android:attr/colorPrimaryDark</item>
|
||||
<item name="android:paddingTop">24dp</item>
|
||||
<item name="android:paddingBottom">16dp</item>
|
||||
<item name="android:paddingEnd">16dp</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
|
||||
|
||||
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
|
||||
@@ -482,7 +458,6 @@
|
||||
</style>
|
||||
|
||||
<style name="ContextualCardStyle">
|
||||
<item name="android:layout_marginTop">@dimen/homepage_card_vertical_margin</item>
|
||||
<item name="android:layout_marginBottom">@dimen/homepage_card_vertical_margin</item>
|
||||
<item name="android:layout_marginStart">@dimen/homepage_card_side_margin</item>
|
||||
<item name="android:layout_marginEnd">@dimen/homepage_card_side_margin</item>
|
||||
|
||||
@@ -200,4 +200,8 @@
|
||||
<item name="cardBackgroundColor">?android:attr/colorBackground</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.BottomDialog" parent="@*android:style/Theme.DeviceDefault.Settings.Dialog">
|
||||
<item name="android:windowBackground">@drawable/settings_panel_background</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="accessibility_content_timeout_preference"
|
||||
android:title="@string/accessibility_accessibility_content_timeout_preference_title"
|
||||
android:title="@string/accessibility_content_timeout_preference_title"
|
||||
android:persistent="false" >
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
@@ -32,7 +32,7 @@
|
||||
android:key="accessibility_content_timeout_summary"
|
||||
android:selectable="false"
|
||||
android:enabled="true"
|
||||
android:summary="@string/accessibility_accessibility_timeout_preference_summary"
|
||||
android:summary="@string/accessibility_content_timeout_preference_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="accessibility_control_timeout_preference"
|
||||
android:title="@string/accessibility_accessibility_control_timeout_preference_title"
|
||||
android:title="@string/accessibility_control_timeout_preference_title"
|
||||
android:persistent="false" >
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
@@ -32,7 +32,7 @@
|
||||
android:key="accessibility_control_timeout_summary"
|
||||
android:selectable="false"
|
||||
android:enabled="true"
|
||||
android:summary="@string/accessibility_accessibility_timeout_preference_summary"
|
||||
android:summary="@string/accessibility_control_timeout_preference_summary"
|
||||
android:persistent="false" />
|
||||
|
||||
<com.android.settings.widget.RadioButtonPreference
|
||||
|
||||
@@ -75,8 +75,7 @@
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.AccessibilityContentTimeoutPreferenceFragment"
|
||||
android:key="accessibility_content_timeout_preference_fragment"
|
||||
android:title="@string/accessibility_accessibility_content_timeout_preference_title"
|
||||
android:icon="@drawable/ic_accessibility_generic"
|
||||
android:title="@string/accessibility_content_timeout_preference_title"
|
||||
android:persistent="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
@@ -111,8 +110,7 @@
|
||||
<Preference
|
||||
android:fragment="com.android.settings.accessibility.AccessibilityControlTimeoutPreferenceFragment"
|
||||
android:key="accessibility_control_timeout_preference_fragment"
|
||||
android:title="@string/accessibility_accessibility_control_timeout_preference_title"
|
||||
android:icon="@drawable/ic_accessibility_generic"
|
||||
android:title="@string/accessibility_control_timeout_preference_title"
|
||||
android:persistent="false" />
|
||||
|
||||
<Preference
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
android:title="@string/account_settings_title"
|
||||
settings:keywords="@string/keywords_accounts">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="account_header"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
@@ -35,7 +35,7 @@
|
||||
android:icon="@drawable/ic_sync"
|
||||
android:order="200"/>
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="remove_account"
|
||||
android:layout="@layout/remove_account_button"
|
||||
android:order="1000"
|
||||
|
||||
@@ -21,14 +21,14 @@
|
||||
android:key="installed_app_detail_settings_screen"
|
||||
settings:initialExpandedChildrenCount="6">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="header_view"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
android:order="-10000"
|
||||
settings:allowDividerBelow="true"/>
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="instant_app_buttons"
|
||||
android:layout="@layout/instant_app_buttons"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="app_notifications">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="pref_app_header"
|
||||
android:layout="@layout/settings_entity_header" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="block"
|
||||
android:layout="@layout/styled_switch_bar" />
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
android:selectable="false"
|
||||
android:layout="@layout/horizontal_preference" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="change_storage_button"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/single_button_panel" />
|
||||
@@ -78,7 +78,7 @@
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
settings:allowDividerAbove="false"
|
||||
settings:allowDividerBelow="false">
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="clear_uri_button"
|
||||
android:layout="@layout/single_button_panel"
|
||||
android:selectable="false" />
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/device_details_title">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="bluetooth_device_header"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
android:key="channel_settings"
|
||||
android:title="@string/notification_channel_title" >
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="pref_app_header"
|
||||
android:order="1"
|
||||
android:layout="@layout/settings_entity_header" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="block"
|
||||
android:order="2"
|
||||
android:layout="@layout/styled_switch_bar" />
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<!-- Layout preference doesn't obey allowDividerAbove, so put it in a PreferenceCategory -->
|
||||
<PreferenceCategory
|
||||
android:key="dream_start_now_category">
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="dream_start_now_button_container"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/dream_start_button" />
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:key="my_device_info_pref_screen"
|
||||
android:title="@string/about_settings">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="my_device_info_header"
|
||||
android:order="0"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
settings:useAdminDisabledSummary="true" />
|
||||
|
||||
<com.android.settingslib.RestrictedSwitchPreference
|
||||
android:key="toggle_airplane"
|
||||
android:key="airplane_mode"
|
||||
android:title="@string/airplane_mode"
|
||||
android:icon="@drawable/ic_airplanemode_active"
|
||||
android:disableDependentsState="true"
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
settings:keywords="@string/keywords_display_night_display"
|
||||
settings:controller="com.android.settings.display.NightDisplayIntensityPreferenceController" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="night_display_activated"
|
||||
android:title="@string/night_display_title"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="pref_app_header"
|
||||
android:layout="@layout/settings_entity_header" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="block"
|
||||
android:layout="@layout/styled_switch_bar" />
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="header_view"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="two_buttons"
|
||||
android:layout="@layout/two_buttons_panel"
|
||||
android:selectable="false" />
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
android:title="@string/power_usage_summary_title"
|
||||
settings:keywords="@string/keywords_battery">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="battery_header"
|
||||
android:title="@string/summary_placeholder"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
android:key="privacy_dashboard_page"
|
||||
android:title="@string/privacy_dashboard_title">
|
||||
|
||||
<!-- App permissions -->
|
||||
<Preference
|
||||
android:key="privacy_manage_perms"
|
||||
android:title="@string/app_permissions"
|
||||
@@ -29,6 +30,14 @@
|
||||
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
|
||||
</Preference>
|
||||
|
||||
<!-- On lock screen notifications -->
|
||||
<com.android.settings.RestrictedListPreference
|
||||
android:key="privacy_lock_screen_notifications"
|
||||
android:title="@string/lock_screen_notifications_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
settings:searchable="false"/>
|
||||
|
||||
<!-- Show passwords -->
|
||||
<SwitchPreference
|
||||
android:key="show_password"
|
||||
android:title="@string/show_password"
|
||||
@@ -42,4 +51,20 @@
|
||||
<PreferenceCategory
|
||||
android:key="dashboard_tile_placeholder"/>
|
||||
|
||||
<!-- Work profile settings are at the bottom with high order value to avoid users thinking that
|
||||
any of the above settings (including dynamic) are specific to the work profile. -->
|
||||
<PreferenceCategory
|
||||
android:key="privacy_work_profile_notifications_category"
|
||||
android:title="@string/profile_section_header"
|
||||
android:order="998"
|
||||
settings:searchable="false">
|
||||
|
||||
<com.android.settings.RestrictedListPreference
|
||||
android:key="privacy_lock_screen_work_profile_notifications"
|
||||
android:title="@string/locked_work_profile_notification_title"
|
||||
android:summary="@string/summary_placeholder"
|
||||
android:order="999"
|
||||
settings:searchable="false"/>
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -55,7 +55,7 @@
|
||||
android:title="@string/security_settings_face_settings_improve_face">
|
||||
</Preference>
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="security_settings_face_delete_faces_container"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/face_remove_button" />
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
android:title="@string/usb_preference"
|
||||
android:key="usb_details_fragment">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="usb_device_header"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"/>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
settings:initialExpandedChildrenCount="5">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="connection_header"
|
||||
android:layout="@layout/settings_entity_header"
|
||||
android:selectable="false"
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
android:key="zen_mode_event_rule_settings"
|
||||
android:title="@string/zen_mode_automatic_rule_settings_page_title">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="pref_app_header"
|
||||
android:layout="@layout/settings_entity_header" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="zen_automatic_rule_switch"
|
||||
android:layout="@layout/styled_switch_bar" />
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
android:key="zen_mode_schedule_rule_settings"
|
||||
android:title="@string/zen_mode_automatic_rule_settings_page_title">
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="pref_app_header"
|
||||
android:layout="@layout/settings_entity_header" />
|
||||
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="zen_automatic_rule_switch"
|
||||
android:layout="@layout/styled_switch_bar" />
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
android:fragment="com.android.settings.notification.ZenModeAutomationSettings"/>
|
||||
|
||||
<!-- Turn on DND button -->
|
||||
<com.android.settings.applications.LayoutPreference
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="zen_mode_settings_button_container"
|
||||
android:selectable="false"
|
||||
android:layout="@layout/zen_mode_settings_button"
|
||||
|
||||
@@ -133,15 +133,10 @@ public class SettingsActivity extends SettingsBaseActivity
|
||||
":settings:show_fragment_title_res_package_name";
|
||||
public static final String EXTRA_SHOW_FRAGMENT_TITLE_RESID =
|
||||
":settings:show_fragment_title_resid";
|
||||
public static final String EXTRA_SHOW_FRAGMENT_AS_SHORTCUT =
|
||||
":settings:show_fragment_as_shortcut";
|
||||
|
||||
public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING =
|
||||
":settings:show_fragment_as_subsetting";
|
||||
|
||||
@Deprecated
|
||||
public static final String EXTRA_HIDE_DRAWER = ":settings:hide_drawer";
|
||||
|
||||
public static final String META_DATA_KEY_FRAGMENT_CLASS =
|
||||
"com.android.settings.FRAGMENT_CLASS";
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settings.search.Indexable;
|
||||
@@ -55,6 +54,7 @@ import com.android.settingslib.CustomDialogPreferenceCompat;
|
||||
import com.android.settingslib.CustomEditTextPreferenceCompat;
|
||||
import com.android.settingslib.core.instrumentation.Instrumentable;
|
||||
import com.android.settingslib.widget.FooterPreferenceMixinCompat;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -155,13 +155,14 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
|
||||
checkAvailablePrefs(getPreferenceScreen());
|
||||
}
|
||||
|
||||
private void checkAvailablePrefs(PreferenceGroup preferenceGroup) {
|
||||
@VisibleForTesting
|
||||
void checkAvailablePrefs(PreferenceGroup preferenceGroup) {
|
||||
if (preferenceGroup == null) return;
|
||||
for (int i = 0; i < preferenceGroup.getPreferenceCount(); i++) {
|
||||
Preference pref = preferenceGroup.getPreference(i);
|
||||
if (pref instanceof SelfAvailablePreference
|
||||
&& !((SelfAvailablePreference) pref).isAvailable(getContext())) {
|
||||
preferenceGroup.removePreference(pref);
|
||||
pref.setVisible(false);
|
||||
} else if (pref instanceof PreferenceGroup) {
|
||||
checkAvailablePrefs((PreferenceGroup) pref);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
@@ -37,6 +36,7 @@ import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class AccountHeaderPreferenceController extends AbstractPreferenceController
|
||||
implements PreferenceControllerMixin, LifecycleObserver, OnResume {
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.content.pm.UserInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.util.FeatureFlagUtils;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
@@ -63,7 +64,7 @@ public class EmergencyInfoPreferenceController extends AbstractPreferenceControl
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
if (KEY_EMERGENCY_INFO.equals(preference.getKey())) {
|
||||
Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO);
|
||||
Intent intent = new Intent(getIntentAction(mContext));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mContext.startActivity(intent);
|
||||
return true;
|
||||
@@ -73,7 +74,7 @@ public class EmergencyInfoPreferenceController extends AbstractPreferenceControl
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
Intent intent = new Intent(ACTION_EDIT_EMERGENCY_INFO).setPackage(PACKAGE_NAME_EMERGENCY);
|
||||
Intent intent = new Intent(getIntentAction(mContext)).setPackage(getPackageName(mContext));
|
||||
List<ResolveInfo> infos = mContext.getPackageManager().queryIntentActivities(intent, 0);
|
||||
return infos != null && !infos.isEmpty();
|
||||
}
|
||||
@@ -82,4 +83,20 @@ public class EmergencyInfoPreferenceController extends AbstractPreferenceControl
|
||||
public String getPreferenceKey() {
|
||||
return KEY_EMERGENCY_INFO;
|
||||
}
|
||||
|
||||
private String getIntentAction(Context context) {
|
||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
|
||||
return context.getResources().getString(R.string.config_emergency_intent_action);
|
||||
}
|
||||
|
||||
return ACTION_EDIT_EMERGENCY_INFO;
|
||||
}
|
||||
|
||||
private String getPackageName(Context context) {
|
||||
if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SAFETY_HUB)) {
|
||||
return context.getResources().getString(R.string.config_emergency_package_name);
|
||||
}
|
||||
|
||||
return PACKAGE_NAME_EMERGENCY;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,13 +39,13 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
||||
import com.android.settingslib.RestrictedLockUtilsInternal;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState.Callbacks;
|
||||
import com.android.settingslib.applications.StorageStatsSource;
|
||||
import com.android.settingslib.applications.StorageStatsSource.AppStorageStats;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.applications;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
|
||||
public class LayoutPreference extends Preference {
|
||||
|
||||
private final View.OnClickListener mClickListener = v -> performClick(v);
|
||||
private boolean mAllowDividerAbove;
|
||||
private boolean mAllowDividerBelow;
|
||||
private View mRootView;
|
||||
|
||||
public LayoutPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0 /* defStyleAttr */);
|
||||
}
|
||||
|
||||
public LayoutPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public LayoutPreference(Context context, int resource) {
|
||||
this(context, LayoutInflater.from(context).inflate(resource, null, false));
|
||||
}
|
||||
|
||||
public LayoutPreference(Context context, View view) {
|
||||
super(context);
|
||||
setView(view);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Preference);
|
||||
mAllowDividerAbove = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerAbove,
|
||||
R.styleable.Preference_allowDividerAbove, false);
|
||||
mAllowDividerBelow = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerBelow,
|
||||
R.styleable.Preference_allowDividerBelow, false);
|
||||
a.recycle();
|
||||
|
||||
a = context.obtainStyledAttributes(
|
||||
attrs, com.android.internal.R.styleable.Preference, defStyleAttr, 0);
|
||||
int layoutResource = a.getResourceId(com.android.internal.R.styleable.Preference_layout,
|
||||
0);
|
||||
if (layoutResource == 0) {
|
||||
throw new IllegalArgumentException("LayoutPreference requires a layout to be defined");
|
||||
}
|
||||
a.recycle();
|
||||
|
||||
// Need to create view now so that findViewById can be called immediately.
|
||||
final View view = LayoutInflater.from(getContext())
|
||||
.inflate(layoutResource, null, false);
|
||||
setView(view);
|
||||
}
|
||||
|
||||
private void setView(View view) {
|
||||
setLayoutResource(R.layout.layout_preference_frame);
|
||||
final ViewGroup allDetails = view.findViewById(R.id.all_details);
|
||||
if (allDetails != null) {
|
||||
Utils.forceCustomPadding(allDetails, true /* additive padding */);
|
||||
}
|
||||
mRootView = view;
|
||||
setShouldDisableView(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(PreferenceViewHolder holder) {
|
||||
holder.itemView.setOnClickListener(mClickListener);
|
||||
|
||||
final boolean selectable = isSelectable();
|
||||
holder.itemView.setFocusable(selectable);
|
||||
holder.itemView.setClickable(selectable);
|
||||
holder.setDividerAllowedAbove(mAllowDividerAbove);
|
||||
holder.setDividerAllowedBelow(mAllowDividerBelow);
|
||||
|
||||
FrameLayout layout = (FrameLayout) holder.itemView;
|
||||
layout.removeAllViews();
|
||||
ViewGroup parent = (ViewGroup) mRootView.getParent();
|
||||
if (parent != null) {
|
||||
parent.removeView(mRootView);
|
||||
}
|
||||
layout.addView(mRootView);
|
||||
}
|
||||
|
||||
public <T extends View> T findViewById(int id) {
|
||||
return mRootView.findViewById(id);
|
||||
}
|
||||
|
||||
public void setAllowDividerBelow(boolean allowed) {
|
||||
mAllowDividerBelow = allowed;
|
||||
}
|
||||
|
||||
public boolean isAllowDividerBelow() {
|
||||
return mAllowDividerBelow;
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,6 @@ import android.content.pm.PackageInfo;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
@@ -32,6 +30,7 @@ import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class AppHeaderViewPreferenceController extends BasePreferenceController
|
||||
implements AppInfoDashboardFragment.Callback, LifecycleObserver, OnStart {
|
||||
|
||||
@@ -34,7 +34,6 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.AppStoreUtil;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
@@ -42,6 +41,7 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnCreateOptionsMenu;
|
||||
import com.android.settingslib.core.lifecycle.events.OnOptionsItemSelected;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPrepareOptionsMenu;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import android.widget.Button;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
/**
|
||||
* Controller for the remove button.
|
||||
|
||||
@@ -25,13 +25,13 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
/**
|
||||
* This class adds a header with device name and status (connected/disconnected, etc.).
|
||||
|
||||
@@ -21,8 +21,8 @@ import android.content.Context;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
/**
|
||||
* This class adds a header with device name.
|
||||
|
||||
@@ -84,11 +84,6 @@ public class SubSettingLauncher {
|
||||
return this;
|
||||
}
|
||||
|
||||
public SubSettingLauncher setIsShortCut(boolean isShortCut) {
|
||||
mLaunchRequest.isShortCut = isShortCut;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SubSettingLauncher setArguments(Bundle arguments) {
|
||||
mLaunchRequest.arguments = arguments;
|
||||
return this;
|
||||
@@ -159,8 +154,6 @@ public class SubSettingLauncher {
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE_RESID,
|
||||
mLaunchRequest.titleResId);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_TITLE, mLaunchRequest.title);
|
||||
intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_AS_SHORTCUT,
|
||||
mLaunchRequest.isShortCut);
|
||||
intent.addFlags(mLaunchRequest.flags);
|
||||
return intent;
|
||||
}
|
||||
@@ -195,7 +188,6 @@ public class SubSettingLauncher {
|
||||
int titleResId;
|
||||
String titleResPackageName;
|
||||
CharSequence title;
|
||||
boolean isShortCut;
|
||||
int sourceMetricsCategory = -100;
|
||||
int flags;
|
||||
Fragment mResultListener;
|
||||
|
||||
@@ -88,8 +88,6 @@ public class StorageWizardMoveProgress extends StorageWizardBase {
|
||||
return getString(R.string.move_error_device_admin);
|
||||
case PackageManager.MOVE_FAILED_DOESNT_EXIST:
|
||||
return getString(R.string.does_not_exist);
|
||||
case PackageManager.MOVE_FAILED_FORWARD_LOCKED:
|
||||
return getString(R.string.app_forward_locked);
|
||||
case PackageManager.MOVE_FAILED_INVALID_LOCATION:
|
||||
return getString(R.string.invalid_location);
|
||||
case PackageManager.MOVE_FAILED_SYSTEM_PACKAGE:
|
||||
|
||||
@@ -29,9 +29,7 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.accounts.EmergencyInfoPreferenceController;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.deviceinfo.BluetoothAddressPreferenceController;
|
||||
import com.android.settings.deviceinfo.BrandedAccountPreferenceController;
|
||||
import com.android.settings.deviceinfo.BuildNumberPreferenceController;
|
||||
@@ -53,6 +51,7 @@ import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -23,12 +23,12 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.search.Indexable;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -28,8 +28,8 @@ import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class NightDisplayActivationPreferenceController extends TogglePreferenceController {
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.dream.DreamBackend;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class StartNowPreferenceController extends AbstractPreferenceController implements
|
||||
PreferenceControllerMixin {
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.android.internal.util.ArrayUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.applications.appinfo.AppButtonsPreferenceController;
|
||||
import com.android.settings.applications.appinfo.ButtonActionDialogFragment;
|
||||
import com.android.settings.core.InstrumentedPreferenceFragment;
|
||||
@@ -52,6 +51,7 @@ import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -30,7 +30,6 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
@@ -38,6 +37,7 @@ import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
/**
|
||||
* Controller that update the battery header view
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.SubSettingLauncher;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipLoader;
|
||||
import com.android.settings.fuelgauge.batterytip.BatteryTipPreferenceController;
|
||||
@@ -49,6 +48,7 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.utils.PowerUtil;
|
||||
import com.android.settingslib.utils.StringUtil;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,13 +33,16 @@ public class ContextualCard {
|
||||
/**
|
||||
* Flags indicating the type of the ContextualCard.
|
||||
*/
|
||||
@IntDef({CardType.DEFAULT, CardType.SLICE, CardType.LEGACY_SUGGESTION, CardType.CONDITIONAL})
|
||||
@IntDef({CardType.DEFAULT, CardType.SLICE, CardType.LEGACY_SUGGESTION, CardType.CONDITIONAL,
|
||||
CardType.CONDITIONAL_HEADER, CardType.CONDITIONAL_FOOTER})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CardType {
|
||||
int DEFAULT = 0;
|
||||
int SLICE = 1;
|
||||
int LEGACY_SUGGESTION = 2;
|
||||
int CONDITIONAL = 3;
|
||||
int CONDITIONAL_HEADER = 4;
|
||||
int CONDITIONAL_FOOTER = 5;
|
||||
}
|
||||
|
||||
private final Builder mBuilder;
|
||||
|
||||
@@ -23,7 +23,6 @@ import static androidx.slice.widget.SliceLiveData.SUPPORTED_SPECS;
|
||||
import android.content.ContentProviderClient;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.ContentObserver;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
@@ -35,7 +34,6 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.slice.Slice;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.deviceinfo.BatterySlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.ConnectedDeviceSlice;
|
||||
import com.android.settings.wifi.WifiSlice;
|
||||
import com.android.settingslib.utils.AsyncLoaderCompat;
|
||||
@@ -52,11 +50,17 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
|
||||
private static final String TAG = "ContextualCardLoader";
|
||||
|
||||
private Context mContext;
|
||||
private final ContentObserver mObserver = new ContentObserver(
|
||||
new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
if (isStarted()) {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public interface CardContentLoaderListener {
|
||||
void onFinishCardLoading(List<ContextualCard> contextualCards);
|
||||
}
|
||||
private Context mContext;
|
||||
|
||||
ContextualCardLoader(Context context) {
|
||||
super(context);
|
||||
@@ -86,9 +90,7 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
public List<ContextualCard> loadInBackground() {
|
||||
final List<ContextualCard> result = new ArrayList<>();
|
||||
try (Cursor cursor = getContextualCardsFromProvider()) {
|
||||
if (cursor.getCount() == 0) {
|
||||
result.addAll(createStaticCards());
|
||||
} else {
|
||||
if (cursor.getCount() > 0) {
|
||||
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
|
||||
final ContextualCard card = new ContextualCard(cursor);
|
||||
if (card.isCustomCard()) {
|
||||
@@ -130,24 +132,6 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
return CardDatabaseHelper.getInstance(mContext).getContextualCards();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
List<ContextualCard> createStaticCards() {
|
||||
final long appVersionCode = getAppVersionCode();
|
||||
final String packageName = mContext.getPackageName();
|
||||
final double rankingScore = 0.0;
|
||||
final List<ContextualCard> result = new ArrayList();
|
||||
result.add(new ContextualCard.Builder()
|
||||
.setSliceUri(BatterySlice.BATTERY_CARD_URI)
|
||||
.setName(BatterySlice.PATH_BATTERY_INFO)
|
||||
.setPackageName(packageName)
|
||||
.setRankingScore(rankingScore)
|
||||
.setAppVersion(appVersionCode)
|
||||
.setCardType(ContextualCard.CardType.SLICE)
|
||||
.setIsHalfWidth(false)
|
||||
.build());
|
||||
return result;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
List<ContextualCard> filterEligibleCards(List<ContextualCard> candidates) {
|
||||
return candidates.stream().filter(card -> isCardEligibleToDisplay(card))
|
||||
@@ -191,23 +175,7 @@ public class ContextualCardLoader extends AsyncLoaderCompat<List<ContextualCard>
|
||||
.count();
|
||||
}
|
||||
|
||||
private long getAppVersionCode() {
|
||||
try {
|
||||
return mContext.getPackageManager().getPackageInfo(mContext.getPackageName(),
|
||||
0 /* flags */).getLongVersionCode();
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.e(TAG, "Invalid package name for context", e);
|
||||
}
|
||||
return -1L;
|
||||
public interface CardContentLoaderListener {
|
||||
void onFinishCardLoading(List<ContextualCard> contextualCards);
|
||||
}
|
||||
|
||||
private final ContentObserver mObserver = new ContentObserver(
|
||||
new Handler(Looper.getMainLooper())) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
if (isStarted()) {
|
||||
forceLoad();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,14 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard.CardType;
|
||||
import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.conditional
|
||||
.ConditionHeaderContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.legacysuggestion
|
||||
.LegacySuggestionContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.legacysuggestion
|
||||
.LegacySuggestionContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.conditional
|
||||
.ConditionFooterContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer;
|
||||
|
||||
@@ -83,6 +87,14 @@ public class ContextualCardLookupTable {
|
||||
SliceContextualCardRenderer.VIEW_TYPE,
|
||||
SliceContextualCardController.class,
|
||||
SliceContextualCardRenderer.class));
|
||||
add(new ControllerRendererMapping(CardType.CONDITIONAL_FOOTER,
|
||||
ConditionFooterContextualCardRenderer.VIEW_TYPE,
|
||||
ConditionContextualCardController.class,
|
||||
ConditionFooterContextualCardRenderer.class));
|
||||
add(new ControllerRendererMapping(CardType.CONDITIONAL_HEADER,
|
||||
ConditionHeaderContextualCardRenderer.VIEW_TYPE,
|
||||
ConditionContextualCardController.class,
|
||||
ConditionHeaderContextualCardRenderer.class));
|
||||
}};
|
||||
|
||||
public static Class<? extends ContextualCardController> getCardControllerClass(
|
||||
|
||||
@@ -129,5 +129,7 @@ public class ContextualCardsAdapter extends RecyclerView.Adapter<RecyclerView.Vi
|
||||
// Adding items to empty list, should animate.
|
||||
mRecyclerView.scheduleLayoutAnimation();
|
||||
}
|
||||
|
||||
//TODO(b/119465242): flickering conditional cards after collapsing/expanding
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,14 @@ import androidx.lifecycle.LifecycleOwner;
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.conditional.ConditionContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.conditional
|
||||
.ConditionHeaderContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.legacysuggestion
|
||||
.LegacySuggestionContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.legacysuggestion
|
||||
.LegacySuggestionContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.conditional
|
||||
.ConditionFooterContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer;
|
||||
|
||||
@@ -131,6 +135,12 @@ public class ControllerRendererPool {
|
||||
} else if (LegacySuggestionContextualCardRenderer.class == clz) {
|
||||
return new LegacySuggestionContextualCardRenderer(context,
|
||||
this /* controllerRendererPool */);
|
||||
} else if (ConditionFooterContextualCardRenderer.class == clz) {
|
||||
return new ConditionFooterContextualCardRenderer(context,
|
||||
this /*controllerRendererPool*/);
|
||||
} else if (ConditionHeaderContextualCardRenderer.class == clz) {
|
||||
return new ConditionHeaderContextualCardRenderer(context,
|
||||
this /*controllerRendererPool*/);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import static android.provider.SettingsSlicesContract.KEY_WIFI;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.deviceinfo.BatterySlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.BatteryFixSlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.ConnectedDeviceSlice;
|
||||
import com.android.settings.homepage.contextualcards.slices.LowStorageSlice;
|
||||
@@ -44,12 +43,6 @@ public class SettingsContextualCardProvider extends ContextualCardProvider {
|
||||
.setCardName(KEY_WIFI)
|
||||
.setCardCategory(ContextualCard.Category.IMPORTANT)
|
||||
.build();
|
||||
final ContextualCard batteryInfoCard =
|
||||
ContextualCard.newBuilder()
|
||||
.setSliceUri(BatterySlice.BATTERY_CARD_URI.toString())
|
||||
.setCardName(BatterySlice.PATH_BATTERY_INFO)
|
||||
.setCardCategory(ContextualCard.Category.DEFAULT)
|
||||
.build();
|
||||
final ContextualCard connectedDeviceCard =
|
||||
ContextualCard.newBuilder()
|
||||
.setSliceUri(ConnectedDeviceSlice.CONNECTED_DEVICE_URI.toString())
|
||||
@@ -70,7 +63,6 @@ public class SettingsContextualCardProvider extends ContextualCardProvider {
|
||||
.build();
|
||||
final ContextualCardList cards = ContextualCardList.newBuilder()
|
||||
.addCard(wifiCard)
|
||||
.addCard(batteryInfoCard)
|
||||
.addCard(connectedDeviceCard)
|
||||
.addCard(lowStorageCard)
|
||||
.addCard(batteryFixCard)
|
||||
@@ -78,4 +70,4 @@ public class SettingsContextualCardProvider extends ContextualCardProvider {
|
||||
|
||||
return cards;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ package com.android.settings.homepage.contextualcards.conditional;
|
||||
import android.content.Context;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardController;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardUpdateListener;
|
||||
@@ -26,8 +28,11 @@ import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStart;
|
||||
import com.android.settingslib.core.lifecycle.events.OnStop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This controller triggers the loading of conditional cards and monitors state changes to
|
||||
@@ -35,13 +40,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class ConditionContextualCardController implements ContextualCardController,
|
||||
ConditionListener, LifecycleObserver, OnStart, OnStop {
|
||||
public static final int EXPANDING_THRESHOLD = 2;
|
||||
|
||||
private static final double UNSUPPORTED_RANKING = -99999.0;
|
||||
private static final String TAG = "ConditionCtxCardCtrl";
|
||||
private static final String CONDITION_FOOTER = "condition_footer";
|
||||
private static final String CONDITION_HEADER = "condition_header";
|
||||
|
||||
private final Context mContext;
|
||||
private final ConditionManager mConditionManager;
|
||||
|
||||
private ContextualCardUpdateListener mListener;
|
||||
private boolean mIsExpanded;
|
||||
|
||||
public ConditionContextualCardController(Context context) {
|
||||
mContext = context;
|
||||
@@ -49,6 +59,10 @@ public class ConditionContextualCardController implements ContextualCardControll
|
||||
mConditionManager.startMonitoringStateChange();
|
||||
}
|
||||
|
||||
public void setIsExpanded(boolean isExpanded) {
|
||||
mIsExpanded = isExpanded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCardUpdateListener(ContextualCardUpdateListener listener) {
|
||||
mListener = listener;
|
||||
@@ -88,20 +102,102 @@ public class ConditionContextualCardController implements ContextualCardControll
|
||||
|
||||
@Override
|
||||
public void onConditionsChanged() {
|
||||
if (mListener == null) {
|
||||
return;
|
||||
}
|
||||
final List<ContextualCard> conditionCards = mConditionManager.getDisplayableCards();
|
||||
final Map<Integer, List<ContextualCard>> conditionalCards =
|
||||
buildConditionalCardsWithFooterOrHeader(conditionCards);
|
||||
mListener.onContextualCardUpdated(conditionalCards);
|
||||
|
||||
final boolean isOddNumber = conditionCards.size() % 2 == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* According to conditional cards, build a map that includes conditional cards, header card and
|
||||
* footer card.
|
||||
*
|
||||
* Rules:
|
||||
* - The last one of conditional cards will be displayed as a full-width card if the size of
|
||||
* conditional cards is odd number. The rest will be displayed as a half-width card.
|
||||
* - By default conditional cards will be collapsed if there are more than TWO cards.
|
||||
*
|
||||
* For examples:
|
||||
* - Only one conditional card: Returns a map that contains a full-width conditional card,
|
||||
* no header card and no footer card.
|
||||
* <p>Map{(CONDITIONAL, conditionCards), (CONDITIONAL_FOOTER, EMPTY_LIST), (CONDITIONAL_HEADER,
|
||||
* EMPTY_LIST)}</p>
|
||||
* - Two conditional cards: Returns a map that contains two half-width conditional cards,
|
||||
* no header card and no footer card.
|
||||
* <p>Map{(CONDITIONAL, conditionCards), (CONDITIONAL_FOOTER, EMPTY_LIST), (CONDITIONAL_HEADER,
|
||||
* EMPTY_LIST)}</p>
|
||||
* - Three conditional cards or above: By default, returns a map that contains no conditional
|
||||
* card, one header card and no footer card. If conditional cards are expanded, will returns a
|
||||
* map that contains three conditional cards, no header card and one footer card.
|
||||
* If expanding conditional cards:
|
||||
* <p>Map{(CONDITIONAL, conditionCards), (CONDITIONAL_FOOTER, footerCards), (CONDITIONAL_HEADER,
|
||||
* EMPTY_LIST)}</p>
|
||||
* If collapsing conditional cards:
|
||||
* <p>Map{(CONDITIONAL, EMPTY_LIST), (CONDITIONAL_FOOTER, EMPTY_LIST), (CONDITIONAL_HEADER,
|
||||
* headerCards)}</p>
|
||||
*
|
||||
* @param conditionCards A list of conditional cards that are from {@link
|
||||
* ConditionManager#getDisplayableCards}
|
||||
* @return A map contained three types of lists
|
||||
*/
|
||||
@VisibleForTesting
|
||||
Map<Integer, List<ContextualCard>> buildConditionalCardsWithFooterOrHeader(
|
||||
List<ContextualCard> conditionCards) {
|
||||
final Map<Integer, List<ContextualCard>> conditionalCards = new ArrayMap<>();
|
||||
conditionalCards.put(ContextualCard.CardType.CONDITIONAL,
|
||||
getExpandedConditionalCards(conditionCards));
|
||||
conditionalCards.put(ContextualCard.CardType.CONDITIONAL_FOOTER,
|
||||
getConditionalFooterCard(conditionCards));
|
||||
conditionalCards.put(ContextualCard.CardType.CONDITIONAL_HEADER,
|
||||
getConditionalHeaderCard(conditionCards));
|
||||
return conditionalCards;
|
||||
}
|
||||
|
||||
private List<ContextualCard> getExpandedConditionalCards(List<ContextualCard> conditionCards) {
|
||||
if (conditionCards.isEmpty() || (conditionCards.size() > EXPANDING_THRESHOLD
|
||||
&& !mIsExpanded)) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
final List<ContextualCard> expandedCards = conditionCards.stream().collect(
|
||||
Collectors.toList());
|
||||
final boolean isOddNumber = expandedCards.size() % 2 == 1;
|
||||
if (isOddNumber) {
|
||||
final int lastIndex = conditionCards.size() - 1;
|
||||
final ConditionalContextualCard card = (ConditionalContextualCard) conditionCards
|
||||
.get(lastIndex);
|
||||
conditionCards.set(lastIndex, card.mutate().setIsHalfWidth(false).build());
|
||||
final int lastIndex = expandedCards.size() - 1;
|
||||
final ConditionalContextualCard card =
|
||||
(ConditionalContextualCard) expandedCards.get(lastIndex);
|
||||
expandedCards.set(lastIndex, card.mutate().setIsHalfWidth(false).build());
|
||||
}
|
||||
return expandedCards;
|
||||
}
|
||||
|
||||
if (mListener != null) {
|
||||
final Map<Integer, List<ContextualCard>> conditionalCards = new ArrayMap<>();
|
||||
conditionalCards.put(ContextualCard.CardType.CONDITIONAL, conditionCards);
|
||||
mListener.onContextualCardUpdated(conditionalCards);
|
||||
private List<ContextualCard> getConditionalFooterCard(List<ContextualCard> conditionCards) {
|
||||
if (!conditionCards.isEmpty() && mIsExpanded
|
||||
&& conditionCards.size() > EXPANDING_THRESHOLD) {
|
||||
final List<ContextualCard> footerCards = new ArrayList<>();
|
||||
footerCards.add(new ConditionFooterContextualCard.Builder()
|
||||
.setName(CONDITION_FOOTER)
|
||||
.setRankingScore(UNSUPPORTED_RANKING)
|
||||
.build());
|
||||
return footerCards;
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
private List<ContextualCard> getConditionalHeaderCard(List<ContextualCard> conditionCards) {
|
||||
if (!conditionCards.isEmpty() && !mIsExpanded
|
||||
&& conditionCards.size() > EXPANDING_THRESHOLD) {
|
||||
final List<ContextualCard> headerCards = new ArrayList<>();
|
||||
headerCards.add(new ConditionHeaderContextualCard.Builder()
|
||||
.setConditionalCards(conditionCards)
|
||||
.setName(CONDITION_HEADER)
|
||||
.setRankingScore(UNSUPPORTED_RANKING)
|
||||
.build());
|
||||
return headerCards;
|
||||
}
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.contextualcards.conditional;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
|
||||
/**
|
||||
* Data class representing a condition footer {@link ContextualCard}.
|
||||
*
|
||||
* Use this class for {@link ConditionFooterContextualCardRenderer} and
|
||||
* {@link ConditionContextualCardController}.
|
||||
*/
|
||||
public class ConditionFooterContextualCard extends ContextualCard {
|
||||
|
||||
private ConditionFooterContextualCard(Builder builder) {
|
||||
super(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardType() {
|
||||
return CardType.CONDITIONAL_FOOTER;
|
||||
}
|
||||
|
||||
public static class Builder extends ContextualCard.Builder {
|
||||
|
||||
@Override
|
||||
public Builder setCardType(int cardType) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot change card type for " + getClass().getName());
|
||||
}
|
||||
|
||||
public ConditionFooterContextualCard build() {
|
||||
return new ConditionFooterContextualCard(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.contextualcards.conditional;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.ControllerRendererPool;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class ConditionFooterContextualCardRenderer implements ContextualCardRenderer {
|
||||
public static final int VIEW_TYPE = R.layout.homepage_condition_footer;
|
||||
private static final String TAG = "ConditionFooterRenderer";
|
||||
|
||||
private final Context mContext;
|
||||
private final ControllerRendererPool mControllerRendererPool;
|
||||
|
||||
public ConditionFooterContextualCardRenderer(Context context,
|
||||
ControllerRendererPool controllerRendererPool) {
|
||||
mContext = context;
|
||||
mControllerRendererPool = controllerRendererPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewType(boolean isHalfWidth) {
|
||||
return VIEW_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder createViewHolder(View view) {
|
||||
return new ConditionFooterCardHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
|
||||
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getMetricsFeatureProvider();
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
MetricsProto.MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND,
|
||||
SettingsEnums.SETTINGS_HOMEPAGE,
|
||||
null /* key */,
|
||||
0 /* false */);
|
||||
final ConditionContextualCardController controller =
|
||||
mControllerRendererPool.getController(mContext,
|
||||
ContextualCard.CardType.CONDITIONAL_FOOTER);
|
||||
controller.setIsExpanded(false);
|
||||
controller.onConditionsChanged();
|
||||
});
|
||||
}
|
||||
|
||||
public static class ConditionFooterCardHolder extends RecyclerView.ViewHolder {
|
||||
public ConditionFooterCardHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.contextualcards.conditional;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Data class representing a condition header {@link ContextualCard}.
|
||||
*
|
||||
* Use this class to store additional attributes on top of {@link ContextualCard} for
|
||||
* {@link ConditionHeaderContextualCardRenderer} and {@link ConditionContextualCardController}.
|
||||
*/
|
||||
public class ConditionHeaderContextualCard extends ContextualCard {
|
||||
|
||||
private final List<ContextualCard> mConditionalCards;
|
||||
|
||||
private ConditionHeaderContextualCard(Builder builder) {
|
||||
super(builder);
|
||||
mConditionalCards = builder.mConditionalCards;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCardType() {
|
||||
return CardType.CONDITIONAL_HEADER;
|
||||
}
|
||||
|
||||
public List<ContextualCard> getConditionalCards() {
|
||||
return mConditionalCards;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getName(), mConditionalCards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ConditionHeaderContextualCard)) {
|
||||
return false;
|
||||
}
|
||||
final ConditionHeaderContextualCard that = (ConditionHeaderContextualCard) obj;
|
||||
|
||||
return TextUtils.equals(getName(), that.getName()) && mConditionalCards.equals(
|
||||
that.mConditionalCards);
|
||||
}
|
||||
|
||||
public static class Builder extends ContextualCard.Builder {
|
||||
|
||||
private List<ContextualCard> mConditionalCards;
|
||||
|
||||
public Builder setConditionalCards(List<ContextualCard> conditionalCards) {
|
||||
mConditionalCards = conditionalCards;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setCardType(int cardType) {
|
||||
throw new IllegalArgumentException(
|
||||
"Cannot change card type for " + getClass().getName());
|
||||
}
|
||||
|
||||
public ConditionHeaderContextualCard build() {
|
||||
return new ConditionHeaderContextualCard(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.contextualcards.conditional;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCard;
|
||||
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
|
||||
import com.android.settings.homepage.contextualcards.ControllerRendererPool;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
|
||||
public class ConditionHeaderContextualCardRenderer implements ContextualCardRenderer {
|
||||
public static final int VIEW_TYPE = R.layout.homepage_condition_header;
|
||||
private static final String TAG = "ConditionHeaderRenderer";
|
||||
|
||||
private final Context mContext;
|
||||
private final ControllerRendererPool mControllerRendererPool;
|
||||
|
||||
public ConditionHeaderContextualCardRenderer(Context context,
|
||||
ControllerRendererPool controllerRendererPool) {
|
||||
mContext = context;
|
||||
mControllerRendererPool = controllerRendererPool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewType(boolean isHalfWidth) {
|
||||
return VIEW_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecyclerView.ViewHolder createViewHolder(View view) {
|
||||
return new ConditionHeaderCardHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(RecyclerView.ViewHolder holder, ContextualCard contextualCard) {
|
||||
final ConditionHeaderContextualCard headerCard =
|
||||
(ConditionHeaderContextualCard) contextualCard;
|
||||
final ConditionHeaderCardHolder view = (ConditionHeaderCardHolder) holder;
|
||||
final MetricsFeatureProvider metricsFeatureProvider = FeatureFactory.getFactory(
|
||||
mContext).getMetricsFeatureProvider();
|
||||
view.icons.removeAllViews();
|
||||
headerCard.getConditionalCards().stream().forEach(card -> {
|
||||
final ImageView icon = (ImageView) LayoutInflater.from(mContext).inflate(
|
||||
R.layout.homepage_condition_header_icon, view.icons, false);
|
||||
icon.setImageDrawable(card.getIconDrawable());
|
||||
view.icons.addView(icon);
|
||||
});
|
||||
view.itemView.setOnClickListener(v -> {
|
||||
metricsFeatureProvider.action(SettingsEnums.PAGE_UNKNOWN,
|
||||
MetricsProto.MetricsEvent.ACTION_SETTINGS_CONDITION_EXPAND,
|
||||
SettingsEnums.SETTINGS_HOMEPAGE,
|
||||
null /* key */,
|
||||
1 /* true */);
|
||||
final ConditionContextualCardController controller =
|
||||
mControllerRendererPool.getController(mContext,
|
||||
ContextualCard.CardType.CONDITIONAL_HEADER);
|
||||
controller.setIsExpanded(true);
|
||||
controller.onConditionsChanged();
|
||||
});
|
||||
}
|
||||
|
||||
public static class ConditionHeaderCardHolder extends RecyclerView.ViewHolder {
|
||||
public final LinearLayout icons;
|
||||
public final ImageView expandIndicator;
|
||||
|
||||
public ConditionHeaderCardHolder(View itemView) {
|
||||
super(itemView);
|
||||
icons = itemView.findViewById(R.id.header_icons_container);
|
||||
expandIndicator = itemView.findViewById(R.id.expand_indicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class AirplaneModePreferenceController extends TogglePreferenceController
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return TextUtils.equals(getPreferenceKey(), "toggle_airplane");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,9 +27,9 @@ import android.widget.Switch;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class BlockPreferenceController extends NotificationPreferenceController
|
||||
implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
|
||||
|
||||
@@ -31,10 +31,10 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class HeaderPreferenceController extends NotificationPreferenceController
|
||||
implements PreferenceControllerMixin, LifecycleObserver {
|
||||
|
||||
@@ -22,9 +22,9 @@ import android.view.View;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.widget.ToggleSwitch;
|
||||
import com.android.settingslib.RestrictedLockUtils;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class NotificationSwitchBarPreference extends LayoutPreference {
|
||||
private ToggleSwitch mSwitch;
|
||||
|
||||
@@ -28,17 +28,17 @@ import android.text.TextUtils;
|
||||
import android.util.Slog;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class ZenAutomaticRuleHeaderPreferenceController extends AbstractZenModePreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class ZenAutomaticRuleSwitchPreferenceController extends
|
||||
AbstractZenModeAutomaticRulePreferenceController implements
|
||||
|
||||
@@ -26,9 +26,9 @@ import androidx.preference.Preference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
public class ZenModeButtonPreferenceController extends AbstractZenModePreferenceController
|
||||
implements PreferenceControllerMixin {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider;
|
||||
import com.android.settings.fuelgauge.PowerUsageFeatureProvider;
|
||||
import com.android.settings.gestures.AssistGestureFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
import com.android.settings.panel.PanelFeatureProvider;
|
||||
import com.android.settings.search.SearchFeatureProvider;
|
||||
import com.android.settings.security.SecurityFeatureProvider;
|
||||
import com.android.settings.slices.SlicesFeatureProvider;
|
||||
@@ -105,6 +106,8 @@ public abstract class FeatureFactory {
|
||||
|
||||
public abstract AccountFeatureProvider getAccountFeatureProvider();
|
||||
|
||||
public abstract PanelFeatureProvider getPanelFeatureProvider();
|
||||
|
||||
public static final class FactoryNotFoundException extends RuntimeException {
|
||||
public FactoryNotFoundException(Throwable throwable) {
|
||||
super("Unable to create factory. Did you misconfigure Proguard?", throwable);
|
||||
|
||||
@@ -42,6 +42,8 @@ import com.android.settings.gestures.AssistGestureFeatureProvider;
|
||||
import com.android.settings.gestures.AssistGestureFeatureProviderImpl;
|
||||
import com.android.settings.localepicker.LocaleFeatureProvider;
|
||||
import com.android.settings.localepicker.LocaleFeatureProviderImpl;
|
||||
import com.android.settings.panel.PanelFeatureProvider;
|
||||
import com.android.settings.panel.PanelFeatureProviderImpl;
|
||||
import com.android.settings.search.SearchFeatureProvider;
|
||||
import com.android.settings.search.SearchFeatureProviderImpl;
|
||||
import com.android.settings.security.SecurityFeatureProvider;
|
||||
@@ -72,6 +74,7 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
private UserFeatureProvider mUserFeatureProvider;
|
||||
private SlicesFeatureProvider mSlicesFeatureProvider;
|
||||
private AccountFeatureProvider mAccountFeatureProvider;
|
||||
private PanelFeatureProvider mPanelFeatureProvider;
|
||||
|
||||
@Override
|
||||
public SupportFeatureProvider getSupportFeatureProvider(Context context) {
|
||||
@@ -209,4 +212,12 @@ public class FeatureFactoryImpl extends FeatureFactory {
|
||||
}
|
||||
return mAccountFeatureProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PanelFeatureProvider getPanelFeatureProvider() {
|
||||
if (mPanelFeatureProvider == null) {
|
||||
mPanelFeatureProvider = new PanelFeatureProviderImpl();
|
||||
}
|
||||
return mPanelFeatureProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.panel;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.provider.SettingsSlicesContract;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.wifi.WifiSlice;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the Internet Connectivity Panel.
|
||||
*
|
||||
* <p>
|
||||
* Displays Wifi (full Slice) and Airplane mode.
|
||||
* </p>
|
||||
*/
|
||||
public class InternetConnectivityPanel implements PanelContent {
|
||||
|
||||
@VisibleForTesting
|
||||
static final Uri AIRPLANE_URI = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(SettingsSlicesContract.AUTHORITY)
|
||||
.appendPath(SettingsSlicesContract.PATH_SETTING_ACTION)
|
||||
.appendPath(SettingsSlicesContract.KEY_AIRPLANE_MODE)
|
||||
.build();
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
public static InternetConnectivityPanel create(Context context) {
|
||||
return new InternetConnectivityPanel(context);
|
||||
}
|
||||
|
||||
private InternetConnectivityPanel(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return (String) mContext.getText(R.string.internet_connectivity_panel_title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Uri> getSlices() {
|
||||
final List<Uri> uris = new ArrayList<>();
|
||||
uris.add(WifiSlice.WIFI_URI);
|
||||
uris.add(AIRPLANE_URI);
|
||||
return uris;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getSeeMoreIntent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
49
src/com/android/settings/panel/PanelContent.java
Normal file
49
src/com/android/settings/panel/PanelContent.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.panel;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents the data class needed to create a Settings Panel. See {@link PanelFragment}.
|
||||
*/
|
||||
public interface PanelContent {
|
||||
|
||||
/**
|
||||
* @return a string for the title of the Panel.
|
||||
*/
|
||||
CharSequence getTitle();
|
||||
|
||||
/**
|
||||
* @return an ordered list of the Slices to be displayed in the Panel. The first item in the
|
||||
* list is shown on top of the Panel.
|
||||
*/
|
||||
List<Uri> getSlices();
|
||||
|
||||
|
||||
/**
|
||||
* @return an {@link Intent} to the full content in Settings that is summarized by the Panel.
|
||||
*
|
||||
* <p>
|
||||
* For example, for the connectivity panel you would intent to the Network & Internet page.
|
||||
* </p>
|
||||
*/
|
||||
Intent getSeeMoreIntent();
|
||||
}
|
||||
27
src/com/android/settings/panel/PanelFeatureProvider.java
Normal file
27
src/com/android/settings/panel/PanelFeatureProvider.java
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.panel;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public interface PanelFeatureProvider {
|
||||
|
||||
/**
|
||||
* Returns {@link PanelContent} as specified by the {@param panelType}.
|
||||
*/
|
||||
PanelContent getPanel(Context context, String panelType);
|
||||
}
|
||||
32
src/com/android/settings/panel/PanelFeatureProviderImpl.java
Normal file
32
src/com/android/settings/panel/PanelFeatureProviderImpl.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.panel;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class PanelFeatureProviderImpl implements PanelFeatureProvider {
|
||||
|
||||
@Override
|
||||
public PanelContent getPanel(Context context, String panelType) {
|
||||
switch (panelType) {
|
||||
case SettingsPanelActivity.PANEL_TYPE_WIFI:
|
||||
return InternetConnectivityPanel.create(context);
|
||||
}
|
||||
|
||||
throw new IllegalStateException("No matching panel for: " + panelType);
|
||||
}
|
||||
}
|
||||
88
src/com/android/settings/panel/PanelFragment.java
Normal file
88
src/com/android/settings/panel/PanelFragment.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.panel;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.slice.Slice;
|
||||
import androidx.slice.widget.SliceLiveData;
|
||||
import androidx.slice.widget.SliceView;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PanelFragment extends Fragment {
|
||||
|
||||
private static final String TAG = "PanelFragment";
|
||||
|
||||
private List<SliceView> mSliceViewList;
|
||||
private List<LiveData<Slice>> mSliceDataList;
|
||||
private LinearLayout mPanelLayout;
|
||||
|
||||
public PanelFragment() {
|
||||
mSliceViewList = new ArrayList<>();
|
||||
mSliceDataList = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
final FragmentActivity activity = getActivity();
|
||||
final View view = inflater.inflate(R.layout.panel_layout, container, false);
|
||||
|
||||
mPanelLayout = view.findViewById(R.id.panel_parent_layout);
|
||||
final Bundle arguments = getArguments();
|
||||
|
||||
final String panelType = arguments.getString(SettingsPanelActivity.KEY_PANEL_TYPE_ARGUMENT);
|
||||
|
||||
final PanelContent panel = FeatureFactory.getFactory(activity)
|
||||
.getPanelFeatureProvider()
|
||||
.getPanel(activity, panelType);
|
||||
|
||||
activity.setTitle(panel.getTitle());
|
||||
|
||||
|
||||
for (Uri uri : panel.getSlices()) {
|
||||
final SliceView sliceView = new SliceView(activity);
|
||||
mPanelLayout.addView(sliceView);
|
||||
final LiveData<Slice> liveData = SliceLiveData.fromUri(activity, uri);
|
||||
liveData.observe(this /* lifecycleOwner */, sliceView);
|
||||
|
||||
mSliceDataList.add(liveData);
|
||||
mSliceViewList.add(sliceView);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
103
src/com/android/settings/panel/SettingsPanelActivity.java
Normal file
103
src/com/android/settings/panel/SettingsPanelActivity.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.panel;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* Dialog Activity to host Settings Slices.
|
||||
*
|
||||
* TODO link to action / framework API
|
||||
*/
|
||||
public class SettingsPanelActivity extends FragmentActivity {
|
||||
|
||||
private final String TAG = "panel_activity";
|
||||
|
||||
/**
|
||||
* Key specifying which Panel the app is requesting.
|
||||
*/
|
||||
public static final String KEY_PANEL_TYPE_ARGUMENT = "PANEL_TYPE_ARGUMENT";
|
||||
|
||||
|
||||
// TODO (b/117804442) move to framework
|
||||
public static final String EXTRA_PANEL_TYPE = "com.android.settings.panel.extra";
|
||||
|
||||
// TODO (b/117804442) move to framework
|
||||
public static final String PANEL_TYPE_WIFI = "wifi_panel";
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
final ComponentName callingActivityName = getCallingActivity();
|
||||
|
||||
if (callingActivityName == null) {
|
||||
Log.e(TAG, "Must start with startActivityForResult. Closing.");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final Intent callingIntent = getIntent();
|
||||
if (callingIntent == null) {
|
||||
Log.e(TAG, "Null intent, closing Panel Activity");
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
final String typeExtra = callingIntent.getStringExtra(EXTRA_PANEL_TYPE);
|
||||
if (TextUtils.isEmpty(typeExtra)) {
|
||||
Log.e(TAG, "No intent passed, closing Panel Activity");
|
||||
return;
|
||||
}
|
||||
|
||||
setContentView(R.layout.settings_panel);
|
||||
|
||||
// Move the window to the bottom of screen, and make it take up the entire screen width.
|
||||
final Window window = getWindow();
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
|
||||
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(KEY_PANEL_TYPE_ARGUMENT, typeExtra);
|
||||
|
||||
final PanelFragment panelFragment = new PanelFragment();
|
||||
panelFragment.setArguments(bundle);
|
||||
|
||||
final FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
final Fragment fragment = fragmentManager.findFragmentById(R.id.main_content);
|
||||
if (fragment == null) {
|
||||
fragmentManager.beginTransaction().add(R.id.main_content, panelFragment).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,7 @@ package com.android.settings.password;
|
||||
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD;
|
||||
import static android.app.admin.DevicePolicyManager.ACTION_SET_NEW_PASSWORD;
|
||||
|
||||
import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment
|
||||
.RESULT_FINISHED;
|
||||
import static com.android.settings.password.ChooseLockPassword.ChooseLockPasswordFragment.RESULT_FINISHED;
|
||||
|
||||
import android.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.app.Activity;
|
||||
@@ -77,12 +76,6 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
public Intent getIntent() {
|
||||
Intent modIntent = new Intent(super.getIntent());
|
||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
|
||||
|
||||
String action = modIntent.getAction();
|
||||
if (ACTION_SET_NEW_PASSWORD.equals(action)
|
||||
|| ACTION_SET_NEW_PARENT_PROFILE_PASSWORD.equals(action)) {
|
||||
modIntent.putExtra(EXTRA_HIDE_DRAWER, true);
|
||||
}
|
||||
return modIntent;
|
||||
}
|
||||
|
||||
@@ -154,7 +147,6 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
private FingerprintManager mFingerprintManager;
|
||||
private FaceManager mFaceManager;
|
||||
private int mUserId;
|
||||
private boolean mHideDrawer = false;
|
||||
private ManagedLockPasswordProvider mManagedPasswordProvider;
|
||||
private boolean mIsSetNewPassword = false;
|
||||
private UserManager mUserManager;
|
||||
@@ -194,7 +186,6 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
mUserPassword = getActivity().getIntent().getStringExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
|
||||
}
|
||||
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
|
||||
|
||||
mHasChallenge = getActivity().getIntent().getBooleanExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, false);
|
||||
@@ -345,7 +336,6 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
mForFingerprint);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE,
|
||||
mForFace);
|
||||
intent.putExtra(EXTRA_HIDE_DRAWER, mHideDrawer);
|
||||
startActivityForResult(
|
||||
intent,
|
||||
mIsSetNewPassword && mHasChallenge
|
||||
@@ -748,9 +738,6 @@ public class ChooseLockGeneric extends SettingsActivity {
|
||||
} else if (quality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
|
||||
intent = getLockPatternIntent();
|
||||
}
|
||||
if (intent != null) {
|
||||
intent.putExtra(EXTRA_HIDE_DRAWER, mHideDrawer);
|
||||
}
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
private int mPasswordMinNonLetter = 0;
|
||||
private int mPasswordMinLengthToFulfillAllPolicies = 0;
|
||||
protected int mUserId;
|
||||
private boolean mHideDrawer = false;
|
||||
private byte[] mPasswordHistoryHashFactor;
|
||||
/**
|
||||
* Password requirements that we need to verify.
|
||||
@@ -375,7 +374,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
mForFace = intent.getBooleanExtra(ChooseLockSettingsHelper.EXTRA_KEY_FOR_FACE, false);
|
||||
processPasswordRequirements(intent);
|
||||
mChooseLockSettingsHelper = new ChooseLockSettingsHelper(getActivity());
|
||||
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
|
||||
|
||||
if (intent.getBooleanExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_FOR_CHANGE_CRED_REQUIRED_FOR_BOOT, false)) {
|
||||
@@ -975,7 +973,6 @@ public class ChooseLockPassword extends SettingsActivity {
|
||||
if (!wasSecureBefore) {
|
||||
Intent intent = getRedactionInterstitialIntent(getActivity());
|
||||
if (intent != null) {
|
||||
intent.putExtra(EXTRA_HIDE_DRAWER, mHideDrawer);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,6 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
private TextView mFooterLeftButton;
|
||||
private TextView mFooterRightButton;
|
||||
protected List<LockPatternView.Cell> mChosenPattern = null;
|
||||
private boolean mHideDrawer = false;
|
||||
private ColorStateList mDefaultHeaderColorList;
|
||||
|
||||
// ScrollView that contains title and header, only exist in land mode
|
||||
@@ -464,7 +463,6 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
w.start(mChooseLockSettingsHelper.utils(), required,
|
||||
false, 0, LockPatternUtils.stringToPattern(current), current, mUserId);
|
||||
}
|
||||
mHideDrawer = getActivity().getIntent().getBooleanExtra(EXTRA_HIDE_DRAWER, false);
|
||||
mForFingerprint = intent.getBooleanExtra(
|
||||
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
|
||||
mForFace = intent.getBooleanExtra(
|
||||
@@ -808,7 +806,6 @@ public class ChooseLockPattern extends SettingsActivity {
|
||||
if (!wasSecureBefore) {
|
||||
Intent intent = getRedactionInterstitialIntent(getActivity());
|
||||
if (intent != null) {
|
||||
intent.putExtra(EXTRA_HIDE_DRAWER, mHideDrawer);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,8 +391,6 @@ public final class ChooseLockSettingsHelper {
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_RETURN_CREDENTIALS, returnCredentials);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_HAS_CHALLENGE, hasChallenge);
|
||||
intent.putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE, challenge);
|
||||
// we should never have a drawer when confirming device credentials.
|
||||
intent.putExtra(SettingsActivity.EXTRA_HIDE_DRAWER, true);
|
||||
intent.putExtra(Intent.EXTRA_USER_ID, userId);
|
||||
intent.putExtra(KeyguardManager.EXTRA_ALTERNATE_BUTTON_LABEL, alternateButton);
|
||||
if (extras != null) {
|
||||
|
||||
@@ -22,7 +22,10 @@ import android.provider.SearchIndexableResource;
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.notification.LockScreenNotificationPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -31,6 +34,11 @@ import java.util.List;
|
||||
@SearchIndexable
|
||||
public class PrivacyDashboardFragment extends DashboardFragment {
|
||||
private static final String TAG = "PrivacyDashboardFragment";
|
||||
private static final String KEY_LOCK_SCREEN_NOTIFICATIONS = "privacy_lock_screen_notifications";
|
||||
private static final String KEY_WORK_PROFILE_CATEGORY =
|
||||
"privacy_work_profile_notifications_category";
|
||||
private static final String KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS =
|
||||
"privacy_lock_screen_work_profile_notifications";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
@@ -52,6 +60,28 @@ public class PrivacyDashboardFragment extends DashboardFragment {
|
||||
return R.string.help_url_privacy_dashboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, getSettingsLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(
|
||||
Context context, Lifecycle lifecycle) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
final LockScreenNotificationPreferenceController notificationController =
|
||||
new LockScreenNotificationPreferenceController(context,
|
||||
KEY_LOCK_SCREEN_NOTIFICATIONS,
|
||||
KEY_WORK_PROFILE_CATEGORY,
|
||||
KEY_NOTIFICATION_WORK_PROFILE_NOTIFICATIONS);
|
||||
if (lifecycle != null) {
|
||||
lifecycle.addObserver(notificationController);
|
||||
}
|
||||
controllers.add(notificationController);
|
||||
|
||||
return controllers;
|
||||
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
@@ -64,5 +94,11 @@ public class PrivacyDashboardFragment extends DashboardFragment {
|
||||
result.add(sir);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> createPreferenceControllers(
|
||||
Context context) {
|
||||
return buildPreferenceControllers(context, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ public class SettingsSliceProvider extends SliceProvider {
|
||||
try {
|
||||
sliceData = mSlicesDatabaseAccessor.getSliceDataFromUri(uri);
|
||||
} catch (IllegalStateException e) {
|
||||
Log.d(TAG, "Could not create slicedata for uri: " + uri);
|
||||
Log.d(TAG, "Could not create slicedata for uri: " + uri, e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.slices;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package com.android.settings.widget;
|
||||
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent
|
||||
.ACTION_OPEN_APP_NOTIFICATION_SETTING;
|
||||
import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_OPEN_APP_NOTIFICATION_SETTING;
|
||||
|
||||
import android.annotation.IdRes;
|
||||
import android.annotation.UserIdInt;
|
||||
@@ -48,11 +47,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.applications.appinfo.AppInfoDashboardFragment;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@@ -26,7 +26,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import androidx.core.content.res.TypedArrayUtils;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
/**
|
||||
* Preference that presents a button with two states(On vs Off)
|
||||
|
||||
@@ -54,7 +54,6 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.core.PreferenceControllerMixin;
|
||||
import com.android.settings.widget.ActionButtonPreference;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
@@ -68,6 +67,7 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||
import com.android.settingslib.core.lifecycle.events.OnPause;
|
||||
import com.android.settingslib.core.lifecycle.events.OnResume;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
import com.android.settingslib.wifi.AccessPoint;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
|
||||
@@ -6,4 +6,5 @@ com.android.settings.password.ChooseLockPattern$SaveAndFinishWorker
|
||||
com.android.settings.RestrictedListPreference$RestrictedListPreferenceDialogFragment
|
||||
com.android.settings.password.ConfirmDeviceCredentialBaseFragment$LastTryDialog
|
||||
com.android.settings.password.CredentialCheckResultTracker
|
||||
com.android.settings.dashboard.profileselector.ProfileSelectDialog
|
||||
com.android.settings.dashboard.profileselector.ProfileSelectDialog
|
||||
com.android.settings.panel.PanelFragment
|
||||
@@ -18,8 +18,10 @@ package com.android.settings;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -37,6 +39,7 @@ import androidx.preference.PreferenceScreen;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.SettingsShadowResources;
|
||||
import com.android.settings.widget.WorkOnlyCategory;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -174,6 +177,20 @@ public class SettingsPreferenceFragmentTest {
|
||||
// no crash
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAvailablePrefs_selfAvialbalePreferenceNotAvailable_shouldHidePreference() {
|
||||
doReturn(mPreferenceScreen).when(mFragment).getPreferenceScreen();
|
||||
final WorkOnlyCategory workOnlyCategory = mock(WorkOnlyCategory.class);
|
||||
when(mPreferenceScreen.getPreferenceCount()).thenReturn(1);
|
||||
when(mPreferenceScreen.getPreference(0)).thenReturn(workOnlyCategory);
|
||||
when(workOnlyCategory.isAvailable(any(Context.class))).thenReturn(false);
|
||||
|
||||
mFragment.checkAvailablePrefs(mPreferenceScreen);
|
||||
|
||||
verify(mPreferenceScreen, never()).removePreference(workOnlyCategory);
|
||||
verify(workOnlyCategory).setVisible(false);
|
||||
}
|
||||
|
||||
public static class TestFragment extends SettingsPreferenceFragment {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,11 +35,11 @@ import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settingslib.accounts.AuthenticatorHelper;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -51,12 +51,12 @@ import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowAccountManager;
|
||||
import com.android.settings.testutils.shadow.ShadowContentResolver;
|
||||
import com.android.settings.testutils.shadow.ShadowDevicePolicyManager;
|
||||
import com.android.settings.testutils.shadow.ShadowUserManager;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState;
|
||||
import com.android.settingslib.applications.instantapps.InstantAppDataProvider;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user