Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f052223 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "[Provider Model] Fixed the height of the WiFi list" into sc-v2-dev am:...

Merge "[Provider Model] Fixed the height of the WiFi list" into sc-v2-dev am: 32e61218 am: 944762a6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16346901

Change-Id: I43a828bf663da82aaf219e048a93267c33de3c0f
parents c941fb50 944762a6
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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">
+2 −2
Original line number Diff line number Diff line
@@ -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">
+2 −0
Original line number Diff line number Diff line
@@ -1240,6 +1240,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>
+24 −6
Original line number Diff line number Diff line
@@ -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
+59 −5
Original line number Diff line number Diff line
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);
    }
}