Snap for 8398296 from dfb59f8d71 to udc-release
Change-Id: I7e52044f29930addbdb720a89aa3de73181ef6d4
This commit is contained in:
@@ -3245,6 +3245,22 @@
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" android:color="@color/homepage_network_background" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/drawable/ic_homepage_data_usage.xml"
|
||||
line="24"
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
@@ -3453,6 +3469,22 @@
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" android:color="@color/homepage_network_background" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/drawable/ic_homepage_vpn.xml"
|
||||
line="24"
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
@@ -3469,6 +3501,22 @@
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
message="Avoid using hardcoded color"
|
||||
category="Correctness"
|
||||
priority="4"
|
||||
summary="Using hardcoded color"
|
||||
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
|
||||
errorLine1=" android:color="@color/homepage_network_background" />"
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/drawable/ic_homepage_wifi_tethering.xml"
|
||||
line="24"
|
||||
column="13"/>
|
||||
</issue>
|
||||
|
||||
<issue
|
||||
id="HardCodedColor"
|
||||
severity="Error"
|
||||
@@ -4521,7 +4569,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values-en-rXC/strings.xml"
|
||||
line="3108"
|
||||
line="3144"
|
||||
column="170"/>
|
||||
</issue>
|
||||
|
||||
@@ -4537,7 +4585,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values-en-rAU/strings.xml"
|
||||
line="3112"
|
||||
line="3158"
|
||||
column="64"/>
|
||||
</issue>
|
||||
|
||||
@@ -4553,7 +4601,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values-en-rCA/strings.xml"
|
||||
line="3112"
|
||||
line="3158"
|
||||
column="64"/>
|
||||
</issue>
|
||||
|
||||
@@ -4569,7 +4617,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values-en-rGB/strings.xml"
|
||||
line="3112"
|
||||
line="3158"
|
||||
column="64"/>
|
||||
</issue>
|
||||
|
||||
@@ -4585,7 +4633,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values-en-rIN/strings.xml"
|
||||
line="3112"
|
||||
line="3158"
|
||||
column="64"/>
|
||||
</issue>
|
||||
|
||||
@@ -4601,7 +4649,7 @@
|
||||
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
|
||||
<location
|
||||
file="res/values/strings.xml"
|
||||
line="7103"
|
||||
line="7139"
|
||||
column="36"/>
|
||||
</issue>
|
||||
|
||||
|
||||
18
res/color-night/settings_two_pane_background_color.xml
Normal file
18
res/color-night/settings_two_pane_background_color.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@android:color/system_neutral1_500" android:lStar="5" />
|
||||
</selector>
|
||||
18
res/color/settings_two_pane_background_color.xml
Normal file
18
res/color/settings_two_pane_background_color.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@android:color/system_neutral1_500" android:lStar="87" />
|
||||
</selector>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid
|
||||
android:color="#639DF6"/>
|
||||
<corners android:radius="28dp"/>
|
||||
</shape>
|
||||
28
res/drawable/ic_error_outline.xml
Normal file
28
res/drawable/ic_error_outline.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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.
|
||||
*/
|
||||
-->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:pathData="M11,15h2v2h-2v-2zM11,7h2v6h-2L11,7zM11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"
|
||||
android:fillColor="?android:attr/colorError"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
||||
27
res/drawable/ic_person.xml
Normal file
27
res/drawable/ic_person.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,12q-1.65,0 -2.825,-1.175Q8,9.65 8,8q0,-1.65 1.175,-2.825Q10.35,4 12,4q1.65,0 2.825,1.175Q16,6.35 16,8q0,1.65 -1.175,2.825Q13.65,12 12,12zM4,20v-2.8q0,-0.85 0.438,-1.562 0.437,-0.713 1.162,-1.088 1.55,-0.775 3.15,-1.163Q10.35,13 12,13t3.25,0.387q1.6,0.388 3.15,1.163 0.725,0.375 1.163,1.088Q20,16.35 20,17.2L20,20zM6,18h12v-0.8q0,-0.275 -0.137,-0.5 -0.138,-0.225 -0.363,-0.35 -1.35,-0.675 -2.725,-1.013Q13.4,15 12,15t-2.775,0.338Q7.85,15.675 6.5,16.35q-0.225,0.125 -0.362,0.35 -0.138,0.225 -0.138,0.5zM12,10q0.825,0 1.412,-0.588Q14,8.825 14,8t-0.588,-1.412Q12.825,6 12,6t-1.412,0.588Q10,7.175 10,8t0.588,1.412Q11.175,10 12,10zM12,8zM12,18z"/>
|
||||
</vector>
|
||||
@@ -34,45 +34,19 @@
|
||||
android:paddingEnd="@dimen/conversation_message_list_padding"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.android.settings.display.ConversationMessageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:incoming="false"
|
||||
app:messageText="@string/screen_zoom_conversation_message_1"
|
||||
app:timestampText="@string/screen_zoom_conversation_timestamp_1"
|
||||
app:iconText="@string/screen_zoom_conversation_icon_alex"
|
||||
app:iconTextColor="@color/message_icon_text_outgoing"
|
||||
app:iconBackgroundColor="@color/message_icon_background_outgoing" />
|
||||
|
||||
<com.android.settings.display.ConversationMessageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:incoming="true"
|
||||
app:messageText="@string/screen_zoom_conversation_message_2"
|
||||
app:timestampText="@string/screen_zoom_conversation_timestamp_2"
|
||||
app:iconText="@string/screen_zoom_conversation_icon_pete"
|
||||
app:iconTextColor="@color/message_icon_text_incoming"
|
||||
app:messageText="@string/accessibility_text_reading_conversation_message_1"
|
||||
app:iconBackgroundColor="@color/message_icon_background_incoming" />
|
||||
|
||||
<com.android.settings.display.ConversationMessageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:incoming="false"
|
||||
app:messageText="@string/screen_zoom_conversation_message_3"
|
||||
app:timestampText="@string/screen_zoom_conversation_timestamp_3"
|
||||
app:iconText="@string/screen_zoom_conversation_icon_alex"
|
||||
app:iconTextColor="@color/message_icon_text_outgoing"
|
||||
app:messageText="@string/accessibility_text_reading_conversation_message_2"
|
||||
app:iconBackgroundColor="@color/message_icon_background_outgoing" />
|
||||
|
||||
<com.android.settings.display.ConversationMessageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:incoming="true"
|
||||
app:messageText="@string/screen_zoom_conversation_message_4"
|
||||
app:timestampText="@string/screen_zoom_conversation_timestamp_4"
|
||||
app:iconText="@string/screen_zoom_conversation_icon_pete"
|
||||
app:iconTextColor="@color/message_icon_text_incoming"
|
||||
app:iconBackgroundColor="@color/message_icon_background_incoming" />
|
||||
</LinearLayout>
|
||||
</view>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?androidprv:attr/colorSurface"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:background="@color/settings_two_pane_background_color">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/two_pane_suggestion_content"
|
||||
|
||||
@@ -44,16 +44,17 @@
|
||||
<color name="material_grey_100">#f5f5f5</color>
|
||||
<color name="material_grey_200">#ffffff</color>
|
||||
|
||||
<color name="message_text_incoming">#ffffffff</color>
|
||||
<color name="message_text_outgoing">#ff323232</color>
|
||||
<color name="message_text_incoming">#E4E3DA</color>
|
||||
<color name="message_text_outgoing">#1B1C17</color>
|
||||
<color name="timestamp_text_outgoing">#99323232</color>
|
||||
<color name="timestamp_text_incoming">#99ffffff</color>
|
||||
<color name="message_bubble_incoming">#689f38</color>
|
||||
<color name="message_bubble_outgoing">#ffffffff</color>
|
||||
<color name="message_icon_background_incoming">#689f38</color>
|
||||
<color name="message_bubble_incoming">#52534D</color>
|
||||
<color name="message_bubble_outgoing">#C7C8B7</color>
|
||||
<color name="message_icon_background_incoming">#E6F451</color>
|
||||
<color name="message_icon_text_incoming">#ffffffff</color>
|
||||
<color name="message_icon_background_outgoing">#4285f4</color>
|
||||
<color name="message_icon_background_outgoing">#FBBC04</color>
|
||||
<color name="message_icon_text_outgoing">#ffffffff</color>
|
||||
<color name="message_icon_color">#DADADA</color>
|
||||
|
||||
<color name="usage_graph_dots">#B0BEC5</color>
|
||||
|
||||
|
||||
@@ -266,12 +266,13 @@
|
||||
<dimen name="conversation_message_text_size">16sp</dimen>
|
||||
<dimen name="conversation_status_text_size">12sp</dimen>
|
||||
<dimen name="conversation_bubble_width_snap">20dp</dimen>
|
||||
<dimen name="message_bubble_arrow_width">9dp</dimen>
|
||||
<dimen name="message_bubble_left_right_padding">9dp</dimen>
|
||||
<dimen name="message_padding_default">18dp</dimen>
|
||||
<dimen name="message_text_left_right_padding">14dp</dimen>
|
||||
<dimen name="message_text_top_padding">10dp</dimen>
|
||||
<dimen name="message_text_bottom_padding">12dp</dimen>
|
||||
<dimen name="message_metadata_top_padding">4dp</dimen>
|
||||
<dimen name="message_icon_inset">11dp</dimen>
|
||||
|
||||
<!-- Accessibility Settings -->
|
||||
<dimen name="accessibility_layout_margin_start_end">16dp</dimen>
|
||||
|
||||
@@ -500,6 +500,15 @@
|
||||
<!-- Title for the App's locale picker activity. [CHAR LIMIT=50]-->
|
||||
<string name="app_locale_picker_title">App Language</string>
|
||||
|
||||
<!-- Title for the warning message of the locale picker activity. [CHAR LIMIT=50]-->
|
||||
<string name="warnings_title">Update the app</string>
|
||||
|
||||
<!-- Summary for the warning message of the locale picker activity. [CHAR LIMIT=70]-->
|
||||
<string name="warnings_summary">You need to update the app for the latest available languages</string>
|
||||
|
||||
<!-- Button text on warning message [CHAR LIMIT=20]-->
|
||||
<string name="warnings_button_update">Update now</string>
|
||||
|
||||
<!-- Category for the suggested app's locales. [CHAR LIMIT=50]-->
|
||||
<string name="suggested_app_locales_title">Suggested languages</string>
|
||||
|
||||
@@ -513,7 +522,11 @@
|
||||
<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]-->
|
||||
<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="desc_no_available_supported_locale">Language selection for this app isn\u2019t available from Settings.</string>
|
||||
|
||||
<!-- Description for the app without any supported languages. [CHAR LIMIT=NONE]-->
|
||||
<string name="desc_disallow_locale_change_in_settings">You can\u2019t select a language for this app from Settings.</string>
|
||||
|
||||
<!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] -->
|
||||
<plurals name="dlg_remove_locales_title">
|
||||
<item quantity="one">Remove selected language?</item>
|
||||
|
||||
@@ -244,6 +244,16 @@
|
||||
<item name="preferenceFragmentCompatStyle">@style/SetupWizardPreferenceFragmentStyle</item>
|
||||
</style>
|
||||
|
||||
<!-- This theme was applied to Settings pages which are running under SUW. -->
|
||||
<style name="SettingsPreferenceTheme.SetupWizard" parent="@style/PreferenceTheme.SettingsLib">
|
||||
<item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle.SettingsLib</item>
|
||||
<item name="android:listPreferredItemPaddingStart">@dimen/settingslib_listPreferredItemPaddingStart</item>
|
||||
<item name="android:listPreferredItemPaddingEnd">16dp</item>
|
||||
<item name="preferenceTheme">@style/PreferenceTheme.SettingsLib</item>
|
||||
<item name="android:switchStyle">@style/Switch.SettingsLib</item>
|
||||
<item name="preferenceFragmentCompatStyle">@style/SetupWizardPreferenceFragmentStyle</item>
|
||||
</style>
|
||||
|
||||
<!-- DayNight themes -->
|
||||
<style name="GlifTheme.DayNight" parent="GlifTheme.Light" />
|
||||
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme.Light" />
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/app_locale_picker_title">
|
||||
|
||||
<com.android.settingslib.widget.BannerMessagePreference
|
||||
android:key="key_warnings"
|
||||
android:icon="@drawable/ic_error_outline"
|
||||
android:title="@string/warnings_title"
|
||||
android:summary="@string/warnings_summary"/>
|
||||
|
||||
<com.android.settingslib.widget.LayoutPreference
|
||||
android:key="app_locale_description"
|
||||
android:layout="@layout/app_locale_details_description"
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
android:title="@string/date_time_set_timezone">
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
android:key="time_zone_region_preference_category">
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="region"
|
||||
@@ -35,6 +36,7 @@
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/preference_category_no_label"
|
||||
android:key="time_zone_fixed_offset_preference_category">
|
||||
<com.android.settingslib.RestrictedPreference
|
||||
android:key="fixed_offset"
|
||||
|
||||
@@ -102,11 +102,7 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
||||
|
||||
private void applyTheme() {
|
||||
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||
if (ThemeHelper.trySetDynamicColor(this)) {
|
||||
final int appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
||||
? R.style.SudDynamicColorThemeSettings_SetupWizard_DayNight
|
||||
: R.style.SudDynamicColorThemeSettings_SetupWizard;
|
||||
setTheme(appliedTheme);
|
||||
}
|
||||
setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
|
||||
ThemeHelper.trySetDynamicColor(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,19 @@ import android.app.LocaleConfig;
|
||||
import android.app.LocaleManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.InstallSourceInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.LocaleList;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -42,6 +47,8 @@ import com.android.settings.applications.AppInfoBase;
|
||||
import com.android.settings.widget.EntityHeaderController;
|
||||
import com.android.settingslib.applications.AppUtils;
|
||||
import com.android.settingslib.applications.ApplicationsState.AppEntry;
|
||||
import com.android.settingslib.widget.BannerMessagePreference;
|
||||
import com.android.settingslib.widget.BannerMessagePreference.AttentionLevel;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
|
||||
import java.util.Locale;
|
||||
@@ -54,10 +61,12 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
private static final String TAG = "AppLocaleDetails";
|
||||
|
||||
private static final String KEY_APP_DESCRIPTION = "app_locale_description";
|
||||
private static final String KEY_WARNINGS = "key_warnings";
|
||||
|
||||
private boolean mCreated = false;
|
||||
private String mPackageName;
|
||||
private LayoutPreference mPrefOfDescription;
|
||||
private ApplicationInfo mApplicationInfo;
|
||||
|
||||
/**
|
||||
* Create a instance of AppLocaleDetails.
|
||||
@@ -74,14 +83,16 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.app_locale_details);
|
||||
Bundle bundle = getArguments();
|
||||
mPackageName = bundle.getString(AppInfoBase.ARG_PACKAGE_NAME, "");
|
||||
|
||||
if (mPackageName.isEmpty()) {
|
||||
Log.d(TAG, "No package name.");
|
||||
finish();
|
||||
}
|
||||
addPreferencesFromResource(R.xml.app_locale_details);
|
||||
mPrefOfDescription = getPreferenceScreen().findPreference(KEY_APP_DESCRIPTION);
|
||||
mApplicationInfo = getApplicationInfo(mPackageName, getContext().getUserId());
|
||||
setWarningMessage();
|
||||
}
|
||||
|
||||
// Override here so we don't have an empty screen
|
||||
@@ -98,19 +109,13 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
refreshUiInternal();
|
||||
super.onResume();
|
||||
refreshUi();
|
||||
}
|
||||
|
||||
private void refreshUiInternal() {
|
||||
if (!hasAppSupportedLocales()) {
|
||||
Log.d(TAG, "No supported language.");
|
||||
mPrefOfDescription.setVisible(true);
|
||||
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
||||
description.setText(getContext().getString(R.string.no_multiple_language_supported,
|
||||
Locale.getDefault().getDisplayName(Locale.getDefault())));
|
||||
return;
|
||||
}
|
||||
private void refreshUi() {
|
||||
setWarningMessage();
|
||||
setDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,22 +136,62 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
}
|
||||
// Creates a head icon button of app on this page.
|
||||
final Activity activity = getActivity();
|
||||
ApplicationInfo applicationInfo =
|
||||
getApplicationInfo(mPackageName, getContext().getUserId());
|
||||
final Preference pref = EntityHeaderController
|
||||
.newInstance(activity, this, null /* header */)
|
||||
.setRecyclerView(getListView(), getSettingsLifecycle())
|
||||
.setIcon(Utils.getBadgedIcon(getContext(), applicationInfo))
|
||||
.setLabel(applicationInfo.loadLabel(getContext().getPackageManager()))
|
||||
.setIsInstantApp(AppUtils.isInstant(applicationInfo))
|
||||
.setIcon(Utils.getBadgedIcon(getContext(), mApplicationInfo))
|
||||
.setLabel(mApplicationInfo.loadLabel(getContext().getPackageManager()))
|
||||
.setIsInstantApp(AppUtils.isInstant(mApplicationInfo))
|
||||
.setPackageName(mPackageName)
|
||||
.setUid(applicationInfo.uid)
|
||||
.setUid(mApplicationInfo.uid)
|
||||
.setHasAppInfoLink(true)
|
||||
.setButtonActions(ActionType.ACTION_NONE, ActionType.ACTION_NONE)
|
||||
.done(activity, getPrefContext());
|
||||
getPreferenceScreen().addPreference(pref);
|
||||
}
|
||||
|
||||
private void setWarningMessage() {
|
||||
BannerMessagePreference warningPreference =
|
||||
(BannerMessagePreference) getPreferenceScreen().findPreference(KEY_WARNINGS);
|
||||
try {
|
||||
InstallSourceInfo installSourceInfo =
|
||||
getContext().getPackageManager().getInstallSourceInfo(mPackageName);
|
||||
if (mApplicationInfo.isSystemApp()
|
||||
&& installSourceInfo.getInstallingPackageName() == null) {
|
||||
warningPreference.setAttentionLevel(AttentionLevel.MEDIUM);
|
||||
warningPreference.setPositiveButtonOnClickListener(mBannerButtonClickListener);
|
||||
warningPreference.setPositiveButtonText(R.string.warnings_button_update);
|
||||
warningPreference.setVisible(true);
|
||||
} else {
|
||||
warningPreference.setVisible(false);
|
||||
}
|
||||
} catch (NameNotFoundException e) {
|
||||
Log.e(TAG, "Exception while retrieving the package installer of " + mPackageName, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDescription() {
|
||||
int res = getAppDescription();
|
||||
if (res != -1) {
|
||||
mPrefOfDescription.setVisible(true);
|
||||
TextView description = (TextView) mPrefOfDescription.findViewById(R.id.description);
|
||||
description.setText(getContext().getString(res));
|
||||
}
|
||||
}
|
||||
|
||||
private OnClickListener mBannerButtonClickListener = new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(getAppSearchIntent(mPackageName));
|
||||
}
|
||||
};
|
||||
|
||||
private static Intent getAppSearchIntent(String pkg) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse("market://details?id=" + pkg));
|
||||
return intent;
|
||||
}
|
||||
|
||||
private ApplicationInfo getApplicationInfo(String packageName, int userId) {
|
||||
ApplicationInfo applicationInfo;
|
||||
try {
|
||||
@@ -159,9 +204,19 @@ public class AppLocaleDetails extends SettingsPreferenceFragment {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasAppSupportedLocales() {
|
||||
LocaleList localeList = getPackageLocales();
|
||||
return (localeList != null && localeList.size() > 0) || getAssetLocales().length > 0;
|
||||
private int getAppDescription() {
|
||||
LocaleList packageLocaleList = getPackageLocales();
|
||||
String[] assetLocaleList = getAssetLocales();
|
||||
// TODO add apended url string, "Learn more", to these both sentenses.
|
||||
if (packageLocaleList == null && assetLocaleList.length == 0) {
|
||||
// There is no locale info from PackageManager amd AssetManager.
|
||||
return R.string.desc_no_available_supported_locale;
|
||||
} else if (packageLocaleList != null && packageLocaleList.isEmpty()) {
|
||||
// LocaleConfig is empty, and this means only allow user modify language
|
||||
// by the application.
|
||||
return R.string.desc_disallow_locale_change_in_settings;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private String[] getAssetLocales() {
|
||||
|
||||
@@ -96,12 +96,8 @@ public class SettingsBaseActivity extends FragmentActivity implements CategoryHa
|
||||
final boolean isAnySetupWizard = WizardManagerHelper.isAnySetupWizard(getIntent());
|
||||
if (isAnySetupWizard && this instanceof SubSettings) {
|
||||
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||
if (ThemeHelper.trySetDynamicColor(this)) {
|
||||
final int appliedTheme = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
||||
? R.style.SudDynamicColorThemeSettings_SetupWizard_DayNight
|
||||
: R.style.SudDynamicColorThemeSettings_SetupWizard;
|
||||
setTheme(appliedTheme);
|
||||
}
|
||||
setTheme(R.style.SettingsPreferenceTheme_SetupWizard);
|
||||
ThemeHelper.trySetDynamicColor(this);
|
||||
}
|
||||
|
||||
if (isToolbarEnabled() && !isAnySetupWizard) {
|
||||
|
||||
@@ -73,21 +73,20 @@ public class ChartDataUsagePreference extends Preference {
|
||||
}
|
||||
|
||||
private void onUpdateView() {
|
||||
UsageView chart = mUsageView;
|
||||
if ((chart == null) || (mNetworkCycleChartData == null)) {
|
||||
if ((mUsageView == null) || (mNetworkCycleChartData == null)) {
|
||||
return;
|
||||
}
|
||||
final int top = getTop();
|
||||
chart.clearPaths();
|
||||
chart.configureGraph(toInt(mEnd - mStart), top);
|
||||
calcPoints(chart, mNetworkCycleChartData.getUsageBuckets());
|
||||
setupContentDescription(chart, mNetworkCycleChartData.getUsageBuckets());
|
||||
chart.setBottomLabels(new CharSequence[] {
|
||||
mUsageView.clearPaths();
|
||||
mUsageView.configureGraph(toInt(mEnd - mStart), top);
|
||||
calcPoints(mUsageView, mNetworkCycleChartData.getUsageBuckets());
|
||||
setupContentDescription(mUsageView, mNetworkCycleChartData.getUsageBuckets());
|
||||
mUsageView.setBottomLabels(new CharSequence[] {
|
||||
Utils.formatDateRange(getContext(), mStart, mStart),
|
||||
Utils.formatDateRange(getContext(), mEnd, mEnd),
|
||||
});
|
||||
|
||||
bindNetworkPolicy(chart, mPolicy, top);
|
||||
bindNetworkPolicy(mUsageView, mPolicy, top);
|
||||
}
|
||||
|
||||
public int getTop() {
|
||||
|
||||
@@ -315,6 +315,9 @@ public class DataUsageList extends DataUsageBaseFragment
|
||||
*/
|
||||
@VisibleForTesting
|
||||
void updatePolicy() {
|
||||
if (mHeader == null) {
|
||||
return;
|
||||
}
|
||||
final NetworkPolicy policy = services.mPolicyEditor.getPolicy(mTemplate);
|
||||
final View configureButton = mHeader.findViewById(R.id.filter_settings);
|
||||
//SUB SELECT
|
||||
|
||||
@@ -21,6 +21,8 @@ import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -106,14 +108,14 @@ public class ConversationMessageView extends FrameLayout {
|
||||
MeasureSpec.EXACTLY);
|
||||
mContactIconView.measure(iconMeasureSpec, iconMeasureSpec);
|
||||
|
||||
final int arrowWidth =
|
||||
getResources().getDimensionPixelSize(R.dimen.message_bubble_arrow_width);
|
||||
final int messageBubblePadding =
|
||||
getResources().getDimensionPixelOffset(R.dimen.message_bubble_left_right_padding);
|
||||
|
||||
// We need to subtract contact icon width twice from the horizontal space to get
|
||||
// the max leftover space because we want the message bubble to extend no further than the
|
||||
// starting position of the message bubble in the opposite direction.
|
||||
final int maxLeftoverSpace = horizontalSpace - mContactIconView.getMeasuredWidth() * 2
|
||||
- arrowWidth - getPaddingLeft() - getPaddingRight();
|
||||
- messageBubblePadding - getPaddingLeft() - getPaddingRight();
|
||||
final int messageContentWidthMeasureSpec = MeasureSpec.makeMeasureSpec(maxLeftoverSpace,
|
||||
MeasureSpec.AT_MOST);
|
||||
|
||||
@@ -170,19 +172,28 @@ public class ConversationMessageView extends FrameLayout {
|
||||
private void updateViewContent() {
|
||||
mMessageTextView.setText(mMessageText);
|
||||
mStatusTextView.setText(mTimestampText);
|
||||
mStatusTextView.setVisibility(TextUtils.isEmpty(mTimestampText) ? GONE : VISIBLE);
|
||||
mContactIconView.setText(mIconText);
|
||||
|
||||
mContactIconView.setTextColor(mIconTextColor);
|
||||
final Drawable iconBase = getContext().getDrawable(R.drawable.conversation_message_icon);
|
||||
mContactIconView
|
||||
.setBackground(getTintedDrawable(getContext(), iconBase, mIconBackgroundColor));
|
||||
final Drawable iconBackground = getContext().getDrawable(
|
||||
R.drawable.conversation_message_icon);
|
||||
final Drawable icon = getContext().getDrawable(R.drawable.ic_person);
|
||||
final LayerDrawable layerDrawable = new LayerDrawable(
|
||||
new Drawable[]{
|
||||
getTintedDrawable(getContext(), iconBackground, mIconBackgroundColor),
|
||||
getTintedDrawable(getContext(), icon,
|
||||
getContext().getColor(R.color.message_icon_color))});
|
||||
final int iconInset = getResources().getDimensionPixelOffset(R.dimen.message_icon_inset);
|
||||
layerDrawable.setLayerInset(/* index= */ 1, iconInset, iconInset, iconInset, iconInset);
|
||||
mContactIconView.setBackground(layerDrawable);
|
||||
}
|
||||
|
||||
private void updateViewAppearance() {
|
||||
final Resources res = getResources();
|
||||
|
||||
final int arrowWidth = res.getDimensionPixelOffset(
|
||||
R.dimen.message_bubble_arrow_width);
|
||||
final int messageBubbleLeftRightPadding = res.getDimensionPixelOffset(
|
||||
R.dimen.message_bubble_left_right_padding);
|
||||
final int messageTextLeftRightPadding = res.getDimensionPixelOffset(
|
||||
R.dimen.message_text_left_right_padding);
|
||||
final int textTopPadding = res.getDimensionPixelOffset(
|
||||
@@ -191,14 +202,11 @@ public class ConversationMessageView extends FrameLayout {
|
||||
R.dimen.message_text_bottom_padding);
|
||||
|
||||
final int textLeftPadding, textRightPadding;
|
||||
textLeftPadding = messageTextLeftRightPadding;
|
||||
textRightPadding = messageTextLeftRightPadding;
|
||||
|
||||
if (mIncoming) {
|
||||
textLeftPadding = messageTextLeftRightPadding + arrowWidth;
|
||||
textRightPadding = messageTextLeftRightPadding;
|
||||
} else {
|
||||
textLeftPadding = messageTextLeftRightPadding;
|
||||
textRightPadding = messageTextLeftRightPadding + arrowWidth;
|
||||
}
|
||||
final int messageBubbleLeftPadding = mIncoming ? messageBubbleLeftRightPadding : 0;
|
||||
final int messageBubbleRightPadding = mIncoming ? 0 : messageBubbleLeftRightPadding;
|
||||
|
||||
// These values do not depend on whether the message includes attachments
|
||||
final int gravity = mIncoming ? (Gravity.START | Gravity.CENTER_VERTICAL) :
|
||||
@@ -216,7 +224,7 @@ public class ConversationMessageView extends FrameLayout {
|
||||
final Context context = getContext();
|
||||
|
||||
final Drawable textBackgroundDrawable = getTintedDrawable(context,
|
||||
context.getDrawable(bubbleDrawableResId),
|
||||
context.getDrawable(R.drawable.conversation_message_text_info_view_background),
|
||||
context.getColor(bubbleColorResId));
|
||||
mMessageTextAndInfoView.setBackground(textBackgroundDrawable);
|
||||
|
||||
@@ -234,6 +242,8 @@ public class ConversationMessageView extends FrameLayout {
|
||||
// Update the message row and message bubble views
|
||||
setPadding(getPaddingLeft(), messageTopPadding, getPaddingRight(), 0);
|
||||
mMessageBubble.setGravity(gravity);
|
||||
mMessageBubble.setPaddingRelative(messageBubbleLeftPadding, /* top= */ 0,
|
||||
messageBubbleRightPadding, /* bottom= */ 0);
|
||||
|
||||
updateTextAppearance();
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
|
||||
|
||||
final Window window = getWindow();
|
||||
final int color = mIsTwoPane
|
||||
? Utils.getColorAttrDefaultColor(this, com.android.internal.R.attr.colorSurface)
|
||||
? getColor(R.color.settings_two_pane_background_color)
|
||||
: Utils.getColorAttrDefaultColor(this, android.R.attr.colorBackground);
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
|
||||
@@ -21,7 +21,6 @@ import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.nearby.NearbyManager;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
@@ -55,10 +54,7 @@ public class FastPairSettingsFragment extends SettingsPreferenceFragment {
|
||||
|
||||
MainSwitchPreference mainSwitchPreference = Objects.requireNonNull(
|
||||
findPreference(SCAN_SWITCH_KEY));
|
||||
mainSwitchPreference.addOnSwitchChangeListener(
|
||||
(switchView, isChecked) ->
|
||||
NearbyManager.setFastPairScanEnabled(getContext(), isChecked));
|
||||
mainSwitchPreference.setChecked(NearbyManager.getFastPairScanEnabled(getContext()));
|
||||
mainSwitchPreference.setChecked(false);
|
||||
|
||||
Preference savedDevicePref = Objects.requireNonNull(
|
||||
findPreference(SAVED_DEVICES_PREF_KEY));
|
||||
|
||||
@@ -205,7 +205,7 @@ public class InternetResetHelper implements LifecycleObserver,
|
||||
protected void resumePreferences() {
|
||||
if (mIsRecoveryReady && mMobileNetworkController != null) {
|
||||
Log.d(TAG, "Resume the Mobile Network controller");
|
||||
mMobileNetworkController.hidePreference(false /* hide */, false /* immediately */);
|
||||
mMobileNetworkController.hidePreference(false /* hide */, true /* immediately */);
|
||||
}
|
||||
if (mIsWifiReady && mWifiTogglePreferences != null) {
|
||||
Log.d(TAG, "Resume the Wi-Fi preferences");
|
||||
|
||||
@@ -189,6 +189,8 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
|
||||
// Worker thread used for WifiPickerTracker work
|
||||
private HandlerThread mWorkerThread;
|
||||
private Handler mMainHandler;
|
||||
private Handler mWorkerHandler;
|
||||
|
||||
@VisibleForTesting
|
||||
WifiPickerTracker mWifiPickerTracker;
|
||||
@@ -289,11 +291,13 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
return SystemClock.elapsedRealtime();
|
||||
}
|
||||
};
|
||||
|
||||
mMainHandler = new Handler(Looper.getMainLooper());
|
||||
mWorkerHandler = mWorkerThread.getThreadHandler();
|
||||
mWifiPickerTracker = FeatureFactory.getFactory(context)
|
||||
.getWifiTrackerLibProvider()
|
||||
.createWifiPickerTracker(getSettingsLifecycle(), context,
|
||||
new Handler(Looper.getMainLooper()),
|
||||
mWorkerThread.getThreadHandler(),
|
||||
mMainHandler, mWorkerHandler,
|
||||
elapsedRealtimeClock,
|
||||
MAX_SCAN_AGE_MILLIS,
|
||||
SCAN_INTERVAL_MILLIS,
|
||||
@@ -365,6 +369,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
if (mWifiEnabler != null) {
|
||||
mWifiEnabler.teardownSwitchController();
|
||||
}
|
||||
|
||||
// remove all msg and callback in main handler and worker handler
|
||||
mMainHandler.removeCallbacksAndMessages(null);
|
||||
mWorkerHandler.removeCallbacksAndMessages(null);
|
||||
mWorkerThread.quit();
|
||||
|
||||
super.onDestroyView();
|
||||
@@ -649,7 +657,7 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
/** Called when the state of Wifi has changed. */
|
||||
@Override
|
||||
public void onWifiStateChanged() {
|
||||
if (mIsRestricted) {
|
||||
if (mIsRestricted || isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
final int wifiState = mWifiPickerTracker.getWifiState();
|
||||
@@ -687,6 +695,10 @@ public class WifiSettings extends RestrictedSettingsFragment
|
||||
|
||||
@Override
|
||||
public void onWifiEntriesChanged() {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsWifiEntryListStale) {
|
||||
mIsWifiEntryListStale = false;
|
||||
updateWifiEntryPreferences();
|
||||
|
||||
@@ -117,7 +117,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
|
||||
private int mLatestStatusCode = WifiDppUtils.EASY_CONNECT_EVENT_FAILURE_NONE;
|
||||
|
||||
private WifiPickerTracker mWifiPickerTracker;
|
||||
@VisibleForTesting
|
||||
WifiPickerTracker mWifiPickerTracker;
|
||||
private HandlerThread mWorkerThread;
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
@@ -193,6 +194,9 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
if (id == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!canConnectWifi(qrCodeWifiConfiguration.SSID)) return;
|
||||
|
||||
wifiManager.enableNetwork(id, /* attemptConnect */ false);
|
||||
// WifiTracker only contains a hidden SSID Wi-Fi network if it's saved.
|
||||
// We can't check if a hidden SSID Wi-Fi network is reachable in advance.
|
||||
@@ -266,6 +270,21 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
return false;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
boolean canConnectWifi(String ssid) {
|
||||
final List<WifiEntry> wifiEntries = mWifiPickerTracker.getWifiEntries();
|
||||
for (WifiEntry wifiEntry : wifiEntries) {
|
||||
if (!TextUtils.equals(wifiEntry.getSsid(), sanitizeSsid(ssid))) continue;
|
||||
|
||||
if (!wifiEntry.canConnect()) {
|
||||
Log.w(TAG, "Wi-Fi is not allowed to connect by your organization. SSID:" + ssid);
|
||||
showErrorMessageAndRestartCamera(R.string.not_allowed_by_ent);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -575,7 +594,8 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
message.sendToTarget();
|
||||
}
|
||||
|
||||
private void showErrorMessageAndRestartCamera(@StringRes int messageResId) {
|
||||
@VisibleForTesting
|
||||
void showErrorMessageAndRestartCamera(@StringRes int messageResId) {
|
||||
final Message message = mHandler.obtainMessage(MESSAGE_SHOW_ERROR_MESSAGE,
|
||||
getString(messageResId));
|
||||
message.arg1 = ARG_RESTART_CAMERA;
|
||||
@@ -603,6 +623,7 @@ public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment impl
|
||||
if (wifiConfig.networkId == newNetworkId) {
|
||||
mLatestStatusCode = WifiDppUtils.EASY_CONNECT_EVENT_SUCCESS;
|
||||
mEnrolleeWifiConfiguration = wifiConfig;
|
||||
if (!canConnectWifi(wifiConfig.SSID)) return;
|
||||
wifiManager.connect(wifiConfig, WifiDppQrCodeScannerFragment.this);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -199,7 +200,10 @@ public class WifiP2pSettings extends DashboardFragment
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
final View root = super.onCreateView(inflater, container, savedInstanceState);
|
||||
|
||||
final Activity activity = getActivity();
|
||||
if (mWifiP2pManager == null) {
|
||||
mWifiP2pManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
|
||||
@@ -332,8 +336,7 @@ public class WifiP2pSettings extends DashboardFragment
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -276,6 +276,11 @@ public class WifiSettingsTest {
|
||||
|
||||
@Test
|
||||
public void onWifiEntriesChanged_shouldChangeNextButtonState() {
|
||||
final FragmentActivity activity = mock(FragmentActivity.class);
|
||||
doReturn(false).when(activity).isFinishing();
|
||||
doReturn(false).when(activity).isDestroyed();
|
||||
doReturn(activity).when(mWifiSettings).getActivity();
|
||||
|
||||
mWifiSettings.onWifiEntriesChanged();
|
||||
|
||||
verify(mWifiSettings).changeNextButtonState(anyBoolean());
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 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.wifi.dpp;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
import com.android.wifitrackerlib.WifiPickerTracker;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WifiDppQrCodeScannerFragmentTest {
|
||||
|
||||
static final String WIFI_SSID = "wifi-ssid";
|
||||
|
||||
@Rule
|
||||
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||
@Mock
|
||||
WifiPickerTracker mWifiPickerTracker;
|
||||
@Mock
|
||||
WifiEntry mWifiEntry;
|
||||
|
||||
WifiDppQrCodeScannerFragment mFragment;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
when(mWifiEntry.getSsid()).thenReturn(WIFI_SSID);
|
||||
when(mWifiPickerTracker.getWifiEntries()).thenReturn(Arrays.asList(mWifiEntry));
|
||||
|
||||
mFragment = spy(new WifiDppQrCodeScannerFragment());
|
||||
mFragment.mWifiPickerTracker = mWifiPickerTracker;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canConnectWifi_noAvailableWifiMatch_returnTrue() {
|
||||
when(mWifiEntry.getSsid()).thenReturn("diff-wifi-ssid");
|
||||
when(mWifiEntry.canConnect()).thenReturn(false);
|
||||
|
||||
assertThat(mFragment.canConnectWifi(WIFI_SSID)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canConnectWifi_wifiCanConnect_returnTrue() {
|
||||
when(mWifiEntry.canConnect()).thenReturn(true);
|
||||
|
||||
assertThat(mFragment.canConnectWifi(WIFI_SSID)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canConnectWifi_wifiCanNotConnect_returnFalseAndShowError() {
|
||||
when(mWifiEntry.canConnect()).thenReturn(false);
|
||||
doNothing().when(mFragment).showErrorMessageAndRestartCamera(anyInt());
|
||||
|
||||
assertThat(mFragment.canConnectWifi(WIFI_SSID)).isFalse();
|
||||
verify(mFragment).showErrorMessageAndRestartCamera(anyInt());
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import android.net.wifi.p2p.WifiP2pInfo;
|
||||
import android.net.wifi.p2p.WifiP2pManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
@@ -112,30 +112,30 @@ public class WifiP2pSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityCreate_withNullBundle_canNotGetValue() {
|
||||
mFragment.onActivityCreated(null);
|
||||
public void onCreateView_withNullBundle_canNotGetValue() {
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, null);
|
||||
|
||||
assertThat(mFragment.mSelectedWifiPeer).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityCreate_withDeviceName_shouldGetDeviceName() {
|
||||
public void onCreateView_withDeviceName_shouldGetDeviceName() {
|
||||
final String fakeDeviceName = "fakename";
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiP2pSettings.SAVE_DEVICE_NAME, fakeDeviceName);
|
||||
|
||||
mFragment.onActivityCreated(bundle);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, bundle);
|
||||
|
||||
assertThat(mFragment.mSavedDeviceName).isEqualTo(fakeDeviceName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityCreate_withGroupName_shouldGetGroupName() {
|
||||
public void onCreateView_withGroupName_shouldGetGroupName() {
|
||||
final String fakeGroupName = "fakegroup";
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiP2pSettings.SAVE_SELECTED_GROUP, fakeGroupName);
|
||||
|
||||
mFragment.onActivityCreated(bundle);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, bundle);
|
||||
|
||||
assertThat(mFragment.mSelectedGroupName).isEqualTo(fakeGroupName);
|
||||
assertThat(mFragment.mSavedDeviceName).isNull();
|
||||
@@ -281,7 +281,7 @@ public class WifiP2pSettingsTest {
|
||||
final String fakeDeviceName = "fakeName";
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiP2pSettings.SAVE_DEVICE_NAME, fakeDeviceName);
|
||||
mFragment.onActivityCreated(bundle);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, bundle);
|
||||
final Dialog dialog = mFragment.onCreateDialog(WifiP2pSettings.DIALOG_RENAME);
|
||||
|
||||
mFragment.mRenameListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
@@ -294,7 +294,8 @@ public class WifiP2pSettingsTest {
|
||||
final String fakeDeviceName = "wrongName***";
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiP2pSettings.SAVE_DEVICE_NAME, fakeDeviceName);
|
||||
mFragment.onActivityCreated(bundle);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, bundle);
|
||||
|
||||
final Dialog dialog = mFragment.onCreateDialog(WifiP2pSettings.DIALOG_RENAME);
|
||||
|
||||
mFragment.mRenameListener.onClick(dialog, DialogInterface.BUTTON_POSITIVE);
|
||||
@@ -401,7 +402,7 @@ public class WifiP2pSettingsTest {
|
||||
final String fakeDeviceName = "fakeName";
|
||||
final Bundle createBundle = new Bundle();
|
||||
createBundle.putString(WifiP2pSettings.SAVE_DEVICE_NAME, fakeDeviceName);
|
||||
mFragment.onActivityCreated(createBundle);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, createBundle);
|
||||
final Bundle outBundle = new Bundle();
|
||||
final Dialog dialog = mFragment.onCreateDialog(WifiP2pSettings.DIALOG_RENAME);
|
||||
|
||||
@@ -437,7 +438,7 @@ public class WifiP2pSettingsTest {
|
||||
doReturn(groupList).when(wifiP2pGroupList).getGroupList();
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiP2pSettings.SAVE_SELECTED_GROUP, fakeGroupName);
|
||||
mFragment.onActivityCreated(bundle);
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, bundle);
|
||||
|
||||
mFragment.onPersistentGroupInfoAvailable(wifiP2pGroupList);
|
||||
|
||||
@@ -510,20 +511,20 @@ public class WifiP2pSettingsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityCreate_withNullP2pManager_shouldGetP2pManagerAgain() {
|
||||
mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
|
||||
public void onCreateView_withNullP2pManager_shouldGetP2pManagerAgain() {
|
||||
mFragment.mChannel = null; // Reset channel to re-test onCreateView flow
|
||||
mFragment.mWifiP2pManager = null;
|
||||
|
||||
mFragment.onActivityCreated(new Bundle());
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, new Bundle());
|
||||
|
||||
assertThat(mFragment.mWifiP2pManager).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onActivityCreate_withNullChannel_shouldSetP2pManagerNull() {
|
||||
public void onCreateView_withNullChannel_shouldSetP2pManagerNull() {
|
||||
doReturn(null).when(mWifiP2pManager).initialize(any(), any(), any());
|
||||
mFragment.mChannel = null; // Reset channel to re-test onActivityCreated flow
|
||||
mFragment.onActivityCreated(new Bundle());
|
||||
mFragment.mChannel = null; // Reset channel to re-test onCreateView flow
|
||||
mFragment.onCreateView(LayoutInflater.from(mContext), null, new Bundle());
|
||||
|
||||
assertThat(mFragment.mWifiP2pManager).isNull();
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class InternetResetHelperTest {
|
||||
// Show resetting preference
|
||||
assertThat(mResettingPreference.isVisible()).isTrue();
|
||||
// Show Mobile Network controller
|
||||
verify(mMobileNetworkController).hidePreference(false /* hide */, false /* immediately*/);
|
||||
verify(mMobileNetworkController).hidePreference(false /* hide */, true /* immediately*/);
|
||||
// Hide Wi-Fi preferences
|
||||
assertThat(mWifiTogglePreferences.isVisible()).isFalse();
|
||||
assertThat(mConnectedWifiEntryPreferences.isVisible()).isFalse();
|
||||
@@ -243,7 +243,7 @@ public class InternetResetHelperTest {
|
||||
assertThat(mWifiEntryPreferences.isVisible()).isTrue();
|
||||
// Hide Mobile Network controller
|
||||
verify(mMobileNetworkController, never())
|
||||
.hidePreference(false /* hide */, false /* immediately*/);
|
||||
.hidePreference(false /* hide */, true /* immediately*/);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -254,7 +254,7 @@ public class InternetResetHelperTest {
|
||||
mInternetResetHelper.resumePreferences();
|
||||
|
||||
// Show subsystem preferences
|
||||
verify(mMobileNetworkController).hidePreference(false, false);
|
||||
verify(mMobileNetworkController).hidePreference(false, true);
|
||||
assertThat(mWifiTogglePreferences.isVisible()).isTrue();
|
||||
assertThat(mConnectedWifiEntryPreferences.isVisible()).isTrue();
|
||||
assertThat(mWifiEntryPreferences.isVisible()).isTrue();
|
||||
|
||||
Reference in New Issue
Block a user