diff options
| author | 2021-12-08 13:34:46 +0000 | |
|---|---|---|
| committer | 2021-12-08 13:34:46 +0000 | |
| commit | d54867d6c02545f400160727b1f1ca8681137ab6 (patch) | |
| tree | 8a7b0801bd2d85f922705911f08fa5f203df1c16 | |
| parent | 4e9facf9671149500c174a7fb6e728dd0b809253 (diff) | |
| parent | 427e2410d2566980b2b6068a5eb8c978c94613dc (diff) | |
Merge "[Provider Model] Adjust the design of "See all" (QS Internet Dialog)" into sc-v2-dev
4 files changed, 62 insertions, 30 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 65fe93cb0170..ba4257f52892 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 @@ -137,6 +137,8 @@ public class InternetDialog extends SystemUIDialog implements protected WifiEntry mConnectedWifiEntry; @VisibleForTesting protected int mWifiEntriesCount; + @VisibleForTesting + protected boolean mHasMoreEntry; // Wi-Fi scanning progress bar protected boolean mIsProgressBarVisible; @@ -464,8 +466,7 @@ public class InternetDialog extends SystemUIDialog implements } mWifiRecyclerView.setMinimumHeight(mWifiNetworkHeight * getWifiListMaxCount()); mWifiRecyclerView.setVisibility(View.VISIBLE); - final boolean showSeeAll = mConnectedWifiEntry != null || mWifiEntriesCount > 0; - mSeeAllLayout.setVisibility(showSeeAll ? View.VISIBLE : View.INVISIBLE); + mSeeAllLayout.setVisibility(mHasMoreEntry ? View.VISIBLE : View.INVISIBLE); } @VisibleForTesting @@ -655,13 +656,14 @@ public class InternetDialog extends SystemUIDialog implements @Override @WorkerThread public void onAccessPointsChanged(@Nullable List<WifiEntry> wifiEntries, - @Nullable WifiEntry connectedEntry) { + @Nullable WifiEntry connectedEntry, boolean hasMoreEntry) { // Should update the carrier network layout when it is connected under airplane mode ON. boolean shouldUpdateCarrierNetwork = mMobileNetworkLayout.getVisibility() == View.VISIBLE && mInternetDialogController.isAirplaneModeEnabled(); mHandler.post(() -> { mConnectedWifiEntry = connectedEntry; mWifiEntriesCount = wifiEntries == null ? 0 : wifiEntries.size(); + mHasMoreEntry = hasMoreEntry; updateDialog(shouldUpdateCarrierNetwork /* shouldUpdateMobileNetwork */); mAdapter.setWifiEntries(wifiEntries, mWifiEntriesCount); mAdapter.notifyDataSetChanged(); 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 a1fea6c4eb2a..1fee1b430073 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 @@ -883,11 +883,13 @@ public class InternetDialogController implements AccessPointController.AccessPoi mConnectedEntry = null; mWifiEntriesCount = 0; if (mCallback != null) { - mCallback.onAccessPointsChanged(null /* wifiEntries */, null /* connectedEntry */); + mCallback.onAccessPointsChanged(null /* wifiEntries */, null /* connectedEntry */, + false /* hasMoreEntry */); } return; } + boolean hasMoreEntry = false; int count = MAX_WIFI_ENTRY_COUNT; if (mHasEthernet) { count -= 1; @@ -895,8 +897,11 @@ public class InternetDialogController implements AccessPointController.AccessPoi if (hasActiveSubId() || isCarrierNetworkActive()) { count -= 1; } - if (count > accessPoints.size()) { - count = accessPoints.size(); + final int wifiTotalCount = accessPoints.size(); + if (count > wifiTotalCount) { + count = wifiTotalCount; + } else if (count < wifiTotalCount) { + hasMoreEntry = true; } WifiEntry connectedEntry = null; @@ -913,7 +918,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi mWifiEntriesCount = wifiEntries.size(); if (mCallback != null) { - mCallback.onAccessPointsChanged(wifiEntries, mConnectedEntry); + mCallback.onAccessPointsChanged(wifiEntries, mConnectedEntry, hasMoreEntry); } } @@ -1064,7 +1069,7 @@ public class InternetDialogController implements AccessPointController.AccessPoi void dismissDialog(); void onAccessPointsChanged(@Nullable List<WifiEntry> wifiEntries, - @Nullable WifiEntry connectedEntry); + @Nullable WifiEntry connectedEntry, boolean hasMoreEntry); } void makeOverlayToast(int stringId) { 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 5b7c61d66fa7..3b058b2150fd 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 @@ -410,7 +410,7 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(null /* accessPoints */); - verify(mInternetDialogCallback, never()).onAccessPointsChanged(any(), any()); + verify(mInternetDialogCallback, never()).onAccessPointsChanged(any(), any(), anyBoolean()); } @Test @@ -419,8 +419,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(null /* accessPoints */); - verify(mInternetDialogCallback) - .onAccessPointsChanged(null /* wifiEntries */, null /* connectedEntry */); + verify(mInternetDialogCallback).onAccessPointsChanged(null /* wifiEntries */, + null /* connectedEntry */, false /* hasMoreEntry */); } @Test @@ -433,7 +433,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(mAccessPoints); mWifiEntries.clear(); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + false /* hasMoreEntry */); } @Test @@ -447,8 +448,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.clear(); mWifiEntries.add(mWifiEntry1); - verify(mInternetDialogCallback) - .onAccessPointsChanged(mWifiEntries, null /* connectedEntry */); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, + null /* connectedEntry */, false /* hasMoreEntry */); } @Test @@ -463,7 +464,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.clear(); mWifiEntries.add(mWifiEntry1); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + false /* hasMoreEntry */); } @Test @@ -480,7 +482,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.clear(); mWifiEntries.add(mWifiEntry1); mWifiEntries.add(mWifiEntry2); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + false /* hasMoreEntry */); } @Test @@ -499,7 +502,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.add(mWifiEntry1); mWifiEntries.add(mWifiEntry2); mWifiEntries.add(mWifiEntry3); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + false /* hasMoreEntry */); // Turn off airplane mode to has carrier network, then Wi-Fi entries will cut last one. reset(mInternetDialogCallback); @@ -508,7 +512,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(mAccessPoints); mWifiEntries.remove(mWifiEntry3); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + true /* hasMoreEntry */); } @Test @@ -528,7 +533,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.add(mWifiEntry1); mWifiEntries.add(mWifiEntry2); mWifiEntries.add(mWifiEntry3); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + true /* hasMoreEntry */); // Turn off airplane mode to has carrier network, then Wi-Fi entries will cut last one. reset(mInternetDialogCallback); @@ -537,7 +543,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(mAccessPoints); mWifiEntries.remove(mWifiEntry3); - verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, mConnectedEntry, + true /* hasMoreEntry */); } @Test @@ -587,8 +594,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.add(mWifiEntry2); mWifiEntries.add(mWifiEntry3); mWifiEntries.add(mWifiEntry4); - verify(mInternetDialogCallback) - .onAccessPointsChanged(mWifiEntries, null /* connectedEntry */); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, + null /* connectedEntry */, false /* hasMoreEntry */); // If the Ethernet exists, then Wi-Fi entries will cut last one. reset(mInternetDialogCallback); @@ -597,8 +604,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(mAccessPoints); mWifiEntries.remove(mWifiEntry4); - verify(mInternetDialogCallback) - .onAccessPointsChanged(mWifiEntries, null /* connectedEntry */); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, + null /* connectedEntry */, true /* hasMoreEntry */); // Turn off airplane mode to has carrier network, then Wi-Fi entries will cut last one. reset(mInternetDialogCallback); @@ -607,8 +614,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mInternetDialogController.onAccessPointsChanged(mAccessPoints); mWifiEntries.remove(mWifiEntry3); - verify(mInternetDialogCallback) - .onAccessPointsChanged(mWifiEntries, null /* connectedEntry */); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, + null /* connectedEntry */, true /* hasMoreEntry */); } @Test @@ -624,8 +631,8 @@ public class InternetDialogControllerTest extends SysuiTestCase { mWifiEntries.clear(); mWifiEntries.add(mWifiEntry1); - verify(mInternetDialogCallback) - .onAccessPointsChanged(mWifiEntries, null /* connectedEntry */); + verify(mInternetDialogCallback).onAccessPointsChanged(mWifiEntries, + null /* connectedEntry */, false /* hasMoreEntry */); } @Test 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 0cf063f5db39..651bcdef9978 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 @@ -316,6 +316,20 @@ public class InternetDialogTest extends SysuiTestCase { } @Test + public void updateDialog_wifiOnAndOneWifiEntry_showWifiListAndSeeAllArea() { + // The precondition WiFi ON is already in setUp() + mInternetDialog.mConnectedWifiEntry = null; + mInternetDialog.mWifiEntriesCount = 1; + + mInternetDialog.updateDialog(false); + + assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE); + // Show a blank block to fix the dialog height even if there is no WiFi list + assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE); + assertThat(mSeeAll.getVisibility()).isEqualTo(View.INVISIBLE); + } + + @Test public void updateDialog_wifiOnAndHasConnectedWifi_showAllWifiAndSeeAllArea() { // The preconditions WiFi ON and WiFi entries are already in setUp() mInternetDialog.mWifiEntriesCount = 0; @@ -325,13 +339,15 @@ public class InternetDialogTest extends SysuiTestCase { assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.VISIBLE); // Show a blank block to fix the dialog height even if there is no WiFi list assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE); - assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE); + assertThat(mSeeAll.getVisibility()).isEqualTo(View.INVISIBLE); } @Test - public void updateDialog_wifiOnAndHasWifiList_showWifiListAndSeeAll() { + public void updateDialog_wifiOnAndHasMaxWifiList_showWifiListAndSeeAll() { // The preconditions WiFi ON and WiFi entries are already in setUp() mInternetDialog.mConnectedWifiEntry = null; + mInternetDialog.mWifiEntriesCount = MAX_WIFI_ENTRY_COUNT; + mInternetDialog.mHasMoreEntry = true; mInternetDialog.updateDialog(false); @@ -343,6 +359,8 @@ public class InternetDialogTest extends SysuiTestCase { @Test public void updateDialog_wifiOnAndHasBothWifiEntry_showBothWifiEntryAndSeeAll() { // The preconditions WiFi ON and WiFi entries are already in setUp() + mInternetDialog.mWifiEntriesCount = MAX_WIFI_ENTRY_COUNT - 1; + mInternetDialog.mHasMoreEntry = true; mInternetDialog.updateDialog(false); |