[Provider Model] Show "See All" when only connected WiFi appears

- See b/206061768#comment7 for a screenshot.

Bug: 206061768
Test: manual test
atest -c InternetDialogTest

Change-Id: Iee4a57e4dd1009b324459fef5ff7d4f574fd7419
This commit is contained in:
Weng Su
2021-11-15 22:14:41 +08:00
parent b5827095ca
commit 19686043b1
2 changed files with 60 additions and 24 deletions

View File

@@ -306,12 +306,8 @@ public class InternetDialog extends SystemUIDialog implements
final boolean isWifiScanEnabled = mInternetDialogController.isWifiScanEnabled();
updateWifiToggle(isWifiEnabled, isDeviceLocked);
updateConnectedWifi(isWifiEnabled, isDeviceLocked);
updateWifiListAndSeeAll(isWifiEnabled, isDeviceLocked);
updateWifiScanNotify(isWifiEnabled, isWifiScanEnabled, isDeviceLocked);
final int visibility = (isDeviceLocked || !isWifiEnabled || mWifiEntriesCount <= 0)
? View.GONE : View.VISIBLE;
mWifiRecyclerView.setVisibility(visibility);
mSeeAllLayout.setVisibility(visibility);
}
private void setOnClickListener() {
@@ -413,6 +409,18 @@ public class InternetDialog extends SystemUIDialog implements
mContext.getColor(R.color.connected_network_primary_color));
}
@MainThread
private void updateWifiListAndSeeAll(boolean isWifiEnabled, boolean isDeviceLocked) {
if (!isWifiEnabled || isDeviceLocked) {
mWifiRecyclerView.setVisibility(View.GONE);
mSeeAllLayout.setVisibility(View.GONE);
return;
}
mWifiRecyclerView.setVisibility(mWifiEntriesCount > 0 ? View.VISIBLE : View.GONE);
mSeeAllLayout.setVisibility(
(mConnectedWifiEntry != null || mWifiEntriesCount > 0) ? View.VISIBLE : View.GONE);
}
@MainThread
private void updateWifiScanNotify(boolean isWifiEnabled, boolean isWifiScanEnabled,
boolean isDeviceLocked) {

View File

@@ -219,61 +219,89 @@ public class InternetDialogTest extends SysuiTestCase {
}
@Test
public void updateDialog_wifiOnAndNoWifiList_hideWifiListAndSeeAll() {
public void updateDialog_wifiOnAndNoWifiEntry_hideWifiEntryAndSeeAll() {
// The precondition WiFi ON is already in setUp()
mInternetDialog.mConnectedWifiEntry = null;
mInternetDialog.mWifiEntriesCount = 0;
mInternetDialog.updateDialog(false);
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_wifiOnAndHasWifiList_showWifiListAndSeeAll() {
public void updateDialog_wifiOnAndHasConnectedWifi_showConnectedWifiAndSeeAll() {
// The preconditions WiFi ON and WiFi entries are already in setUp()
mInternetDialog.mWifiEntriesCount = 0;
mInternetDialog.updateDialog(false);
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void updateDialog_wifiOnAndHasWifiList_showWifiListAndSeeAll() {
// The preconditions WiFi ON and WiFi entries are already in setUp()
mInternetDialog.mConnectedWifiEntry = null;
mInternetDialog.updateDialog(false);
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void updateDialog_deviceLockedAndHasInternetWifi_showHighlightWifiToggle() {
// The preconditions WiFi ON and Internet WiFi are already in setUp()
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
public void updateDialog_wifiOnAndHasBothWifiEntry_showBothWifiEntryAndSeeAll() {
// The preconditions WiFi ON and WiFi entries are already in setUp()
mInternetDialog.updateDialog(false);
assertThat(mWifiToggle.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mWifiToggle.getBackground()).isNotNull();
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE);
}
@Test
public void updateDialog_deviceLockedAndHasInternetWifi_hideConnectedWifi() {
// The preconditions WiFi ON and Internet WiFi are already in setUp()
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
mInternetDialog.updateDialog(false);
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_deviceLockedAndHasWifiList_hideWifiListAndSeeAll() {
public void updateDialog_deviceLockedAndNoConnectedWifi_showWifiToggle() {
// The preconditions WiFi entries are already in setUp()
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
mInternetDialog.mConnectedWifiEntry = null;
mInternetDialog.updateDialog(false);
// Show WiFi Toggle without background
assertThat(mWifiToggle.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mWifiToggle.getBackground()).isNull();
// Hide Wi-Fi networks and See all
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_deviceLockedAndHasConnectedWifi_showWifiToggleWithBackground() {
// The preconditions WiFi ON and WiFi entries are already in setUp()
when(mInternetDialogController.isDeviceLocked()).thenReturn(true);
mInternetDialog.updateDialog(false);
// Show WiFi Toggle with highlight background
assertThat(mWifiToggle.getVisibility()).isEqualTo(View.VISIBLE);
assertThat(mWifiToggle.getBackground()).isNotNull();
// Hide Wi-Fi networks and See all
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
}
@Test
public void updateDialog_wifiOn_hideWifiScanNotify() {
// The preconditions WiFi ON and Internet WiFi are already in setUp()
// The preconditions WiFi ON and WiFi entries are already in setUp()
mInternetDialog.updateDialog(false);