From 659b2885d32a808f23193a7a95cd241d82991cae Mon Sep 17 00:00:00 2001 From: Weng Su Date: Fri, 23 Jul 2021 02:29:10 +0800 Subject: [PATCH 1/4] [Provider Model] Show searching sub-title for 2 seconds - When Wi-Fi entry is empty - Show searching sub-title for 2 seconds - Then show following sub-title - "No other networks available" if only Wi-Fi unavailable - "No networks available" if both Wi-Fi and mobile-data unavailable Bug: 192818223 Bug: 192934101 Bug: 192935392 Test: manual test atest InternetDialogTest \ InternetDialogControllerTest Change-Id: I8394f5808d776589cbf115e6df8a7d456df5bc17 Merged-In: I8394f5808d776589cbf115e6df8a7d456df5bc17 (cherry picked from commit dc7dea86733b71d034fa229b3d545c3f3b402430) --- .../qs/tiles/dialog/InternetDialog.java | 29 ++++++--- .../dialog/InternetDialogController.java | 10 +-- .../dialog/InternetDialogControllerTest.java | 5 +- .../qs/tiles/dialog/InternetDialogTest.java | 61 +++++++++++++++++++ 4 files changed, 91 insertions(+), 14 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java index ce1c2fd08a4d9..44c933cd16e9a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java @@ -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; @@ -125,9 +125,19 @@ public class InternetDialog extends SystemUIDialog implements 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) { @@ -243,6 +253,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); @@ -374,7 +385,8 @@ public class InternetDialog extends SystemUIDialog implements } CharSequence getSubtitleText() { - return mInternetDialogController.getSubtitleText(mIsProgressBarVisible); + return mInternetDialogController.getSubtitleText( + mIsProgressBarVisible && !mIsSearchingHidden); } private Drawable getConnectedWifiDrawable() { @@ -406,7 +418,7 @@ public class InternetDialog extends SystemUIDialog implements return mInternetDialogController.getConnectedWifiSummary(); } - private void showProgressBar() { + protected void showProgressBar() { if (mWifiManager == null || !mWifiManager.isWifiEnabled()) { setProgressBarVisible(false); return; @@ -414,8 +426,9 @@ public class InternetDialog extends SystemUIDialog implements setProgressBarVisible(true); List 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); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java index edab33aa6aff5..13c576301e643 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java @@ -269,17 +269,17 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, return mContext.getText(SUBTITLE_TEXT_WIFI_IS_OFF); } + final List 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 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 diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java index facb19fae95a4..68df19ef93c9a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java @@ -138,9 +138,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 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"))); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java index 94bd959c9585a..a1a7e716e6c0d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java @@ -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,13 @@ 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.MockitoAnnotations; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; @SmallTest @RunWith(AndroidTestingRunner.class) @@ -170,6 +178,59 @@ public class InternetDialogTest extends SysuiTestCase { verify(mInternetDialogController).launchNetworkSetting(); } + @Test + public void showProgressBar_wifiDisabled_hideProgressBar() { + 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() { + when(mMockWifiManager.isWifiEnabled()).thenReturn(true); + List wifiScanResults = mock(ArrayList.class); + when(wifiScanResults.size()).thenReturn(1); + when(mMockWifiManager.getScanResults()).thenReturn(wifiScanResults); + + mInternetDialog.showProgressBar(); + + // Show progress bar + assertThat(mInternetDialog.mIsProgressBarVisible).isTrue(); + + ArgumentCaptor 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() { + when(mMockWifiManager.isWifiEnabled()).thenReturn(true); + List wifiScanResults = mock(ArrayList.class); + when(wifiScanResults.size()).thenReturn(0); + when(mMockWifiManager.getScanResults()).thenReturn(wifiScanResults); + + mInternetDialog.showProgressBar(); + + // Show progress bar + assertThat(mInternetDialog.mIsProgressBarVisible).isTrue(); + + ArgumentCaptor 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; From d4712ff999da1d68a21b0f5a20d63775c3b98b21 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Thu, 29 Jul 2021 16:30:21 +0800 Subject: [PATCH 2/4] [Provider Model] Apply the latest figma of Provider Model Test: manual Bug: 194982368 Change-Id: Ic67d00787da7d4a6d971578ee8c7c3daa43fbfc3 Merged-In: Ic67d00787da7d4a6d971578ee8c7c3daa43fbfc3 (cherry picked from commit c9d30aeb46cd672cf68ace4011656c33bfde77aa) --- ...progress_indeterminate_horizontal_rect.xml | 25 ++++++++++ ...eterminate_horizontal_material_trimmed.xml | 23 +++++++++ ...gress_indeterminate_horizontal_trimmed.xml | 44 +++++++++++++++++ .../layout/internet_connectivity_dialog.xml | 48 +++++++++---------- .../res/layout/internet_list_item.xml | 4 +- packages/SystemUI/res/values/styles.xml | 9 ++++ .../qs/tiles/dialog/InternetDialog.java | 5 +- .../dialog/InternetDialogController.java | 7 +-- 8 files changed, 132 insertions(+), 33 deletions(-) create mode 100644 packages/SystemUI/res/anim/progress_indeterminate_horizontal_rect.xml create mode 100644 packages/SystemUI/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml create mode 100644 packages/SystemUI/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml diff --git a/packages/SystemUI/res/anim/progress_indeterminate_horizontal_rect.xml b/packages/SystemUI/res/anim/progress_indeterminate_horizontal_rect.xml new file mode 100644 index 0000000000000..13133cb451e41 --- /dev/null +++ b/packages/SystemUI/res/anim/progress_indeterminate_horizontal_rect.xml @@ -0,0 +1,25 @@ + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml b/packages/SystemUI/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml new file mode 100644 index 0000000000000..95209f8eb8abf --- /dev/null +++ b/packages/SystemUI/res/drawable/progress_indeterminate_horizontal_material_trimmed.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml b/packages/SystemUI/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml new file mode 100644 index 0000000000000..aec204f45aa7c --- /dev/null +++ b/packages/SystemUI/res/drawable/vector_drawable_progress_indeterminate_horizontal_trimmed.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/internet_connectivity_dialog.xml b/packages/SystemUI/res/layout/internet_connectivity_dialog.xml index 7f22b71832a3d..f7919d43c551b 100644 --- a/packages/SystemUI/res/layout/internet_connectivity_dialog.xml +++ b/packages/SystemUI/res/layout/internet_connectivity_dialog.xml @@ -17,6 +17,7 @@ @@ -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 @@ + android:id="@+id/divider" + android:layout_gravity="center_vertical|center_horizontal" + android:layout_width="340dp" + android:layout_height="4dp" + android:background="?androidprv:attr/colorSurfaceVariant"/> + android:layout_gravity="center_horizontal" + android:visibility="gone" + style="@style/TrimmedHorizontalProgressBar"/> + android:layout_marginTop="16dp" + android:paddingStart="22dp" + android:paddingEnd="22dp"> + android:paddingStart="22dp" + android:paddingEnd="22dp"> + android:paddingStart="22dp" + android:paddingEnd="22dp"> + android:paddingStart="22dp" + android:paddingEnd="22dp"> + android:paddingStart="22dp" + android:paddingEnd="22dp"> @dimen/settingslib_min_switch_width + + diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java index 44c933cd16e9a..f303aa9df4127 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java @@ -101,6 +101,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; @@ -205,6 +206,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); @@ -438,7 +440,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()); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java index 13c576301e643..8123fc855be52 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java @@ -318,7 +318,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, Drawable getWifiConnectedDrawable(WifiEntry wifiEntry) throws Throwable { final @ColorInt int tint; tint = Utils.getColorAttrDefaultColor(mContext, - com.android.internal.R.attr.colorAccentPrimaryVariant); + com.android.internal.R.attr.colorControlNormal); final Drawable drawable = mContext.getDrawable( com.android.settingslib.Utils.getWifiIconResource(wifiEntry.getLevel())); drawable.setTint(tint); @@ -345,11 +345,6 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, drawable.setTint( Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal)); - if (activeNetworkIsCellular()) { - drawable.setTint(Utils.getColorAttrDefaultColor(mContext, - com.android.internal.R.attr.colorAccentPrimaryVariant)); - } - } catch (Throwable e) { e.printStackTrace(); } From 29aedbe529b3b63c96746b926c4c589e5f2780d5 Mon Sep 17 00:00:00 2001 From: Weng Su Date: Wed, 28 Jul 2021 00:47:00 +0800 Subject: [PATCH 3/4] [Provider Model] Show Wi-Fi icon with exclamation mark - Show Wi-Fi icon with exclamation mark if the Wi-Fi has no the internet access (e.g. Printer/GoPro cases). - If the Wi-Fi network is the default network from ConnectivityManager, then the Wi-Fi should be available for the internet access. Bug: 192923176 Test: manual test atest -c InternetAdapterTest \ InternetDialogControllerTest \ InternetDialogTest Change-Id: I7239d56b1ad394950f61f51779f0dac611aeddea Merged-In: I7239d56b1ad394950f61f51779f0dac611aeddea (cherry picked from commit a51e9f50c633b6d77609fa73f6c8ccf9a2a71a5a) --- .../qs/tiles/dialog/InternetAdapter.java | 47 +++++----- .../qs/tiles/dialog/InternetDialog.java | 22 ++--- .../dialog/InternetDialogController.java | 45 +++++---- .../qs/tiles/dialog/InternetAdapterTest.java | 55 ++++++++--- .../dialog/InternetDialogControllerTest.java | 93 +++++++++++++------ .../qs/tiles/dialog/InternetDialogTest.java | 10 +- 6 files changed, 172 insertions(+), 100 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java index 44c1b7bd7332f..13ee155d5af26 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java @@ -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 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 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.colorControlNormal)); + final AtomicReference shared = new AtomicReference<>(); + shared.set(drawable); + return shared.get(); } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java index f303aa9df4127..2a962bc90bab2 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java @@ -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; @@ -123,7 +125,6 @@ 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 mCanConfigMobileData; @@ -355,8 +356,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; @@ -364,7 +364,8 @@ public class InternetDialog extends SystemUIDialog implements mConnectedWifListLayout.setVisibility(View.VISIBLE); mConnectedWifiTitleText.setText(getConnectedWifiTitle()); mConnectedWifiSummaryText.setText(getConnectedWifiSummary()); - mConnectedWifiIcon.setImageDrawable(getConnectedWifiDrawable()); + mConnectedWifiIcon.setImageDrawable( + mInternetDialogController.getConnectedWifiDrawable(mConnectedWifiEntry)); mConnectedWifiTitleText.setTextColor( mContext.getColor(R.color.connected_network_primary_color)); mConnectedWifiSummaryText.setTextColor( @@ -391,15 +392,6 @@ public class InternetDialog extends SystemUIDialog implements mIsProgressBarVisible && !mIsSearchingHidden); } - private Drawable getConnectedWifiDrawable() { - try { - return mInternetDialogController.getWifiConnectedDrawable(mConnectedWifiEntry); - } catch (Throwable e) { - e.printStackTrace(); - } - return null; - } - private Drawable getSignalStrengthDrawable() { return mInternetDialogController.getSignalStrengthDrawable(); } @@ -413,11 +405,11 @@ public class InternetDialog extends SystemUIDialog implements } String getConnectedWifiTitle() { - return mInternetDialogController.getConnectedWifiTitle(); + return mInternetDialogController.getDefaultWifiTitle(); } String getConnectedWifiSummary() { - return mInternetDialogController.getConnectedWifiSummary(); + return mInternetDialogController.getDefaultWifiSummary(); } protected void showProgressBar() { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java index 8123fc855be52..5c22e855a3d0f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java @@ -19,7 +19,6 @@ 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; @@ -134,6 +133,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 +182,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) { @@ -315,14 +317,14 @@ 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.colorControlNormal); - 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(Utils.getColorAttrDefaultColor(mContext, + com.android.internal.R.attr.colorControlNormal)); return drawable; } @@ -525,24 +527,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() { @@ -570,8 +572,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() { @@ -770,7 +775,7 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, mConnectedEntry = null; } - mCallback.onAccessPointsChanged(mWifiEntry, mConnectedEntry); + mCallback.onAccessPointsChanged(mWifiEntry, getDefaultWifiEntry()); } @Override @@ -873,6 +878,10 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, } } + public WifiUtils.InternetIconInjector getWifiIconInjector() { + return mWifiIconInjector; + } + interface InternetDialogCallback { void onRefreshCarrierInfo(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java index a8f6f5361d787..9c3301ef3dc48 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetAdapterTest.java @@ -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()); + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java index 68df19ef93c9a..cdd6d66c45d2f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java @@ -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,8 @@ 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.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.qualifiers.Main; @@ -60,16 +65,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 +89,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 @@ -199,35 +210,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 @@ -251,6 +280,18 @@ 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(Utils.getColorAttrDefaultColor(mContext, + com.android.internal.R.attr.colorControlNormal)); + } + @Test public void launchWifiNetworkDetailsSetting_withNoConnectedEntry_doNothing() { mInternetDialogController.mConnectedEntry = null; diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java index a1a7e716e6c0d..856e3a1281939 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java @@ -41,6 +41,7 @@ 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; @@ -141,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); } @@ -180,6 +183,7 @@ public class InternetDialogTest extends SysuiTestCase { @Test public void showProgressBar_wifiDisabled_hideProgressBar() { + Mockito.reset(mHandler); when(mMockWifiManager.isWifiEnabled()).thenReturn(false); mInternetDialog.showProgressBar(); @@ -190,6 +194,7 @@ public class InternetDialogTest extends SysuiTestCase { @Test public void showProgressBar_wifiEnabledWithWifiEntry_showProgressBarThenHide() { + Mockito.reset(mHandler); when(mMockWifiManager.isWifiEnabled()).thenReturn(true); List wifiScanResults = mock(ArrayList.class); when(wifiScanResults.size()).thenReturn(1); @@ -211,6 +216,7 @@ public class InternetDialogTest extends SysuiTestCase { @Test public void showProgressBar_wifiEnabledWithoutWifiScanResults_showProgressBarThenHideSearch() { + Mockito.reset(mHandler); when(mMockWifiManager.isWifiEnabled()).thenReturn(true); List wifiScanResults = mock(ArrayList.class); when(wifiScanResults.size()).thenReturn(0); From 007eb0da4bdfa6d76b62a21a863f067d9c298d44 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Tue, 3 Aug 2021 17:56:11 +0800 Subject: [PATCH 4/4] [Provider Model] 1.Fix the color of the dark mode 2.Fix RTL layout Bug: 194982368 Test: manual test Change-Id: I912e8d21d19be0a82d7f3b3f8398808f335b42de Merged-In: I912e8d21d19be0a82d7f3b3f8398808f335b42de (cherry picked from commit 528298596fbbb1dc66a3442b55b4f6eb307a5238) --- .../layout/internet_connectivity_dialog.xml | 41 +++++++++++-------- .../res/layout/internet_list_item.xml | 12 +++--- packages/SystemUI/res/values/colors.xml | 4 +- .../qs/tiles/dialog/InternetAdapter.java | 2 +- .../qs/tiles/dialog/InternetDialog.java | 29 +++++++------ .../dialog/InternetDialogController.java | 16 +++++--- .../dialog/InternetDialogControllerTest.java | 4 +- 7 files changed, 64 insertions(+), 44 deletions(-) diff --git a/packages/SystemUI/res/layout/internet_connectivity_dialog.xml b/packages/SystemUI/res/layout/internet_connectivity_dialog.xml index f7919d43c551b..f23085a66903f 100644 --- a/packages/SystemUI/res/layout/internet_connectivity_dialog.xml +++ b/packages/SystemUI/res/layout/internet_connectivity_dialog.xml @@ -94,8 +94,8 @@ 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_marginEnd="@dimen/settingslib_switchbar_margin" + android:layout_marginStart="@dimen/settingslib_switchbar_margin" android:layout_marginTop="16dp" android:paddingStart="22dp" android:paddingEnd="22dp"> @@ -107,6 +107,7 @@ android:layout_gravity="center_vertical|start"> @@ -122,10 +123,11 @@ android:gravity="start|center_vertical"> @@ -182,6 +185,7 @@ android:layout_height="match_parent"> @@ -244,10 +248,11 @@ android:gravity="start|center_vertical"> + android:layout_marginStart="16dp"> ?androidprv:attr/colorAccentPrimaryVariant ?androidprv:attr/colorAccentSecondaryVariant - #ff000000 - #808080 + #191C18 + #41493D diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java index 13ee155d5af26..e346044e746de 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetAdapter.java @@ -215,7 +215,7 @@ public class InternetAdapter extends RecyclerView.Adapter shared = new AtomicReference<>(); shared.set(drawable); return shared.get(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java index 2a962bc90bab2..a63d1f80f3947 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java @@ -341,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); @@ -366,10 +369,12 @@ public class InternetDialog extends SystemUIDialog implements mConnectedWifiSummaryText.setText(getConnectedWifiSummary()); mConnectedWifiIcon.setImageDrawable( mInternetDialogController.getConnectedWifiDrawable(mConnectedWifiEntry)); - mConnectedWifiTitleText.setTextColor( - mContext.getColor(R.color.connected_network_primary_color)); - mConnectedWifiSummaryText.setTextColor( - mContext.getColor(R.color.connected_network_tertiary_color)); + 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); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java index 5c22e855a3d0f..890dcfd46f78b 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java @@ -23,6 +23,7 @@ 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; @@ -323,11 +324,15 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, if (drawable == null) { return null; } - drawable.setTint(Utils.getColorAttrDefaultColor(mContext, - com.android.internal.R.attr.colorControlNormal)); + 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); @@ -345,8 +350,9 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, drawable = shared.get(); } - drawable.setTint( - Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal)); + drawable.setTint(activeNetworkIsCellular() ? mContext.getColor( + R.color.connected_network_primary_color) : Utils.getColorAttrDefaultColor( + mContext, android.R.attr.textColorTertiary)); } catch (Throwable e) { e.printStackTrace(); } @@ -393,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; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java index cdd6d66c45d2f..f876a43f75d40 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogControllerTest.java @@ -35,6 +35,7 @@ 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; @@ -288,8 +289,7 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.getConnectedWifiDrawable(mConnectedEntry); verify(mWifiIconInjector).getIcon(eq(false), anyInt()); - verify(drawable).setTint(Utils.getColorAttrDefaultColor(mContext, - com.android.internal.R.attr.colorControlNormal)); + verify(drawable).setTint(mContext.getColor(R.color.connected_network_primary_color)); } @Test