[Provider Model] Fixed the height of the WiFi list

- Show a blank area when there is no WiFi list

- Set "See all" to INVISIBLE instead of GONE

Bug: 205789643
Test: manual test
atest -c InternetDialogTest

Change-Id: Id3367563104dd1125e288b252ee540d8c9068c6f
This commit is contained in:
Weng Su
2021-11-29 02:42:40 +08:00
parent 488d986cae
commit adfa8fc2fd
5 changed files with 90 additions and 16 deletions

View File

@@ -185,7 +185,7 @@
<LinearLayout
android:id="@+id/turn_on_wifi_layout"
style="@style/InternetDialog.Network"
android:layout_height="72dp"
android:layout_height="@dimen/internet_dialog_wifi_network_height"
android:gravity="center"
android:clickable="false"
android:focusable="false">
@@ -227,7 +227,7 @@
<LinearLayout
android:id="@+id/wifi_connected_layout"
style="@style/InternetDialog.Network"
android:layout_height="72dp"
android:layout_height="@dimen/internet_dialog_wifi_network_height"
android:paddingStart="20dp"
android:paddingEnd="24dp"
android:background="@drawable/settingslib_switch_bar_bg_on"
@@ -249,7 +249,7 @@
android:orientation="vertical"
android:clickable="false"
android:layout_width="wrap_content"
android:layout_height="72dp"
android:layout_height="@dimen/internet_dialog_wifi_network_height"
android:layout_marginEnd="30dp"
android:layout_weight="1"
android:gravity="start|center_vertical">

View File

@@ -25,7 +25,7 @@
<LinearLayout
android:id="@+id/wifi_list"
style="@style/InternetDialog.Network"
android:layout_height="72dp"
android:layout_height="@dimen/internet_dialog_wifi_network_height"
android:paddingStart="20dp"
android:paddingEnd="24dp">
<FrameLayout
@@ -45,7 +45,7 @@
android:orientation="vertical"
android:clickable="false"
android:layout_width="wrap_content"
android:layout_height="72dp"
android:layout_height="@dimen/internet_dialog_wifi_network_height"
android:layout_marginEnd="30dp"
android:layout_weight="1"
android:gravity="start|center_vertical">

View File

@@ -1243,6 +1243,8 @@
<!-- Internet panel related dimensions -->
<dimen name="internet_dialog_list_max_height">662dp</dimen>
<!-- The height of the WiFi network in Internet panel. -->
<dimen name="internet_dialog_wifi_network_height">72dp</dimen>
<!-- The width of large/content heavy dialogs (e.g. Internet, Media output, etc) -->
<dimen name="large_dialog_width">@dimen/match_parent</dimen>

View File

@@ -130,6 +130,7 @@ public class InternetDialog extends SystemUIDialog implements
private boolean mCanConfigMobileData;
// Wi-Fi entries
private int mWifiNetworkHeight;
@VisibleForTesting
protected WifiEntry mConnectedWifiEntry;
@VisibleForTesting
@@ -187,6 +188,9 @@ public class InternetDialog extends SystemUIDialog implements
window.setWindowAnimations(R.style.Animation_InternetDialog);
mWifiNetworkHeight = mContext.getResources()
.getDimensionPixelSize(R.dimen.internet_dialog_wifi_network_height);
mInternetDialogLayout = mDialogView.requireViewById(R.id.internet_connectivity_dialog);
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
@@ -335,9 +339,6 @@ public class InternetDialog extends SystemUIDialog implements
mSeeAllLayout.setOnClickListener(v -> onClickSeeMoreButton());
mWiFiToggle.setOnCheckedChangeListener(
(buttonView, isChecked) -> {
if (isChecked) {
mWifiScanNotifyLayout.setVisibility(View.GONE);
}
buttonView.setChecked(isChecked);
mWifiManager.setWifiEnabled(isChecked);
});
@@ -427,9 +428,26 @@ public class InternetDialog extends SystemUIDialog implements
mSeeAllLayout.setVisibility(View.GONE);
return;
}
mWifiRecyclerView.setVisibility(mWifiEntriesCount > 0 ? View.VISIBLE : View.GONE);
mSeeAllLayout.setVisibility(
(mConnectedWifiEntry != null || mWifiEntriesCount > 0) ? View.VISIBLE : View.GONE);
mWifiRecyclerView.setMinimumHeight(mWifiNetworkHeight * getWifiListMaxCount());
mWifiRecyclerView.setVisibility(View.VISIBLE);
final boolean showSeeAll = mConnectedWifiEntry != null || mWifiEntriesCount > 0;
mSeeAllLayout.setVisibility(showSeeAll ? View.VISIBLE : View.INVISIBLE);
}
@VisibleForTesting
@MainThread
int getWifiListMaxCount() {
int count = InternetDialogController.MAX_WIFI_ENTRY_COUNT;
if (mEthernetLayout.getVisibility() == View.VISIBLE) {
count -= 1;
}
if (mMobileNetworkLayout.getVisibility() == View.VISIBLE) {
count -= 1;
}
if (mConnectedWifListLayout.getVisibility() == View.VISIBLE) {
count -= 1;
}
return count;
}
@MainThread

