Merge "Add new summaries for homepage preferences" into sc-dev
diff --git a/res/drawable/ic_homepage_search.xml b/res/drawable/ic_homepage_search.xml
index 3895b6b..3da1cc7 100644
--- a/res/drawable/ic_homepage_search.xml
+++ b/res/drawable/ic_homepage_search.xml
@@ -20,7 +20,7 @@
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
- android:tint="?android:attr/colorAccent">
+ android:tint="?android:attr/textColorSecondary">
<path
android:fillColor="#FF000000"
android:pathData="M20.49,19l-5.73,-5.73C15.53,12.2 16,10.91 16,9.5C16,5.91 13.09,3 9.5,3S3,5.91 3,9.5C3,13.09 5.91,16 9.5,16c1.41,0 2.7,-0.47 3.77,-1.24L19,20.49L20.49,19zM5,9.5C5,7.01 7.01,5 9.5,5S14,7.01 14,9.5S11.99,14 9.5,14S5,11.99 5,9.5z"/>
diff --git a/res/layout/horizontal_preference.xml b/res/layout/horizontal_preference.xml
index 9358cff..e50fc3f 100644
--- a/res/layout/horizontal_preference.xml
+++ b/res/layout/horizontal_preference.xml
@@ -22,7 +22,7 @@
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:orientation="horizontal"
- android:paddingStart="@dimen/preference_no_icon_padding_start"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd">
<TextView
diff --git a/res/layout/one_handed_header.xml b/res/layout/one_handed_header.xml
index 2104e40..3fa8183 100644
--- a/res/layout/one_handed_header.xml
+++ b/res/layout/one_handed_header.xml
@@ -21,7 +21,7 @@
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:scaleType="centerCrop"
+ android:scaleType="centerInside"
android:cropToPadding="true"
android:src="@drawable/one_handed_guideline"
android:contentDescription="@null" />
diff --git a/res/layout/search_bar.xml b/res/layout/search_bar.xml
index 63f1c95..7cdf04d 100644
--- a/res/layout/search_bar.xml
+++ b/res/layout/search_bar.xml
@@ -19,10 +19,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/search_bar_margin"
- android:layout_marginStart="@dimen/search_bar_margin"
- android:layout_marginEnd="@dimen/search_bar_margin"
- android:layout_marginBottom="@dimen/search_bar_margin_bottom">
+ android:layout_margin="@dimen/search_bar_margin">
<com.google.android.material.card.MaterialCardView
android:id="@+id/search_bar"
@@ -34,7 +31,7 @@
android:id="@+id/search_action_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/search_bar_height"
- android:layout_marginStart="-2dp"
+ android:paddingStart="4dp"
android:background="@drawable/search_bar_selected_background"
android:contentInsetStartWithNavigation="@dimen/search_bar_content_inset"
android:navigationIcon="@drawable/ic_homepage_search">
@@ -43,16 +40,11 @@
style="@style/TextAppearance.SearchBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:paddingStart="-4dp"
android:layout_gravity="start"
android:text="@string/search_menu"/>
</Toolbar>
</com.google.android.material.card.MaterialCardView>
- <ImageView
- android:id="@+id/account_avatar"
- android:layout_width="@dimen/avatar_length"
- android:layout_height="@dimen/avatar_length"
- android:layout_gravity="center_vertical"
- android:contentDescription="@string/search_bar_account_avatar_content_description"/>
</LinearLayout>
diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml
index d9bcb83..4fd62fd 100644
--- a/res/layout/settings_homepage_container.xml
+++ b/res/layout/settings_homepage_container.xml
@@ -65,34 +65,26 @@
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">
- <LinearLayout
- android:id="@+id/contextual_suggestion_content"
+ <ImageView
+ android:id="@+id/account_avatar"
+ android:layout_width="@dimen/avatar_length"
+ android:layout_height="@dimen/avatar_length"
+ android:layout_marginTop="@dimen/avatar_margin_top"
+ android:layout_marginEnd="@dimen/avatar_margin_end"
+ android:layout_gravity="end"
+ android:visibility="invisible"
+ android:accessibilityTraversalAfter="@id/homepage_title"
+ android:contentDescription="@string/search_bar_account_avatar_content_description"/>
+
+ <TextView
+ android:id="@+id/homepage_title"
+ android:text="@string/settings_label"
+ style="@style/HomepageTitleText"/>
+
+ <FrameLayout
+ android:id="@+id/suggestion_content"
android:layout_width="match_parent"
- android:layout_height="@dimen/suggestion_height"
- android:paddingHorizontal="@dimen/suggestion_padding_horizontal"
- android:paddingVertical="@dimen/suggestion_padding_vertical"
- android:orientation="vertical"
- android:gravity="bottom"
- android:visibility="gone">
-
- <TextView
- android:id="@+id/suggestion_title"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1"
- android:text="@string/settings_label"
- style="@style/ContextualSuggestionText"/>
-
- <Button
- android:id="@+id/suggestion_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suggestion_button_margin_top"
- android:paddingHorizontal="@dimen/suggestion_button_padding_horizontal"
- android:visibility="gone"
- style="@style/ActionPrimaryButton"/>
-
- </LinearLayout>
+ android:layout_height="wrap_content"/>
<include layout="@layout/search_bar"/>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 4eb0afd..b2f9a89 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -21,7 +21,7 @@
<color name="homepage_support_background">#3F5FBD</color>
<color name="homepage_card_dismissal_background">@*android:color/material_grey_900</color>
<color name="contextual_card_background">@*android:color/material_grey_900</color>
- <color name="search_bar_background">@*android:color/material_grey_800</color>
+ <color name="search_bar_background">@*android:color/material_grey_900</color>
<!-- Dialog background color. -->
<color name="dialog_background">@*android:color/material_grey_800</color>
<color name="notification_importance_selection_bg">@*android:color/material_grey_800</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 0ee39cd..e0e0219 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -131,25 +131,21 @@
<dimen name="switchbar_subsettings_margin_start">72dp</dimen>
<dimen name="switchbar_subsettings_margin_end">16dp</dimen>
- <!-- Search bar and avatar -->
- <dimen name="search_bar_margin">24dp</dimen>
- <dimen name="search_bar_margin_bottom">16dp</dimen>
- <dimen name="search_bar_height">48dp</dimen>
- <dimen name="search_bar_text_size">16sp</dimen>
- <dimen name="search_bar_card_elevation">2dp</dimen>
- <dimen name="search_bar_content_inset">64dp</dimen>
- <dimen name="avatar_length">@dimen/search_bar_height</dimen>
+ <!-- Search bar -->
+ <dimen name="search_bar_margin">16dp</dimen>
+ <dimen name="search_bar_height">52dp</dimen>
+ <dimen name="search_bar_text_size">20sp</dimen>
+ <dimen name="search_bar_corner_radius">28dp</dimen>
+ <dimen name="search_bar_content_inset">56dp</dimen>
- <!-- Contextual suggestions -->
- <dimen name="suggestion_height">232dp</dimen>
- <dimen name="suggestion_padding_horizontal">24dp</dimen>
- <dimen name="suggestion_padding_vertical">8dp</dimen>
- <dimen name="suggestion_button_margin_top">16dp</dimen>
- <dimen name="suggestion_button_padding_horizontal">24dp</dimen>
+ <!-- Avatar -->
+ <dimen name="avatar_length">48dp</dimen>
+ <dimen name="avatar_margin_top">56dp</dimen>
+ <dimen name="avatar_margin_end">24dp</dimen>
- <!-- Tool bar text -->
- <dimen name="tool_bar_max_text_size">36sp</dimen>
- <dimen name="tool_bar_min_text_size">24sp</dimen>
+ <!-- Homepage title -->
+ <dimen name="homepage_title_margin_bottom">8dp</dimen>
+ <dimen name="homepage_title_margin_horizontal">24dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2f668b3..29609d0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -7773,8 +7773,8 @@
<string name="app_and_notification_dashboard_summary">Recent apps, default apps</string>
<!-- Toast shown when an app in the work profile attempts to open notification settings. The apps in the work profile cannot access notification settings. [CHAR LIMIT=NONE] -->
<string name="notification_settings_work_profile">Notification access is not available for apps in the work profile.</string>
- <!-- Title for setting tile leading to account settings [CHAR LIMIT=40]-->
- <string name="account_dashboard_title">Accounts</string>
+ <!-- Title for setting tile leading to saved autofill passwords, autofill , and account settings [CHAR LIMIT=40]-->
+ <string name="account_dashboard_title">Passwords and accounts</string>
<!-- Summary for account settings tiles when there is no accounts on device [CHAR LIMIT=NONE]-->
<string name="account_dashboard_default_summary">No accounts added</string>
<!-- Title for setting tile leading to setting UI which allows user set default app to
@@ -11291,8 +11291,8 @@
<!-- Title text for swiping downwards on the bottom of the screen for notifications [CHAR LIMIT=60]-->
<string name="swipe_bottom_to_notifications_title">Swipe for notifications</string>
- <!-- Summary text for swiping downwards on the bottom of the screen for notifications [CHAR LIMIT=80]-->
- <string name="swipe_bottom_to_notifications_summary">Swipe down on the bottom edge of the screen to show your notifications</string>
+ <!-- Summary text for swiping downwards on the bottom of the screen for notifications [CHAR LIMIT=NONE]-->
+ <string name="swipe_bottom_to_notifications_summary">Swipe down on the bottom edge of the screen to show your notifications.\nYou can\'t use one-handed mode when this feature is turned on.</string>
<!-- Preference and settings suggestion title text for one handed [CHAR LIMIT=60] -->
<string name="one_handed_title">One-Handed mode</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0d773f1..8ca72db 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -310,6 +310,7 @@
<style name="TextAppearance.SearchBar"
parent="@*android:style/TextAppearance.DeviceDefault.Widget.Toolbar.Subtitle">
<item name="android:textSize">@dimen/search_bar_text_size</item>
+ <item name="android:textColor">?android:attr/textColorTertiary</item>
<item name="android:singleLine">true</item>
</style>
@@ -418,7 +419,6 @@
</style>
<style name="ActionPrimaryButton" parent="android:Widget.DeviceDefault.Button.Colored"/>
-
<style name="ActionSecondaryButton" parent="android:Widget.DeviceDefault.Button"/>
<style name="LockPatternContainerStyle">
@@ -481,11 +481,8 @@
</style>
<style name="SearchBarStyle">
- <item name="android:layout_marginEnd">@dimen/search_bar_margin</item>
- <item name="cardCornerRadius">34dp</item>
- <item name="enforceMaterialTheme">true</item>
- <item name="cardElevation">3dp</item>
- <item name="shapeAppearance">@null</item>
+ <item name="cardCornerRadius">@dimen/search_bar_corner_radius</item>
+ <item name="cardElevation">0dp</item>
</style>
<style name="ConditionCardBorderlessButton"
@@ -789,13 +786,11 @@
<item name="android:fontFamily">@*android:string/config_headlineFontFamily</item>
</style>
- <style name="ContextualSuggestionText"
- parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
- <item name="android:autoSizeTextType">uniform</item>
- <item name="android:autoSizeMaxTextSize">@dimen/tool_bar_max_text_size</item>
- <item name="android:autoSizeMinTextSize">@dimen/tool_bar_min_text_size</item>
- <item name="android:maxLines">3</item>
- <item name="android:gravity">bottom</item>
+ <style name="HomepageTitleText" parent="ToolbarText">
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginBottom">@dimen/homepage_title_margin_bottom</item>
+ <item name="android:layout_marginHorizontal">@dimen/homepage_title_margin_horizontal</item>
</style>
<style name="RequestManageCredentialsButtonPanel">
@@ -883,16 +878,7 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
- <style name="ToolbarText.Collapsed"
- parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
- </style>
-
- <style name="ToolbarText"
- parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
- <item name="android:textSize">@dimen/tool_bar_max_text_size</item>
- </style>
-
- <style name="ToolbarText.MoreThanTwoLines">
- <item name="android:textSize">@dimen/tool_bar_min_text_size</item>
- </style>
+ <style name="ToolbarText.Collapsed" parent="CollapsingToolbarTitle.Collapsed"/>
+ <style name="ToolbarText" parent="CollapsingToolbarTitle"/>
+ <style name="ToolbarText.MoreThanTwoLines" parent="CollapsingToolbarTitle.MoreThanTwoLines"/>
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index bed02c8..d7b3257 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -23,10 +23,7 @@
<item name="android:windowIsFloating">true</item>
</style>
- <style name="Theme.SettingsBase" parent="@android:style/Theme.DeviceDefault.Settings" />
-
<style name="Theme.Settings" parent="Theme.SettingsBase">
- <item name="preferenceTheme">@style/PreferenceTheme</item>
<item name="android:clipToPadding">false</item>
<item name="android:clipChildren">false</item>
<item name="android:listPreferredItemHeight">72dip</item>
diff --git a/res/xml/accounts_dashboard_settings.xml b/res/xml/accounts_dashboard_settings.xml
index d2affc7..c8627e7 100644
--- a/res/xml/accounts_dashboard_settings.xml
+++ b/res/xml/accounts_dashboard_settings.xml
@@ -22,14 +22,38 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
+
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:order="20"
+ android:title="@string/autofill_app">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ settings:keywords="@string/autofill_keywords">
+ <extra
+ android:name="for_work"
+ android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:order="130"/>
<SwitchPreference
android:key="auto_sync_account_data"
android:title="@string/auto_sync_account_title"
android:summary="@string/auto_sync_account_summary"
- android:order="102"
+ android:order="202"
settings:allowDividerAbove="true"/>
<SwitchPreference
@@ -37,12 +61,12 @@
android:title="@string/account_settings_menu_auto_sync_work"
android:summary="@string/auto_sync_account_summary"
settings:forWork="true"
- android:order="103"/>
+ android:order="203"/>
<SwitchPreference
android:key="auto_sync_personal_account_data"
android:title="@string/account_settings_menu_auto_sync_personal"
android:summary="@string/auto_sync_account_summary"
- android:order="104"/>
+ android:order="204"/>
</PreferenceScreen>
diff --git a/res/xml/accounts_personal_dashboard_settings.xml b/res/xml/accounts_personal_dashboard_settings.xml
index db57e3d..3d88cf9 100644
--- a/res/xml/accounts_personal_dashboard_settings.xml
+++ b/res/xml/accounts_personal_dashboard_settings.xml
@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
+ <PreferenceCategory
+ android:key="default_service_category"
+ android:order="20"
+ android:title="@string/autofill_app">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_main"
+ android:title="@string/autofill_app"
+ settings:keywords="@string/autofill_keywords">
+ <extra
+ android:name="for_work"
+ android:value="false" />
+ </com.android.settings.widget.GearPreference>
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="accounts_category"
android:order="100"
- settings:allowDividerAbove="true"/>
+ android:title="@string/account_settings">
- <SwitchPreference
- android:key="auto_sync_personal_account_data"
- android:title="@string/account_settings_menu_auto_sync_personal"
- android:summary="@string/auto_sync_account_summary"
- android:order="110"/>
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="200"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_personal_account_data"
+ android:title="@string/account_settings_menu_auto_sync_personal"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="210"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/accounts_work_dashboard_settings.xml b/res/xml/accounts_work_dashboard_settings.xml
index b27357d..29e71e2 100644
--- a/res/xml/accounts_work_dashboard_settings.xml
+++ b/res/xml/accounts_work_dashboard_settings.xml
@@ -23,20 +23,50 @@
settings:keywords="@string/keywords_accounts">
<PreferenceCategory
- android:key="dashboard_tile_placeholder"
- android:order="30"/>
+ android:key="passwords_category"
+ android:order="10"
+ android:persistent="false"
+ android:title="@string/autofill_passwords"
+ settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController"
+ settings:keywords="@string/autofill_keywords" />
- <SwitchPreference
- android:key="auto_sync_account_data"
- android:title="@string/auto_sync_account_title"
- android:summary="@string/auto_sync_account_summary"
+ <com.android.settings.widget.WorkOnlyCategory
+ android:key="autofill_work_app_defaults"
+ android:order="30"
+ android:title="@string/default_for_work">
+
+ <com.android.settings.widget.GearPreference
+ android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
+ android:key="default_autofill_work"
+ android:title="@string/autofill_app"
+ settings:searchable="false">
+ <extra
+ android:name="for_work"
+ android:value="true" />
+ </com.android.settings.widget.GearPreference>
+ </com.android.settings.widget.WorkOnlyCategory>
+
+ <PreferenceCategory
+ android:key="accounts_category"
android:order="100"
- settings:allowDividerAbove="true"/>
+ android:title="@string/account_settings">
- <SwitchPreference
- android:key="auto_sync_work_account_data"
- android:title="@string/account_settings_menu_auto_sync_work"
- android:summary="@string/auto_sync_account_summary"
- android:order="110"/>
+ <PreferenceCategory
+ android:key="dashboard_tile_placeholder"
+ android:order="130"/>
+
+ <SwitchPreference
+ android:key="auto_sync_account_data"
+ android:title="@string/auto_sync_account_title"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="200"
+ settings:allowDividerAbove="true"/>
+
+ <SwitchPreference
+ android:key="auto_sync_work_account_data"
+ android:title="@string/account_settings_menu_auto_sync_work"
+ android:summary="@string/auto_sync_account_summary"
+ android:order="210"/>
+ </PreferenceCategory>
</PreferenceScreen>
diff --git a/res/xml/default_autofill_picker_settings.xml b/res/xml/default_autofill_picker_settings.xml
deleted file mode 100644
index 392f733..0000000
--- a/res/xml/default_autofill_picker_settings.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="default_autofill_picker"
- android:title="@string/autofill_app"
- settings:keywords="@string/autofill_keywords">
-
- <PreferenceCategory
- android:key="passwords_category"
- android:persistent="false"
- android:title="@string/autofill_passwords"
- settings:controller="com.android.settings.applications.autofill.PasswordsPreferenceController" >
- </PreferenceCategory>
-
- <PreferenceCategory
- android:key="default_service_category"
- android:title="@string/autofill_app">
-
- <!-- TODO(b/169455298): Fix the redundant title. -->
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_main"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="false" />
- </com.android.settings.widget.GearPreference>
- </PreferenceCategory>
-
-
- <com.android.settings.widget.WorkOnlyCategory
- android:key="autofill_work_app_defaults"
- android:title="@string/default_for_work">
-
- <com.android.settings.widget.GearPreference
- android:key="default_autofill_work"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.DefaultAutofillPicker"
- settings:searchable="false"
- settings:keywords="@string/autofill_keywords">
- <extra android:name="for_work" android:value="true" />
- </com.android.settings.widget.GearPreference>
- </com.android.settings.widget.WorkOnlyCategory>
-</PreferenceScreen>
diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml
index 50968d9..d7b8364 100644
--- a/res/xml/language_and_input.xml
+++ b/res/xml/language_and_input.xml
@@ -54,12 +54,6 @@
android:persistent="false"
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
- <Preference
- android:key="default_autofill"
- android:title="@string/autofill_app"
- android:fragment="com.android.settings.applications.defaultapps.AutofillPicker"
- settings:keywords="@string/autofill_keywords" />
-
<!-- User dictionary preference title and fragment will be set programmatically. -->
<Preference
android:key="key_user_dictionary_settings"
diff --git a/res/xml/swipe_bottom_to_notification_settings.xml b/res/xml/swipe_bottom_to_notification_settings.xml
index bec774b..2a75c14 100644
--- a/res/xml/swipe_bottom_to_notification_settings.xml
+++ b/res/xml/swipe_bottom_to_notification_settings.xml
@@ -20,11 +20,13 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/swipe_bottom_to_notifications_title">
- <com.android.settings.widget.VideoPreference
- android:title="@string/swipe_bottom_to_notifications_title"
- settings:animation="@raw/gesture_fingerprint_swipe"
- settings:preview="@drawable/gesture_fingerprint_swipe"
- settings:controller="com.android.settings.widget.VideoPreferenceController"/>
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="one_handed_header"
+ android:layout="@layout/one_handed_header"
+ android:persistent="false"
+ android:selectable="false"
+ settings:allowDividerBelow="false"
+ settings:searchable="false"/>
<SwitchPreference
android:key="gesture_swipe_bottom_to_notification"
diff --git a/src/com/android/settings/accessibility/ShortcutPreference.java b/src/com/android/settings/accessibility/ShortcutPreference.java
index a9b542a..cff9117 100644
--- a/src/com/android/settings/accessibility/ShortcutPreference.java
+++ b/src/com/android/settings/accessibility/ShortcutPreference.java
@@ -63,7 +63,7 @@
super(context, attrs);
setLayoutResource(R.layout.accessibility_shortcut_secondary_action);
setWidgetLayoutResource(R.layout.preference_widget_primary_switch);
- setIconSpaceReserved(true);
+ setIconSpaceReserved(false);
}
@Override
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index cf9c08b..be6b141 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -488,7 +488,7 @@
// Show the "Settings" menu as if it were a preference screen.
mSettingsPreference = new Preference(getPrefContext());
mSettingsPreference.setTitle(mSettingsTitle);
- mSettingsPreference.setIconSpaceReserved(true);
+ mSettingsPreference.setIconSpaceReserved(false);
mSettingsPreference.setIntent(mSettingsIntent);
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
diff --git a/src/com/android/settings/accounts/AccountDashboardFragment.java b/src/com/android/settings/accounts/AccountDashboardFragment.java
index 7b50b46..9e232f4 100644
--- a/src/com/android/settings/accounts/AccountDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountDashboardFragment.java
@@ -27,6 +27,8 @@
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
+import com.android.settings.applications.defaultapps.DefaultAutofillPreferenceController;
+import com.android.settings.applications.defaultapps.DefaultWorkAutofillPreferenceController;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
import com.android.settings.search.BaseSearchIndexProvider;
@@ -68,14 +70,22 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ static void buildAutofillPreferenceControllers(
+ Context context, List<AbstractPreferenceController> controllers) {
+ controllers.add(new DefaultAutofillPreferenceController(context));
+ controllers.add(new DefaultWorkAutofillPreferenceController(context));
+ }
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.ALL);
@@ -86,7 +96,6 @@
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
- return controllers;
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -95,8 +104,11 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(
- context, null /* parent */, null /* authorities*/);
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAccountPreferenceControllers(
+ context, null /* parent */, null /* authorities*/, controllers);
+ buildAutofillPreferenceControllers(context, controllers);
+ return controllers;
}
@Override
diff --git a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
index f29326e..c97c886 100644
--- a/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountPersonalDashboardFragment.java
@@ -18,6 +18,8 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.PERSONAL);
@@ -78,7 +82,6 @@
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncPersonalDataPreferenceController(context, parent));
- return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
+// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }
diff --git a/src/com/android/settings/accounts/AccountPreferenceController.java b/src/com/android/settings/accounts/AccountPreferenceController.java
index ff5bc78..64c2d13 100644
--- a/src/com/android/settings/accounts/AccountPreferenceController.java
+++ b/src/com/android/settings/accounts/AccountPreferenceController.java
@@ -75,11 +75,12 @@
private static final String TAG = "AccountPrefController";
- private static final int ORDER_ACCOUNT_PROFILES = 1;
+ private static final int ORDER_ACCOUNT_PROFILES = 101;
private static final int ORDER_LAST = 1002;
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
+ private static final String PREF_KEY_ACCOUNTS = "accounts_category";
private static final String PREF_KEY_ADD_ACCOUNT = "add_account";
private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
@@ -348,8 +349,10 @@
}
}
final PreferenceScreen screen = mFragment.getPreferenceScreen();
- if (screen != null) {
- screen.addPreference(preferenceGroup);
+ final PreferenceGroup accounts =
+ screen == null ? null : screen.findPreference(PREF_KEY_ACCOUNTS);
+ if (accounts != null) {
+ accounts.addPreference(preferenceGroup);
}
profileData.preferenceGroup = preferenceGroup;
if (userInfo.isEnabled()) {
diff --git a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
index 853c66b..4e6515b 100644
--- a/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
+++ b/src/com/android/settings/accounts/AccountWorkProfileDashboardFragment.java
@@ -18,6 +18,8 @@
import static android.provider.Settings.EXTRA_AUTHORITIES;
+import static com.android.settings.accounts.AccountDashboardFragment.buildAutofillPreferenceControllers;
+
import android.app.settings.SettingsEnums;
import android.content.Context;
@@ -61,14 +63,16 @@
@Override
protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
+ final List<AbstractPreferenceController> controllers = new ArrayList<>();
+ buildAutofillPreferenceControllers(context, controllers);
final String[] authorities = getIntent().getStringArrayExtra(EXTRA_AUTHORITIES);
- return buildPreferenceControllers(context, this /* parent */, authorities);
+ buildAccountPreferenceControllers(context, this /* parent */, authorities, controllers);
+ return controllers;
}
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- SettingsPreferenceFragment parent, String[] authorities) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
-
+ private static void buildAccountPreferenceControllers(
+ Context context, SettingsPreferenceFragment parent, String[] authorities,
+ List<AbstractPreferenceController> controllers) {
final AccountPreferenceController accountPrefController =
new AccountPreferenceController(context, parent, authorities,
ProfileSelectFragment.ProfileType.WORK);
@@ -78,7 +82,6 @@
controllers.add(accountPrefController);
controllers.add(new AutoSyncDataPreferenceController(context, parent));
controllers.add(new AutoSyncWorkDataPreferenceController(context, parent));
- return controllers;
}
// TODO: b/141601408. After featureFlag settings_work_profile is launched, unmark this
@@ -88,6 +91,7 @@
// @Override
// public List<AbstractPreferenceController> createPreferenceControllers(
// Context context) {
+// ..Add autofill here too..
// return buildPreferenceControllers(
// context, null /* parent */, null /* authorities*/);
// }
diff --git a/src/com/android/settings/accounts/AvatarViewMixin.java b/src/com/android/settings/accounts/AvatarViewMixin.java
index 7eb8cab..c4ab55a 100644
--- a/src/com/android/settings/accounts/AvatarViewMixin.java
+++ b/src/com/android/settings/accounts/AvatarViewMixin.java
@@ -17,7 +17,6 @@
package com.android.settings.accounts;
import android.accounts.Account;
-import android.app.ActivityManager;
import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
@@ -65,14 +64,23 @@
private final Context mContext;
private final ImageView mAvatarView;
private final MutableLiveData<Bitmap> mAvatarImage;
- private final ActivityManager mActivityManager;
@VisibleForTesting
String mAccountName;
+ /**
+ * @return true if the avatar icon is supported.
+ */
+ public static boolean isAvatarSupported(Context context) {
+ if (!context.getResources().getBoolean(R.bool.config_show_avatar_in_homepage)) {
+ Log.d(TAG, "Feature disabled by config. Skipping");
+ return false;
+ }
+ return true;
+ }
+
public AvatarViewMixin(SettingsHomepageActivity activity, ImageView avatarView) {
mContext = activity.getApplicationContext();
- mActivityManager = mContext.getSystemService(ActivityManager.class);
mAvatarView = avatarView;
mAvatarView.setOnClickListener(v -> {
Intent intent;
@@ -117,14 +125,6 @@
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onStart() {
- if (!mContext.getResources().getBoolean(R.bool.config_show_avatar_in_homepage)) {
- Log.d(TAG, "Feature disabled by config. Skipping");
- return;
- }
- if (mActivityManager.isLowRamDevice()) {
- Log.d(TAG, "Feature disabled on low ram device. Skipping");
- return;
- }
if (hasAccount()) {
loadAccount();
} else {
diff --git a/src/com/android/settings/applications/defaultapps/AutofillPicker.java b/src/com/android/settings/applications/defaultapps/AutofillPicker.java
deleted file mode 100644
index 62a478f..0000000
--- a/src/com/android/settings/applications/defaultapps/AutofillPicker.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.settings.applications.defaultapps;
-
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.provider.SearchIndexableResource;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.search.Indexable;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.Arrays;
-import java.util.List;
-
-@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
-public class AutofillPicker extends DashboardFragment {
- private static final String TAG = "AutofillPicker";
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.DEFAULT_AUTOFILL_PICKER;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.default_autofill_picker_settings;
- }
-
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context);
- }
-
- public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider(R.xml.default_autofill_picker_settings) {
-
- @Override
- public List<AbstractPreferenceController> getPreferenceControllers(Context
- context) {
- return buildPreferenceControllers(context);
- }
- };
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context) {
- return Arrays.asList(
- new DefaultAutofillPreferenceController(context),
- new DefaultWorkAutofillPreferenceController(context));
- }
-}
diff --git a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
index c6db4ea..03bd195 100644
--- a/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
+++ b/src/com/android/settings/gestures/OneHandedEnablePreferenceController.java
@@ -17,7 +17,6 @@
package com.android.settings.gestures;
import android.content.Context;
-import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
@@ -28,15 +27,13 @@
**/
public class OneHandedEnablePreferenceController extends TogglePreferenceController {
- static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
-
public OneHandedEnablePreferenceController(Context context, String key) {
super(context, key);
}
@Override
public int getAvailabilityStatus() {
- return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)
+ return OneHandedSettingsUtils.isSupportOneHandedMode()
? BasePreferenceController.AVAILABLE
: BasePreferenceController.UNSUPPORTED_ON_DEVICE;
}
@@ -45,6 +42,7 @@
public boolean setChecked(boolean isChecked) {
OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext,
isChecked);
+ OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, !isChecked);
return true;
}
diff --git a/src/com/android/settings/gestures/OneHandedSettings.java b/src/com/android/settings/gestures/OneHandedSettings.java
index 2449cf2..6a07c85 100644
--- a/src/com/android/settings/gestures/OneHandedSettings.java
+++ b/src/com/android/settings/gestures/OneHandedSettings.java
@@ -18,7 +18,6 @@
import android.app.settings.SettingsEnums;
import android.content.Context;
-import android.os.SystemProperties;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -52,8 +51,7 @@
new BaseSearchIndexProvider(R.xml.one_handed_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
- return SystemProperties.getBoolean(
- OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, false);
+ return OneHandedSettingsUtils.isSupportOneHandedMode();
}
};
}
diff --git a/src/com/android/settings/gestures/OneHandedSettingsUtils.java b/src/com/android/settings/gestures/OneHandedSettingsUtils.java
index f3d7e33..ed0f62f 100644
--- a/src/com/android/settings/gestures/OneHandedSettingsUtils.java
+++ b/src/com/android/settings/gestures/OneHandedSettingsUtils.java
@@ -22,6 +22,7 @@
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
+import android.os.SystemProperties;
import android.provider.Settings;
/**
@@ -29,6 +30,8 @@
*/
public class OneHandedSettingsUtils {
+ static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";
+
public enum OneHandedTimeout {
NEVER(0), SHORT(4), MEDIUM(8), LONG(12);
@@ -52,6 +55,13 @@
}
/**
+ * Get One-Handed mode support flag.
+ */
+ public static boolean isSupportOneHandedMode() {
+ return SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false);
+ }
+
+ /**
* Get one-handed mode enable or disable flag from Settings provider.
*
* @param context App context
@@ -119,6 +129,28 @@
}
/**
+ * Get Swipe-down-notification enable or disable flag from Settings provider.
+ *
+ * @param context App context
+ * @return enable or disable Swipe-down-notification flag.
+ */
+ public static boolean isSwipeDownNotificationEnabled(Context context) {
+ return Settings.Secure.getInt(context.getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0) == 1;
+ }
+
+ /**
+ * Set Swipe-down-notification enable or disable flag to Settings provider.
+ *
+ * @param context App context
+ * @param enable enable or disable Swipe-down-notification.
+ */
+ public static void setSwipeDownNotificationEnabled(Context context, boolean enable) {
+ Settings.Secure.putInt(context.getContentResolver(),
+ Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, enable ? 1 : 0);
+ }
+
+ /**
* Register callback for observing Settings.Secure.ONE_HANDED_MODE_ENABLED state.
* @param callback for state changes
*/
diff --git a/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java b/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java
index 5eba539..28441cd 100644
--- a/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java
+++ b/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceController.java
@@ -16,14 +16,8 @@
package com.android.settings.gestures;
-import static android.provider.Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
-
-import static com.android.settings.gestures.OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE;
import android.content.Context;
-import android.os.SystemProperties;
-import android.provider.Settings;
-import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
@@ -33,32 +27,20 @@
**/
public class SwipeBottomToNotificationPreferenceController extends TogglePreferenceController {
- private static final int ON = 1;
- private static final int OFF = 0;
-
private static final String PREF_KEY = "gesture_swipe_bottom_to_notification";
public SwipeBottomToNotificationPreferenceController(Context context, String key) {
super(context, key);
}
- /** Indicates whether the gesture is available or not. */
- public static boolean isGestureAvailable(Context context) {
- // Disable the gesture once One-Handed mode gesture enabled.
- if (SystemProperties.getBoolean(SUPPORT_ONE_HANDED_MODE, false)) {
- return !OneHandedSettingsUtils.isOneHandedModeEnabled(context);
- }
- return true;
- }
-
@Override
public int getAvailabilityStatus() {
- return isGestureAvailable(mContext) ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
+ return OneHandedSettingsUtils.isSupportOneHandedMode() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
public boolean isSliceable() {
- return TextUtils.equals(getPreferenceKey(), PREF_KEY);
+ return true;
}
@Override
@@ -68,15 +50,16 @@
@Override
public boolean setChecked(boolean isChecked) {
- Settings.Secure.putInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, isChecked ? ON : OFF);
+ if (isChecked) {
+ OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
+ }
+ OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, isChecked);
return true;
}
@Override
public boolean isChecked() {
- return Settings.Secure.getInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, OFF) == ON;
+ return OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext);
}
@Override
diff --git a/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java b/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java
index d0441f3..9d85f11 100644
--- a/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java
+++ b/src/com/android/settings/gestures/SwipeBottomToNotificationSettings.java
@@ -50,8 +50,10 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
- return SwipeBottomToNotificationPreferenceController
- .isGestureAvailable(context);
+ if (!OneHandedSettingsUtils.isSupportOneHandedMode()) {
+ return false;
+ }
+ return !OneHandedSettingsUtils.isOneHandedModeEnabled(context);
}
};
}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index aa7b2d1..881e39c 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -43,6 +43,25 @@
private static final String TAG = "SettingsHomepageActivity";
+ private static final long HOMEPAGE_LOADING_TIMEOUT_MS = 300;
+
+ private View mHomepageView;
+ private View mSuggestionView;
+
+ /**
+ * Shows the homepage and shows/hides the suggestion together. Only allows to be executed once
+ * to avoid the flicker caused by the suggestion suddenly appearing/disappearing.
+ */
+ public void showHomepageWithSuggestion(boolean showSuggestion) {
+ if (mHomepageView == null) {
+ return;
+ }
+ Log.i(TAG, "showHomepageWithSuggestion: " + showSuggestion);
+ mSuggestionView.setVisibility(showSuggestion ? View.VISIBLE : View.GONE);
+ mHomepageView.setVisibility(View.VISIBLE);
+ mHomepageView = null;
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -56,15 +75,23 @@
FeatureFactory.getFactory(this).getSearchFeatureProvider()
.initSearchToolbar(this /* activity */, toolbar, SettingsEnums.SETTINGS_HOMEPAGE);
- final ImageView avatarView = findViewById(R.id.account_avatar);
- getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
getLifecycle().addObserver(new HideNonSystemOverlayMixin(this));
if (!getSystemService(ActivityManager.class).isLowRamDevice()) {
- // Only allow contextual features on high ram devices.
+ // Only allow features on high ram devices.
+ final ImageView avatarView = findViewById(R.id.account_avatar);
+ if (AvatarViewMixin.isAvatarSupported(this)) {
+ avatarView.setVisibility(View.VISIBLE);
+ getLifecycle().addObserver(new AvatarViewMixin(this, avatarView));
+ }
+
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.SILKY_HOME)) {
showSuggestionFragment();
+ } else {
+ findViewById(R.id.homepage_title).setVisibility(View.GONE);
+ avatarView.setVisibility(View.GONE);
}
+
if (FeatureFlagUtils.isEnabled(this, FeatureFlags.CONTEXTUAL_HOME)) {
showFragment(new ContextualCardsFragment(), R.id.contextual_cards_content);
}
@@ -81,9 +108,16 @@
return;
}
+ mSuggestionView = findViewById(R.id.suggestion_content);
+ mHomepageView = findViewById(R.id.settings_homepage_container);
+ // Hide the homepage for preparing the suggestion.
+ mHomepageView.setVisibility(View.GONE);
+ // Schedule a timer to show the homepage and hide the suggestion on timeout.
+ mHomepageView.postDelayed(() -> showHomepageWithSuggestion(false),
+ HOMEPAGE_LOADING_TIMEOUT_MS);
try {
- showFragment(fragment.newInstance(), R.id.contextual_suggestion_content);
- } catch (IllegalAccessException | InstantiationException e) {
+ showFragment(fragment.getConstructor().newInstance(), R.id.suggestion_content);
+ } catch (Exception e) {
Log.w(TAG, "Cannot show fragment", e);
}
}
@@ -110,10 +144,7 @@
private int getSearchBoxHeight() {
final int searchBarHeight = getResources().getDimensionPixelSize(R.dimen.search_bar_height);
- final int searchBarMarginTop = getResources().getDimensionPixelSize(
- R.dimen.search_bar_margin);
- final int searchBarMarginBottom = getResources().getDimensionPixelSize(
- R.dimen.search_bar_margin_bottom);
- return searchBarHeight + searchBarMarginTop + searchBarMarginBottom;
+ final int searchBarMargin = getResources().getDimensionPixelSize(R.dimen.search_bar_margin);
+ return searchBarHeight + searchBarMargin * 2;
}
}
diff --git a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
index cfd587a..a4cff33 100644
--- a/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
+++ b/src/com/android/settings/network/telephony/NetworkOperatorPreference.java
@@ -19,6 +19,7 @@
import static android.telephony.SignalStrength.NUM_SIGNAL_STRENGTH_BINS;
import android.content.Context;
+import android.telephony.AccessNetworkConstants.AccessNetworkType;
import android.telephony.CellIdentity;
import android.telephony.CellIdentityGsm;
import android.telephony.CellIdentityLte;
@@ -180,7 +181,7 @@
public OperatorInfo getOperatorInfo() {
return new OperatorInfo(Objects.toString(mCellId.getOperatorAlphaLong(), ""),
Objects.toString(mCellId.getOperatorAlphaShort(), ""),
- getOperatorNumeric());
+ getOperatorNumeric(), getAccessNetworkTypeFromCellInfo(mCellInfo));
}
private int getIconIdForCell(CellInfo ci) {
@@ -225,6 +226,25 @@
return null;
}
+ private int getAccessNetworkTypeFromCellInfo(CellInfo ci) {
+ if (ci instanceof CellInfoGsm) {
+ return AccessNetworkType.GERAN;
+ }
+ if (ci instanceof CellInfoCdma) {
+ return AccessNetworkType.CDMA2000;
+ }
+ if ((ci instanceof CellInfoWcdma) || (ci instanceof CellInfoTdscdma)) {
+ return AccessNetworkType.UTRAN;
+ }
+ if (ci instanceof CellInfoLte) {
+ return AccessNetworkType.EUTRAN;
+ }
+ if (ci instanceof CellInfoNr) {
+ return AccessNetworkType.NGRAN;
+ }
+ return AccessNetworkType.UNKNOWN;
+ }
+
private void updateIcon(int level) {
if (!mUseNewApi || level < 0 || level >= NUM_SIGNAL_STRENGTH_BINS) {
return;
diff --git a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
index b22b156..4b6a6a8 100644
--- a/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AccountPreferenceControllerTest.java
@@ -39,6 +39,7 @@
import android.text.TextUtils;
import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;
@@ -72,9 +73,13 @@
ShadowSettingsLibUtils.class})
public class AccountPreferenceControllerTest {
+ private static final String PREF_KEY_ACCOUNTS = "accounts_category";
+
@Mock(answer = RETURNS_DEEP_STUBS)
private PreferenceScreen mScreen;
@Mock(answer = RETURNS_DEEP_STUBS)
+ private PreferenceCategory mAccountsCategory;
+ @Mock(answer = RETURNS_DEEP_STUBS)
private UserManager mUserManager;
@Mock(answer = RETURNS_DEEP_STUBS)
private SettingsPreferenceFragment mFragment;
@@ -95,6 +100,9 @@
shadowApp.setSystemService(Context.ACCOUNT_SERVICE, mAccountManager);
when(mFragment.getPreferenceScreen()).thenReturn(mScreen);
+ // This is a bit ugly, but hard to avoid because of how the mocks are used in these tests.
+ // TODO: Refactor these tests to not use RETURNS_DEEP_STUBS.
+ when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
when(mFragment.getPreferenceManager().getContext()).thenReturn(mContext);
when(mAccountManager.getAuthenticatorTypesAsUser(anyInt()))
.thenReturn(new AuthenticatorDescription[0]);
@@ -166,6 +174,7 @@
// First time resume will build the UI
mController.onResume();
reset(mScreen);
+ when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
mController.onResume();
verify(mScreen, never()).addPreference(any(PreferenceGroup.class));
@@ -184,6 +193,7 @@
// add a new profile
infos.add(new UserInfo(2, "user 2", UserInfo.FLAG_MANAGED_PROFILE));
reset(mScreen);
+ when(mScreen.findPreference(PREF_KEY_ACCOUNTS)).thenReturn(mScreen);
mController.onResume();
verify(mScreen, times(1)).addPreference(any(PreferenceGroup.class));
diff --git a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
index 534d3c6..04db527 100644
--- a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
@@ -27,7 +27,6 @@
import static org.mockito.Mockito.verify;
import android.accounts.Account;
-import android.app.ActivityManager;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
@@ -57,7 +56,6 @@
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
-import org.robolectric.shadows.ShadowActivityManager;
import org.robolectric.shadows.ShadowContentResolver;
import org.robolectric.shadows.ShadowPackageManager;
@@ -97,31 +95,7 @@
}
@Test
- public void onStart_configDisabled_doNothing() {
- final AvatarViewMixin mixin = spy(new AvatarViewMixin(mActivity, mImageView));
- mixin.onStart();
-
- verify(mixin, never()).hasAccount();
- }
-
- @Test
- public void onStart_lowRamDevice_doNothing() {
- final AvatarViewMixin mixin = spy(new AvatarViewMixin(mActivity, mImageView));
-
- final ShadowActivityManager activityManager =
- Shadow.extract(mContext.getSystemService(ActivityManager.class));
- activityManager.setIsLowRamDevice(true);
-
- mixin.onStart();
-
- verify(mixin, never()).hasAccount();
- }
-
- @Test
- @Config(qualifiers = "mcc999",
- shadows = {
- BatteryFixSliceTest.ShadowBatteryTipLoader.class
- })
+ @Config(shadows = BatteryFixSliceTest.ShadowBatteryTipLoader.class)
public void onStart_useMockAvatarViewMixin_shouldBeExecuted() {
final AvatarViewMixin mockAvatar = spy(new AvatarViewMixin(mActivity, mImageView));
@@ -132,7 +106,6 @@
}
@Test
- @Config(qualifiers = "mcc999")
public void onStart_noAccount_mAccountNameShouldBeNull() {
final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(mActivity, mImageView);
avatarViewMixin.mAccountName = FAKE_ACCOUNT;
diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java
index 11128f3..b53629e 100644
--- a/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/OneHandedEnablePreferenceControllerTest.java
@@ -51,14 +51,16 @@
public void setChecked_setBoolean_checkIsTrueOrFalse() {
mController.setChecked(false);
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isFalse();
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isTrue();
mController.setChecked(true);
assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isTrue();
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isFalse();
}
@Test
public void getAvailabilityStatus_setSupportOneHandedModeProperty_shouldAvailable() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE);
@@ -66,7 +68,7 @@
@Test
public void getAvailabilityStatus_unsetSupportOneHandedModeProperty_shouldUnsupported() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
assertThat(mController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
diff --git a/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java
index fcea919..2651708 100644
--- a/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/OneHandedSettingsTest.java
@@ -55,7 +55,7 @@
@Test
public void isPageSearchEnabled_setSupportOneHandedModeProperty_shouldReturnTrue() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
final Object obj = ReflectionHelpers.callInstanceMethod(
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
@@ -66,7 +66,7 @@
@Test
public void isPageSearchEnabled_unsetSupportOneHandedModeProperty_shouldReturnFalse() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
final Object obj = ReflectionHelpers.callInstanceMethod(
OneHandedSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java
index c6d8233..9f76800 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationPreferenceControllerTest.java
@@ -16,10 +16,7 @@
package com.android.settings.gestures;
-import static android.provider.Settings.Secure.SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED;
-
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
-import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
import static com.google.common.truth.Truth.assertThat;
@@ -28,6 +25,7 @@
import android.provider.Settings;
import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -57,44 +55,33 @@
public void setChecked_toggledOn_enablesSwipeBottomToNotification() {
mController.setChecked(true);
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0)).isEqualTo(1);
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isTrue();
+ assertThat(OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)).isFalse();
}
@Test
public void setChecked_toggledOff_disablesSwipeBottomToNotification() {
mController.setChecked(false);
- assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
- SWIPE_BOTTOM_TO_NOTIFICATION_ENABLED, 0)).isEqualTo(0);
+ assertThat(OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext)).isFalse();
}
@Test
- public void getAvailabilityStatus_oneHandedUnsupported_returnsAvailable() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ public void getAvailabilityStatus_oneHandedUnsupported_returnsUnsupport() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+ }
+
+ @Test
+ public void getAvailabilityStatus_oneHandedSupported_returnsAvailable() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
- public void getAvailabilityStatus_oneHandedDisabled_returnsAvailable() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 0);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_oneHandedEnabled_returnsDisabled() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
- }
-
- @Test
public void getSummary_gestureEnabled_returnsOnSummary() {
mController.setChecked(true);
@@ -111,8 +98,8 @@
}
@Test
- public void getDefaultConfig_returnsOffState() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ public void isChecked_getDefaultConfig_returnFalse() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
Settings.Secure.resetToDefaults(mContext.getContentResolver(),
Settings.Secure.ONE_HANDED_MODE_ENABLED);
diff --git a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java
index ad8104c..3a65b26 100644
--- a/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/SwipeBottomToNotificationSettingsTest.java
@@ -21,7 +21,6 @@
import android.content.Context;
import android.os.SystemProperties;
import android.provider.SearchIndexableResource;
-import android.provider.Settings;
import com.android.settings.R;
@@ -64,22 +63,21 @@
}
@Test
- public void isPageSearchEnabled_oneHandedUnsupported_shouldReturnTrue() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "false");
+ public void isPageSearchEnabled_oneHandedUnsupported_shouldReturnFalse() {
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "false");
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
ReflectionHelpers.ClassParameter.from(Context.class, mContext));
final boolean isEnabled = (Boolean) obj;
- assertThat(isEnabled).isTrue();
+ assertThat(isEnabled).isFalse();
}
@Test
public void isPageSearchEnabled_oneHandedDisabled_shouldReturnTrue() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 0);
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
+ OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, false);
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
@@ -91,9 +89,8 @@
@Test
public void isPageSearchEnabled_oneHandedEnabled_shouldReturnFalse() {
- SystemProperties.set(OneHandedEnablePreferenceController.SUPPORT_ONE_HANDED_MODE, "true");
- Settings.Secure.putInt(mContext.getContentResolver(),
- Settings.Secure.ONE_HANDED_MODE_ENABLED, 1);
+ SystemProperties.set(OneHandedSettingsUtils.SUPPORT_ONE_HANDED_MODE, "true");
+ OneHandedSettingsUtils.setSettingsOneHandedModeEnabled(mContext, true);
final Object obj = ReflectionHelpers.callInstanceMethod(
SwipeBottomToNotificationSettings.SEARCH_INDEX_DATA_PROVIDER, "isPageSearchEnabled",
diff --git a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
index 173f625..c7a2650 100644
--- a/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/SettingsHomepageActivityTest.java
@@ -25,16 +25,20 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.ActivityManager;
import android.os.Build;
-import android.util.FeatureFlagUtils;
+import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
+import androidx.fragment.app.Fragment;
+
import com.android.settings.R;
-import com.android.settings.core.FeatureFlags;
import com.android.settings.core.HideNonSystemOverlayMixin;
+import com.android.settings.dashboard.suggestions.SuggestionFeatureProviderImpl;
import com.android.settings.homepage.contextualcards.slices.BatteryFixSliceTest;
+import com.android.settings.testutils.shadow.ShadowUserManager;
import org.junit.Before;
import org.junit.Test;
@@ -46,15 +50,20 @@
import org.robolectric.RuntimeEnvironment;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+import org.robolectric.shadow.api.Shadow;
+import org.robolectric.shadows.ShadowActivityManager;
import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowUserManager.class,
+ SettingsHomepageActivityTest.ShadowSuggestionFeatureProviderImpl.class})
public class SettingsHomepageActivityTest {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- FeatureFlagUtils.setEnabled(RuntimeEnvironment.application, FeatureFlags.SILKY_HOME, false);
}
@Test
@@ -67,6 +76,77 @@
}
@Test
+ public void launch_configDisabled_shouldHideAvatar() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+
+ final View avatarView = activity.findViewById(R.id.account_avatar);
+ assertThat(avatarView.getVisibility()).isNotEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void launch_configEnabled_shouldShowAvatar() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+
+ final View avatarView = activity.findViewById(R.id.account_avatar);
+ assertThat(avatarView.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void launch_LowRamDevice_shouldHideAvatar() {
+ final ShadowActivityManager activityManager = Shadow.extract(
+ RuntimeEnvironment.application.getSystemService(ActivityManager.class));
+ activityManager.setIsLowRamDevice(true);
+
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+
+ final View avatarView = activity.findViewById(R.id.account_avatar);
+ assertThat(avatarView.getVisibility()).isNotEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void showHomepageWithSuggestion_showSuggestion() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+ final View viewRoot = activity.findViewById(R.id.settings_homepage_container);
+ final View suggestionTile = activity.findViewById(R.id.suggestion_content);
+
+ activity.showHomepageWithSuggestion(true);
+
+ assertThat(viewRoot.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(suggestionTile.getVisibility()).isEqualTo(View.VISIBLE);
+ }
+
+ @Test
+ public void showHomepageWithSuggestion_hideSuggestion() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+ final View viewRoot = activity.findViewById(R.id.settings_homepage_container);
+ final View suggestionTile = activity.findViewById(R.id.suggestion_content);
+
+ activity.showHomepageWithSuggestion(false);
+
+ assertThat(viewRoot.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
+ public void showHomepageWithSuggestion_callTwice_shouldKeepPreviousVisibility() {
+ final SettingsHomepageActivity activity = Robolectric.buildActivity(
+ SettingsHomepageActivity.class).create().get();
+ final View suggestionTile = activity.findViewById(R.id.suggestion_content);
+
+ activity.showHomepageWithSuggestion(false);
+ activity.showHomepageWithSuggestion(true);
+
+ assertThat(suggestionTile.getVisibility()).isEqualTo(View.GONE);
+ }
+
+ @Test
@Config(shadows = {
BatteryFixSliceTest.ShadowBatteryTipLoader.class
})
@@ -114,4 +194,13 @@
assertThat(paramCaptor.getValue().privateFlags
& SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS).isEqualTo(0);
}
+
+ @Implements(SuggestionFeatureProviderImpl.class)
+ public static class ShadowSuggestionFeatureProviderImpl {
+
+ @Implementation
+ public Class<? extends Fragment> getContextualSuggestionFragment() {
+ return Fragment.class;
+ }
+ }
}