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
|
||||
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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -28,7 +29,7 @@
|
||||
style="@style/Widget.SliceView.Panel"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -46,7 +47,7 @@
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:fontFamily="google-sans"
|
||||
@@ -54,18 +55,20 @@
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?android:attr/listDivider"/>
|
||||
android:id="@+id/divider"
|
||||
android:layout_gravity="center_vertical|center_horizontal"
|
||||
android:layout_width="340dp"
|
||||
android:layout_height="4dp"
|
||||
android:background="?androidprv:attr/colorSurfaceVariant"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/wifi_searching_progress"
|
||||
android:indeterminate="true"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="340dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="1dp"
|
||||
android:maxHeight="1dp"
|
||||
style="@*android:style/Widget.Material.ProgressBar.Horizontal"/>
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:visibility="gone"
|
||||
style="@style/TrimmedHorizontalProgressBar"/>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
@@ -91,12 +94,11 @@
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:paddingStart="19dp"
|
||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginTop="16dp"
|
||||
android:paddingStart="22dp"
|
||||
android:paddingEnd="22dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="24dp"
|
||||
@@ -105,6 +107,7 @@
|
||||
android:layout_gravity="center_vertical|start">
|
||||
<ImageView
|
||||
android:id="@+id/signal_icon"
|
||||
android:autoMirrored="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
@@ -120,10 +123,11 @@
|
||||
android:gravity="start|center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/mobile_title"
|
||||
android:layout_marginLeft="17dp"
|
||||
android:textDirection="locale"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
@@ -131,10 +135,11 @@
|
||||
android:fontFamily="google-sans"/>
|
||||
<TextView
|
||||
android:id="@+id/mobile_summary"
|
||||
android:layout_marginLeft="17dp"
|
||||
android:textDirection="locale"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
@@ -161,18 +166,16 @@
|
||||
<LinearLayout
|
||||
android:id="@+id/turn_on_wifi_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_height="72dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||
android:paddingStart="22dp"
|
||||
android:paddingEnd="22dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_weight="1"
|
||||
@@ -182,6 +185,7 @@
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:text="@string/turn_on_wifi"
|
||||
android:textDirection="locale"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="start|center_vertical"
|
||||
@@ -217,10 +221,10 @@
|
||||
android:visibility="gone"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginRight="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginLeft="@dimen/settingslib_switchbar_margin"
|
||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
||||
android:layout_marginEnd="@dimen/settingslib_switchbar_margin"
|
||||
android:layout_marginStart="@dimen/settingslib_switchbar_margin"
|
||||
android:paddingStart="22dp"
|
||||
android:paddingEnd="22dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="24dp"
|
||||
@@ -244,10 +248,11 @@
|
||||
android:gravity="start|center_vertical">
|
||||
<TextView
|
||||
android:id="@+id/wifi_connected_title"
|
||||
android:textDirection="locale"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
@@ -255,10 +260,11 @@
|
||||
android:fontFamily="google-sans"/>
|
||||
<TextView
|
||||
android:id="@+id/wifi_connected_summary"
|
||||
android:textDirection="locale"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorTertiary"
|
||||
@@ -269,7 +275,7 @@
|
||||
<FrameLayout
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:clickable="false"
|
||||
android:gravity="center">
|
||||
<ImageView
|
||||
@@ -301,8 +307,8 @@
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
||||
android:paddingStart="22dp"
|
||||
android:paddingEnd="22dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="24dp"
|
||||
@@ -323,9 +329,10 @@
|
||||
android:clickable="false"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp">
|
||||
android:layout_marginStart="16dp">
|
||||
<TextView
|
||||
android:text="@string/see_all_networks"
|
||||
android:textDirection="locale"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="start|center_vertical"
|
||||
@@ -353,7 +360,7 @@
|
||||
android:id="@+id/done"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_gravity="end"
|
||||
android:background="@drawable/internet_dialog_footer_background"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
android:focusable="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="@dimen/settingslib_switchbar_padding_left"
|
||||
android:paddingEnd="@dimen/settingslib_switchbar_padding_right">
|
||||
android:paddingStart="22dp"
|
||||
android:paddingEnd="22dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="24dp"
|
||||
@@ -56,12 +56,13 @@
|
||||
android:layout_height="72dp">
|
||||
<TextView
|
||||
android:id="@+id/wifi_title"
|
||||
android:textDirection="locale"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:gravity="start|center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
@@ -69,12 +70,13 @@
|
||||
android:fontFamily="google-sans"/>
|
||||
<TextView
|
||||
android:id="@+id/wifi_summary"
|
||||
android:textDirection="locale"
|
||||
android:layout_weight="1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical|start"
|
||||
android:gravity="start|center_vertical"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
@@ -85,7 +87,7 @@
|
||||
<FrameLayout
|
||||
android:layout_width="24dp"
|
||||
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:gravity="center">
|
||||
<ImageView
|
||||
|
||||
@@ -291,6 +291,6 @@
|
||||
<color name="settingslib_track_on_color">?androidprv:attr/colorAccentPrimaryVariant</color>
|
||||
<!-- Material next track off color-->
|
||||
<color name="settingslib_track_off_color">?androidprv:attr/colorAccentSecondaryVariant</color>
|
||||
<color name="connected_network_primary_color">#ff000000</color>
|
||||
<color name="connected_network_tertiary_color">#808080</color>
|
||||
<color name="connected_network_primary_color">#191C18</color>
|
||||
<color name="connected_network_secondary_color">#41493D</color>
|
||||
</resources>
|
||||
|
||||
@@ -942,4 +942,13 @@
|
||||
<item name="android:switchMinWidth">@dimen/settingslib_min_switch_width</item>
|
||||
</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>
|
||||
|
||||
@@ -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_OWE;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -35,10 +34,10 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.android.settingslib.Utils;
|
||||
import com.android.settingslib.wifi.WifiUtils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.wifitrackerlib.WifiEntry;
|
||||
|
||||
@@ -98,8 +97,7 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
||||
}
|
||||
|
||||
return mInternetDialogController.getWifiEntryList().stream()
|
||||
.filter(wifiAp -> wifiAp.getConnectedState()
|
||||
!= WifiEntry.CONNECTED_STATE_CONNECTED)
|
||||
.filter(wifiEntry -> !wifiEntry.isDefaultNetwork())
|
||||
.limit(getItemCount())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
@@ -109,21 +107,21 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
||||
* {@link InternetDialog}.
|
||||
*
|
||||
* Airplane mode is ON (mobile network is gone):
|
||||
* Return four Wi-Fi's entries if no connected Wi-Fi.
|
||||
* Return three Wi-Fi's entries if one connected Wi-Fi.
|
||||
* Return four Wi-Fi's entries if no default Wi-Fi.
|
||||
* Return three Wi-Fi's entries if one default Wi-Fi.
|
||||
* Airplane mode is OFF (mobile network is visible):
|
||||
* Return three Wi-Fi's entries if no connected Wi-Fi.
|
||||
* Return two Wi-Fi's entries if one connected Wi-Fi.
|
||||
* Return three Wi-Fi's entries if no default Wi-Fi.
|
||||
* Return two Wi-Fi's entries if one default Wi-Fi.
|
||||
*
|
||||
* @return The total number of networks.
|
||||
*/
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
boolean hasConnectedWifi = mInternetDialogController.getConnectedWifiEntry() != null;
|
||||
final boolean hasDefaultWifi = mInternetDialogController.getDefaultWifiEntry() != null;
|
||||
if (mInternetDialogController.isAirplaneModeEnabled()) {
|
||||
return hasConnectedWifi ? 3 : 4;
|
||||
return hasDefaultWifi ? 3 : 4;
|
||||
} 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 InternetDialogController mInternetDialogController;
|
||||
|
||||
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||
|
||||
InternetViewHolder(View view, InternetDialogController internetDialogController) {
|
||||
super(view);
|
||||
mContext = view.getContext();
|
||||
@@ -153,6 +153,7 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
||||
mWifiTitleText = view.requireViewById(R.id.wifi_title);
|
||||
mWifiSummaryText = view.requireViewById(R.id.wifi_summary);
|
||||
mWifiLockedIcon = view.requireViewById(R.id.wifi_locked_icon);
|
||||
mWifiIconInjector = mInternetDialogController.getWifiIconInjector();
|
||||
}
|
||||
|
||||
void onBind(WifiEntry wifiEntry) {
|
||||
@@ -207,19 +208,17 @@ public class InternetAdapter extends RecyclerView.Adapter<InternetAdapter.Intern
|
||||
mWifiSummaryText.setText(summary);
|
||||
}
|
||||
|
||||
Drawable getWifiDrawable(WifiEntry wifiEntry) throws Throwable {
|
||||
Drawable drawable = mContext.getDrawable(
|
||||
com.android.internal.R.drawable.ic_wifi_signal_0);
|
||||
|
||||
AtomicReference<Drawable> shared = new AtomicReference<>();
|
||||
final @ColorInt int tint = Utils.getColorAttrDefaultColor(mContext,
|
||||
android.R.attr.colorControlNormal);
|
||||
Drawable signalDrawable = mContext.getDrawable(
|
||||
Utils.getWifiIconResource(wifiEntry.getLevel()));
|
||||
signalDrawable.setTint(tint);
|
||||
shared.set(signalDrawable);
|
||||
drawable = shared.get();
|
||||
return drawable;
|
||||
Drawable getWifiDrawable(@NonNull WifiEntry wifiEntry) throws Throwable {
|
||||
final Drawable drawable = mWifiIconInjector.getIcon(wifiEntry.shouldShowXLevelIcon(),
|
||||
wifiEntry.getLevel());
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
drawable.setTint(
|
||||
Utils.getColorAttrDefaultColor(mContext, android.R.attr.textColorTertiary));
|
||||
final AtomicReference<Drawable> shared = new AtomicReference<>();
|
||||
shared.set(drawable);
|
||||
return shared.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
InternetDialogController.InternetDialogCallback, Window.Callback {
|
||||
private static final String TAG = "InternetDialog";
|
||||
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
|
||||
|
||||
static final long PROGRESS_DELAY_MS = 2000L;
|
||||
|
||||
private final Handler mHandler;
|
||||
private final LinearLayoutManager mLayoutManager;
|
||||
private final Runnable mHideProgressBarRunnable = () -> {
|
||||
setProgressBarVisible(false);
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
protected InternetAdapter mAdapter;
|
||||
@@ -91,6 +91,8 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
protected WifiManager mWifiManager;
|
||||
@VisibleForTesting
|
||||
protected View mDialogView;
|
||||
@VisibleForTesting
|
||||
protected WifiEntry mConnectedWifiEntry;
|
||||
|
||||
private InternetDialogFactory mInternetDialogFactory;
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
@@ -101,6 +103,7 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
private InternetDialogController mInternetDialogController;
|
||||
private TextView mInternetDialogTitle;
|
||||
private TextView mInternetDialogSubTitle;
|
||||
private View mDivider;
|
||||
private ProgressBar mProgressBar;
|
||||
private LinearLayout mInternetListLayout;
|
||||
private LinearLayout mConnectedWifListLayout;
|
||||
@@ -122,12 +125,21 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
private Switch mWiFiToggle;
|
||||
private Button mDoneButton;
|
||||
private Drawable mBackgroundOn;
|
||||
private WifiEntry mConnectedWifiEntry;
|
||||
private int mListMaxHeight;
|
||||
private int mDefaultDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
|
||||
private boolean mIsProgressBarVisible;
|
||||
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 = () -> {
|
||||
// Set max height for list
|
||||
if (mInternetListLayout.getHeight() > mListMaxHeight) {
|
||||
@@ -195,6 +207,7 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
|
||||
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
||||
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
||||
mDivider = mDialogView.requireViewById(R.id.divider);
|
||||
mProgressBar = mDialogView.requireViewById(R.id.wifi_searching_progress);
|
||||
mInternetListLayout = mDialogView.requireViewById(R.id.internet_list);
|
||||
mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout);
|
||||
@@ -243,6 +256,7 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
Log.d(TAG, "onStop");
|
||||
}
|
||||
mHandler.removeCallbacks(mHideProgressBarRunnable);
|
||||
mHandler.removeCallbacks(mHideSearchingRunnable);
|
||||
mMobileNetworkLayout.setOnClickListener(null);
|
||||
mMobileDataToggle.setOnCheckedChangeListener(null);
|
||||
mConnectedWifListLayout.setOnClickListener(null);
|
||||
@@ -327,14 +341,17 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mMobileSummaryText.setVisibility(View.GONE);
|
||||
}
|
||||
mSignalIcon.setImageDrawable(getSignalStrengthDrawable());
|
||||
int titleColor = isCellularNetwork ? mContext.getColor(
|
||||
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||
mContext, android.R.attr.textColorPrimary);
|
||||
int summaryColor = isCellularNetwork ? mContext.getColor(
|
||||
R.color.connected_network_tertiary_color) : Utils.getColorAttrDefaultColor(
|
||||
mContext, android.R.attr.textColorTertiary);
|
||||
mMobileTitleText.setTextColor(titleColor);
|
||||
mMobileSummaryText.setTextColor(summaryColor);
|
||||
if (mInternetDialogController.isNightMode()) {
|
||||
int titleColor = isCellularNetwork ? mContext.getColor(
|
||||
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||
mContext, android.R.attr.textColorPrimary);
|
||||
int summaryColor = isCellularNetwork ? mContext.getColor(
|
||||
R.color.connected_network_secondary_color) : Utils.getColorAttrDefaultColor(
|
||||
mContext, android.R.attr.textColorSecondary);
|
||||
|
||||
mMobileTitleText.setTextColor(titleColor);
|
||||
mMobileSummaryText.setTextColor(summaryColor);
|
||||
}
|
||||
mMobileNetworkLayout.setBackground(isCellularNetwork ? mBackgroundOn : null);
|
||||
|
||||
mMobileDataToggle.setVisibility(mCanConfigMobileData ? View.VISIBLE : View.INVISIBLE);
|
||||
@@ -342,8 +359,7 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
}
|
||||
|
||||
private void setConnectedWifiLayout() {
|
||||
if (!mWifiManager.isWifiEnabled()
|
||||
|| mInternetDialogController.getConnectedWifiEntry() == null) {
|
||||
if (!mWifiManager.isWifiEnabled() || mConnectedWifiEntry == null) {
|
||||
mConnectedWifListLayout.setBackground(null);
|
||||
mConnectedWifListLayout.setVisibility(View.GONE);
|
||||
return;
|
||||
@@ -351,11 +367,14 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mConnectedWifListLayout.setVisibility(View.VISIBLE);
|
||||
mConnectedWifiTitleText.setText(getConnectedWifiTitle());
|
||||
mConnectedWifiSummaryText.setText(getConnectedWifiSummary());
|
||||
mConnectedWifiIcon.setImageDrawable(getConnectedWifiDrawable());
|
||||
mConnectedWifiTitleText.setTextColor(
|
||||
mContext.getColor(R.color.connected_network_primary_color));
|
||||
mConnectedWifiSummaryText.setTextColor(
|
||||
mContext.getColor(R.color.connected_network_tertiary_color));
|
||||
mConnectedWifiIcon.setImageDrawable(
|
||||
mInternetDialogController.getConnectedWifiDrawable(mConnectedWifiEntry));
|
||||
if (mInternetDialogController.isNightMode()) {
|
||||
mConnectedWifiTitleText.setTextColor(
|
||||
mContext.getColor(R.color.connected_network_primary_color));
|
||||
mConnectedWifiSummaryText.setTextColor(
|
||||
mContext.getColor(R.color.connected_network_secondary_color));
|
||||
}
|
||||
mWifiSettingsIcon.setColorFilter(
|
||||
mContext.getColor(R.color.connected_network_primary_color));
|
||||
mConnectedWifListLayout.setBackground(mBackgroundOn);
|
||||
@@ -374,16 +393,8 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
}
|
||||
|
||||
CharSequence getSubtitleText() {
|
||||
return mInternetDialogController.getSubtitleText(mIsProgressBarVisible);
|
||||
}
|
||||
|
||||
private Drawable getConnectedWifiDrawable() {
|
||||
try {
|
||||
return mInternetDialogController.getWifiConnectedDrawable(mConnectedWifiEntry);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return mInternetDialogController.getSubtitleText(
|
||||
mIsProgressBarVisible && !mIsSearchingHidden);
|
||||
}
|
||||
|
||||
private Drawable getSignalStrengthDrawable() {
|
||||
@@ -399,14 +410,14 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
}
|
||||
|
||||
String getConnectedWifiTitle() {
|
||||
return mInternetDialogController.getConnectedWifiTitle();
|
||||
return mInternetDialogController.getDefaultWifiTitle();
|
||||
}
|
||||
|
||||
String getConnectedWifiSummary() {
|
||||
return mInternetDialogController.getConnectedWifiSummary();
|
||||
return mInternetDialogController.getDefaultWifiSummary();
|
||||
}
|
||||
|
||||
private void showProgressBar() {
|
||||
protected void showProgressBar() {
|
||||
if (mWifiManager == null || !mWifiManager.isWifiEnabled()) {
|
||||
setProgressBarVisible(false);
|
||||
return;
|
||||
@@ -414,8 +425,9 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
setProgressBarVisible(true);
|
||||
List<ScanResult> wifiScanResults = mWifiManager.getScanResults();
|
||||
if (wifiScanResults != null && wifiScanResults.size() > 0) {
|
||||
mContext.getMainThreadHandler().postDelayed(mHideProgressBarRunnable,
|
||||
2000 /* delay millis */);
|
||||
mHandler.postDelayed(mHideProgressBarRunnable, PROGRESS_DELAY_MS);
|
||||
} else if (!mIsSearchingHidden) {
|
||||
mHandler.postDelayed(mHideSearchingRunnable, PROGRESS_DELAY_MS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,7 +437,8 @@ public class InternetDialog extends SystemUIDialog implements
|
||||
mIsProgressBarVisible = true;
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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.mapIconSets;
|
||||
|
||||
import android.annotation.ColorInt;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -134,6 +134,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
protected SubscriptionManager.OnSubscriptionsChangedListener mOnSubscriptionsChangedListener;
|
||||
@VisibleForTesting
|
||||
protected InternetTelephonyCallback mInternetTelephonyCallback;
|
||||
@VisibleForTesting
|
||||
protected WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||
|
||||
private final KeyguardUpdateMonitorCallback mKeyguardUpdateCallback =
|
||||
new KeyguardUpdateMonitorCallback() {
|
||||
@@ -181,6 +183,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
mActivityStarter = starter;
|
||||
mAccessPointController = accessPointController;
|
||||
mConfig = MobileMappings.Config.readConfig(mContext);
|
||||
mWifiIconInjector = new WifiUtils.InternetIconInjector(mContext);
|
||||
}
|
||||
|
||||
void onStart(@NonNull InternetDialogCallback callback) {
|
||||
@@ -269,17 +272,17 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
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) {
|
||||
// When the Wi-Fi scan result callback is received
|
||||
// Sub-Title: 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:
|
||||
// show non_carrier_network_unavailable
|
||||
// - 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);
|
||||
}
|
||||
|
||||
Drawable getWifiConnectedDrawable(WifiEntry wifiEntry) throws Throwable {
|
||||
final @ColorInt int tint;
|
||||
tint = Utils.getColorAttrDefaultColor(mContext,
|
||||
com.android.internal.R.attr.colorAccentPrimaryVariant);
|
||||
final Drawable drawable = mContext.getDrawable(
|
||||
com.android.settingslib.Utils.getWifiIconResource(wifiEntry.getLevel()));
|
||||
drawable.setTint(tint);
|
||||
|
||||
Drawable getConnectedWifiDrawable(@NonNull WifiEntry wifiEntry) {
|
||||
final Drawable drawable =
|
||||
mWifiIconInjector.getIcon(false /* noInternet*/, wifiEntry.getLevel());
|
||||
if (drawable == null) {
|
||||
return null;
|
||||
}
|
||||
drawable.setTint(mContext.getColor(R.color.connected_network_primary_color));
|
||||
return drawable;
|
||||
}
|
||||
|
||||
boolean isNightMode() {
|
||||
return (mContext.getResources().getConfiguration().uiMode
|
||||
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
|
||||
}
|
||||
|
||||
Drawable getSignalStrengthDrawable() {
|
||||
Drawable drawable = mContext.getDrawable(
|
||||
R.drawable.ic_signal_strength_zero_bar_no_internet);
|
||||
@@ -343,13 +350,9 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
drawable = shared.get();
|
||||
}
|
||||
|
||||
drawable.setTint(
|
||||
Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal));
|
||||
if (activeNetworkIsCellular()) {
|
||||
drawable.setTint(Utils.getColorAttrDefaultColor(mContext,
|
||||
com.android.internal.R.attr.colorAccentPrimaryVariant));
|
||||
}
|
||||
|
||||
drawable.setTint(activeNetworkIsCellular() ? mContext.getColor(
|
||||
R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor(
|
||||
mContext, android.R.attr.textColorTertiary));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -396,7 +399,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
// Set the signal strength icon at the bottom right
|
||||
icons.setLayerGravity(1 /* index of SignalDrawable */, Gravity.BOTTOM | Gravity.RIGHT);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -530,24 +533,24 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
return summary;
|
||||
}
|
||||
|
||||
String getConnectedWifiTitle() {
|
||||
if (getConnectedWifiEntry() == null) {
|
||||
String getDefaultWifiTitle() {
|
||||
if (getDefaultWifiEntry() == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "connected entry is null");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return getConnectedWifiEntry().getTitle();
|
||||
return getDefaultWifiEntry().getTitle();
|
||||
}
|
||||
|
||||
String getConnectedWifiSummary() {
|
||||
if (getConnectedWifiEntry() == null) {
|
||||
String getDefaultWifiSummary() {
|
||||
if (getDefaultWifiEntry() == null) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "connected entry is null");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
return getConnectedWifiEntry().getSummary(false);
|
||||
return getDefaultWifiEntry().getSummary(false);
|
||||
}
|
||||
|
||||
void launchNetworkSetting() {
|
||||
@@ -575,8 +578,11 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
return mWifiEntry;
|
||||
}
|
||||
|
||||
WifiEntry getConnectedWifiEntry() {
|
||||
return mConnectedEntry;
|
||||
WifiEntry getDefaultWifiEntry() {
|
||||
if (mConnectedEntry != null && mConnectedEntry.isDefaultNetwork()) {
|
||||
return mConnectedEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
WifiManager getWifiManager() {
|
||||
@@ -775,7 +781,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
mConnectedEntry = null;
|
||||
}
|
||||
|
||||
mCallback.onAccessPointsChanged(mWifiEntry, mConnectedEntry);
|
||||
mCallback.onAccessPointsChanged(mWifiEntry, getDefaultWifiEntry());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -878,6 +884,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback,
|
||||
}
|
||||
}
|
||||
|
||||
public WifiUtils.InternetIconInjector getWifiIconInjector() {
|
||||
return mWifiIconInjector;
|
||||
}
|
||||
|
||||
interface InternetDialogCallback {
|
||||
|
||||
void onRefreshCarrierInfo();
|
||||
|
||||
@@ -2,7 +2,9 @@ package com.android.systemui.qs.tiles.dialog;
|
||||
|
||||
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 android.testing.AndroidTestingRunner;
|
||||
@@ -11,6 +13,7 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.settingslib.wifi.WifiUtils;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
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_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.InternetViewHolder mViewHolder;
|
||||
@Mock
|
||||
private WifiEntry mWifiEntry = mock(WifiEntry.class);
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mInternetAdapter = new InternetAdapter(mInternetDialogController);
|
||||
mViewHolder = (InternetAdapter.InternetViewHolder) mInternetAdapter
|
||||
.onCreateViewHolder(new LinearLayout(mContext), 0);
|
||||
mViewHolder = mInternetAdapter.onCreateViewHolder(new LinearLayout(mContext), 0);
|
||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||
when(mInternetDialogController.getWifiEntryList()).thenReturn(Arrays.asList(mWifiEntry));
|
||||
mViewHolder.mWifiIconInjector = mWifiIconInjector;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getItemCount_withApmOnWifiOnNoConnectedWifi_returnFour() {
|
||||
public void getItemCount_withApmOnWifiOnNoDefaultWifi_returnFour() {
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
|
||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getItemCount_withApmOnWifiOnHasConnectedWifi_returnThree() {
|
||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
||||
when(mInternetDialogController.getConnectedWifiEntry()).thenReturn(mWifiEntry);
|
||||
public void getItemCount_withApmOnWifiOnHasDefaultWifi_returnThree() {
|
||||
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||
when(mInternetDialogController.getDefaultWifiEntry()).thenReturn(mWifiEntry);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(true);
|
||||
|
||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getItemCount_withApmOffWifiOnNoConnectedWifi_returnThree() {
|
||||
public void getItemCount_withApmOffWifiOnNoDefaultWifi_returnThree() {
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||
|
||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getItemCount_withApmOffWifiOnHasConnectedWifi_returnTwo() {
|
||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
||||
when(mInternetDialogController.getConnectedWifiEntry()).thenReturn(mWifiEntry);
|
||||
public void getItemCount_withApmOffWifiOnHasDefaultWifi_returnTwo() {
|
||||
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||
when(mInternetDialogController.getDefaultWifiEntry()).thenReturn(mWifiEntry);
|
||||
when(mInternetDialogController.isAirplaneModeEnabled()).thenReturn(false);
|
||||
|
||||
assertThat(mInternetAdapter.getItemCount()).isEqualTo(2);
|
||||
@@ -99,4 +106,22 @@ public class InternetAdapterTest extends SysuiTestCase {
|
||||
assertThat(mViewHolder.mWifiIcon.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.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
@@ -13,6 +15,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiInfo;
|
||||
@@ -30,6 +33,9 @@ import androidx.test.filters.SmallTest;
|
||||
|
||||
import com.android.internal.logging.UiEventLogger;
|
||||
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.broadcast.BroadcastDispatcher;
|
||||
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_SUMMARY = "Connected Wi-Fi Summary";
|
||||
|
||||
private final UiEventLogger mUiEventLogger = mock(UiEventLogger.class);
|
||||
private MockInternetDialogController mInternetDialogController;
|
||||
private InternetDialogController.InternetDialogCallback mCallback =
|
||||
mock(InternetDialogController.InternetDialogCallback.class);
|
||||
private ActivityStarter mStarter = mock(ActivityStarter.class);
|
||||
private WifiManager mWifiManager = mock(WifiManager.class);
|
||||
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
|
||||
private WifiManager mWifiManager;
|
||||
@Mock
|
||||
private TelephonyManager mTelephonyManager;
|
||||
@Mock
|
||||
private SubscriptionManager mSubscriptionManager;
|
||||
@Mock
|
||||
private Handler mHandler;
|
||||
@Mock
|
||||
@@ -88,21 +90,31 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
||||
private ServiceState mServiceState;
|
||||
@Mock
|
||||
private BroadcastDispatcher mBroadcastDispatcher;
|
||||
@Mock
|
||||
private WifiUtils.InternetIconInjector mWifiIconInjector;
|
||||
|
||||
private MockInternetDialogController mInternetDialogController;
|
||||
private FakeExecutor mExecutor = new FakeExecutor(new FakeSystemClock());
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
doReturn(mTelephonyManager).when(mTelephonyManager).createForSubscriptionId(SUB_ID);
|
||||
when(mWifiManager.getConnectionInfo()).thenReturn(mWifiInfo);
|
||||
mInternetDialogController = new MockInternetDialogController(mContext, mUiEventLogger,
|
||||
mStarter, mAccessPointController, mSubscriptionManager, mTelephonyManager,
|
||||
mWifiManager, mConnectivityManager, mHandler, mExecutor, mBroadcastDispatcher,
|
||||
when(mConnectedEntry.isDefaultNetwork()).thenReturn(true);
|
||||
|
||||
mInternetDialogController = new MockInternetDialogController(mContext,
|
||||
mock(UiEventLogger.class), mock(ActivityStarter.class), mAccessPointController,
|
||||
mSubscriptionManager, mTelephonyManager, mWifiManager,
|
||||
mock(ConnectivityManager.class), mHandler, mExecutor, mBroadcastDispatcher,
|
||||
mKeyguardUpdateMonitor, mGlobalSettings);
|
||||
mSubscriptionManager.addOnSubscriptionsChangedListener(mExecutor,
|
||||
mInternetDialogController.mOnSubscriptionsChangedListener);
|
||||
mInternetDialogController.onStart(mCallback);
|
||||
mInternetDialogController.onStart(
|
||||
mock(InternetDialogController.InternetDialogCallback.class));
|
||||
mInternetDialogController.mActivityStarter = mActivityStarter;
|
||||
mInternetDialogController.mConnectedEntry = mConnectedEntry;
|
||||
mInternetDialogController.mWifiIconInjector = mWifiIconInjector;
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -138,9 +150,12 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSubtitleText_withWifiOn_returnSearchWifi() {
|
||||
public void getSubtitleText_withNoWifiEntry_returnSearchWifi() {
|
||||
mInternetDialogController.setAirplaneModeEnabled(false);
|
||||
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),
|
||||
getResourcesString("wifi_empty_list_wifi_on")));
|
||||
@@ -196,35 +211,53 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConnectedWifiTitle_withNoConnectedEntry_returnNull() {
|
||||
public void getDefaultWifiEntry_connectedEntryIsNull_returnNull() {
|
||||
mInternetDialogController.mConnectedEntry = null;
|
||||
|
||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
||||
""));
|
||||
assertThat(mInternetDialogController.getDefaultWifiEntry()).isNull();
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiTitle(),
|
||||
CONNECTED_TITLE));
|
||||
assertThat(mInternetDialogController.getDefaultWifiTitle()).isEqualTo(CONNECTED_TITLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConnectedWifiSummary_withNoConnectedEntry_returnNull() {
|
||||
public void getDefaultWifiSummary_withNoDefaultEntry_returnEmpty() {
|
||||
mInternetDialogController.mConnectedEntry = null;
|
||||
|
||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
||||
""));
|
||||
assertThat(mInternetDialogController.getDefaultWifiSummary()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getConnectedWifiSummary_withConnectedEntry_returnSummary() {
|
||||
public void getDefaultWifiSummary_withDefaultEntry_returnSummary() {
|
||||
when(mConnectedEntry.getSummary(false)).thenReturn(CONNECTED_SUMMARY);
|
||||
|
||||
assertTrue(TextUtils.equals(mInternetDialogController.getConnectedWifiSummary(),
|
||||
CONNECTED_SUMMARY));
|
||||
assertThat(mInternetDialogController.getDefaultWifiSummary()).isEqualTo(CONNECTED_SUMMARY);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -248,6 +281,17 @@ public class InternetDialogControllerTest extends SysuiTestCase {
|
||||
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
|
||||
public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() {
|
||||
mInternetDialogController.mConnectedEntry = null;
|
||||
|
||||
@@ -2,8 +2,12 @@ package com.android.systemui.qs.tiles.dialog;
|
||||
|
||||
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.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -11,6 +15,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.wifi.ScanResult;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Handler;
|
||||
@@ -34,10 +39,14 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@@ -133,11 +142,13 @@ public class InternetDialogTest extends SysuiTestCase {
|
||||
when(mWifiEntry.getTitle()).thenReturn(WIFI_TITLE);
|
||||
when(mWifiEntry.getSummary(false)).thenReturn(WIFI_SUMMARY);
|
||||
when(mWifiEntry.getConnectedState()).thenReturn(WifiEntry.CONNECTED_STATE_CONNECTED);
|
||||
when(mInternetDialogController.getConnectedWifiEntry()).thenReturn(mWifiEntry);
|
||||
when(mWifiEntry.isDefaultNetwork()).thenReturn(true);
|
||||
mInternetDialog.mConnectedWifiEntry = mWifiEntry;
|
||||
|
||||
mInternetDialog.updateDialog();
|
||||
|
||||
final LinearLayout linearLayout = mInternetDialog.mDialogView.requireViewById(
|
||||
R.id.wifi_connected_layout);
|
||||
|
||||
assertThat(linearLayout.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -170,6 +181,62 @@ public class InternetDialogTest extends SysuiTestCase {
|
||||
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 String mMobileNetworkTitle;
|
||||
|
||||
Reference in New Issue
Block a user