Snap for 8183382 from d23672a469 to tm-release
Change-Id: I9e52c24250544eca3dfa5d668e6e47c9c4f2a0ce
This commit is contained in:
@@ -2942,24 +2942,6 @@
|
|||||||
android:value="true" />
|
android:value="true" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".dream.DreamSetupActivity"
|
|
||||||
android:exported="true"
|
|
||||||
android:immersive="true"
|
|
||||||
android:theme="@style/SudThemeGlif.DayNight"
|
|
||||||
android:icon="@drawable/ic_settings_display">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
|
||||||
<category android:name="com.android.settings.suggested.category.SCREEN_SAVER"/>
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="com.android.settings.is_supported"
|
|
||||||
android:resource="@bool/dream_setup_supported"/>
|
|
||||||
<meta-data android:name="com.android.settings.title"
|
|
||||||
android:resource="@string/dream_setup_title"/>
|
|
||||||
<meta-data android:name="com.android.settings.summary"
|
|
||||||
android:resource="@string/dream_setup_description"/>
|
|
||||||
<meta-data android:name="com.android.settings.icon_tintable" android:value="true"/>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="Settings$UserSettingsActivity"
|
android:name="Settings$UserSettingsActivity"
|
||||||
android:label="@string/user_settings_title"
|
android:label="@string/user_settings_title"
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2022 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.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<com.google.android.setupdesign.GlifLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:id="@+id/setup_wizard_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:icon="@drawable/ic_settings_display"
|
|
||||||
app:sucHeaderText="@string/dream_setup_title"
|
|
||||||
app:sudDescriptionText="@string/dream_setup_description">
|
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/dream_container"
|
|
||||||
style="@style/SudContentFrame"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/dream_setup_list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
</com.google.android.setupdesign.GlifLayout>
|
|
||||||
@@ -491,6 +491,12 @@
|
|||||||
<!-- Category for the app's locale picker activity. [CHAR LIMIT=50]-->
|
<!-- Category for the app's locale picker activity. [CHAR LIMIT=50]-->
|
||||||
<string name="all_supported_app_locales_title">All languages</string>
|
<string name="all_supported_app_locales_title">All languages</string>
|
||||||
|
|
||||||
|
<!-- Title for preference of the system default locale. [CHAR LIMIT=50]-->
|
||||||
|
<string name="preference_of_system_locale_title">System language</string>
|
||||||
|
|
||||||
|
<!-- Summary for preference of the system default locale. [CHAR LIMIT=50]-->
|
||||||
|
<string name="preference_of_system_locale_summary">System default - <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
||||||
<string name="no_multiple_language_supported">The app is set to <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g> by default and doesn\u2019t support multiple languages.</string>
|
<string name="no_multiple_language_supported">The app is set to <xliff:g id="default_language" example="English (United States)">%1$s</xliff:g> by default and doesn\u2019t support multiple languages.</string>
|
||||||
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
||||||
@@ -597,7 +603,7 @@
|
|||||||
<string name="date_and_time_settings_title_setup_wizard">Set date and time</string>
|
<string name="date_and_time_settings_title_setup_wizard">Set date and time</string>
|
||||||
<!-- Main Settings screen setting option summary text for the item to go into the date and time settings. -->
|
<!-- Main Settings screen setting option summary text for the item to go into the date and time settings. -->
|
||||||
<string name="date_and_time_settings_summary">Set date, time, time zone, & formats</string>
|
<string name="date_and_time_settings_summary">Set date, time, time zone, & formats</string>
|
||||||
<!-- Date & time setting screen setting switch title: whether the system clock (UTC time) should be determined automatically [CHAR LIMIT=100] -->
|
<!-- Date & time setting screen setting switch title: whether the system clock (Unix epoch time) should be determined automatically [CHAR LIMIT=100] -->
|
||||||
<string name="date_time_auto">Set time automatically</string>
|
<string name="date_time_auto">Set time automatically</string>
|
||||||
<!-- Date & time setting screen setting switch title: whether the time zone should be determined automatically [CHAR LIMIT=100] -->
|
<!-- Date & time setting screen setting switch title: whether the time zone should be determined automatically [CHAR LIMIT=100] -->
|
||||||
<string name="zone_auto_title">Set time zone automatically</string>
|
<string name="zone_auto_title">Set time zone automatically</string>
|
||||||
@@ -5248,9 +5254,11 @@
|
|||||||
<string name="accessibility_screen_magnification_short_summary">Tap 3 times to zoom</string>
|
<string name="accessibility_screen_magnification_short_summary">Tap 3 times to zoom</string>
|
||||||
<!-- Short summary for nav bar Magnification. Tells the user that this feature allows the user to magnify the screen using a button in the nav bar -->
|
<!-- Short summary for nav bar Magnification. Tells the user that this feature allows the user to magnify the screen using a button in the nav bar -->
|
||||||
<string name="accessibility_screen_magnification_navbar_short_summary">Tap a button to zoom</string>
|
<string name="accessibility_screen_magnification_navbar_short_summary">Tap a button to zoom</string>
|
||||||
|
<!-- Intro for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
|
||||||
|
<string name="accessibility_screen_magnification_intro_text">Quickly zoom in on the screen to make content larger</string>
|
||||||
<!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
|
<!-- Summary for the accessibility preference screen to enable screen magnification gestures. [CHAR LIMIT=none] -->
|
||||||
<string name="accessibility_screen_magnification_summary">
|
<string name="accessibility_screen_magnification_summary">
|
||||||
<![CDATA[Quickly zoom in on the screen to make content larger.<br/><br/>
|
<![CDATA[
|
||||||
<b>To zoom in:</b><br/>
|
<b>To zoom in:</b><br/>
|
||||||
{0,number,integer}. Use shortcut to start magnification<br/>
|
{0,number,integer}. Use shortcut to start magnification<br/>
|
||||||
{1,number,integer}. Tap the screen<br/>
|
{1,number,integer}. Tap the screen<br/>
|
||||||
@@ -5258,10 +5266,11 @@
|
|||||||
{3,number,integer}. Pinch with 2 fingers to adjust zoom<br/>
|
{3,number,integer}. Pinch with 2 fingers to adjust zoom<br/>
|
||||||
{4,number,integer}. Use shortcut to stop magnification<br/><br/>
|
{4,number,integer}. Use shortcut to stop magnification<br/><br/>
|
||||||
<b>To zoom in temporarily:</b><br/>
|
<b>To zoom in temporarily:</b><br/>
|
||||||
{0,number,integer}. Use shortcut to start magnification<br/>
|
{0,number,integer}. Make sure your magnification type is set to full screen<br/>
|
||||||
{1,number,integer}. Touch & hold anywhere on the screen<br/>
|
{1,number,integer}. Use shortcut to start magnification<br/>
|
||||||
{2,number,integer}. Drag finger to move around screen<br/>
|
{2,number,integer}. Touch & hold anywhere on the screen<br/>
|
||||||
{3,number,integer}. Lift finger to stop magnification
|
{3,number,integer}. Drag finger to move around screen<br/>
|
||||||
|
{4,number,integer}. Lift finger to stop magnification
|
||||||
]]>
|
]]>
|
||||||
</string>
|
</string>
|
||||||
<!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
|
<!-- Summary for the accessibility preference screen to enable screen magnification via the nav bar. [CHAR LIMIT=none] -->
|
||||||
@@ -5386,6 +5395,8 @@
|
|||||||
<string name="accessibility_button_high_label">Non-transparent</string>
|
<string name="accessibility_button_high_label">Non-transparent</string>
|
||||||
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
|
<string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
|
||||||
|
<!-- Summary for the accessibility preference to high contrast text. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_toggle_high_text_contrast_preference_summary">Change text color to black or white. Maximizes contrast with the background.</string>
|
||||||
<!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference to auto update screen magnification. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_toggle_screen_magnification_auto_update_preference_title">Auto
|
<string name="accessibility_toggle_screen_magnification_auto_update_preference_title">Auto
|
||||||
update screen magnification</string>
|
update screen magnification</string>
|
||||||
@@ -5428,7 +5439,9 @@
|
|||||||
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
|
||||||
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
<!-- 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>
|
<string name="accessibility_control_timeout_preference_summary">This timing preference isn\u2019t supported by all apps</string>
|
||||||
|
<!-- Intro text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_control_timeout_preference_intro_text">Choose how long to show temporary messages that ask you to take action</string>
|
||||||
|
|
||||||
<!-- Title for accessibility preference to choose long-press delay i.e. timeout before it is detected. [CHAR LIMIT=35] -->
|
<!-- 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>
|
<string name="accessibility_long_press_timeout_preference_title">Touch & hold delay</string>
|
||||||
@@ -5438,14 +5451,15 @@
|
|||||||
<string name="accessibility_display_inversion_switch_title">Use color inversion</string>
|
<string name="accessibility_display_inversion_switch_title">Use color inversion</string>
|
||||||
<!-- Title for accessibility shortcut preference for color inversion. [CHAR LIMIT=60] -->
|
<!-- Title for accessibility shortcut preference for color inversion. [CHAR LIMIT=60] -->
|
||||||
<string name="accessibility_display_inversion_shortcut_title">Color inversion shortcut</string>
|
<string name="accessibility_display_inversion_shortcut_title">Color inversion shortcut</string>
|
||||||
|
<!-- Intro for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_display_inversion_preference_intro_text">Color inversion turns light screens dark. It also turns dark screens light.</string>
|
||||||
<!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
|
<!-- Subtitle for the accessibility preference to configure display color inversion. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_display_inversion_preference_subtitle">
|
<string name="accessibility_display_inversion_preference_subtitle">
|
||||||
<![CDATA[Color inversion turns light screens dark.<br/><br/>
|
<![CDATA[<b>Keep in mind</b><br/>
|
||||||
Note:
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>\u00a0Color inversion also turns dark screens light.</li>
|
<li>\u00a0Colors will change in media and images</li>
|
||||||
<li>\u00a0Colors will change in media and images.</li>
|
<li>\u00a0Color inversion works on all apps</li>
|
||||||
<li>\u00a0Dark theme can be used to display a dark background. Dark theme works with supported apps. Color inversion works on all apps.</li>
|
<li>\u00a0To display a dark background, Dark theme can be used instead</li>
|
||||||
</ol>
|
</ol>
|
||||||
]]>
|
]]>
|
||||||
</string>
|
</string>
|
||||||
@@ -5455,10 +5469,12 @@
|
|||||||
<string name="accessibility_autoclick_about_title">About autoclick (dwell timing)</string>
|
<string name="accessibility_autoclick_about_title">About autoclick (dwell timing)</string>
|
||||||
<!-- Accessibility dwell timing footer link content description [CHAR LIMIT=NONE] -->
|
<!-- Accessibility dwell timing footer link content description [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_autoclick_footer_learn_more_content_description">Learn more about autoclick (dwell timing)</string>
|
<string name="accessibility_autoclick_footer_learn_more_content_description">Learn more about autoclick (dwell timing)</string>
|
||||||
<!-- Footer text to explain what autoclick does -->
|
<!-- Intro text to explain what autoclick does. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_autoclick_description">Autoclick works with a connected mouse. You can set the mouse cursor to click automatically when the cursor stops moving for a certain amount of time.</string>
|
<string name="accessibility_autoclick_intro_text">You can set a connected mouse to click automatically when the cursor stops moving for a certain amount of time</string>
|
||||||
|
<!-- Footer text to explain what autoclick does. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_autoclick_description">Autoclick can be helpful if clicking the mouse is difficult</string>
|
||||||
<!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=50] -->
|
<!-- Option heading to leave the auto click requirement for accessibility users at its default level. [CHAR LIMIT=50] -->
|
||||||
<string name="accessibility_autoclick_default_title">Off</string>
|
<string name="accessibility_autoclick_default_title">Autoclick off</string>
|
||||||
<!-- Option heading to leave the auto click requirement for accessibility users at its short level. [CHAR LIMIT=35] -->
|
<!-- Option heading to leave the auto click requirement for accessibility users at its short level. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_autoclick_short_title">Short</string>
|
<string name="accessibility_autoclick_short_title">Short</string>
|
||||||
<!-- Option summary text for the auto click delay 0.2 seconds radio button. [CHAR LIMIT=35] -->
|
<!-- Option summary text for the auto click delay 0.2 seconds radio button. [CHAR LIMIT=35] -->
|
||||||
@@ -5511,6 +5527,10 @@
|
|||||||
<string name="accessibility_service_quick_settings_tooltips_content"><xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
<string name="accessibility_service_quick_settings_tooltips_content"><xliff:g id="accessibility_app_name" example="TalkBack">%1$s</xliff:g> added to Quick Settings. Swipe down to turn it on or off anytime.</string>
|
||||||
<!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
|
<!-- Used in the accessibility action for accessibility quick settings tooltips to dismiss. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_quick_settings_tooltips_dismiss">Dismiss</string>
|
<string name="accessibility_quick_settings_tooltips_dismiss">Dismiss</string>
|
||||||
|
<!-- Intro for color correction settings screen to control turning on/off the feature entirely. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_daltonizer_about_intro_text" product="default">Adjust how colors display on your phone</string>
|
||||||
|
<!-- Intro for color correction settings screen to control turning on/off the feature entirely. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_daltonizer_about_intro_text" product="tablet">Adjust how colors display on your tablet</string>
|
||||||
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
|
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely [CHAR LIMIT=60] -->
|
||||||
<string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
|
<string name="accessibility_daltonizer_primary_switch_title">Use color correction</string>
|
||||||
<!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
|
<!-- Title for accessibility shortcut preference for color correction. [CHAR LIMIT=60] -->
|
||||||
@@ -5590,22 +5610,20 @@
|
|||||||
|
|
||||||
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
|
<!-- Title for the preference to show a tile for a particular feature in the Quick Settings pane. [CHAR LIMIT=NONE] -->
|
||||||
<string name="enable_quick_setting">Show in Quick Settings</string>
|
<string name="enable_quick_setting">Show in Quick Settings</string>
|
||||||
<!-- Title for the preference to configure the type of color space correction to apply. [CHAR LIMIT=NONE] -->
|
|
||||||
<string name="daltonizer_type">Correction mode</string>
|
|
||||||
<!-- Title shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
<!-- Title shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_deuteranomaly_title">Deuteranomaly</string>
|
<string name="daltonizer_mode_deuteranomaly_title">Red-green</string>
|
||||||
<!-- Title shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
<!-- Title shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_protanomaly_title">Protanomaly</string>
|
<string name="daltonizer_mode_protanomaly_title">Red-green</string>
|
||||||
<!-- Title shown for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
|
<!-- Title shown for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_tritanomaly_title">Tritanomaly</string>
|
<string name="daltonizer_mode_tritanomaly_title">Blue-yellow</string>
|
||||||
<!-- Title shown for grayscale [CHAR LIMIT=45] -->
|
<!-- Title shown for grayscale [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_grayscale_title">Grayscale</string>
|
<string name="daltonizer_mode_grayscale_title">Grayscale</string>
|
||||||
<!-- Summary shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
<!-- Summary shown for deuteranomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_deuteranomaly_summary">Red-green</string>
|
<string name="daltonizer_mode_deuteranomaly_summary">Green weak, deuteranomaly</string>
|
||||||
<!-- Summary shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
<!-- Summary shown for protanomaly (red-green color blindness) [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_protanomaly_summary">Red-green</string>
|
<string name="daltonizer_mode_protanomaly_summary">Red weak, protanomaly</string>
|
||||||
<!-- Summary shown for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
|
<!-- Summary shown for tritanomaly (blue-yellow color blindness) [CHAR LIMIT=45] -->
|
||||||
<string name="daltonizer_mode_tritanomaly_summary">Blue-yellow</string>
|
<string name="daltonizer_mode_tritanomaly_summary">Tritanomaly</string>
|
||||||
|
|
||||||
<!-- Title for the accessibility preference of the Extra Dim/Reduce Brightness feature that dims your screen. [CHAR LIMIT=NONE] -->
|
<!-- Title for the accessibility preference of the Extra Dim/Reduce Brightness feature that dims your screen. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_preference_title">Extra dim</string>
|
<string name="reduce_bright_colors_preference_title">Extra dim</string>
|
||||||
@@ -5619,10 +5637,11 @@
|
|||||||
<string name="reduce_bright_colors_preference_summary" product="default">Dim screen beyond your phone\u2019s minimum brightness</string>
|
<string name="reduce_bright_colors_preference_summary" product="default">Dim screen beyond your phone\u2019s minimum brightness</string>
|
||||||
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
<!-- Summary for the accessibility preference to configure Reduce Brightness feature. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_preference_summary" product="tablet">Dim screen beyond your tablet\u2019s minimum brightness</string>
|
<string name="reduce_bright_colors_preference_summary" product="tablet">Dim screen beyond your tablet\u2019s minimum brightness</string>
|
||||||
|
<!-- Intro that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="reduce_bright_colors_preference_intro_text">Make your screen dimmer so it\u2019s more comfortable to read</string>
|
||||||
<!-- Subtitle that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
|
<!-- Subtitle that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_preference_subtitle" product="default">
|
<string name="reduce_bright_colors_preference_subtitle" product="default">
|
||||||
<![CDATA[Make your screen dimmer so it\u2019s more comfortable to read.<br/><br/>
|
<![CDATA[Extra dim can be helpful when:
|
||||||
This can be helpful when:
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>\u00a0Your phone\u2019s default minimum brightness is still too bright</li>
|
<li>\u00a0Your phone\u2019s default minimum brightness is still too bright</li>
|
||||||
<li>\u00a0You\u2019re using your phone in dark situations, like at night or in a dark room before bed</li>
|
<li>\u00a0You\u2019re using your phone in dark situations, like at night or in a dark room before bed</li>
|
||||||
@@ -5631,8 +5650,7 @@
|
|||||||
</string>
|
</string>
|
||||||
<!-- Subtitle that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
|
<!-- Subtitle that describes Reduce Brightness. [CHAR LIMIT=NONE] -->
|
||||||
<string name="reduce_bright_colors_preference_subtitle" product="tablet">
|
<string name="reduce_bright_colors_preference_subtitle" product="tablet">
|
||||||
<![CDATA[Make your screen darker so it\u2019s more comfortable to read.<br/><br/>
|
<![CDATA[Extra dim can be helpful when:
|
||||||
This can be helpful when:
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>\u00a0Your tablet\u2019s default minimum brightness is still too bright</li>
|
<li>\u00a0Your tablet\u2019s default minimum brightness is still too bright</li>
|
||||||
<li>\u00a0You\u2019re using your tablet in dark situations, like at night or in a dark room before bed</li>
|
<li>\u00a0You\u2019re using your tablet in dark situations, like at night or in a dark room before bed</li>
|
||||||
|
|||||||
@@ -19,18 +19,21 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/accessibility_autoclick_preference_title">
|
android:title="@string/accessibility_autoclick_preference_title">
|
||||||
|
|
||||||
|
<com.android.settingslib.widget.TopIntroPreference
|
||||||
|
android:key="accessibility_autoclick_intro"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/accessibility_autoclick_intro_text" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.IllustrationPreference
|
<com.android.settingslib.widget.IllustrationPreference
|
||||||
android:key="accessibility_autoclick_banner"
|
android:key="accessibility_autoclick_banner"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
settings:allowDividerBelow="true"
|
|
||||||
settings:searchable="false"
|
settings:searchable="false"
|
||||||
settings:lottie_rawRes="@drawable/accessibility_dwell" />
|
settings:lottie_rawRes="@drawable/accessibility_dwell" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:key="accessibility_control_autoclick_default"
|
android:key="accessibility_control_autoclick_default"
|
||||||
android:title="@string/accessibility_autoclick_default_title"
|
android:title="@string/accessibility_autoclick_default_title" />
|
||||||
settings:allowDividerAbove="true" />
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:key="accessibility_control_autoclick_200ms"
|
android:key="accessibility_control_autoclick_200ms"
|
||||||
@@ -56,7 +59,6 @@
|
|||||||
android:layout="@layout/accessibility_autoclick_custom_seekbar"
|
android:layout="@layout/accessibility_autoclick_custom_seekbar"
|
||||||
android:selectable="false"
|
android:selectable="false"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
settings:allowDividerBelow="true"
|
|
||||||
settings:controller="com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController" />
|
settings:controller="com.android.settings.accessibility.ToggleAutoclickCustomSeekbarController" />
|
||||||
|
|
||||||
<com.android.settings.accessibility.AccessibilityFooterPreference
|
<com.android.settings.accessibility.AccessibilityFooterPreference
|
||||||
|
|||||||
@@ -21,6 +21,11 @@
|
|||||||
android:title="@string/accessibility_control_timeout_preference_title"
|
android:title="@string/accessibility_control_timeout_preference_title"
|
||||||
android:persistent="false" >
|
android:persistent="false" >
|
||||||
|
|
||||||
|
<com.android.settingslib.widget.TopIntroPreference
|
||||||
|
android:key="accessibility_control_timeout_intro"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/accessibility_control_timeout_preference_intro_text" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.IllustrationPreference
|
<com.android.settingslib.widget.IllustrationPreference
|
||||||
android:key="accessibility_control_timeout_banner"
|
android:key="accessibility_control_timeout_banner"
|
||||||
settings:lottie_rawRes="@raw/accessibility_timeout_banner"/>
|
settings:lottie_rawRes="@raw/accessibility_timeout_banner"/>
|
||||||
@@ -28,7 +33,6 @@
|
|||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:key="accessibility_control_timeout_default"
|
android:key="accessibility_control_timeout_default"
|
||||||
android:title="@string/accessibility_timeout_default"
|
android:title="@string/accessibility_timeout_default"
|
||||||
settings:allowDividerAbove="true"
|
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
|
|||||||
@@ -28,32 +28,27 @@
|
|||||||
settings:allowDividerBelow="true"
|
settings:allowDividerBelow="true"
|
||||||
settings:searchable="false"/>
|
settings:searchable="false"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:title="@string/daltonizer_type"
|
android:key="daltonizer_mode_deuteranomaly"
|
||||||
android:key="daltonizer_mode_category" >
|
android:persistent="false"
|
||||||
|
android:summary="@string/daltonizer_mode_deuteranomaly_summary"
|
||||||
|
android:title="@string/daltonizer_mode_deuteranomaly_title" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:key="daltonizer_mode_deuteranomaly"
|
android:key="daltonizer_mode_protanomaly"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:summary="@string/daltonizer_mode_deuteranomaly_summary"
|
android:summary="@string/daltonizer_mode_protanomaly_summary"
|
||||||
android:title="@string/daltonizer_mode_deuteranomaly_title" />
|
android:title="@string/daltonizer_mode_protanomaly_title" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:key="daltonizer_mode_protanomaly"
|
android:key="daltonizer_mode_tritanomaly"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:summary="@string/daltonizer_mode_protanomaly_summary"
|
android:summary="@string/daltonizer_mode_tritanomaly_summary"
|
||||||
android:title="@string/daltonizer_mode_protanomaly_title" />
|
android:title="@string/daltonizer_mode_tritanomaly_title" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
||||||
android:key="daltonizer_mode_tritanomaly"
|
android:key="daltonizer_mode_grayscale"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:summary="@string/daltonizer_mode_tritanomaly_summary"
|
android:title="@string/daltonizer_mode_grayscale_title" />
|
||||||
android:title="@string/daltonizer_mode_tritanomaly_title" />
|
|
||||||
<com.android.settingslib.widget.SelectorWithWidgetPreference
|
|
||||||
android:key="daltonizer_mode_grayscale"
|
|
||||||
android:persistent="false"
|
|
||||||
android:title="@string/daltonizer_mode_grayscale_title" />
|
|
||||||
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="toggle_high_text_contrast_preference"
|
android:key="toggle_high_text_contrast_preference"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
|
android:summary="@string/accessibility_toggle_high_text_contrast_preference_summary"
|
||||||
android:title="@string/accessibility_toggle_high_text_contrast_preference_title" />
|
android:title="@string/accessibility_toggle_high_text_contrast_preference_title" />
|
||||||
|
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
<com.android.settingslib.widget.LayoutPreference
|
||||||
|
|||||||
@@ -28,7 +28,14 @@
|
|||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="category_key_suggested_languages"
|
android:key="category_key_suggested_languages"
|
||||||
android:title="@string/suggested_app_locales_title" />
|
android:title="@string/suggested_app_locales_title" >
|
||||||
|
|
||||||
|
<com.android.settingslib.widget.RadioButtonPreference
|
||||||
|
android:key="system_default_locale"
|
||||||
|
android:title="@string/preference_of_system_locale_title"
|
||||||
|
android:order="-10000"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="category_key_all_languages"
|
android:key="category_key_all_languages"
|
||||||
|
|||||||
@@ -25,7 +25,6 @@
|
|||||||
<Preference
|
<Preference
|
||||||
android:key="phone_language"
|
android:key="phone_language"
|
||||||
android:title="@string/phone_language"
|
android:title="@string/phone_language"
|
||||||
android:icon="@drawable/ic_translate_24dp"
|
|
||||||
android:fragment="com.android.settings.localepicker.LocaleListEditor" />
|
android:fragment="com.android.settings.localepicker.LocaleListEditor" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
|||||||
@@ -100,7 +100,10 @@ public class MagnificationGesturesPreferenceController extends TogglePreferenceC
|
|||||||
extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
|
extras.putInt(AccessibilitySettings.EXTRA_TITLE_RES,
|
||||||
R.string.accessibility_screen_magnification_gestures_title);
|
R.string.accessibility_screen_magnification_gestures_title);
|
||||||
|
|
||||||
String summary = context.getString(R.string.accessibility_screen_magnification_summary);
|
String intro = context.getString(R.string.accessibility_screen_magnification_intro_text);
|
||||||
|
extras.putCharSequence(AccessibilitySettings.EXTRA_INTRO, intro);
|
||||||
|
|
||||||
|
String summary = context.getString(R.string.accessibility_screen_magnification_summary);
|
||||||
final Object[] numberArguments = {1, 2, 3, 4, 5};
|
final Object[] numberArguments = {1, 2, 3, 4, 5};
|
||||||
summary = MessageFormat.format(summary, numberArguments);
|
summary = MessageFormat.format(summary, numberArguments);
|
||||||
extras.putCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, summary);
|
extras.putCharSequence(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, summary);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
mComponentName = COLOR_INVERSION_COMPONENT_NAME;
|
mComponentName = COLOR_INVERSION_COMPONENT_NAME;
|
||||||
mPackageName = getText(R.string.accessibility_display_inversion_preference_title);
|
mPackageName = getText(R.string.accessibility_display_inversion_preference_title);
|
||||||
mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
|
mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
|
||||||
|
mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
|
||||||
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||||
.authority(getPrefContext().getPackageName())
|
.authority(getPrefContext().getPackageName())
|
||||||
.appendPath(String.valueOf(R.raw.accessibility_color_inversion_banner))
|
.appendPath(String.valueOf(R.raw.accessibility_color_inversion_banner))
|
||||||
|
|||||||
@@ -51,7 +51,10 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
|
|
||||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED;
|
||||||
private static final String KEY_PREVIEW = "daltonizer_preview";
|
private static final String KEY_PREVIEW = "daltonizer_preview";
|
||||||
private static final String KEY_CATEGORY_MODE = "daltonizer_mode_category";
|
private static final String KEY_DEUTERANOMALY = "daltonizer_mode_deuteranomaly";
|
||||||
|
private static final String KEY_PROTANOMALY = "daltonizer_mode_protanomaly";
|
||||||
|
private static final String KEY_TRITANOMEALY = "daltonizer_mode_tritanomaly";
|
||||||
|
private static final String KEY_GRAYSCALE = "daltonizer_mode_grayscale";
|
||||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||||
|
|
||||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||||
@@ -82,6 +85,7 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
mComponentName = DALTONIZER_COMPONENT_NAME;
|
mComponentName = DALTONIZER_COMPONENT_NAME;
|
||||||
mPackageName = getText(R.string.accessibility_display_daltonizer_preference_title);
|
mPackageName = getText(R.string.accessibility_display_daltonizer_preference_title);
|
||||||
mHtmlDescription = getText(R.string.accessibility_display_daltonizer_preference_subtitle);
|
mHtmlDescription = getText(R.string.accessibility_display_daltonizer_preference_subtitle);
|
||||||
|
mTopIntroTitle = getText(R.string.accessibility_daltonizer_about_intro_text);
|
||||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||||
updateFooterPreference();
|
updateFooterPreference();
|
||||||
return view;
|
return view;
|
||||||
@@ -111,9 +115,13 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
/** Customizes the order by preference key. */
|
/** Customizes the order by preference key. */
|
||||||
protected List<String> getPreferenceOrderList() {
|
protected List<String> getPreferenceOrderList() {
|
||||||
final List<String> lists = new ArrayList<>();
|
final List<String> lists = new ArrayList<>();
|
||||||
|
lists.add(KEY_TOP_INTRO_PREFERENCE);
|
||||||
lists.add(KEY_PREVIEW);
|
lists.add(KEY_PREVIEW);
|
||||||
lists.add(KEY_USE_SERVICE_PREFERENCE);
|
lists.add(KEY_USE_SERVICE_PREFERENCE);
|
||||||
lists.add(KEY_CATEGORY_MODE);
|
lists.add(KEY_DEUTERANOMALY);
|
||||||
|
lists.add(KEY_PROTANOMALY);
|
||||||
|
lists.add(KEY_TRITANOMEALY);
|
||||||
|
lists.add(KEY_GRAYSCALE);
|
||||||
lists.add(KEY_GENERAL_CATEGORY);
|
lists.add(KEY_GENERAL_CATEGORY);
|
||||||
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
|
lists.add(KEY_HTML_DESCRIPTION_PREFERENCE);
|
||||||
return lists;
|
return lists;
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre
|
|||||||
mComponentName = REDUCE_BRIGHT_COLORS_COMPONENT_NAME;
|
mComponentName = REDUCE_BRIGHT_COLORS_COMPONENT_NAME;
|
||||||
mPackageName = getText(R.string.reduce_bright_colors_preference_title);
|
mPackageName = getText(R.string.reduce_bright_colors_preference_title);
|
||||||
mHtmlDescription = getText(R.string.reduce_bright_colors_preference_subtitle);
|
mHtmlDescription = getText(R.string.reduce_bright_colors_preference_subtitle);
|
||||||
|
mTopIntroTitle = getText(R.string.reduce_bright_colors_preference_intro_text);
|
||||||
mRbcIntensityPreferenceController =
|
mRbcIntensityPreferenceController =
|
||||||
new ReduceBrightColorsIntensityPreferenceController(getContext(), KEY_INTENSITY);
|
new ReduceBrightColorsIntensityPreferenceController(getContext(), KEY_INTENSITY);
|
||||||
mRbcPersistencePreferenceController =
|
mRbcPersistencePreferenceController =
|
||||||
|
|||||||
@@ -38,8 +38,6 @@ import androidx.appcompat.app.AlertDialog;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceGroup;
|
import androidx.preference.PreferenceGroup;
|
||||||
|
|
||||||
import com.android.internal.app.LocalePicker;
|
|
||||||
import com.android.internal.app.LocalePicker.LocaleInfo;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.applications.AppInfoBase;
|
import com.android.settings.applications.AppInfoBase;
|
||||||
@@ -48,11 +46,8 @@ import com.android.settingslib.applications.AppUtils;
|
|||||||
import com.android.settingslib.widget.LayoutPreference;
|
import com.android.settingslib.widget.LayoutPreference;
|
||||||
import com.android.settingslib.widget.RadioButtonPreference;
|
import com.android.settingslib.widget.RadioButtonPreference;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,13 +61,17 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
private static final String CATEGORY_KEY_ALL_LANGUAGES =
|
private static final String CATEGORY_KEY_ALL_LANGUAGES =
|
||||||
"category_key_all_languages";
|
"category_key_all_languages";
|
||||||
private static final String KEY_APP_DESCRIPTION = "app_locale_description";
|
private static final String KEY_APP_DESCRIPTION = "app_locale_description";
|
||||||
|
@VisibleForTesting
|
||||||
|
static final String KEY_SYSTEM_DEFAULT_LOCALE = "system_default_locale";
|
||||||
|
|
||||||
private boolean mCreated = false;
|
private boolean mCreated = false;
|
||||||
private AppLocaleDetailsHelper mAppLocaleDetailsHelper;
|
@VisibleForTesting
|
||||||
|
AppLocaleDetailsHelper mAppLocaleDetailsHelper;
|
||||||
|
|
||||||
private PreferenceGroup mGroupOfSuggestedLocales;
|
private PreferenceGroup mGroupOfSuggestedLocales;
|
||||||
private PreferenceGroup mGroupOfSupportedLocales;
|
private PreferenceGroup mGroupOfSupportedLocales;
|
||||||
private LayoutPreference mPrefOfDescription;
|
private LayoutPreference mPrefOfDescription;
|
||||||
|
private RadioButtonPreference mDefaultPreference;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -85,6 +84,10 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
mGroupOfSupportedLocales =
|
mGroupOfSupportedLocales =
|
||||||
getPreferenceScreen().findPreference(CATEGORY_KEY_ALL_LANGUAGES);
|
getPreferenceScreen().findPreference(CATEGORY_KEY_ALL_LANGUAGES);
|
||||||
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
||||||
|
|
||||||
|
mDefaultPreference = (RadioButtonPreference) getPreferenceScreen()
|
||||||
|
.findPreference(KEY_SYSTEM_DEFAULT_LOCALE);
|
||||||
|
mDefaultPreference.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Override here so we don't have an empty screen
|
// Override here so we don't have an empty screen
|
||||||
@@ -104,30 +107,43 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
// Update Locales first, before refresh ui.
|
// Update Locales first, before refresh ui.
|
||||||
mAppLocaleDetailsHelper.handleAllLocalesData();
|
mAppLocaleDetailsHelper.handleAllLocalesData();
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
mDefaultPreference.setSummary(Locale.getDefault().getDisplayName(Locale.getDefault()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean refreshUi() {
|
protected boolean refreshUi() {
|
||||||
|
refreshUiInternal();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
void refreshUiInternal() {
|
||||||
if (mAppLocaleDetailsHelper.getSupportedLocales().isEmpty()) {
|
if (mAppLocaleDetailsHelper.getSupportedLocales().isEmpty()) {
|
||||||
Log.d(TAG, "No supported language.");
|
Log.d(TAG, "No supported language.");
|
||||||
mGroupOfSuggestedLocales.setVisible(false);
|
mGroupOfSuggestedLocales.setVisible(false);
|
||||||
mGroupOfSupportedLocales.setVisible(false);
|
mGroupOfSupportedLocales.setVisible(false);
|
||||||
mPrefOfDescription.setVisible(true);
|
mPrefOfDescription.setVisible(true);
|
||||||
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
||||||
Locale locale = mAppLocaleDetailsHelper.getCurrentSystemLocales().get(0);
|
|
||||||
description.setText(getContext().getString(R.string.no_multiple_language_supported,
|
description.setText(getContext().getString(R.string.no_multiple_language_supported,
|
||||||
locale.getDisplayName(locale)));
|
Locale.getDefault().getDisplayName(Locale.getDefault())));
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
resetLocalePreferences();
|
||||||
mGroupOfSuggestedLocales.removeAll();
|
|
||||||
mGroupOfSupportedLocales.removeAll();
|
|
||||||
Locale appLocale = AppLocaleDetailsHelper.getAppDefaultLocale(getContext(), mPackageName);
|
Locale appLocale = AppLocaleDetailsHelper.getAppDefaultLocale(getContext(), mPackageName);
|
||||||
|
// Sets up default locale preference.
|
||||||
|
mGroupOfSuggestedLocales.addPreference(mDefaultPreference);
|
||||||
|
mDefaultPreference.setChecked(appLocale == null);
|
||||||
|
// Sets up suggested locales of per app.
|
||||||
setLanguagesPreference(mGroupOfSuggestedLocales,
|
setLanguagesPreference(mGroupOfSuggestedLocales,
|
||||||
mAppLocaleDetailsHelper.getSuggestedLocales(), appLocale);
|
mAppLocaleDetailsHelper.getSuggestedLocales(), appLocale);
|
||||||
|
// Sets up supported locales of per app.
|
||||||
setLanguagesPreference(mGroupOfSupportedLocales,
|
setLanguagesPreference(mGroupOfSupportedLocales,
|
||||||
mAppLocaleDetailsHelper.getSupportedLocales(), appLocale);
|
mAppLocaleDetailsHelper.getSupportedLocales(), appLocale);
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
private void resetLocalePreferences() {
|
||||||
|
mGroupOfSuggestedLocales.removeAll();
|
||||||
|
mGroupOfSupportedLocales.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -142,7 +158,12 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRadioButtonClicked(RadioButtonPreference pref) {
|
public void onRadioButtonClicked(RadioButtonPreference pref) {
|
||||||
mAppLocaleDetailsHelper.setAppDefaultLocale(pref.getKey());
|
String key = pref.getKey();
|
||||||
|
if (KEY_SYSTEM_DEFAULT_LOCALE.equals(key)) {
|
||||||
|
mAppLocaleDetailsHelper.setAppDefaultLocale(LocaleList.forLanguageTags(""));
|
||||||
|
} else {
|
||||||
|
mAppLocaleDetailsHelper.setAppDefaultLocale(key);
|
||||||
|
}
|
||||||
refreshUi();
|
refreshUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +201,13 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
public static CharSequence getSummary(Context context, String packageName) {
|
public static CharSequence getSummary(Context context, String packageName) {
|
||||||
Locale appLocale =
|
Locale appLocale =
|
||||||
AppLocaleDetailsHelper.getAppDefaultLocale(context, packageName);
|
AppLocaleDetailsHelper.getAppDefaultLocale(context, packageName);
|
||||||
return appLocale == null ? "" : appLocale.getDisplayName(appLocale);
|
if (appLocale == null) {
|
||||||
|
Locale systemLocale = Locale.getDefault();
|
||||||
|
return context.getString(R.string.preference_of_system_locale_summary,
|
||||||
|
systemLocale.getDisplayName(systemLocale));
|
||||||
|
} else {
|
||||||
|
return appLocale.getDisplayName(appLocale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLanguagesPreference(PreferenceGroup group,
|
private void setLanguagesPreference(PreferenceGroup group,
|
||||||
@@ -190,9 +217,15 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Locale locale : locales) {
|
for (Locale locale : locales) {
|
||||||
|
if (locale == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
RadioButtonPreference pref = new RadioButtonPreference(getContext());
|
RadioButtonPreference pref = new RadioButtonPreference(getContext());
|
||||||
pref.setTitle(locale.getDisplayName(locale));
|
pref.setTitle(locale.getDisplayName(locale));
|
||||||
pref.setKey(locale.toLanguageTag());
|
pref.setKey(locale.toLanguageTag());
|
||||||
|
// Will never be checked if appLocale is null
|
||||||
|
// aka if there is no per-app locale
|
||||||
pref.setChecked(locale.equals(appLocale));
|
pref.setChecked(locale.equals(appLocale));
|
||||||
pref.setOnClickListener(this);
|
pref.setOnClickListener(this);
|
||||||
group.addPreference(pref);
|
group.addPreference(pref);
|
||||||
@@ -206,14 +239,17 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
private TelephonyManager mTelephonyManager;
|
private TelephonyManager mTelephonyManager;
|
||||||
private LocaleManager mLocaleManager;
|
private LocaleManager mLocaleManager;
|
||||||
|
|
||||||
private Collection<Locale> mSuggestedLocales = new ArrayList<>();
|
private Collection<Locale> mProcessedSuggestedLocales = new ArrayList<>();
|
||||||
private Collection<Locale> mSupportedLocales = new ArrayList<>();
|
private Collection<Locale> mProcessedSupportedLocales = new ArrayList<>();
|
||||||
|
|
||||||
|
private Collection<Locale> mAppSupportedLocales = new ArrayList<>();
|
||||||
|
|
||||||
AppLocaleDetailsHelper(Context context, String packageName) {
|
AppLocaleDetailsHelper(Context context, String packageName) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mPackageName = packageName;
|
mPackageName = packageName;
|
||||||
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
mTelephonyManager = context.getSystemService(TelephonyManager.class);
|
||||||
mLocaleManager = context.getSystemService(LocaleManager.class);
|
mLocaleManager = context.getSystemService(LocaleManager.class);
|
||||||
|
mAppSupportedLocales = getAppSupportedLocales();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handle suggested and supported locales for UI display. */
|
/** Handle suggested and supported locales for UI display. */
|
||||||
@@ -225,49 +261,47 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
|
|
||||||
/** Gets suggested locales in the app. */
|
/** Gets suggested locales in the app. */
|
||||||
public Collection<Locale> getSuggestedLocales() {
|
public Collection<Locale> getSuggestedLocales() {
|
||||||
return mSuggestedLocales;
|
return mProcessedSuggestedLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets supported locales in the app. */
|
/** Gets supported locales in the app. */
|
||||||
public Collection<Locale> getSupportedLocales() {
|
public Collection<Locale> getSupportedLocales() {
|
||||||
return mSupportedLocales;
|
return mProcessedSupportedLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void handleSuggestedLocales() {
|
void handleSuggestedLocales() {
|
||||||
LocaleList currentSystemLocales = getCurrentSystemLocales();
|
|
||||||
Locale appLocale = getAppDefaultLocale(mContext, mPackageName);
|
Locale appLocale = getAppDefaultLocale(mContext, mPackageName);
|
||||||
|
// 1st locale in suggested languages group.
|
||||||
|
for (Locale supportedlocale : mAppSupportedLocales) {
|
||||||
|
if (compareLocale(supportedlocale, appLocale)) {
|
||||||
|
mProcessedSuggestedLocales.add(appLocale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2nd and 3rd locale in suggested languages group.
|
||||||
String simCountry = mTelephonyManager.getSimCountryIso().toUpperCase(Locale.US);
|
String simCountry = mTelephonyManager.getSimCountryIso().toUpperCase(Locale.US);
|
||||||
String networkCountry = mTelephonyManager.getNetworkCountryIso().toUpperCase(Locale.US);
|
String networkCountry = mTelephonyManager.getNetworkCountryIso().toUpperCase(Locale.US);
|
||||||
// 1st locale in suggested languages group.
|
mAppSupportedLocales.forEach(supportedlocale -> {
|
||||||
if (appLocale != null) {
|
String localeCountry = supportedlocale.getCountry().toUpperCase(Locale.US);
|
||||||
mSuggestedLocales.add(appLocale);
|
if (!compareLocale(supportedlocale, appLocale)
|
||||||
}
|
|
||||||
// 2nd locale in suggested languages group.
|
|
||||||
final List<LocaleInfo> localeInfos = LocalePicker.getAllAssetLocales(mContext, false);
|
|
||||||
for (LocaleInfo localeInfo : localeInfos) {
|
|
||||||
Locale locale = localeInfo.getLocale();
|
|
||||||
String localeCountry = locale.getCountry().toUpperCase(Locale.US);
|
|
||||||
if (!compareLocale(locale, appLocale)
|
|
||||||
&& isCountrySuggestedLocale(localeCountry, simCountry, networkCountry)) {
|
&& isCountrySuggestedLocale(localeCountry, simCountry, networkCountry)) {
|
||||||
mSuggestedLocales.add(locale);
|
mProcessedSuggestedLocales.add(supportedlocale);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Other locales in suggested languages group.
|
// Other locales in suggested languages group.
|
||||||
for (int i = 0; i < currentSystemLocales.size(); i++) {
|
Collection<Locale> supportedSystemLocales = new ArrayList<>();
|
||||||
Locale locale = currentSystemLocales.get(i);
|
getCurrentSystemLocales().forEach(systemLocale -> {
|
||||||
boolean isInSuggestedLocales = false;
|
mAppSupportedLocales.forEach(supportedLocale -> {
|
||||||
for (int j = 0; j < mSuggestedLocales.size(); j++) {
|
if (compareLocale(systemLocale, supportedLocale)) {
|
||||||
Locale suggestedLocale = Iterables.get(mSuggestedLocales, j);
|
supportedSystemLocales.add(supportedLocale);
|
||||||
if (compareLocale(locale, suggestedLocale)) {
|
|
||||||
isInSuggestedLocales = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
if (!isInSuggestedLocales) {
|
});
|
||||||
mSuggestedLocales.add(locale);
|
supportedSystemLocales.removeAll(mProcessedSuggestedLocales);
|
||||||
}
|
mProcessedSuggestedLocales.addAll(supportedSystemLocales);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -290,26 +324,34 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void handleSupportedLocales() {
|
void handleSupportedLocales() {
|
||||||
LocaleList localeList = getPackageLocales();
|
mProcessedSupportedLocales.addAll(mAppSupportedLocales);
|
||||||
if (localeList == null) {
|
|
||||||
String[] languages = getAssetSystemLocales();
|
|
||||||
for (String language : languages) {
|
|
||||||
mSupportedLocales.add(Locale.forLanguageTag(language));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (int i = 0; i < localeList.size(); i++) {
|
|
||||||
mSupportedLocales.add(localeList.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mSuggestedLocales != null || !mSuggestedLocales.isEmpty()) {
|
if (mProcessedSuggestedLocales != null || !mProcessedSuggestedLocales.isEmpty()) {
|
||||||
mSupportedLocales.removeAll(mSuggestedLocales);
|
mProcessedSuggestedLocales.retainAll(mProcessedSupportedLocales);
|
||||||
|
mProcessedSupportedLocales.removeAll(mProcessedSuggestedLocales);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearLocalesData() {
|
private void clearLocalesData() {
|
||||||
mSuggestedLocales.clear();
|
mProcessedSuggestedLocales.clear();
|
||||||
mSupportedLocales.clear();
|
mProcessedSupportedLocales.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Collection<Locale> getAppSupportedLocales() {
|
||||||
|
Collection<Locale> appSupportedLocales = new ArrayList<>();
|
||||||
|
LocaleList localeList = getPackageLocales();
|
||||||
|
|
||||||
|
if (localeList != null && localeList.size() > 0) {
|
||||||
|
for (int i = 0; i < localeList.size(); i++) {
|
||||||
|
appSupportedLocales.add(localeList.get(i));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String[] languages = getAssetLocales();
|
||||||
|
for (String language : languages) {
|
||||||
|
appSupportedLocales.add(Locale.forLanguageTag(language));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return appSupportedLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets per app's default locale */
|
/** Gets per app's default locale */
|
||||||
@@ -317,8 +359,8 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
LocaleManager localeManager = context.getSystemService(LocaleManager.class);
|
LocaleManager localeManager = context.getSystemService(LocaleManager.class);
|
||||||
try {
|
try {
|
||||||
LocaleList localeList = (localeManager == null)
|
LocaleList localeList = (localeManager == null)
|
||||||
? new LocaleList() : localeManager.getApplicationLocales(packageName);
|
? null : localeManager.getApplicationLocales(packageName);
|
||||||
return localeList.isEmpty() ? null : localeList.get(0);
|
return localeList == null ? null : localeList.get(0);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Log.w(TAG, "package name : " + packageName + " is not correct. " + e);
|
Log.w(TAG, "package name : " + packageName + " is not correct. " + e);
|
||||||
}
|
}
|
||||||
@@ -344,12 +386,17 @@ public class AppLocaleDetails extends AppInfoBase implements RadioButtonPreferen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
LocaleList getCurrentSystemLocales() {
|
Collection<Locale> getCurrentSystemLocales() {
|
||||||
return Resources.getSystem().getConfiguration().getLocales();
|
LocaleList localeList = Resources.getSystem().getConfiguration().getLocales();
|
||||||
|
Collection<Locale> systemLocales = new ArrayList<>();
|
||||||
|
for (int i = 0; i < localeList.size(); i++) {
|
||||||
|
systemLocales.add(localeList.get(i));
|
||||||
|
}
|
||||||
|
return systemLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
String[] getAssetSystemLocales() {
|
String[] getAssetLocales() {
|
||||||
try {
|
try {
|
||||||
PackageManager packageManager = mContext.getPackageManager();
|
PackageManager packageManager = mContext.getPackageManager();
|
||||||
return packageManager.getResourcesForApplication(
|
return packageManager.getResourcesForApplication(
|
||||||
|
|||||||
@@ -171,11 +171,13 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
intent.setAction(action);
|
intent.setAction(action);
|
||||||
}
|
}
|
||||||
// Register the rule for injected apps.
|
// Register the rule for injected apps.
|
||||||
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
|
if (fragment instanceof TopLevelSettings) {
|
||||||
mContext,
|
ActivityEmbeddingRulesController.registerTwoPanePairRuleForSettingsHome(
|
||||||
new ComponentName(tile.getPackageName(), tile.getComponentName()),
|
mContext,
|
||||||
action,
|
new ComponentName(tile.getPackageName(), tile.getComponentName()),
|
||||||
true /* clearTop */);
|
action,
|
||||||
|
true /* clearTop */);
|
||||||
|
}
|
||||||
pref.setOnPreferenceClickListener(preference -> {
|
pref.setOnPreferenceClickListener(preference -> {
|
||||||
TopLevelHighlightMixin highlightMixin = null;
|
TopLevelHighlightMixin highlightMixin = null;
|
||||||
if (fragment instanceof TopLevelSettings
|
if (fragment instanceof TopLevelSettings
|
||||||
@@ -442,11 +444,6 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
|||||||
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
|
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
|
||||||
mMetricsFeatureProvider.logStartedIntent(intent, sourceMetricCategory);
|
mMetricsFeatureProvider.logStartedIntent(intent, sourceMetricCategory);
|
||||||
|
|
||||||
//TODO(b/201970810): Add test cases.
|
|
||||||
if (tile.isNewTask(mContext)) {
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tile.userHandle == null || tile.isPrimaryProfileOnly()) {
|
if (tile.userHandle == null || tile.isPrimaryProfileOnly()) {
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
} else if (tile.userHandle.size() == 1) {
|
} else if (tile.userHandle.size() == 1) {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class ProfileSelectDialog extends DialogFragment implements OnClickListen
|
|||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
final UserHandle user = mSelectedTile.userHandle.get(which);
|
final UserHandle user = mSelectedTile.userHandle.get(which);
|
||||||
// Show menu on top level items.
|
// Show menu on top level items.
|
||||||
final Intent intent = mSelectedTile.getIntent();
|
final Intent intent = new Intent(mSelectedTile.getIntent());
|
||||||
FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider()
|
FeatureFactory.getFactory(getContext()).getMetricsFeatureProvider()
|
||||||
.logStartedIntentWithProfile(intent, mSourceMetricCategory,
|
.logStartedIntentWithProfile(intent, mSourceMetricCategory,
|
||||||
which == 1 /* isWorkProfile */);
|
which == 1 /* isWorkProfile */);
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
/** Grid layout manager that calculates the number of columns for the screen size. */
|
/** Grid layout manager that calculates the number of columns for the screen size. */
|
||||||
final class AutoFitGridLayoutManager extends GridLayoutManager {
|
public final class AutoFitGridLayoutManager extends GridLayoutManager {
|
||||||
private final float mColumnWidth;
|
private final float mColumnWidth;
|
||||||
|
|
||||||
AutoFitGridLayoutManager(Context context) {
|
public AutoFitGridLayoutManager(Context context) {
|
||||||
super(context, /* spanCount= */ 1);
|
super(context, /* spanCount= */ 1);
|
||||||
this.mColumnWidth = context
|
this.mColumnWidth = context
|
||||||
.getResources()
|
.getResources()
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* RecyclerView adapter which displays list of items for the user to select.
|
* RecyclerView adapter which displays list of items for the user to select.
|
||||||
*/
|
*/
|
||||||
class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
private final List<IDreamItem> mItemList;
|
private final List<IDreamItem> mItemList;
|
||||||
private int mLastSelectedPos = -1;
|
private int mLastSelectedPos = -1;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ class DreamAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DreamAdapter(List<IDreamItem> itemList) {
|
public DreamAdapter(List<IDreamItem> itemList) {
|
||||||
mItemList = itemList;
|
mItemList = itemList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,177 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2022 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.dream;
|
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.SettingsActivity;
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
|
||||||
import com.android.settingslib.dream.DreamBackend;
|
|
||||||
|
|
||||||
import com.google.android.setupcompat.template.FooterBarMixin;
|
|
||||||
import com.google.android.setupcompat.template.FooterButton;
|
|
||||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
|
||||||
import com.google.android.setupdesign.GlifLayout;
|
|
||||||
import com.google.android.setupdesign.util.ThemeHelper;
|
|
||||||
import com.google.android.setupdesign.util.ThemeResolver;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The setup activity for dreams which is displayed during setup wizard.
|
|
||||||
*/
|
|
||||||
public class DreamSetupActivity extends SettingsActivity {
|
|
||||||
@Override
|
|
||||||
public Intent getIntent() {
|
|
||||||
Intent modIntent = new Intent(super.getIntent());
|
|
||||||
modIntent.putExtra(EXTRA_SHOW_FRAGMENT, DreamSetupFragment.class.getName());
|
|
||||||
return modIntent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isValidFragment(String fragmentName) {
|
|
||||||
return DreamSetupFragment.class.getName().equals(fragmentName);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstance) {
|
|
||||||
setTheme(ThemeResolver.getDefault().resolve(getIntent()));
|
|
||||||
ThemeHelper.trySetDynamicColor(this);
|
|
||||||
super.onCreate(savedInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isToolbarEnabled() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fragment used to control the active dream.
|
|
||||||
*/
|
|
||||||
public static class DreamSetupFragment extends SettingsPreferenceFragment {
|
|
||||||
private DreamBackend mBackend;
|
|
||||||
private DreamBackend.DreamInfo mActiveDream;
|
|
||||||
private FooterButton mFooterButton;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.DREAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
return inflater.inflate(R.layout.dream_setup_layout, container, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
mBackend = DreamBackend.getInstance(getContext());
|
|
||||||
final List<DreamBackend.DreamInfo> dreamInfos = mBackend.getDreamInfos();
|
|
||||||
mActiveDream = dreamInfos.stream().filter(d -> d.isActive).findFirst().orElse(null);
|
|
||||||
DreamAdapter dreamAdapter = new DreamAdapter(dreamInfos.stream()
|
|
||||||
.map(DreamItem::new)
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
|
|
||||||
final RecyclerView recyclerView = view.findViewById(R.id.dream_setup_list);
|
|
||||||
recyclerView.setLayoutManager(new AutoFitGridLayoutManager(getContext()));
|
|
||||||
recyclerView.setHasFixedSize(true);
|
|
||||||
recyclerView.setAdapter(dreamAdapter);
|
|
||||||
|
|
||||||
final GlifLayout layout = view.findViewById(R.id.setup_wizard_layout);
|
|
||||||
final FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);
|
|
||||||
mFooterButton = new FooterButton.Builder(getContext())
|
|
||||||
.setListener(this::onPrimaryButtonClicked)
|
|
||||||
.setButtonType(FooterButton.ButtonType.NEXT)
|
|
||||||
.setTheme(R.style.SudGlifButton_Primary)
|
|
||||||
.build();
|
|
||||||
updateFooterButtonText();
|
|
||||||
mixin.setPrimaryButton(mFooterButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateFooterButtonText() {
|
|
||||||
final int res = canCustomizeDream() ? R.string.wizard_next : R.string.wizard_finish;
|
|
||||||
mFooterButton.setText(getContext().getString(res));
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean canCustomizeDream() {
|
|
||||||
return mActiveDream != null && mActiveDream.settingsComponentName != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPrimaryButtonClicked(View view) {
|
|
||||||
if (canCustomizeDream()) {
|
|
||||||
final Intent intent = new Intent().setComponent(mActiveDream.settingsComponentName);
|
|
||||||
WizardManagerHelper.copyWizardManagerExtras(getIntent(), intent);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use RESULT_CANCELED here so that the user may go back and change this if they wish.
|
|
||||||
setResult(RESULT_CANCELED);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DreamItem implements IDreamItem {
|
|
||||||
private final DreamBackend.DreamInfo mDreamInfo;
|
|
||||||
|
|
||||||
private DreamItem(DreamBackend.DreamInfo dreamInfo) {
|
|
||||||
mDreamInfo = dreamInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence getTitle() {
|
|
||||||
return mDreamInfo.caption;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Drawable getIcon() {
|
|
||||||
return mDreamInfo.icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClicked() {
|
|
||||||
mActiveDream = mDreamInfo;
|
|
||||||
mBackend.setActiveDream(mDreamInfo.componentName);
|
|
||||||
updateFooterButtonText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Drawable getPreviewImage() {
|
|
||||||
return mDreamInfo.previewImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActive() {
|
|
||||||
if (mActiveDream == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return mDreamInfo.componentName.equals(mActiveDream.componentName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,10 @@ package com.android.settings.dream;
|
|||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
interface IDreamItem {
|
/**
|
||||||
|
* Interface representing a dream item to be displayed.
|
||||||
|
*/
|
||||||
|
public interface IDreamItem {
|
||||||
CharSequence getTitle();
|
CharSequence getTitle();
|
||||||
|
|
||||||
Drawable getIcon();
|
Drawable getIcon();
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||||
|
import com.android.settings.overlay.FeatureFactory;
|
||||||
import com.android.settingslib.applications.RecentAppOpsAccess;
|
import com.android.settingslib.applications.RecentAppOpsAccess;
|
||||||
|
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||||
import com.android.settingslib.widget.AppPreference;
|
import com.android.settingslib.widget.AppPreference;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -37,8 +39,10 @@ import java.util.List;
|
|||||||
public class RecentLocationAccessSeeAllPreferenceController
|
public class RecentLocationAccessSeeAllPreferenceController
|
||||||
extends LocationBasePreferenceController {
|
extends LocationBasePreferenceController {
|
||||||
|
|
||||||
private PreferenceScreen mCategoryAllRecentLocationAccess;
|
|
||||||
private final RecentAppOpsAccess mRecentLocationAccesses;
|
private final RecentAppOpsAccess mRecentLocationAccesses;
|
||||||
|
|
||||||
|
private PreferenceScreen mCategoryAllRecentLocationAccess;
|
||||||
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
private boolean mShowSystem = false;
|
private boolean mShowSystem = false;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
|
||||||
@@ -47,6 +51,7 @@ public class RecentLocationAccessSeeAllPreferenceController
|
|||||||
mShowSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
mShowSystem = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
Settings.Secure.LOCATION_SHOW_SYSTEM_OPS, 0) == 1;
|
||||||
mRecentLocationAccesses = RecentAppOpsAccess.createForLocation(context);
|
mRecentLocationAccesses = RecentAppOpsAccess.createForLocation(context);
|
||||||
|
mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,6 +104,7 @@ public class RecentLocationAccessSeeAllPreferenceController
|
|||||||
mShowSystem = showSystem;
|
mShowSystem = showSystem;
|
||||||
if (mPreference != null) {
|
if (mPreference != null) {
|
||||||
updateState(mPreference);
|
updateState(mPreference);
|
||||||
|
mMetricsFeatureProvider.logClickedPreference(mPreference, getMetricsCategory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ public final class PaymentDefaultDialog extends AlertActivity implements
|
|||||||
ComponentName component = intent.getParcelableExtra(
|
ComponentName component = intent.getParcelableExtra(
|
||||||
CardEmulation.EXTRA_SERVICE_COMPONENT);
|
CardEmulation.EXTRA_SERVICE_COMPONENT);
|
||||||
String category = intent.getStringExtra(CardEmulation.EXTRA_CATEGORY);
|
String category = intent.getStringExtra(CardEmulation.EXTRA_CATEGORY);
|
||||||
int userId = intent.getIntExtra(CardEmulation.EXTRA_USERID, UserHandle.myUserId());
|
UserHandle userHandle = intent.getParcelableExtra(Intent.EXTRA_USER);
|
||||||
|
if (userHandle == null) {
|
||||||
|
userHandle = UserHandle.CURRENT;
|
||||||
|
}
|
||||||
|
int userId = userHandle.getIdentifier();
|
||||||
|
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
if (!buildDialog(component, category, userId)) {
|
if (!buildDialog(component, category, userId)) {
|
||||||
|
|||||||
@@ -24,20 +24,26 @@ import static org.mockito.ArgumentMatchers.any;
|
|||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import androidx.core.graphics.drawable.IconCompat;
|
||||||
import androidx.slice.Slice;
|
import androidx.slice.Slice;
|
||||||
import androidx.slice.SliceProvider;
|
import androidx.slice.SliceProvider;
|
||||||
import androidx.slice.widget.SliceLiveData;
|
import androidx.slice.widget.SliceLiveData;
|
||||||
|
import androidx.slice.builders.ListBuilder;
|
||||||
|
import androidx.slice.builders.SliceAction;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settings.slices.CustomSliceRegistry;
|
import com.android.settings.slices.CustomSliceRegistry;
|
||||||
import com.android.settings.wifi.slice.ContextualWifiSlice;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
@@ -48,6 +54,7 @@ public class EligibleCardCheckerTest {
|
|||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private EligibleCardChecker mEligibleCardChecker;
|
private EligibleCardChecker mEligibleCardChecker;
|
||||||
|
private Activity mActivity;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -55,22 +62,19 @@ public class EligibleCardCheckerTest {
|
|||||||
mEligibleCardChecker =
|
mEligibleCardChecker =
|
||||||
spy(new EligibleCardChecker(mContext, getContextualCard(TEST_SLICE_URI)));
|
spy(new EligibleCardChecker(mContext, getContextualCard(TEST_SLICE_URI)));
|
||||||
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
|
||||||
|
mActivity = Robolectric.buildActivity(Activity.class).create().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void isSliceToggleable_cardWithToggle_returnTrue() {
|
public void isSliceToggleable_cardWithToggle_returnTrue() {
|
||||||
final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
|
final Slice slice = buildSlice();
|
||||||
final Slice slice = wifiSlice.getSlice();
|
|
||||||
|
|
||||||
assertThat(mEligibleCardChecker.isSliceToggleable(slice)).isTrue();
|
assertThat(mEligibleCardChecker.isSliceToggleable(slice)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
|
public void isCardEligibleToDisplay_toggleSlice_hasInlineActionShouldBeTrue() {
|
||||||
final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
|
final Slice slice = buildSlice();
|
||||||
final Slice slice = wifiSlice.getSlice();
|
|
||||||
doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
|
doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
|
||||||
|
|
||||||
mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
|
mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
|
||||||
@@ -118,10 +122,8 @@ public class EligibleCardCheckerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void isCardEligibleToDisplay_sliceNotNull_cacheSliceToCard() {
|
public void isCardEligibleToDisplay_sliceNotNull_cacheSliceToCard() {
|
||||||
final ContextualWifiSlice wifiSlice = new ContextualWifiSlice(mContext);
|
final Slice slice = buildSlice();
|
||||||
final Slice slice = wifiSlice.getSlice();
|
|
||||||
doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
|
doReturn(slice).when(mEligibleCardChecker).bindSlice(any(Uri.class));
|
||||||
|
|
||||||
mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
|
mEligibleCardChecker.isCardEligibleToDisplay(getContextualCard(TEST_SLICE_URI));
|
||||||
@@ -137,4 +139,23 @@ public class EligibleCardCheckerTest {
|
|||||||
.setSliceUri(sliceUri)
|
.setSliceUri(sliceUri)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Slice buildSlice() {
|
||||||
|
final String title = "test_title";
|
||||||
|
final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
|
||||||
|
final PendingIntent pendingIntent = PendingIntent.getActivity(
|
||||||
|
mActivity,
|
||||||
|
title.hashCode() /* requestCode */,
|
||||||
|
new Intent("test action"),
|
||||||
|
PendingIntent.FLAG_IMMUTABLE);
|
||||||
|
final SliceAction action
|
||||||
|
= SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
|
||||||
|
return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
|
||||||
|
.addRow(new ListBuilder.RowBuilder()
|
||||||
|
.addEndItem(icon, ListBuilder.ICON_IMAGE)
|
||||||
|
.setTitle(title)
|
||||||
|
.setPrimaryAction(action))
|
||||||
|
.addAction(SliceAction.createToggle(pendingIntent, null /* actionTitle */, true))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ import androidx.lifecycle.Lifecycle;
|
|||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
import com.android.settings.Settings.MobileNetworkActivity;
|
import com.android.settings.Settings.MobileNetworkActivity;
|
||||||
|
import com.android.settings.network.helper.SubscriptionAnnotation;
|
||||||
|
import com.android.settings.network.helper.SubscriptionGrouping;
|
||||||
import com.android.settings.widget.AddPreference;
|
import com.android.settings.widget.AddPreference;
|
||||||
import com.android.settingslib.RestrictedLockUtils;
|
import com.android.settingslib.RestrictedLockUtils;
|
||||||
|
|
||||||
@@ -123,7 +125,6 @@ public class MobileNetworkSummaryControllerTest {
|
|||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void getSummary_noSubscriptions_correctSummaryAndClickHandler() {
|
public void getSummary_noSubscriptions_correctSummaryAndClickHandler() {
|
||||||
mController.displayPreference(mPreferenceScreen);
|
mController.displayPreference(mPreferenceScreen);
|
||||||
mController.onResume();
|
mController.onResume();
|
||||||
@@ -211,23 +212,6 @@ public class MobileNetworkSummaryControllerTest {
|
|||||||
SubscriptionManager.INVALID_SUBSCRIPTION_ID)).isEqualTo(sub1.getSubscriptionId());
|
SubscriptionManager.INVALID_SUBSCRIPTION_ID)).isEqualTo(sub1.getSubscriptionId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@Ignore
|
|
||||||
public void getSummary_providerModel_Enabled() {
|
|
||||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
|
||||||
final SubscriptionInfo sub2 = mock(SubscriptionInfo.class);
|
|
||||||
when(sub1.getSubscriptionId()).thenReturn(1);
|
|
||||||
when(sub2.getSubscriptionId()).thenReturn(2);
|
|
||||||
when(sub1.getDisplayName()).thenReturn("sub1");
|
|
||||||
when(sub2.getDisplayName()).thenReturn("sub2");
|
|
||||||
|
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
|
||||||
SubscriptionUtil.setActiveSubscriptionsForTesting(Arrays.asList(sub1, sub2));
|
|
||||||
mController.displayPreference(mPreferenceScreen);
|
|
||||||
mController.onResume();
|
|
||||||
assertThat(mController.getSummary()).isEqualTo("sub1, sub2");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addButton_noSubscriptionsNoEuiccMgr_noAddClickListener() {
|
public void addButton_noSubscriptionsNoEuiccMgr_noAddClickListener() {
|
||||||
when(mEuiccManager.isEnabled()).thenReturn(false);
|
when(mEuiccManager.isEnabled()).thenReturn(false);
|
||||||
@@ -319,7 +303,6 @@ public class MobileNetworkSummaryControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOn_isDisabled() {
|
public void onAirplaneModeChanged_oneSubscriptionAirplaneModeGetsTurnedOn_isDisabled() {
|
||||||
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
final SubscriptionInfo sub1 = mock(SubscriptionInfo.class);
|
||||||
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
|
SubscriptionUtil.setAvailableSubscriptionsForTesting(Arrays.asList(sub1));
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.LocaleManager;
|
import android.app.LocaleManager;
|
||||||
@@ -32,7 +33,7 @@ import androidx.test.annotation.UiThreadTest;
|
|||||||
import androidx.test.core.app.ApplicationProvider;
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.android.settingslib.widget.RadioButtonPreference;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -40,8 +41,14 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unittest for ApplocaleDetails
|
||||||
|
* TODO Need to add a unittest for the UI preference component.
|
||||||
|
*/
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class AppLocaleDetailsTest {
|
public class AppLocaleDetailsTest {
|
||||||
private static final String APP_PACKAGE_NAME = "app_package_name";
|
private static final String APP_PACKAGE_NAME = "app_package_name";
|
||||||
@@ -52,7 +59,7 @@ public class AppLocaleDetailsTest {
|
|||||||
private LocaleManager mLocaleManager;
|
private LocaleManager mLocaleManager;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private LocaleList mSystemLocales;
|
private Collection<Locale> mSystemLocales;
|
||||||
private LocaleList mAppLocale;
|
private LocaleList mAppLocale;
|
||||||
private String[] mAssetLocales;
|
private String[] mAssetLocales;
|
||||||
private LocaleList mPackageLocales;
|
private LocaleList mPackageLocales;
|
||||||
@@ -69,12 +76,48 @@ public class AppLocaleDetailsTest {
|
|||||||
when(mContext.getSystemService(LocaleManager.class)).thenReturn(mLocaleManager);
|
when(mContext.getSystemService(LocaleManager.class)).thenReturn(mLocaleManager);
|
||||||
|
|
||||||
setupInitialLocales(
|
setupInitialLocales(
|
||||||
/* appLocale= */ "en",
|
/* appLocale= */ "en-gb",
|
||||||
/* simCountry= */ "tw",
|
/* simCountry= */ "tw",
|
||||||
/* networkCountry= */ "jp",
|
/* networkCountry= */ "jp",
|
||||||
/* systemLocales= */ "en, uk, jp, ne",
|
/* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
|
||||||
/* packageLocales= */ "pa, cn, tw, en",
|
/* packageLocales= */ "pa, cn, zh-tw, en-gb, ja-jp",
|
||||||
/* assetLocales= */ new String[]{"en", "ne", "ms", "pa"});
|
/* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "zh-tw", "ja-jp"});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void onRadioButtonClicked_setCurrentLocaleToSystem() {
|
||||||
|
AppLocaleDetails appLocaleDetails = new AppLocaleDetails() {
|
||||||
|
@Override
|
||||||
|
void refreshUiInternal() {}
|
||||||
|
};
|
||||||
|
DummyAppLocaleDetailsHelper helper =
|
||||||
|
spy(new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME));
|
||||||
|
appLocaleDetails.mAppLocaleDetailsHelper = helper;
|
||||||
|
RadioButtonPreference pref = new RadioButtonPreference(mContext);
|
||||||
|
pref.setKey(AppLocaleDetails.KEY_SYSTEM_DEFAULT_LOCALE);
|
||||||
|
|
||||||
|
appLocaleDetails.onRadioButtonClicked(pref);
|
||||||
|
|
||||||
|
verify(helper).setAppDefaultLocale(LocaleList.forLanguageTags(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void onRadioButtonClicked_setCurrentLocaleForUserSelected() {
|
||||||
|
AppLocaleDetails appLocaleDetails = new AppLocaleDetails() {
|
||||||
|
@Override
|
||||||
|
void refreshUiInternal() {}
|
||||||
|
};
|
||||||
|
DummyAppLocaleDetailsHelper helper =
|
||||||
|
spy(new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME));
|
||||||
|
appLocaleDetails.mAppLocaleDetailsHelper = helper;
|
||||||
|
RadioButtonPreference pref = new RadioButtonPreference(mContext);
|
||||||
|
pref.setKey("en");
|
||||||
|
|
||||||
|
appLocaleDetails.onRadioButtonClicked(pref);
|
||||||
|
|
||||||
|
verify(helper).setAppDefaultLocale("en");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -90,7 +133,7 @@ public class AppLocaleDetailsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void handleAllLocalesData_1stLocaleOfSuggestedLocaleListIsAppLocale() {
|
public void handleAllLocalesData_1stLocaleIsAppLocaleAndHasSimAndNetwork() {
|
||||||
Locale simCountryLocale = new Locale("zh", "TW");
|
Locale simCountryLocale = new Locale("zh", "TW");
|
||||||
Locale networkCountryLocale = new Locale("ja", "JP");
|
Locale networkCountryLocale = new Locale("ja", "JP");
|
||||||
DummyAppLocaleDetailsHelper helper =
|
DummyAppLocaleDetailsHelper helper =
|
||||||
@@ -98,36 +141,122 @@ public class AppLocaleDetailsTest {
|
|||||||
|
|
||||||
helper.handleAllLocalesData();
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
|
Locale locale = suggestedLocales.iterator().next();
|
||||||
assertTrue(locale.equals(mAppLocale.get(0)));
|
assertTrue(locale.equals(mAppLocale.get(0)));
|
||||||
assertTrue(helper.getSuggestedLocales().contains(simCountryLocale));
|
assertTrue(suggestedLocales.contains(simCountryLocale));
|
||||||
assertTrue(helper.getSuggestedLocales().contains(networkCountryLocale));
|
assertTrue(suggestedLocales.contains(networkCountryLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void handleAllLocalesData_withoutAppLocale_1stSuggestedLocaleIsSimCountryLocale() {
|
public void
|
||||||
Locale simCountryLocale = new Locale("zh", "TW");
|
handleAllLocalesData_noAppAndNoSupportedSimLocale_1stSuggestedLocaleIsAssetLocale() {
|
||||||
|
Locale firstAssetLocale = new Locale("en", "GB");
|
||||||
setupInitialLocales(
|
setupInitialLocales(
|
||||||
/* appLocale= */ "",
|
/* appLocale= */ "",
|
||||||
/* simCountry= */ "tw",
|
/* simCountry= */ "tw",
|
||||||
/* networkCountry= */ "",
|
/* networkCountry= */ "",
|
||||||
/* systemLocales= */ "en, uk, jp, ne",
|
/* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
|
||||||
/* packageLocales= */ "",
|
/* packageLocales= */ "",
|
||||||
/* assetLocales= */ new String[]{});
|
/* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "ja-jp"});
|
||||||
DummyAppLocaleDetailsHelper helper =
|
DummyAppLocaleDetailsHelper helper =
|
||||||
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
||||||
|
|
||||||
helper.handleAllLocalesData();
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
assertTrue(locale.equals(simCountryLocale));
|
Locale locale = suggestedLocales.iterator().next();
|
||||||
assertFalse(helper.getSuggestedLocales().contains(mAppLocale.get(0)));
|
assertTrue(locale.equals(firstAssetLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UiThreadTest
|
@UiThreadTest
|
||||||
public void handleAllLocalesData_withoutAppLocale_1stSuggestedLocaleIsNetworkCountryLocale() {
|
public void handleAllLocalesData_noAppButHasSupportedSimLocale_1stSuggestedLocaleIsSim() {
|
||||||
|
Locale simLocale = new Locale("zh", "tw");
|
||||||
|
setupInitialLocales(
|
||||||
|
/* appLocale= */ "",
|
||||||
|
/* simCountry= */ "tw",
|
||||||
|
/* networkCountry= */ "",
|
||||||
|
/* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
|
||||||
|
/* packageLocales= */ "",
|
||||||
|
/* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "ja-jp", "zh-tw"});
|
||||||
|
DummyAppLocaleDetailsHelper helper =
|
||||||
|
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
||||||
|
|
||||||
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
|
Locale locale = suggestedLocales.iterator().next();
|
||||||
|
assertTrue(locale.equals(simLocale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void
|
||||||
|
handleAllLocalesData_noAppButHasSupportedNetworkLocale_1stSuggestedLocaleIsNetwork() {
|
||||||
|
Locale networkLocale = new Locale("ja", "JP");
|
||||||
|
setupInitialLocales(
|
||||||
|
/* appLocale= */ "",
|
||||||
|
/* simCountry= */ "",
|
||||||
|
/* networkCountry= */ "jp",
|
||||||
|
/* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
|
||||||
|
/* packageLocales= */ "",
|
||||||
|
/* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "ja-jp"});
|
||||||
|
DummyAppLocaleDetailsHelper helper =
|
||||||
|
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
||||||
|
|
||||||
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
|
Locale locale = suggestedLocales.iterator().next();
|
||||||
|
assertTrue(locale.equals(networkLocale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void handleAllLocalesData_noAppSimOrNetworkLocale_suggestedLocalesHasSystemLocale() {
|
||||||
|
setupInitialLocales(
|
||||||
|
/* appLocale= */ "",
|
||||||
|
/* simCountry= */ "",
|
||||||
|
/* networkCountry= */ "",
|
||||||
|
/* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
|
||||||
|
/* packageLocales= */ "",
|
||||||
|
/* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "zh-tw", "ja-jp"});
|
||||||
|
DummyAppLocaleDetailsHelper helper =
|
||||||
|
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
||||||
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
|
assertTrue(suggestedLocales.contains(Locale.forLanguageTag("ne")));
|
||||||
|
// ru language is not present in the asset locales
|
||||||
|
assertFalse(suggestedLocales.contains(Locale.forLanguageTag("ru")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void handleAllLocalesData_noAppButHasSimAndNetworkLocale_1stLocaleIsSimLocale() {
|
||||||
|
Locale simCountryLocale = new Locale("zh", "TW");
|
||||||
|
setupInitialLocales(
|
||||||
|
/* appLocale= */ "",
|
||||||
|
/* simCountry= */ "tw",
|
||||||
|
/* networkCountry= */ "jp",
|
||||||
|
/* systemLocales= */ "en-gb, ru, ja-jp, ne, zh-tw",
|
||||||
|
/* packageLocales= */ "",
|
||||||
|
/* assetLocales= */ new String[]{"en-gb", "ne", "ms", "pa", "zh-tw", "ja-jp"});
|
||||||
|
|
||||||
|
DummyAppLocaleDetailsHelper helper =
|
||||||
|
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
||||||
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
|
Locale locale = suggestedLocales.iterator().next();
|
||||||
|
assertTrue(locale.equals(simCountryLocale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@UiThreadTest
|
||||||
|
public void handleAllLocalesData_noSupportedLocale_noSuggestedLocales() {
|
||||||
Locale networkCountryLocale = new Locale("en", "GB");
|
Locale networkCountryLocale = new Locale("en", "GB");
|
||||||
setupInitialLocales(
|
setupInitialLocales(
|
||||||
/* appLocale= */ "",
|
/* appLocale= */ "",
|
||||||
@@ -141,28 +270,8 @@ public class AppLocaleDetailsTest {
|
|||||||
|
|
||||||
helper.handleAllLocalesData();
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
assertTrue(locale.equals(networkCountryLocale));
|
assertTrue(suggestedLocales.size() == 0);
|
||||||
assertFalse(helper.getSuggestedLocales().contains(mAppLocale.get(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@UiThreadTest
|
|
||||||
public void handleAllLocalesData_noAppAndSimNetworkLocale_1stLocaleIsFirstOneInSystemLocales() {
|
|
||||||
setupInitialLocales(
|
|
||||||
/* appLocale= */ "",
|
|
||||||
/* simCountry= */ "",
|
|
||||||
/* networkCountry= */ "",
|
|
||||||
/* systemLocales= */ "en, uk, jp, ne",
|
|
||||||
/* packageLocales= */ "",
|
|
||||||
/* assetLocales= */ new String[]{});
|
|
||||||
DummyAppLocaleDetailsHelper helper =
|
|
||||||
new DummyAppLocaleDetailsHelper(mContext, APP_PACKAGE_NAME);
|
|
||||||
|
|
||||||
helper.handleAllLocalesData();
|
|
||||||
|
|
||||||
Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
|
|
||||||
assertTrue(locale.equals(mSystemLocales.get(0)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -180,8 +289,10 @@ public class AppLocaleDetailsTest {
|
|||||||
|
|
||||||
helper.handleAllLocalesData();
|
helper.handleAllLocalesData();
|
||||||
|
|
||||||
Locale locale = Iterables.get(helper.getSuggestedLocales(), 0);
|
Collection<Locale> suggestedLocales = helper.getSuggestedLocales();
|
||||||
assertTrue(locale.equals(mSystemLocales.get(0)));
|
Locale locale = suggestedLocales.iterator().next();
|
||||||
|
Locale systemLocale = mSystemLocales.iterator().next();
|
||||||
|
assertTrue(locale.equals(systemLocale));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -248,15 +359,23 @@ public class AppLocaleDetailsTest {
|
|||||||
String packageLocales,
|
String packageLocales,
|
||||||
String[] assetLocales) {
|
String[] assetLocales) {
|
||||||
mAppLocale = LocaleList.forLanguageTags(appLocale);
|
mAppLocale = LocaleList.forLanguageTags(appLocale);
|
||||||
mSystemLocales = LocaleList.forLanguageTags(systemLocales);
|
// forLanguageTags does not filter space to the input string. If there is any space included
|
||||||
|
// in string, this will make locale fail to generate.
|
||||||
|
systemLocales = systemLocales.replaceAll("\\s+", "");
|
||||||
|
LocaleList listOfSystemLocales = LocaleList.forLanguageTags(systemLocales);
|
||||||
|
mSystemLocales = new ArrayList<>();
|
||||||
|
for (int i = 0; i < listOfSystemLocales.size(); i++) {
|
||||||
|
mSystemLocales.add(listOfSystemLocales.get(i));
|
||||||
|
}
|
||||||
mAssetLocales = assetLocales;
|
mAssetLocales = assetLocales;
|
||||||
|
packageLocales = packageLocales.replaceAll("\\s+", "");
|
||||||
mPackageLocales = LocaleList.forLanguageTags(packageLocales);
|
mPackageLocales = LocaleList.forLanguageTags(packageLocales);
|
||||||
when(mTelephonyManager.getSimCountryIso()).thenReturn(simCountry);
|
when(mTelephonyManager.getSimCountryIso()).thenReturn(simCountry);
|
||||||
when(mTelephonyManager.getNetworkCountryIso()).thenReturn(networkCountry);
|
when(mTelephonyManager.getNetworkCountryIso()).thenReturn(networkCountry);
|
||||||
when(mLocaleManager.getApplicationLocales(anyString())).thenReturn(mAppLocale);
|
when(mLocaleManager.getApplicationLocales(anyString())).thenReturn(mAppLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DummyAppLocaleDetailsHelper
|
public class DummyAppLocaleDetailsHelper
|
||||||
extends AppLocaleDetails.AppLocaleDetailsHelper {
|
extends AppLocaleDetails.AppLocaleDetailsHelper {
|
||||||
|
|
||||||
DummyAppLocaleDetailsHelper(Context context, String packageName) {
|
DummyAppLocaleDetailsHelper(Context context, String packageName) {
|
||||||
@@ -264,12 +383,12 @@ public class AppLocaleDetailsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String[] getAssetSystemLocales() {
|
String[] getAssetLocales() {
|
||||||
return mAssetLocales;
|
return mAssetLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
LocaleList getCurrentSystemLocales() {
|
Collection<Locale> getCurrentSystemLocales() {
|
||||||
return mSystemLocales;
|
return mSystemLocales;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user