Merge "[Provider Model] Fixed the height of the WiFi list" into sc-v2-dev am: 32e6121883
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16346901 Change-Id: I14464f9a81bbe1f961f8f13992697518e1c30bd1
This commit is contained in:
@@ -185,7 +185,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/turn_on_wifi_layout"
|
android:id="@+id/turn_on_wifi_layout"
|
||||||
style="@style/InternetDialog.Network"
|
style="@style/InternetDialog.Network"
|
||||||
android:layout_height="72dp"
|
android:layout_height="@dimen/internet_dialog_wifi_network_height"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:focusable="false">
|
android:focusable="false">
|
||||||
@@ -227,7 +227,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/wifi_connected_layout"
|
android:id="@+id/wifi_connected_layout"
|
||||||
style="@style/InternetDialog.Network"
|
style="@style/InternetDialog.Network"
|
||||||
android:layout_height="72dp"
|
android:layout_height="@dimen/internet_dialog_wifi_network_height"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="24dp"
|
android:paddingEnd="24dp"
|
||||||
android:background="@drawable/settingslib_switch_bar_bg_on"
|
android:background="@drawable/settingslib_switch_bar_bg_on"
|
||||||
@@ -249,7 +249,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="72dp"
|
android:layout_height="@dimen/internet_dialog_wifi_network_height"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="start|center_vertical">
|
android:gravity="start|center_vertical">
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/wifi_list"
|
android:id="@+id/wifi_list"
|
||||||
style="@style/InternetDialog.Network"
|
style="@style/InternetDialog.Network"
|
||||||
android:layout_height="72dp"
|
android:layout_height="@dimen/internet_dialog_wifi_network_height"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="24dp">
|
android:paddingEnd="24dp">
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="72dp"
|
android:layout_height="@dimen/internet_dialog_wifi_network_height"
|
||||||
android:layout_marginEnd="30dp"
|
android:layout_marginEnd="30dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="start|center_vertical">
|
android:gravity="start|center_vertical">
|
||||||
|
|||||||
@@ -1243,6 +1243,8 @@
|
|||||||
|
|
||||||
<!-- Internet panel related dimensions -->
|
<!-- Internet panel related dimensions -->
|
||||||
<dimen name="internet_dialog_list_max_height">662dp</dimen>
|
<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) -->
|
<!-- The width of large/content heavy dialogs (e.g. Internet, Media output, etc) -->
|
||||||
<dimen name="large_dialog_width">@dimen/match_parent</dimen>
|
<dimen name="large_dialog_width">@dimen/match_parent</dimen>
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
private boolean mCanConfigMobileData;
|
private boolean mCanConfigMobileData;
|
||||||
|
|
||||||
// Wi-Fi entries
|
// Wi-Fi entries
|
||||||
|
private int mWifiNetworkHeight;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected WifiEntry mConnectedWifiEntry;
|
protected WifiEntry mConnectedWifiEntry;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -187,6 +188,9 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
|
|
||||||
window.setWindowAnimations(R.style.Animation_InternetDialog);
|
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);
|
mInternetDialogLayout = mDialogView.requireViewById(R.id.internet_connectivity_dialog);
|
||||||
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
mInternetDialogTitle = mDialogView.requireViewById(R.id.internet_dialog_title);
|
||||||
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
mInternetDialogSubTitle = mDialogView.requireViewById(R.id.internet_dialog_subtitle);
|
||||||
@@ -335,9 +339,6 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mSeeAllLayout.setOnClickListener(v -> onClickSeeMoreButton());
|
mSeeAllLayout.setOnClickListener(v -> onClickSeeMoreButton());
|
||||||
mWiFiToggle.setOnCheckedChangeListener(
|
mWiFiToggle.setOnCheckedChangeListener(
|
||||||
(buttonView, isChecked) -> {
|
(buttonView, isChecked) -> {
|
||||||
if (isChecked) {
|
|
||||||
mWifiScanNotifyLayout.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
buttonView.setChecked(isChecked);
|
buttonView.setChecked(isChecked);
|
||||||
mWifiManager.setWifiEnabled(isChecked);
|
mWifiManager.setWifiEnabled(isChecked);
|
||||||
});
|
});
|
||||||
@@ -427,9 +428,26 @@ public class InternetDialog extends SystemUIDialog implements
|
|||||||
mSeeAllLayout.setVisibility(View.GONE);
|
mSeeAllLayout.setVisibility(View.GONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mWifiRecyclerView.setVisibility(mWifiEntriesCount > 0 ? View.VISIBLE : View.GONE);
|
mWifiRecyclerView.setMinimumHeight(mWifiNetworkHeight * getWifiListMaxCount());
|
||||||
mSeeAllLayout.setVisibility(
|
mWifiRecyclerView.setVisibility(View.VISIBLE);
|
||||||
(mConnectedWifiEntry != null || mWifiEntriesCount > 0) ? View.VISIBLE : View.GONE);
|
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
|
@MainThread
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.android.systemui.qs.tiles.dialog;
|
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 com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
@@ -219,7 +221,7 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_wifiOnAndNoWifiEntry_hideWifiEntryAndSeeAll() {
|
public void updateDialog_wifiOnAndNoWifiEntry_showWifiListAndSeeAllArea() {
|
||||||
// The precondition WiFi ON is already in setUp()
|
// The precondition WiFi ON is already in setUp()
|
||||||
mInternetDialog.mConnectedWifiEntry = null;
|
mInternetDialog.mConnectedWifiEntry = null;
|
||||||
mInternetDialog.mWifiEntriesCount = 0;
|
mInternetDialog.mWifiEntriesCount = 0;
|
||||||
@@ -227,19 +229,21 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
mInternetDialog.updateDialog(false);
|
mInternetDialog.updateDialog(false);
|
||||||
|
|
||||||
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.GONE);
|
||||||
assertThat(mWifiList.getVisibility()).isEqualTo(View.GONE);
|
// Show a blank block to fix the dialog height even if there is no WiFi list
|
||||||
assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE);
|
assertThat(mWifiList.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateDialog_wifiOnAndHasConnectedWifi_showConnectedWifiAndSeeAll() {
|
public void updateDialog_wifiOnAndHasConnectedWifi_showAllWifiAndSeeAllArea() {
|
||||||
// The preconditions WiFi ON and WiFi entries are already in setUp()
|
// The preconditions WiFi ON and WiFi entries are already in setUp()
|
||||||
mInternetDialog.mWifiEntriesCount = 0;
|
mInternetDialog.mWifiEntriesCount = 0;
|
||||||
|
|
||||||
mInternetDialog.updateDialog(false);
|
mInternetDialog.updateDialog(false);
|
||||||
|
|
||||||
assertThat(mConnectedWifi.getVisibility()).isEqualTo(View.VISIBLE);
|
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);
|
assertThat(mSeeAll.getVisibility()).isEqualTo(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,4 +416,54 @@ public class InternetDialogTest extends SysuiTestCase {
|
|||||||
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
assertThat(mInternetDialog.mIsProgressBarVisible).isTrue();
|
||||||
assertThat(mInternetDialog.mIsSearchingHidden).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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user