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

Commit a201cdea authored by Xin Li's avatar Xin Li Committed by Gerrit Code Review
Browse files

Merge "Merge SP1A.211205.008"

parents 6ff62406 4932b013
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -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"
+2 −0
Original line number Diff line number Diff line
@@ -3033,4 +3033,6 @@
    <string name="see_all_networks">See all</string>
    <!-- Summary for warning to disconnect ethernet first then switch to other networks. [CHAR LIMIT=60] -->
    <string name="to_switch_networks_disconnect_ethernet">To switch networks, disconnect ethernet</string>
    <!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off and Wi-Fi scanning is on. [CHAR LIMIT=NONE] -->
    <string name="wifi_scan_notify_message">To improve device experience, apps and services can still scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. You can change this in Wi\u2011Fi scanning settings. <annotation id="link">Change</annotation></string>
</resources>
+5 −5
Original line number Diff line number Diff line
@@ -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) {
@@ -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);
@@ -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);
        }
+26 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -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;
@@ -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;
+9 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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