Merge changes I912e8d21,I7239d56b,Ic67d0078,I8394f580 into sc-qpr1-dev
* changes: [Provider Model] 1.Fix the color of the dark mode 2.Fix RTL layout [Provider Model] Show Wi-Fi icon with exclamation mark [Provider Model] Apply the latest figma of Provider Model [Provider Model] Show searching sub-title for 2 seconds
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Copy of progress_indeterminate_horizontal_rect2 in frameworks/base/core/res -->
|
||||||
|
<set xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<objectAnimator
|
||||||
|
android:duration="2000"
|
||||||
|
android:propertyXName="translateX"
|
||||||
|
android:pathData="M -197.60001,0 c 14.28182,0 85.07782,0 135.54689,0 c 54.26191,0 90.42461,0 168.24331,0 c 144.72154,0 316.40982,0 316.40982,0 "
|
||||||
|
android:interpolator="@interpolator/progress_indeterminate_horizontal_rect2_translatex_copy"
|
||||||
|
android:repeatCount="infinite" />
|
||||||
|
</set>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Copy of progress_indeterminate_horizontal_material_trimmed in frameworks/base/core/res -->
|
||||||
|
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:drawable="@drawable/vector_drawable_progress_indeterminate_horizontal_trimmed" >
|
||||||
|
<target
|
||||||
|
android:name="rect_grp"
|
||||||
|
android:animation="@anim/progress_indeterminate_horizontal_rect" />
|
||||||
|
</animated-vector>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Variant of vector_drawable_progress_indeterminate_horizontal in frameworks/base/core/res, which
|
||||||
|
draws the whole height of the progress bar instead having blank space above and below the
|
||||||
|
bar. -->
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
|
android:height="10dp"
|
||||||
|
android:width="340dp"
|
||||||
|
android:viewportHeight="10"
|
||||||
|
android:viewportWidth="340" >
|
||||||
|
<group
|
||||||
|
android:name="progress_group"
|
||||||
|
android:translateX="180"
|
||||||
|
android:translateY="5" >
|
||||||
|
<path
|
||||||
|
android:name="background_track"
|
||||||
|
android:pathData="M -180.0,-5.0 l 360.0,0 l 0,10.0 l -360.0,0 Z"
|
||||||
|
android:fillColor="?androidprv:attr/colorSurfaceVariant"/>
|
||||||
|
<group
|
||||||
|
android:name="rect_grp"
|
||||||
|
android:translateX="-197.60001"
|
||||||
|
android:scaleX="0.5" >
|
||||||
|
<path
|
||||||
|
android:name="rect"
|
||||||
|
android:pathData="M -144.0,-5.0 l 288.0,0 l 0,10.0 l -288.0,0 Z"
|
||||||
|
android:fillColor="?androidprv:attr/colorAccentPrimaryVariant" />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</vector>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
|
||||||
android:id="@+id/internet_connectivity_dialog"
|
android:id="@+id/internet_connectivity_dialog"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -28,7 +29,7 @@
|
|||||||
style="@style/Widget.SliceView.Panel"
|
style="@style/Widget.SliceView.Panel"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:layout_marginBottom="24dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="20dp"
|
android:layout_height="20dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="4dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:fontFamily="google-sans"
|
android:fontFamily="google-sans"
|
||||||
@@ -54,18 +55,20 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/divider"
|
||||||
android:layout_height="1dp"
|
android:layout_gravity="center_vertical|center_horizontal"
|
||||||
android:background="?android:attr/listDivider"/>
|
android:layout_width="340dp"
|
||||||
|
android:layout_height="4dp"
|
||||||
|
android:background="?androidprv:attr/colorSurfaceVariant"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/wifi_searching_progress"
|
android:id="@+id/wifi_searching_progress"
|
||||||
android:indeterminate="true"
|
android:indeterminate="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="340dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="1dp"
|
android:layout_gravity="center_horizontal"
|
||||||
android:maxHeight="1dp"
|
android:visibility="gone"
|
||||||
style="@*android:style/Widget.Material.ProgressBar.Horizontal"/>
|
style="@style/TrimmedHorizontalProgressBar"/>
|
||||||
|
|
||||||
<androidx.core.widget.NestedScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:id="@+id/scroll_view"
|
android:id="@+id/scroll_view"
|
||||||
@@ -91,12 +94,11 @@
|
|||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:layout_gravity="center_vertical|start"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="16dp"
|
||||||
android:layout_marginBottom="4dp"
|
android:paddingStart="22dp"
|
||||||
android:paddingStart="19dp"
|
android:paddingEnd="22dp">
|
||||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -105,6 +107,7 @@
|
|||||||
android:layout_gravity="center_vertical|start">
|
android:layout_gravity="center_vertical|start">
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/signal_icon"
|
android:id="@+id/signal_icon"
|
||||||
|
android:autoMirrored="true"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
@@ -120,10 +123,11 @@
|
|||||||
android:gravity="start|center_vertical">
|
android:gravity="start|center_vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mobile_title"
|
android:id="@+id/mobile_title"
|
||||||
android:layout_marginLeft="17dp"
|
android:textDirection="locale"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
@@ -131,10 +135,11 @@
|
|||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mobile_summary"
|
android:id="@+id/mobile_summary"
|
||||||
android:layout_marginLeft="17dp"
|
android:textDirection="locale"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
@@ -161,18 +166,16 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/turn_on_wifi_layout"
|
android:id="@+id/turn_on_wifi_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
android:layout_height="72dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
android:paddingStart="22dp"
|
||||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
android:paddingEnd="22dp">
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
|
||||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
@@ -182,6 +185,7 @@
|
|||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/turn_on_wifi"
|
android:text="@string/turn_on_wifi"
|
||||||
|
android:textDirection="locale"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
@@ -217,10 +221,10 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
android:paddingStart="22dp"
|
||||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
android:paddingEnd="22dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -244,10 +248,11 @@
|
|||||||
android:gravity="start|center_vertical">
|
android:gravity="start|center_vertical">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_connected_title"
|
android:id="@+id/wifi_connected_title"
|
||||||
|
android:textDirection="locale"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
@@ -255,10 +260,11 @@
|
|||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_connected_summary"
|
android:id="@+id/wifi_connected_summary"
|
||||||
|
android:textDirection="locale"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorTertiary"
|
android:textColor="?android:attr/textColorTertiary"
|
||||||
@@ -269,7 +275,7 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginEnd="5dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
<ImageView
|
<ImageView
|
||||||
@@ -301,8 +307,8 @@
|
|||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
android:paddingStart="22dp"
|
||||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
android:paddingEnd="22dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -323,9 +329,10 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginLeft="16dp">
|
android:layout_marginStart="16dp">
|
||||||
<TextView
|
<TextView
|
||||||
android:text="@string/see_all_networks"
|
android:text="@string/see_all_networks"
|
||||||
|
android:textDirection="locale"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
@@ -353,7 +360,7 @@
|
|||||||
android:id="@+id/done"
|
android:id="@+id/done"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="30dp"
|
||||||
android:layout_marginRight="24dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:background="@drawable/internet_dialog_footer_background"
|
android:background="@drawable/internet_dialog_footer_background"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
|||||||
@@ -31,8 +31,8 @@
|
|||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:background="?android:attr/selectableItemBackground"
|
android:background="?android:attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
android:paddingStart="22dp"
|
||||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
android:paddingEnd="22dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
@@ -56,12 +56,13 @@
|
|||||||
android:layout_height="72dp">
|
android:layout_height="72dp">
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_title"
|
android:id="@+id/wifi_title"
|
||||||
|
android:textDirection="locale"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorPrimary"
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
@@ -69,12 +70,13 @@
|
|||||||
android:fontFamily="google-sans"/>
|
android:fontFamily="google-sans"/>
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/wifi_summary"
|
android:id="@+id/wifi_summary"
|
||||||
|
android:textDirection="locale"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical|start"
|
||||||
android:gravity="start|center_vertical"
|
android:gravity="start|center_vertical"
|
||||||
android:layout_marginLeft="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
@@ -85,7 +87,7 @@
|
|||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginRight="@dimen/settingslib_switchbar_padding_right"
|
android:layout_marginEnd="@dimen/settingslib_switchbar_padding_right"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
@@ -291,6 +291,6 @@
|
|||||||
<color name="settingslib_track_on_color">?androidprv:attr/colorAccentPrimaryVariant</color>
|
<color name="settingslib_track_on_color">?androidprv:attr/colorAccentPrimaryVariant</color>
|
||||||
<!-- Material next track off color-->
|
<!-- Material next track off color-->
|
||||||
<color name="settingslib_track_off_color">?androidprv:attr/colorAccentSecondaryVariant</color>
|
<color name="settingslib_track_off_color">?androidprv:attr/colorAccentSecondaryVariant</color>
|
||||||
<color name="connected_network_primary_color">#ff000000</color>
|
<color name="connected_network_primary_color">#191C18</color>
|
||||||
<color name="connected_network_tertiary_color">#808080</color>
|
<color name="connected_network_secondary_color">#41493D</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -942,4 +942,13 @@
|
|||||||
<item name="android:switchMinWidth">@dimen/settingslib_min_switch_width</item>
|
<item name="android:switchMinWidth">@dimen/settingslib_min_switch_width</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TrimmedHorizontalProgressBar"
|
||||||
|
parent="android:Widget.Material.ProgressBar.Horizontal">
|
||||||
|
<item name="android:indeterminateDrawable">
|
||||||
|
@drawable/progress_indeterminate_horizontal_material_trimmed
|
||||||
|
</item>
|
||||||
|
<item name="android:minHeight">4dp</item>
|
||||||
|
<item name="android:maxHeight">4dp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package com.android.systemui.qs.tiles.dialog;
|
|||||||
import static com.android.wifitrackerlib.WifiEntry.SECURITY_NONE;
|
import static com.android.wifitrackerlib.WifiEntry.SECURITY_NONE;
|
||||||
import static com.android.wifitrackerlib.WifiEntry.SECURITY_OWE;
|
import static com.android.wifitrackerlib.WifiEntry.SECURITY_OWE;
|
||||||
|
|
||||||
import android.annotation.ColorInt;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -35,10 +34,10 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.VisibleForTesting;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
import com.android.settingslib.Utils;
|
||||||
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
@@ -98,8 +97,7 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
}
|
}
|
||||||
|
|
||||||
return mInternetDialogController.getWifiEntryList().stream()
|
return mInternetDialogController.getWifiEntryList().stream()
|
||||||
.filter(wifiAp -> wifiAp.getConnectedState()
|
.filter(wifiEntry -> !wifiEntry.isDefaultNetwork())
|
||||||
!= WifiEntry.CONNECTED_STATE_CONNECTED)
|
|
||||||
.limit(getItemCount())
|
.limit(getItemCount())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@@ -109,21 +107,21 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
* {@link InternetDialog}.
|
* {@link InternetDialog}.
|
||||||
*
|
*
|
||||||
* Airplane mode is ON (mobile network is gone):
|
* Airplane mode is ON (mobile network is gone):
|
||||||
* Return four Wi-Fi's entries if no connected Wi-Fi.
|
* Return four Wi-Fi's entries if no default Wi-Fi.
|
||||||
* Return three Wi-Fi's entries if one connected Wi-Fi.
|
* Return three Wi-Fi's entries if one default Wi-Fi.
|
||||||
* Airplane mode is OFF (mobile network is visible):
|
* Airplane mode is OFF (mobile network is visible):
|
||||||
* Return three Wi-Fi's entries if no connected Wi-Fi.
|
* Return three Wi-Fi's entries if no default Wi-Fi.
|
||||||
* Return two Wi-Fi's entries if one connected Wi-Fi.
|
* Return two Wi-Fi's entries if one default Wi-Fi.
|
||||||
*
|
*
|
||||||
* @return The total number of networks.
|
* @return The total number of networks.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
boolean hasConnectedWifi = mInternetDialogController.getConnectedWifiEntry() != null;
|
final boolean hasDefaultWifi = mInternetDialogController.getDefaultWifiEntry() != null;
|
||||||
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
||||||
return hasConnectedWifi ? 3 : 4;
|
return hasDefaultWifi ? 3 : 4;
|
||||||
} else {
|
} else {
|
||||||
return hasConnectedWifi ? 2 : 3;
|
return hasDefaultWifi ? 2 : 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,6 +140,8 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
final Context mContext;
|
final Context mContext;
|
||||||
final InternetDialogController mInternetDialogController;
|
final InternetDialogController mInternetDialogController;
|
||||||
|
|
||||||
|
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
InternetViewHolder(View view, InternetDialogController internetDialogController) {
|
InternetViewHolder(View view, InternetDialogController internetDialogController) {
|
||||||
super(view);
|
super(view);
|
||||||
mContext = view.getContext();
|
mContext = view.getContext();
|
||||||
@@ -153,6 +153,7 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
mWifiTitleText = view.requireViewById(R.id.wifi_title);
|
mWifiTitleText = view.requireViewById(R.id.wifi_title);
|
||||||
mWifiSummaryText = view.requireViewById(R.id.wifi_summary);
|
mWifiSummaryText = view.requireViewById(R.id.wifi_summary);
|
||||||
mWifiLockedIcon = view.requireViewById(R.id.wifi_locked_icon);
|
mWifiLockedIcon = view.requireViewById(R.id.wifi_locked_icon);
|
||||||
|
mWifiIconInjector = mInternetDialogController.getWifiIconInjector();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onBind(WifiEntry wifiEntry) {
|
void onBind(WifiEntry wifiEntry) {
|
||||||
@@ -207,19 +208,17 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
|||||||
mWifiSummaryText.setText(summary);
|
mWifiSummaryText.setText(summary);
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable getWifiDrawable(WifiEntry wifiEntry) throws Throwable {
|
Drawable getWifiDrawable(@NonNull WifiEntry wifiEntry) throws Throwable {
|
||||||
Drawable drawable = mContext.getDrawable(
|
final Drawable drawable = mWifiIconInjector.getIcon(wifiEntry.shouldShowXLevelIcon(),
|
||||||
com.android.internal.R.drawable.ic_wifi_signal_0);
|
wifiEntry.getLevel());
|
||||||
|
if (drawable == null) {
|
||||||
AtomicReference<Drawable> shared = new AtomicReference<>();
|
return null;
|
||||||
final @ColorInt int tint = Utils.getColorAttrDefaultColor(mContext,
|
}
|
||||||
android.R.attr.colorControlNormal);
|
drawable.setTint(
|
||||||
Drawable signalDrawable = mContext.getDrawable(
|
Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorTertiary));
|
||||||
Utils.getWifiIconResource(wifiEntry.getLevel()));
|
final AtomicReference<Drawable> shared = new AtomicReference<>();
|
||||||
signalDrawable.setTint(tint);
|
shared.set(drawable);
|
||||||
shared.set(signalDrawable);
|
return shared.get();
|
||||||
drawable = shared.get();
|
|
||||||
return drawable;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,11 +79,11 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
InternetDialogController.InternetDialogCallback, Window.Callback {
|
InternetDialogController.InternetDialogCallback, Window.Callback {
|
||||||
private static final String TAG = "InternetDialog";
|
private static final String TAG = "InternetDialog";
|
||||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||||
|
|
||||||
|
static final long PROGRESS_DELAY_MS = 2000L;
|
||||||
|
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
private final LinearLayoutManager mLayoutManager;
|
private final LinearLayoutManager mLayoutManager;
|
||||||
private final Runnable mHideProgressBarRunnable = () -> {
|
|
||||||
setProgressBarVisible(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected InternetAdapter mAdapter;
|
protected InternetAdapter mAdapter;
|
||||||
@@ -91,6 +91,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
protected WifiManager mWifiManager;
|
protected WifiManager mWifiManager;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected View mDialogView;
|
protected View mDialogView;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected WifiEntry mConnectedWifiEntry;
|
||||||
|
|
||||||
private InternetDialogFactory mInternetDialogFactory;
|
private InternetDialogFactory mInternetDialogFactory;
|
||||||
private SubscriptionManager mSubscriptionManager;
|
private SubscriptionManager mSubscriptionManager;
|
||||||
@@ -101,6 +103,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private InternetDialogController mInternetDialogController;
|
private InternetDialogController mInternetDialogController;
|
||||||
private TextView mInternetDialogTitle;
|
private TextView mInternetDialogTitle;
|
||||||
private TextView mInternetDialogSubTitle;
|
private TextView mInternetDialogSubTitle;
|
||||||
|
private View mDivider;
|
||||||
private ProgressBar mProgressBar;
|
private ProgressBar mProgressBar;
|
||||||
private LinearLayout mInternetListLayout;
|
private LinearLayout mInternetListLayout;
|
||||||
private LinearLayout mConnectedWifListLayout;
|
private LinearLayout mConnectedWifListLayout;
|
||||||
@@ -122,12 +125,21 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private Switch mWiFiToggle;
|
private Switch mWiFiToggle;
|
||||||
private Button mDoneButton;
|
private Button mDoneButton;
|
||||||
private Drawable mBackgroundOn;
|
private Drawable mBackgroundOn;
|
||||||
private WifiEntry mConnectedWifiEntry;
|
|
||||||
private int mListMaxHeight;
|
private int mListMaxHeight;
|
||||||
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||||
private boolean mIsProgressBarVisible;
|
|
||||||
private boolean mCanConfigMobileData;
|
private boolean mCanConfigMobileData;
|
||||||
|
|
||||||
|
// Wi-Fi scanning progress bar
|
||||||
|
protected boolean mIsProgressBarVisible;
|
||||||
|
protected boolean mIsSearchingHidden;
|
||||||
|
protected final Runnable mHideProgressBarRunnable = () -> {
|
||||||
|
setProgressBarVisible(false);
|
||||||
|
};
|
||||||
|
protected Runnable mHideSearchingRunnable = () -> {
|
||||||
|
mIsSearchingHidden = true;
|
||||||
|
mInternetDialogSubTitle.setText(getSubtitleText());
|
||||||
|
};
|
||||||
|
|
||||||
private final ViewTreeObserver.OnGlobalLayoutListener mInternetListLayoutListener = () -> {
|
private final ViewTreeObserver.OnGlobalLayoutListener mInternetListLayoutListener = () -> {
|
||||||
// Set max height for list
|
// Set max height for list
|
||||||
if (mInternetListLayout.getHeight() > mListMaxHeight) {
|
if (mInternetListLayout.getHeight() > mListMaxHeight) {
|
||||||
@@ -195,6 +207,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
|
|
||||||
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
||||||
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
||||||
|
mDivider = mDialogView.requireViewById(R.id.divider);
|
||||||
mProgressBar = mDialogView.requireViewById(R.id.wifi_searching_progress);
|
mProgressBar = mDialogView.requireViewById(R.id.wifi_searching_progress);
|
||||||
mInternetListLayout = mDialogView.requireViewById(R.id.internet_list);
|
mInternetListLayout = mDialogView.requireViewById(R.id.internet_list);
|
||||||
mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout);
|
mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout);
|
||||||
@@ -243,6 +256,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
Log.d(TAG, "onStop");
|
Log.d(TAG, "onStop");
|
||||||
}
|
}
|
||||||
mHandler.removeCallbacks(mHideProgressBarRunnable);
|
mHandler.removeCallbacks(mHideProgressBarRunnable);
|
||||||
|
mHandler.removeCallbacks(mHideSearchingRunnable);
|
||||||
mMobileNetworkLayout.setOnClickListener(null);
|
mMobileNetworkLayout.setOnClickListener(null);
|
||||||
mMobileDataToggle.setOnCheckedChangeListener(null);
|
mMobileDataToggle.setOnCheckedChangeListener(null);
|
||||||
mConnectedWifListLayout.setOnClickListener(null);
|
mConnectedWifListLayout.setOnClickListener(null);
|
||||||
@@ -327,14 +341,17 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mMobileSummaryText.setVisibility(View.GONE);
|
mMobileSummaryText.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
mSignalIcon.setImageDrawable(getSignalStrengthDrawable());
|
mSignalIcon.setImageDrawable(getSignalStrengthDrawable());
|
||||||
|
if (mInternetDialogController.isNightMode()) {
|
||||||
int titleColor = isCellularNetwork ? mContext.getColor(
|
int titleColor = isCellularNetwork ? mContext.getColor(
|
||||||
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||||
mContext, android.R.attr.textColorPrimary);
|
mContext, android.R.attr.textColorPrimary);
|
||||||
int summaryColor = isCellularNetwork ? mContext.getColor(
|
int summaryColor = isCellularNetwork ? mContext.getColor(
|
||||||
R.color.connected_network_tertiary_color) : Utils.getColorAttrDefaultColor(
|
R.color.connected_network_secondary_color) : Utils.getColorAttrDefaultColor(
|
||||||
mContext, android.R.attr.textColorTertiary);
|
mContext, android.R.attr.textColorSecondary);
|
||||||
|
|
||||||
mMobileTitleText.setTextColor(titleColor);
|
mMobileTitleText.setTextColor(titleColor);
|
||||||
mMobileSummaryText.setTextColor(summaryColor);
|
mMobileSummaryText.setTextColor(summaryColor);
|
||||||
|
}
|
||||||
mMobileNetworkLayout.setBackground(isCellularNetwork ? mBackgroundOn : null);
|
mMobileNetworkLayout.setBackground(isCellularNetwork ? mBackgroundOn : null);
|
||||||
|
|
||||||
mMobileDataToggle.setVisibility(mCanConfigMobileData ? View.VISIBLE : View.INVISIBLE);
|
mMobileDataToggle.setVisibility(mCanConfigMobileData ? View.VISIBLE : View.INVISIBLE);
|
||||||
@@ -342,8 +359,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setConnectedWifiLayout() {
|
private void setConnectedWifiLayout() {
|
||||||
if (!mWifiManager.isWifiEnabled()
|
if (!mWifiManager.isWifiEnabled() || mConnectedWifiEntry == null) {
|
||||||
|| mInternetDialogController.getConnectedWifiEntry() == null) {
|
|
||||||
mConnectedWifListLayout.setBackground(null);
|
mConnectedWifListLayout.setBackground(null);
|
||||||
mConnectedWifListLayout.setVisibility(View.GONE);
|
mConnectedWifListLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
@@ -351,11 +367,14 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
||||||
mConnectedWifiTitleText.setText(getConnectedWifiTitle());
|
mConnectedWifiTitleText.setText(getConnectedWifiTitle());
|
||||||
mConnectedWifiSummaryText.setText(getConnectedWifiSummary());
|
mConnectedWifiSummaryText.setText(getConnectedWifiSummary());
|
||||||
mConnectedWifiIcon.setImageDrawable(getConnectedWifiDrawable());
|
mConnectedWifiIcon.setImageDrawable(
|
||||||
|
mInternetDialogController.getConnectedWifiDrawable(mConnectedWifiEntry));
|
||||||
|
if (mInternetDialogController.isNightMode()) {
|
||||||
mConnectedWifiTitleText.setTextColor(
|
mConnectedWifiTitleText.setTextColor(
|
||||||
mContext.getColor(R.color.connected_network_primary_color));
|
mContext.getColor(R.color.connected_network_primary_color));
|
||||||
mConnectedWifiSummaryText.setTextColor(
|
mConnectedWifiSummaryText.setTextColor(
|
||||||
mContext.getColor(R.color.connected_network_tertiary_color));
|
mContext.getColor(R.color.connected_network_secondary_color));
|
||||||
|
}
|
||||||
mWifiSettingsIcon.setColorFilter(
|
mWifiSettingsIcon.setColorFilter(
|
||||||
mContext.getColor(R.color.connected_network_primary_color));
|
mContext.getColor(R.color.connected_network_primary_color));
|
||||||
mConnectedWifListLayout.setBackground(mBackgroundOn);
|
mConnectedWifListLayout.setBackground(mBackgroundOn);
|
||||||
@@ -374,16 +393,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
CharSequence getSubtitleText() {
|
CharSequence getSubtitleText() {
|
||||||
return mInternetDialogController.getSubtitleText(mIsProgressBarVisible);
|
return mInternetDialogController.getSubtitleText(
|
||||||
}
|
mIsProgressBarVisible && !mIsSearchingHidden);
|
||||||
|
|
||||||
private Drawable getConnectedWifiDrawable() {
|
|
||||||
try {
|
|
||||||
return mInternetDialogController.getWifiConnectedDrawable(mConnectedWifiEntry);
|
|
||||||
} catch (Throwable e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getSignalStrengthDrawable() {
|
private Drawable getSignalStrengthDrawable() {
|
||||||
@@ -399,14 +410,14 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getConnectedWifiTitle() {
|
String getConnectedWifiTitle() {
|
||||||
return mInternetDialogController.getConnectedWifiTitle();
|
return mInternetDialogController.getDefaultWifiTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getConnectedWifiSummary() {
|
String getConnectedWifiSummary() {
|
||||||
return mInternetDialogController.getConnectedWifiSummary();
|
return mInternetDialogController.getDefaultWifiSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showProgressBar() {
|
protected void showProgressBar() {
|
||||||
if (mWifiManager == null || !mWifiManager.isWifiEnabled()) {
|
if (mWifiManager == null || !mWifiManager.isWifiEnabled()) {
|
||||||
setProgressBarVisible(false);
|
setProgressBarVisible(false);
|
||||||
return;
|
return;
|
||||||
@@ -414,8 +425,9 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
setProgressBarVisible(true);
|
setProgressBarVisible(true);
|
||||||
List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
|
List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
|
||||||
if (wifiScanResults != null && wifiScanResults.size() > 0) {
|
if (wifiScanResults != null && wifiScanResults.size() > 0) {
|
||||||
mContext.getMainThreadHandler().postDelayed(mHideProgressBarRunnable,
|
mHandler.postDelayed(mHideProgressBarRunnable, PROGRESS_DELAY_MS);
|
||||||
2000 /* delay millis */);
|
} else if (!mIsSearchingHidden) {
|
||||||
|
mHandler.postDelayed(mHideSearchingRunnable, PROGRESS_DELAY_MS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,7 +437,8 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mIsProgressBarVisible = true;
|
mIsProgressBarVisible = true;
|
||||||
}
|
}
|
||||||
mIsProgressBarVisible = visible;
|
mIsProgressBarVisible = visible;
|
||||||
mProgressBar.setVisibility(mIsProgressBarVisible ? View.VISIBLE : View.INVISIBLE);
|
mProgressBar.setVisibility(mIsProgressBarVisible ? View.VISIBLE : View.GONE);
|
||||||
|
mDivider.setVisibility(mIsProgressBarVisible ? View.GONE : View.VISIBLE);
|
||||||
mInternetDialogSubTitle.setText(getSubtitleText());
|
mInternetDialogSubTitle.setText(getSubtitleText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ package com.android.systemui.qs.tiles.dialog;
|
|||||||
import static com.android.settingslib.mobile.MobileMappings.getIconKey;
|
import static com.android.settingslib.mobile.MobileMappings.getIconKey;
|
||||||
import static com.android.settingslib.mobile.MobileMappings.mapIconSets;
|
import static com.android.settingslib.mobile.MobileMappings.mapIconSets;
|
||||||
|
|
||||||
import android.annotation.ColorInt;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.ColorDrawable;
|
import android.graphics.drawable.ColorDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -134,6 +134,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected InternetTelephonyCallback mInternetTelephonyCallback;
|
protected InternetTelephonyCallback mInternetTelephonyCallback;
|
||||||
|
@VisibleForTesting
|
||||||
|
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
||||||
new KeyguardUpdateMonitorCallback() {
|
new KeyguardUpdateMonitorCallback() {
|
||||||
@@ -181,6 +183,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mActivityStarter = starter;
|
mActivityStarter = starter;
|
||||||
mAccessPointController = accessPointController;
|
mAccessPointController = accessPointController;
|
||||||
mConfig = MobileMappings.Config.readConfig(mContext);
|
mConfig = MobileMappings.Config.readConfig(mContext);
|
||||||
|
mWifiIconInjector = new WifiUtils.InternetIconInjector(mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onStart(@NonNull InternetDialogCallback callback) {
|
void onStart(@NonNull InternetDialogCallback callback) {
|
||||||
@@ -269,17 +272,17 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF);
|
return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
||||||
|
if (wifiList != null && wifiList.size() != 0) {
|
||||||
|
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
||||||
|
}
|
||||||
|
|
||||||
if (isProgressBarVisible) {
|
if (isProgressBarVisible) {
|
||||||
// When the Wi-Fi scan result callback is received
|
// When the Wi-Fi scan result callback is received
|
||||||
// Sub-Title: Searching for networks...
|
// Sub-Title: Searching for networks...
|
||||||
return mContext.getText(SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS);
|
return mContext.getText(SUBTITLE_TEXT_SEARCHING_FOR_NETWORKS);
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<ScanResult> wifiList = mWifiManager.getScanResults();
|
|
||||||
if (wifiList != null && wifiList.size() != 0) {
|
|
||||||
return mContext.getText(SUBTITLE_TEXT_TAP_A_NETWORK_TO_CONNECT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sub-Title:
|
// Sub-Title:
|
||||||
// show non_carrier_network_unavailable
|
// show non_carrier_network_unavailable
|
||||||
// - while Wi-Fi on + no Wi-Fi item
|
// - while Wi-Fi on + no Wi-Fi item
|
||||||
@@ -315,17 +318,21 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mContext.getText(SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE);
|
return mContext.getText(SUBTITLE_TEXT_NON_CARRIER_NETWORK_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Drawable getWifiConnectedDrawable(WifiEntry wifiEntry) throws Throwable {
|
Drawable getConnectedWifiDrawable(@NonNull WifiEntry wifiEntry) {
|
||||||
final @ColorInt int tint;
|
final Drawable drawable =
|
||||||
tint = Utils.getColorAttrDefaultColor(mContext,
|
mWifiIconInjector.getIcon(false /* noInternet*/, wifiEntry.getLevel());
|
||||||
com.android.internal.R.attr.colorAccentPrimaryVariant);
|
if (drawable == null) {
|
||||||
final Drawable drawable = mContext.getDrawable(
|
return null;
|
||||||
com.android.settingslib.Utils.getWifiIconResource(wifiEntry.getLevel()));
|
}
|
||||||
drawable.setTint(tint);
|
drawable.setTint(mContext.getColor(R.color.connected_network_primary_color));
|
||||||
|
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isNightMode() {
|
||||||
|
return (mContext.getResources().getConfiguration().uiMode
|
||||||
|
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
|
||||||
|
}
|
||||||
|
|
||||||
Drawable getSignalStrengthDrawable() {
|
Drawable getSignalStrengthDrawable() {
|
||||||
Drawable drawable = mContext.getDrawable(
|
Drawable drawable = mContext.getDrawable(
|
||||||
R.drawable.ic_signal_strength_zero_bar_no_internet);
|
R.drawable.ic_signal_strength_zero_bar_no_internet);
|
||||||
@@ -343,13 +350,9 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
drawable = shared.get();
|
drawable = shared.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawable.setTint(
|
drawable.setTint(activeNetworkIsCellular() ? mContext.getColor(
|
||||||
Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal));
|
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||||
if (activeNetworkIsCellular()) {
|
mContext, android.R.attr.textColorTertiary));
|
||||||
drawable.setTint(Utils.getColorAttrDefaultColor(mContext,
|
|
||||||
com.android.internal.R.attr.colorAccentPrimaryVariant));
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -396,7 +399,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
// Set the signal strength icon at the bottom right
|
// Set the signal strength icon at the bottom right
|
||||||
icons.setLayerGravity(1 /* index of SignalDrawable */, Gravity.BOTTOM | Gravity.RIGHT);
|
icons.setLayerGravity(1 /* index of SignalDrawable */, Gravity.BOTTOM | Gravity.RIGHT);
|
||||||
icons.setLayerSize(1 /* index of SignalDrawable */, iconSize, iconSize);
|
icons.setLayerSize(1 /* index of SignalDrawable */, iconSize, iconSize);
|
||||||
icons.setTintList(Utils.getColorAttr(context, android.R.attr.colorControlNormal));
|
icons.setTintList(Utils.getColorAttr(context, android.R.attr.textColorTertiary));
|
||||||
return icons;
|
return icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,24 +533,24 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return summary;
|
return summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getConnectedWifiTitle() {
|
String getDefaultWifiTitle() {
|
||||||
if (getConnectedWifiEntry() == null) {
|
if (getDefaultWifiEntry() == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "connected entry is null");
|
Log.d(TAG, "connected entry is null");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getConnectedWifiEntry().getTitle();
|
return getDefaultWifiEntry().getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getConnectedWifiSummary() {
|
String getDefaultWifiSummary() {
|
||||||
if (getConnectedWifiEntry() == null) {
|
if (getDefaultWifiEntry() == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "connected entry is null");
|
Log.d(TAG, "connected entry is null");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return getConnectedWifiEntry().getSummary(false);
|
return getDefaultWifiEntry().getSummary(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void launchNetworkSetting() {
|
void launchNetworkSetting() {
|
||||||
@@ -575,9 +578,12 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
return mWifiEntry;
|
return mWifiEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
WifiEntry getConnectedWifiEntry() {
|
WifiEntry getDefaultWifiEntry() {
|
||||||
|
if (mConnectedEntry != null && mConnectedEntry.isDefaultNetwork()) {
|
||||||
return mConnectedEntry;
|
return mConnectedEntry;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
WifiManager getWifiManager() {
|
WifiManager getWifiManager() {
|
||||||
return mWifiManager;
|
return mWifiManager;
|
||||||
@@ -775,7 +781,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
mConnectedEntry = null;
|
mConnectedEntry = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
mCallback.onAccessPointsChanged(mWifiEntry, mConnectedEntry);
|
mCallback.onAccessPointsChanged(mWifiEntry, getDefaultWifiEntry());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -878,6 +884,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WifiUtils.InternetIconInjector getWifiIconInjector() {
|
||||||
|
return mWifiIconInjector;
|
||||||
|
}
|
||||||
|
|
||||||
interface InternetDialogCallback {
|
interface InternetDialogCallback {
|
||||||
|
|
||||||
void onRefreshCarrierInfo();
|
void onRefreshCarrierInfo();
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.android.systemui.qs.tiles.dialog;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.testing.AndroidTestingRunner;
|
import android.testing.AndroidTestingRunner;
|
||||||
@@ -11,6 +13,7 @@ import android.widget.LinearLayout;
|
|||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
@@ -28,51 +31,55 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
|
|
||||||
private static final String WIFI_TITLE = "Wi-Fi Title";
|
private static final String WIFI_TITLE = "Wi-Fi Title";
|
||||||
private static final String WIFI_SUMMARY = "Wi-Fi Summary";
|
private static final String WIFI_SUMMARY = "Wi-Fi Summary";
|
||||||
private InternetDialogController mInternetDialogController = mock(
|
|
||||||
InternetDialogController.class);
|
@Mock
|
||||||
|
private WifiEntry mWifiEntry;
|
||||||
|
@Mock
|
||||||
|
private InternetDialogController mInternetDialogController;
|
||||||
|
@Mock
|
||||||
|
private WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
private InternetAdapter mInternetAdapter;
|
private InternetAdapter mInternetAdapter;
|
||||||
private InternetAdapter.InternetViewHolder mViewHolder;
|
private InternetAdapter.InternetViewHolder mViewHolder;
|
||||||
@Mock
|
|
||||||
private WifiEntry mWifiEntry = mock(WifiEntry.class);
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
||||||
mViewHolder = (InternetAdapter.InternetViewHolder) mInternetAdapter
|
mViewHolder = mInternetAdapter.onCreateViewHolder(new LinearLayout(mContext), 0);
|
||||||
.onCreateViewHolder(new LinearLayout(mContext), 0);
|
|
||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
||||||
|
mViewHolder.mWifiIconInjector = mWifiIconInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOnWifiOnNoConnectedWifi_returnFour() {
|
public void getItemCount_withApmOnWifiOnNoDefaultWifi_returnFour() {
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(4);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOnWifiOnHasConnectedWifi_returnThree() {
|
public void getItemCount_withApmOnWifiOnHasDefaultWifi_returnThree() {
|
||||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
when(mInternetDialogController.getConnectedWifiEntry()).thenReturn(mWifiEntry);
|
when(mInternetDialogController.getDefaultWifiEntry()).thenReturn(mWifiEntry);
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOffWifiOnNoConnectedWifi_returnThree() {
|
public void getItemCount_withApmOffWifiOnNoDefaultWifi_returnThree() {
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getItemCount_withApmOffWifiOnHasConnectedWifi_returnTwo() {
|
public void getItemCount_withApmOffWifiOnHasDefaultWifi_returnTwo() {
|
||||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
when(mInternetDialogController.getConnectedWifiEntry()).thenReturn(mWifiEntry);
|
when(mInternetDialogController.getDefaultWifiEntry()).thenReturn(mWifiEntry);
|
||||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(2);
|
assertThat(mInternetAdapter.getItemCount()).isEqualTo(2);
|
||||||
@@ -99,4 +106,22 @@ public class InternetAdapterTest extends SysuiTestCase {
|
|||||||
assertThat(mViewHolder.mWifiIcon.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(mViewHolder.mWifiIcon.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
assertThat(mViewHolder.mWifiLockedIcon.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(mViewHolder.mWifiLockedIcon.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBindViewHolder_bindDefaultWifiNetwork_getIconWithInternet() {
|
||||||
|
when(mWifiEntry.shouldShowXLevelIcon()).thenReturn(false);
|
||||||
|
|
||||||
|
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
||||||
|
|
||||||
|
verify(mWifiIconInjector).getIcon(eq(false) /* noInternet */, anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onBindViewHolder_bindNoDefaultWifiNetwork_getIconWithNoInternet() {
|
||||||
|
when(mWifiEntry.shouldShowXLevelIcon()).thenReturn(true);
|
||||||
|
|
||||||
|
mInternetAdapter.onBindViewHolder(mViewHolder, 0);
|
||||||
|
|
||||||
|
verify(mWifiIconInjector).getIcon(eq(true) /* noInternet */, anyInt());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import static com.google.common.truth.Truth.assertThat;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -13,6 +15,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.wifi.ScanResult;
|
import android.net.wifi.ScanResult;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
@@ -30,6 +33,9 @@ import androidx.test.filters.SmallTest;
|
|||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
|
import com.android.settingslib.Utils;
|
||||||
|
import com.android.settingslib.wifi.WifiUtils;
|
||||||
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.SysuiTestCase;
|
import com.android.systemui.SysuiTestCase;
|
||||||
import com.android.systemui.broadcast.BroadcastDispatcher;
|
import com.android.systemui.broadcast.BroadcastDispatcher;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
@@ -60,16 +66,12 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
private static final String CONNECTED_TITLE = "Connected Wi-Fi Title";
|
private static final String CONNECTED_TITLE = "Connected Wi-Fi Title";
|
||||||
private static final String CONNECTED_SUMMARY = "Connected Wi-Fi Summary";
|
private static final String CONNECTED_SUMMARY = "Connected Wi-Fi Summary";
|
||||||
|
|
||||||
private final UiEventLogger mUiEventLogger = mock(UiEventLogger.class);
|
@Mock
|
||||||
private MockInternetDialogController mInternetDialogController;
|
private WifiManager mWifiManager;
|
||||||
private InternetDialogController.InternetDialogCallback mCallback =
|
@Mock
|
||||||
mock(InternetDialogController.InternetDialogCallback.class);
|
private TelephonyManager mTelephonyManager;
|
||||||
private ActivityStarter mStarter = mock(ActivityStarter.class);
|
@Mock
|
||||||
private WifiManager mWifiManager = mock(WifiManager.class);
|
private SubscriptionManager mSubscriptionManager;
|
||||||
private ConnectivityManager mConnectivityManager = mock(ConnectivityManager.class);
|
|
||||||
private TelephonyManager mTelephonyManager = mock(TelephonyManager.class);
|
|
||||||
private SubscriptionManager mSubscriptionManager = mock(SubscriptionManager.class);
|
|
||||||
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
|
||||||
@Mock
|
@Mock
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -88,21 +90,31 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
private ServiceState mServiceState;
|
private ServiceState mServiceState;
|
||||||
@Mock
|
@Mock
|
||||||
private BroadcastDispatcher mBroadcastDispatcher;
|
private BroadcastDispatcher mBroadcastDispatcher;
|
||||||
|
@Mock
|
||||||
|
private WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||||
|
|
||||||
|
private MockInternetDialogController mInternetDialogController;
|
||||||
|
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||||
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
||||||
mInternetDialogController = new MockInternetDialogController(mContext, mUiEventLogger,
|
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
mStarter, mAccessPointController, mSubscriptionManager, mTelephonyManager,
|
|
||||||
mWifiManager, mConnectivityManager, mHandler, mExecutor, mBroadcastDispatcher,
|
mInternetDialogController = new MockInternetDialogController(mContext,
|
||||||
|
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
||||||
|
mSubscriptionManager, mTelephonyManager, mWifiManager,
|
||||||
|
mock(ConnectivityManager.class), mHandler, mExecutor, mBroadcastDispatcher,
|
||||||
mKeyguardUpdateMonitor, mGlobalSettings);
|
mKeyguardUpdateMonitor, mGlobalSettings);
|
||||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||||
mInternetDialogController.mOnSubscriptionsChangedListener);
|
mInternetDialogController.mOnSubscriptionsChangedListener);
|
||||||
mInternetDialogController.onStart(mCallback);
|
mInternetDialogController.onStart(
|
||||||
|
mock(InternetDialogController.InternetDialogCallback.class));
|
||||||
mInternetDialogController.mActivityStarter = mActivityStarter;
|
mInternetDialogController.mActivityStarter = mActivityStarter;
|
||||||
mInternetDialogController.mConnectedEntry = mConnectedEntry;
|
mInternetDialogController.mConnectedEntry = mConnectedEntry;
|
||||||
|
mInternetDialogController.mWifiIconInjector = mWifiIconInjector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -138,9 +150,12 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSubtitleText_withWifiOn_returnSearchWifi() {
|
public void getSubtitleText_withNoWifiEntry_returnSearchWifi() {
|
||||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||||
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
when(mWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
|
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
||||||
|
doReturn(0).when(wifiScanResults).size();
|
||||||
|
when(mWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(true),
|
assertTrue(TextUtils.equals(mInternetDialogController.getSubtitleText(true),
|
||||||
getResourcesString("wifi_empty_list_wifi_on")));
|
getResourcesString("wifi_empty_list_wifi_on")));
|
||||||
@@ -196,35 +211,53 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiTitle_withNoConnectedEntry_returnNull() {
|
public void getDefaultWifiEntry_connectedEntryIsNull_returnNull() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
assertThat(mInternetDialogController.getDefaultWifiEntry()).isNull();
|
||||||
""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiTitle_withConnectedEntry_returnTitle() {
|
public void getDefaultWifiEntry_connectedEntryIsNotDefault_returnNull() {
|
||||||
|
when(mConnectedEntry.isDefaultNetwork()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getDefaultWifiEntry()).isNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDefaultWifiEntry_connectedEntryIsDefault_returnConnectedEntry() {
|
||||||
|
// The default conditions have been set in setUp().
|
||||||
|
// - The connected Wi-Fi entry with the default network condition.
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getDefaultWifiEntry()).isEqualTo(mConnectedEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDefaultWifiTitle_withNoDefaultEntry_returnEmpty() {
|
||||||
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
|
assertThat(mInternetDialogController.getDefaultWifiTitle()).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getDefaultWifiTitle_withDefaultEntry_returnTitle() {
|
||||||
when(mConnectedEntry.getTitle()).thenReturn(CONNECTED_TITLE);
|
when(mConnectedEntry.getTitle()).thenReturn(CONNECTED_TITLE);
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
assertThat(mInternetDialogController.getDefaultWifiTitle()).isEqualTo(CONNECTED_TITLE);
|
||||||
CONNECTED_TITLE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiSummary_withNoConnectedEntry_returnNull() {
|
public void getDefaultWifiSummary_withNoDefaultEntry_returnEmpty() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
assertThat(mInternetDialogController.getDefaultWifiSummary()).isEmpty();
|
||||||
""));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getConnectedWifiSummary_withConnectedEntry_returnSummary() {
|
public void getDefaultWifiSummary_withDefaultEntry_returnSummary() {
|
||||||
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
||||||
|
|
||||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
assertThat(mInternetDialogController.getDefaultWifiSummary()).isEqualTo(CONNECTED_SUMMARY);
|
||||||
CONNECTED_SUMMARY));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -248,6 +281,17 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
|||||||
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNotNull();
|
assertThat(mInternetDialogController.getWifiDetailsSettingsIntent()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getWifiConnectedDrawable_withConnectedEntry_returnIntentIconWithColorAccent() {
|
||||||
|
final Drawable drawable = mock(Drawable.class);
|
||||||
|
when(mWifiIconInjector.getIcon(anyBoolean(), anyInt())).thenReturn(drawable);
|
||||||
|
|
||||||
|
mInternetDialogController.getConnectedWifiDrawable(mConnectedEntry);
|
||||||
|
|
||||||
|
verify(mWifiIconInjector).getIcon(eq(false), anyInt());
|
||||||
|
verify(drawable).setTint(mContext.getColor(R.color.connected_network_primary_color));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() {
|
public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() {
|
||||||
mInternetDialogController.mConnectedEntry = null;
|
mInternetDialogController.mConnectedEntry = null;
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.android.systemui.qs.tiles.dialog;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.doReturn;
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -11,6 +15,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.net.wifi.ScanResult;
|
||||||
import android.net.wifi.WifiInfo;
|
import android.net.wifi.WifiInfo;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -34,10 +39,14 @@ import org.junit.After;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SmallTest
|
@SmallTest
|
||||||
@RunWith(AndroidTestingRunner.class)
|
@RunWith(AndroidTestingRunner.class)
|
||||||
@@ -133,11 +142,13 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
||||||
when(mInternetDialogController.getConnectedWifiEntry()).thenReturn(mWifiEntry);
|
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||||
|
mInternetDialog.mConnectedWifiEntry = mWifiEntry;
|
||||||
|
|
||||||
mInternetDialog.updateDialog();
|
mInternetDialog.updateDialog();
|
||||||
|
|
||||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
||||||
R.id.wifi_connected_layout);
|
R.id.wifi_connected_layout);
|
||||||
|
|
||||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.VISIBLE);
|
assertThat(linearLayout.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,6 +181,62 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
verify(mInternetDialogController).launchNetworkSetting();
|
verify(mInternetDialogController).launchNetworkSetting();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showProgressBar_wifiDisabled_hideProgressBar() {
|
||||||
|
Mockito.reset(mHandler);
|
||||||
|
when(mMockWifiManager.isWifiEnabled()).thenReturn(false);
|
||||||
|
|
||||||
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isFalse();
|
||||||
|
verify(mHandler, never()).postDelayed(any(Runnable.class), anyLong());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() {
|
||||||
|
Mockito.reset(mHandler);
|
||||||
|
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
|
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
||||||
|
when(wifiScanResults.size()).thenReturn(1);
|
||||||
|
when(mMockWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
||||||
|
|
||||||
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
|
// Show progress bar
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
||||||
|
|
||||||
|
ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
|
||||||
|
verify(mHandler).postDelayed(runnableCaptor.capture(),
|
||||||
|
eq(InternetDialog.PROGRESS_DELAY_MS));
|
||||||
|
runnableCaptor.getValue().run();
|
||||||
|
|
||||||
|
// Then hide progress bar
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void showProgressBar_wifiEnabledWithoutWifiScanResults_showProgressBarThenHideSearch() {
|
||||||
|
Mockito.reset(mHandler);
|
||||||
|
when(mMockWifiManager.isWifiEnabled()).thenReturn(true);
|
||||||
|
List<ScanResult> wifiScanResults = mock(ArrayList.class);
|
||||||
|
when(wifiScanResults.size()).thenReturn(0);
|
||||||
|
when(mMockWifiManager.getScanResults()).thenReturn(wifiScanResults);
|
||||||
|
|
||||||
|
mInternetDialog.showProgressBar();
|
||||||
|
|
||||||
|
// Show progress bar
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
||||||
|
|
||||||
|
ArgumentCaptor<Runnable> runnableCaptor = ArgumentCaptor.forClass(Runnable.class);
|
||||||
|
verify(mHandler).postDelayed(runnableCaptor.capture(),
|
||||||
|
eq(InternetDialog.PROGRESS_DELAY_MS));
|
||||||
|
runnableCaptor.getValue().run();
|
||||||
|
|
||||||
|
// Then hide searching sub-title only
|
||||||
|
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
||||||
|
assertThat(mInternetDialog.mIsSearchingHidden).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
private class MockInternetDialog extends InternetDialog {
|
private class MockInternetDialog extends InternetDialog {
|
||||||
|
|
||||||
private String mMobileNetworkTitle;
|
private String mMobileNetworkTitle;
|
||||||
|
|||||||
Reference in New Issue
Block a user