View File

@@ -1,5 +1,7 @@
package com.android.systemui.qs.tiles.dialog;
import static com.android.systemui.qs.tiles.dialog.InternetDialogController.MAX_WIFI_ENTRY_COUNT;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -219,7 +221,7 @@ public class InternetDialogTest extends SysuiTestCase {
}
@Test
public void updateDialog_wifiOnAndNoWifiEntry_hideWifiEntryAndSeeAll() {
public void updateDialog_wifiOnAndNoWifiEntry_showWifiListAndSeeAllArea() {
// The precondition WiFi ON is already in setUp()
mInternetDialog.mConnectedWifiEntry = null;
mInternetDialog.mWifiEntriesCount = 0;
@@ -227,19 +229,21 @@ public class InternetDialogTest extends SysuiTestCase {
mInternetDialog.updateDialog(false);
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
assertThat(mSeeAll.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_showConnectedWifiAndSeeAll() {
public void updateDialog_wifiOnAndHasConnectedWifi_showAllWifiAndSeeAllArea() {
// 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);
// 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);
}
@@ -412,4 +416,54 @@ public class InternetDialogTest extends SysuiTestCase {
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
assertThat(mInternetDialog.mIsSearchingHidden).isTrue();
}
@Test
public void getWifiListMaxCount_returnCountCorrectly() {
// Ethernet, MobileData, ConnectedWiFi are all hidden.
// Then the maximum count is equal to MAX_WIFI_ENTRY_COUNT.
setNetworkVisible(false, false, false);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT);
// Only one of Ethernet, MobileData, ConnectedWiFi is displayed.
// Then the maximum count is equal to MAX_WIFI_ENTRY_COUNT - 1.
setNetworkVisible(true, false, false);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 1);
setNetworkVisible(false, true, false);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 1);
setNetworkVisible(false, false, true);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 1);
// Only one of Ethernet, MobileData, ConnectedWiFi is hidden.
// Then the maximum count is equal to MAX_WIFI_ENTRY_COUNT - 2.
setNetworkVisible(true, true, false);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 2);
setNetworkVisible(true, false, true);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 2);
setNetworkVisible(false, true, true);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 2);
// Ethernet, MobileData, ConnectedWiFi are all displayed.
// Then the maximum count is equal to MAX_WIFI_ENTRY_COUNT - 3.
setNetworkVisible(true, true, true);
assertThat(mInternetDialog.getWifiListMaxCount()).isEqualTo(MAX_WIFI_ENTRY_COUNT - 3);
}
private void setNetworkVisible(boolean ethernetVisible, boolean mobileDataVisible,
boolean connectedWifiVisible) {
mEthernet.setVisibility(ethernetVisible ? View.VISIBLE : View.GONE);
mMobileDataToggle.setVisibility(mobileDataVisible ? View.VISIBLE : View.GONE);
mConnectedWifi.setVisibility(connectedWifiVisible ? View.VISIBLE : View.GONE);
}
}