Loading packages/SystemUI/res/layout/internet_connectivity_dialog.xml +40 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,46 @@ </FrameLayout> </LinearLayout> <LinearLayout android:id="@+id/wifi_scan_notify_layout" style="@style/InternetDialog.Network" android:orientation="vertical" android:layout_height="wrap_content" android:paddingBottom="4dp" android:clickable="false" android:focusable="false"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="56dp" android:gravity="start|top" android:orientation="horizontal" android:paddingEnd="12dp" android:paddingTop="16dp" android:paddingBottom="4dp"> <ImageView android:src="@drawable/ic_info_outline" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="?android:attr/textColorTertiary"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/wifi_scan_notify_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="16dp" android:paddingBottom="8dp" android:textColor="?android:attr/textColorSecondary" android:clickable="true"/> </LinearLayout> </LinearLayout> <FrameLayout android:id="@+id/done_layout" android:layout_width="67dp" Loading packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpan.java +5 −5 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import java.util.Optional; /** * A span that turns the text wrapped by annotation tag into the clickable link text. */ class AnnotationLinkSpan extends ClickableSpan { public class AnnotationLinkSpan extends ClickableSpan { private final Optional<View.OnClickListener> mClickListener; private AnnotationLinkSpan(View.OnClickListener listener) { Loading @@ -50,7 +50,7 @@ class AnnotationLinkSpan extends ClickableSpan { * @param linkInfos used to attach the click action into the corresponding span * @return the text attached with the span */ static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) { public static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) { final SpannableString msg = new SpannableString(text); final Annotation[] spans = msg.getSpans(/* queryStart= */ 0, msg.length(), Annotation.class); Loading Loading @@ -78,12 +78,12 @@ class AnnotationLinkSpan extends ClickableSpan { /** * Data class to store the annotation and the click action. */ static class LinkInfo { static final String DEFAULT_ANNOTATION = "link"; public static class LinkInfo { public static final String DEFAULT_ANNOTATION = "link"; private final Optional<String> mAnnotation; private final Optional<View.OnClickListener> mListener; LinkInfo(@NonNull String annotation, View.OnClickListener listener) { public LinkInfo(@NonNull String annotation, View.OnClickListener listener) { mAnnotation = Optional.of(annotation); mListener = Optional.ofNullable(listener); } Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +26 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.text.Html; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; Loading Loading @@ -63,6 +64,7 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.accessibility.floatingmenu.AnnotationLinkSpan; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.statusbar.phone.SystemUIDialog; Loading Loading @@ -110,6 +112,8 @@ public class InternetDialog extends SystemUIDialog implements private LinearLayout mTurnWifiOnLayout; private LinearLayout mEthernetLayout; private TextView mWifiToggleTitleText; private LinearLayout mWifiScanNotifyLayout; private TextView mWifiScanNotifyText; private LinearLayout mSeeAllLayout; private RecyclerView mWifiRecyclerView; private ImageView mConnectedWifiIcon; Loading Loading @@ -220,6 +224,8 @@ public class InternetDialog extends SystemUIDialog implements mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout); mTurnWifiOnLayout = mDialogView.requireViewById(R.id.turn_on_wifi_layout); mWifiToggleTitleText = mDialogView.requireViewById(R.id.wifi_toggle_title); mWifiScanNotifyLayout = mDialogView.requireViewById(R.id.wifi_scan_notify_layout); mWifiScanNotifyText = mDialogView.requireViewById(R.id.wifi_scan_notify_text); mConnectedWifListLayout = mDialogView.requireViewById(R.id.wifi_connected_layout); mConnectedWifiIcon = mDialogView.requireViewById(R.id.wifi_connected_icon); mConnectedWifiTitleText = mDialogView.requireViewById(R.id.wifi_connected_title); Loading Loading @@ -313,8 +319,10 @@ public class InternetDialog extends SystemUIDialog implements showProgressBar(); final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked(); final boolean isWifiEnabled = mWifiManager.isWifiEnabled(); final boolean isWifiScanEnabled = mWifiManager.isScanAlwaysAvailable(); updateWifiToggle(isWifiEnabled, isDeviceLocked); updateConnectedWifi(isWifiEnabled, isDeviceLocked); updateWifiScanNotify(isWifiEnabled, isWifiScanEnabled, isDeviceLocked); final int visibility = (isDeviceLocked || !isWifiEnabled || mWifiEntriesCount <= 0) ? View.GONE : View.VISIBLE; Loading Loading @@ -411,6 +419,24 @@ public class InternetDialog extends SystemUIDialog implements mContext.getColor(R.color.connected_network_primary_color)); } @MainThread private void updateWifiScanNotify(boolean isWifiEnabled, boolean isWifiScanEnabled, boolean isDeviceLocked) { if (isWifiEnabled || !isWifiScanEnabled || isDeviceLocked) { mWifiScanNotifyLayout.setVisibility(View.GONE); return; } if (TextUtils.isEmpty(mWifiScanNotifyText.getText())) { final AnnotationLinkSpan.LinkInfo linkInfo = new AnnotationLinkSpan.LinkInfo( AnnotationLinkSpan.LinkInfo.DEFAULT_ANNOTATION, v -> mInternetDialogController.launchWifiScanningSetting()); mWifiScanNotifyText.setText(AnnotationLinkSpan.linkify( getContext().getText(R.string.wifi_scan_notify_message), linkInfo)); mWifiScanNotifyText.setMovementMethod(LinkMovementMethod.getInstance()); } mWifiScanNotifyLayout.setVisibility(View.VISIBLE); } void onClickConnectedWifi() { if (mConnectedWifiEntry == null) { return; Loading packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +9 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, private static final String TAG = "InternetDialogController"; private static final String ACTION_NETWORK_PROVIDER_SETTINGS = "android.settings.NETWORK_PROVIDER_SETTINGS"; private static final String ACTION_WIFI_SCANNING_SETTINGS = "android.settings.WIFI_SCANNING_SETTINGS"; private static final String EXTRA_CHOSEN_WIFI_ENTRY_KEY = "key_chosen_wifientry_key"; public static final Drawable EMPTY_DRAWABLE = new ColorDrawable(Color.TRANSPARENT); public static final int NO_CELL_DATA_TYPE_ICON = 0; Loading Loading @@ -603,6 +605,13 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, } } void launchWifiScanningSetting() { mCallback.dismissDialog(); final Intent intent = new Intent(ACTION_WIFI_SCANNING_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mActivityStarter.postStartActivityDismissingKeyguard(intent, 0); } void connectCarrierNetwork() { final MergedCarrierEntry mergedCarrierEntry = mAccessPointController.getMergedCarrierEntry(); Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java +47 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; import androidx.test.filters.SmallTest; Loading Loading @@ -73,6 +74,7 @@ public class InternetDialogTest extends SysuiTestCase { private LinearLayout mConnectedWifi; private RecyclerView mWifiList; private LinearLayout mSeeAll; private LinearLayout mWifiScanNotify; @Before public void setUp() { Loading Loading @@ -104,6 +106,7 @@ public class InternetDialogTest extends SysuiTestCase { mConnectedWifi = mDialogView.requireViewById(R.id.wifi_connected_layout); mWifiList = mDialogView.requireViewById(R.id.wifi_list_layout); mSeeAll = mDialogView.requireViewById(R.id.see_all_layout); mWifiScanNotify = mDialogView.requireViewById(R.id.wifi_scan_notify_layout); } @After Loading Loading @@ -263,6 +266,50 @@ public class InternetDialogTest extends SysuiTestCase { assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOn_hideWifiScanNotify() { // The preconditions WiFi ON and Internet WiFi are already in setUp() mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOffAndWifiScanOff_hideWifiScanNotify() { when(mWifiManager.isWifiEnabled()).thenReturn(false); when(mWifiManager.isScanAlwaysAvailable()).thenReturn(false); mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOffAndWifiScanOnAndDeviceLocked_hideWifiScanNotify() { when(mWifiManager.isWifiEnabled()).thenReturn(false); when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true); when(mInternetDialogController.isDeviceLocked()).thenReturn(true); mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOffAndWifiScanOnAndDeviceUnlocked_showWifiScanNotify() { when(mWifiManager.isWifiEnabled()).thenReturn(false); when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true); when(mInternetDialogController.isDeviceLocked()).thenReturn(false); mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.VISIBLE); TextView wifiScanNotifyText = mDialogView.requireViewById(R.id.wifi_scan_notify_text); assertThat(wifiScanNotifyText.getText().length()).isNotEqualTo(0); assertThat(wifiScanNotifyText.getMovementMethod()).isNotNull(); } @Test public void onClickSeeMoreButton_clickSeeAll_verifyLaunchNetworkSetting() { mSeeAll.performClick(); Loading Loading
packages/SystemUI/res/layout/internet_connectivity_dialog.xml +40 −0 Original line number Diff line number Diff line Loading @@ -323,6 +323,46 @@ </FrameLayout> </LinearLayout> <LinearLayout android:id="@+id/wifi_scan_notify_layout" style="@style/InternetDialog.Network" android:orientation="vertical" android:layout_height="wrap_content" android:paddingBottom="4dp" android:clickable="false" android:focusable="false"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:minWidth="56dp" android:gravity="start|top" android:orientation="horizontal" android:paddingEnd="12dp" android:paddingTop="16dp" android:paddingBottom="4dp"> <ImageView android:src="@drawable/ic_info_outline" android:layout_width="wrap_content" android:layout_height="wrap_content" android:tint="?android:attr/textColorTertiary"/> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/wifi_scan_notify_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="16dp" android:paddingBottom="8dp" android:textColor="?android:attr/textColorSecondary" android:clickable="true"/> </LinearLayout> </LinearLayout> <FrameLayout android:id="@+id/done_layout" android:layout_width="67dp" Loading
packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/AnnotationLinkSpan.java +5 −5 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ import java.util.Optional; /** * A span that turns the text wrapped by annotation tag into the clickable link text. */ class AnnotationLinkSpan extends ClickableSpan { public class AnnotationLinkSpan extends ClickableSpan { private final Optional<View.OnClickListener> mClickListener; private AnnotationLinkSpan(View.OnClickListener listener) { Loading @@ -50,7 +50,7 @@ class AnnotationLinkSpan extends ClickableSpan { * @param linkInfos used to attach the click action into the corresponding span * @return the text attached with the span */ static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) { public static CharSequence linkify(CharSequence text, LinkInfo... linkInfos) { final SpannableString msg = new SpannableString(text); final Annotation[] spans = msg.getSpans(/* queryStart= */ 0, msg.length(), Annotation.class); Loading Loading @@ -78,12 +78,12 @@ class AnnotationLinkSpan extends ClickableSpan { /** * Data class to store the annotation and the click action. */ static class LinkInfo { static final String DEFAULT_ANNOTATION = "link"; public static class LinkInfo { public static final String DEFAULT_ANNOTATION = "link"; private final Optional<String> mAnnotation; private final Optional<View.OnClickListener> mListener; LinkInfo(@NonNull String annotation, View.OnClickListener listener) { public LinkInfo(@NonNull String annotation, View.OnClickListener listener) { mAnnotation = Optional.of(annotation); mListener = Optional.ofNullable(listener); } Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialog.java +26 −0 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.telephony.TelephonyDisplayInfo; import android.telephony.TelephonyManager; import android.text.Html; import android.text.TextUtils; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; Loading Loading @@ -63,6 +64,7 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.systemui.Prefs; import com.android.systemui.R; import com.android.systemui.accessibility.floatingmenu.AnnotationLinkSpan; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.statusbar.phone.SystemUIDialog; Loading Loading @@ -110,6 +112,8 @@ public class InternetDialog extends SystemUIDialog implements private LinearLayout mTurnWifiOnLayout; private LinearLayout mEthernetLayout; private TextView mWifiToggleTitleText; private LinearLayout mWifiScanNotifyLayout; private TextView mWifiScanNotifyText; private LinearLayout mSeeAllLayout; private RecyclerView mWifiRecyclerView; private ImageView mConnectedWifiIcon; Loading Loading @@ -220,6 +224,8 @@ public class InternetDialog extends SystemUIDialog implements mMobileNetworkLayout = mDialogView.requireViewById(R.id.mobile_network_layout); mTurnWifiOnLayout = mDialogView.requireViewById(R.id.turn_on_wifi_layout); mWifiToggleTitleText = mDialogView.requireViewById(R.id.wifi_toggle_title); mWifiScanNotifyLayout = mDialogView.requireViewById(R.id.wifi_scan_notify_layout); mWifiScanNotifyText = mDialogView.requireViewById(R.id.wifi_scan_notify_text); mConnectedWifListLayout = mDialogView.requireViewById(R.id.wifi_connected_layout); mConnectedWifiIcon = mDialogView.requireViewById(R.id.wifi_connected_icon); mConnectedWifiTitleText = mDialogView.requireViewById(R.id.wifi_connected_title); Loading Loading @@ -313,8 +319,10 @@ public class InternetDialog extends SystemUIDialog implements showProgressBar(); final boolean isDeviceLocked = mInternetDialogController.isDeviceLocked(); final boolean isWifiEnabled = mWifiManager.isWifiEnabled(); final boolean isWifiScanEnabled = mWifiManager.isScanAlwaysAvailable(); updateWifiToggle(isWifiEnabled, isDeviceLocked); updateConnectedWifi(isWifiEnabled, isDeviceLocked); updateWifiScanNotify(isWifiEnabled, isWifiScanEnabled, isDeviceLocked); final int visibility = (isDeviceLocked || !isWifiEnabled || mWifiEntriesCount <= 0) ? View.GONE : View.VISIBLE; Loading Loading @@ -411,6 +419,24 @@ public class InternetDialog extends SystemUIDialog implements mContext.getColor(R.color.connected_network_primary_color)); } @MainThread private void updateWifiScanNotify(boolean isWifiEnabled, boolean isWifiScanEnabled, boolean isDeviceLocked) { if (isWifiEnabled || !isWifiScanEnabled || isDeviceLocked) { mWifiScanNotifyLayout.setVisibility(View.GONE); return; } if (TextUtils.isEmpty(mWifiScanNotifyText.getText())) { final AnnotationLinkSpan.LinkInfo linkInfo = new AnnotationLinkSpan.LinkInfo( AnnotationLinkSpan.LinkInfo.DEFAULT_ANNOTATION, v -> mInternetDialogController.launchWifiScanningSetting()); mWifiScanNotifyText.setText(AnnotationLinkSpan.linkify( getContext().getText(R.string.wifi_scan_notify_message), linkInfo)); mWifiScanNotifyText.setMovementMethod(LinkMovementMethod.getInstance()); } mWifiScanNotifyLayout.setVisibility(View.VISIBLE); } void onClickConnectedWifi() { if (mConnectedWifiEntry == null) { return; Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/dialog/InternetDialogController.java +9 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, private static final String TAG = "InternetDialogController"; private static final String ACTION_NETWORK_PROVIDER_SETTINGS = "android.settings.NETWORK_PROVIDER_SETTINGS"; private static final String ACTION_WIFI_SCANNING_SETTINGS = "android.settings.WIFI_SCANNING_SETTINGS"; private static final String EXTRA_CHOSEN_WIFI_ENTRY_KEY = "key_chosen_wifientry_key"; public static final Drawable EMPTY_DRAWABLE = new ColorDrawable(Color.TRANSPARENT); public static final int NO_CELL_DATA_TYPE_ICON = 0; Loading Loading @@ -603,6 +605,13 @@ public class InternetDialogController implements WifiEntry.DisconnectCallback, } } void launchWifiScanningSetting() { mCallback.dismissDialog(); final Intent intent = new Intent(ACTION_WIFI_SCANNING_SETTINGS); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mActivityStarter.postStartActivityDismissingKeyguard(intent, 0); } void connectCarrierNetwork() { final MergedCarrierEntry mergedCarrierEntry = mAccessPointController.getMergedCarrierEntry(); Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/dialog/InternetDialogTest.java +47 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; import androidx.test.filters.SmallTest; Loading Loading @@ -73,6 +74,7 @@ public class InternetDialogTest extends SysuiTestCase { private LinearLayout mConnectedWifi; private RecyclerView mWifiList; private LinearLayout mSeeAll; private LinearLayout mWifiScanNotify; @Before public void setUp() { Loading Loading @@ -104,6 +106,7 @@ public class InternetDialogTest extends SysuiTestCase { mConnectedWifi = mDialogView.requireViewById(R.id.wifi_connected_layout); mWifiList = mDialogView.requireViewById(R.id.wifi_list_layout); mSeeAll = mDialogView.requireViewById(R.id.see_all_layout); mWifiScanNotify = mDialogView.requireViewById(R.id.wifi_scan_notify_layout); } @After Loading Loading @@ -263,6 +266,50 @@ public class InternetDialogTest extends SysuiTestCase { assertThat(mSeeAll.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOn_hideWifiScanNotify() { // The preconditions WiFi ON and Internet WiFi are already in setUp() mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOffAndWifiScanOff_hideWifiScanNotify() { when(mWifiManager.isWifiEnabled()).thenReturn(false); when(mWifiManager.isScanAlwaysAvailable()).thenReturn(false); mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOffAndWifiScanOnAndDeviceLocked_hideWifiScanNotify() { when(mWifiManager.isWifiEnabled()).thenReturn(false); when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true); when(mInternetDialogController.isDeviceLocked()).thenReturn(true); mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.GONE); } @Test public void updateDialog_wifiOffAndWifiScanOnAndDeviceUnlocked_showWifiScanNotify() { when(mWifiManager.isWifiEnabled()).thenReturn(false); when(mWifiManager.isScanAlwaysAvailable()).thenReturn(true); when(mInternetDialogController.isDeviceLocked()).thenReturn(false); mInternetDialog.updateDialog(); assertThat(mWifiScanNotify.getVisibility()).isEqualTo(View.VISIBLE); TextView wifiScanNotifyText = mDialogView.requireViewById(R.id.wifi_scan_notify_text); assertThat(wifiScanNotifyText.getText().length()).isNotEqualTo(0); assertThat(wifiScanNotifyText.getMovementMethod()).isNotNull(); } @Test public void onClickSeeMoreButton_clickSeeAll_verifyLaunchNetworkSetting() { mSeeAll.performClick(); Loading