OSDN Git Service

Improve Wi-Fi Easy Connect lock screen UI information
authorArc Wang <arcwang@google.com>
Wed, 20 Mar 2019 08:34:00 +0000 (16:34 +0800)
committerArc Wang <arcwang@google.com>
Thu, 21 Mar 2019 06:09:22 +0000 (14:09 +0800)
1. Change lock screen title and remove description
2. In QR code generator screen, change summary and show password under QR code picture

Bug: 128920152
Bug: 128576809
Test: manual test
Change-Id: Id096d7f417308df14ffe50c618644750aa991df8

res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
res/layout/wifi_dpp_qrcode_generator_fragment.xml
res/layout/wifi_dpp_qrcode_scanner_fragment.xml
res/values/strings.xml
src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
src/com/android/settings/wifi/dpp/WifiDppUtils.java
src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java

index 3a0e659..c408a97 100644 (file)
                 android:id="@+id/error_message"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
                 android:textAlignment="center"
-                android:layout_marginTop="8dp"
-                android:visibility="invisible"
-                android:textColor="?android:attr/colorError"/>
+                android:textColor="?android:attr/colorError"
+                android:visibility="invisible"/>
 
         </LinearLayout>
 
index 2617aea..31bf7cc 100644 (file)
                 android:layout_height="@dimen/qrcode_size"
                 android:src="@android:color/transparent"/>
 
+            <TextView
+                android:id="@+id/password"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
+                android:textAlignment="center"
+                android:textAppearance="@android:style/TextAppearance.Material.Body1"
+                android:textColor="?android:attr/textColorSecondary"/>
         </LinearLayout>
 
     </ScrollView>
index 4fa8e8b..9bd742a 100644 (file)
                 android:id="@+id/error_message"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:layout_marginTop="16dp"
                 android:textAlignment="center"
-                android:layout_marginTop="8dp"
-                android:visibility="invisible"
-                android:textColor="?android:attr/colorError"/>
+                android:textColor="?android:attr/colorError"
+                android:visibility="invisible"/>
 
         </LinearLayout>
 
index 631d912..0642f0a 100644 (file)
     <!-- Title for the fragment to share Wi-Fi [CHAR LIMIT=50]  -->
     <string name="wifi_dpp_share_wifi">Share Wi\u2011Fi</string>
     <!-- Hint for the user to use another device to scan QR code on screen to join Wi-Fi [CHAR LIMIT=NONE] -->
-    <string name="wifi_dpp_scan_qr_code_with_another_device">Scan this QR code with another device to join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
+    <string name="wifi_dpp_scan_qr_code_with_another_device">Scan this QR code to connect to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d and share the password</string>
+    <!-- Hint for the user to use another device to scan QR code on screen to join a open Wi-Fi [CHAR LIMIT=NONE] -->
+    <string name="wifi_dpp_scan_open_network_qr_code_with_another_device">Scan this QR code to connect to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
     <!-- Hint for QR code detection [CHAR LIMIT=NONE]  -->
     <string name="wifi_dpp_could_not_detect_valid_qr_code">Couldn\u2019t read QR code. Re-center code and try again</string>
     <!-- Hint for Wi-Fi DPP handshake failure [CHAR LIMIT=NONE]  -->
     <string name="wifi_dpp_connecting">Connecting\u2026</string>
     <!-- Title for the fragment to show that the QR code is for sharing Wi-Fi hotspot network [CHAR LIMIT=50] -->
     <string name="wifi_dpp_share_hotspot">Share hotspot</string>
-    <!-- Hint for the user to share Wi-Fi hotspot network [CHAR LIMIT=NONE] -->
-    <string name="wifi_dpp_scan_qr_code_to_share_hotspot">Scan this QR code with another device to join hotspot \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
+    <!-- Title for Wi-Fi DPP lockscreen title [CHAR LIMIT=50] -->
+    <string name="wifi_dpp_lockscreen_title">Verify it\u0027s you</string>
+    <!-- Hint for Wi-Fi password [CHAR LIMIT=50]  -->
+    <string name="wifi_dpp_wifi_password">Wi\u2011Fi password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
+    <!-- Hint for Wi-Fi hotspot password [CHAR LIMIT=50]  -->
+    <string name="wifi_dpp_hotspot_password">Hotspot password: <xliff:g id="password" example="my password">%1$s</xliff:g></string>
      <!-- Label for the try again button [CHAR LIMIT=20]-->
     <string name="retry">Retry</string>
     <!-- Label for the check box to share a network with other users on the same device -->
     <string name="lockpassword_choose_your_pattern_header_for_face">To use face authentication, set pattern</string>
     <!-- Header on first screen of choose password/PIN as backup for face authentication flow. If this string cannot be translated in under 40 characters, please translate "Set face authentication backup" [CHAR LIMIT=40] -->
     <string name="lockpassword_choose_your_pin_header_for_face">To use face authentication, set PIN</string>
-    <!-- Message on Wi-Fi Sharing screen [CHAR LIMIT=NONE] -->
-    <string name="wifi_sharing_message">Your Wi\u2011Fi name and password for \"<xliff:g id="SSID" example="GoogleGuest">%1$s</xliff:g>\" will be shared.</string>
 
     <!-- Message to be used to explain the user that he needs to enter his pattern to continue a
          particular operation. [CHAR LIMIT=70]-->
index 5588977..416933b 100644 (file)
@@ -768,14 +768,7 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
      * Share the wifi network with QR code.
      */
     private void shareNetwork() {
-        final String title = mContext.getString(
-                R.string.lockpassword_confirm_your_pattern_header);
-        final String description = String.format(
-                mContext.getString(R.string.wifi_sharing_message),
-                mAccessPoint.getSsidStr());
-
-        WifiDppUtils.showLockScreen(mContext, title, description,
-                () -> launchWifiDppConfiguratorActivity());
+        WifiDppUtils.showLockScreen(mContext, () -> launchWifiDppConfiguratorActivity());
     }
 
     /**
index 2cd5e23..4e6a0d6 100644 (file)
@@ -21,6 +21,7 @@ import android.app.settings.SettingsEnums;
 import android.content.Context;
 import android.graphics.Bitmap;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -29,6 +30,7 @@ import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ImageView;
+import android.widget.TextView;
 
 import com.android.settings.R;
 import com.android.settings.wifi.qrcode.QrCodeGenerator;
@@ -43,6 +45,7 @@ public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
     private static final String TAG = "WifiDppQrCodeGeneratorFragment";
 
     private ImageView mQrCodeView;
+    private TextView mPasswordView;
     private String mQrCode;
 
     @Override
@@ -138,12 +141,27 @@ public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
         final WifiNetworkConfig wifiNetworkConfig = getWifiNetworkConfigFromHostActivity();
         if (wifiNetworkConfig.isHotspot()) {
             mTitle.setText(R.string.wifi_dpp_share_hotspot);
-            mSummary.setText(getString(R.string.wifi_dpp_scan_qr_code_to_share_hotspot,
-                    wifiNetworkConfig.getSsid()));
         } else {
             mTitle.setText(R.string.wifi_dpp_share_wifi);
+        }
+
+        final String password = wifiNetworkConfig.getPreSharedKey();
+        mPasswordView = view.findViewById(R.id.password);
+        if (TextUtils.isEmpty(password)) {
+            mSummary.setText(getString(
+                    R.string.wifi_dpp_scan_open_network_qr_code_with_another_device,
+                    wifiNetworkConfig.getSsid()));
+
+            mPasswordView.setVisibility(View.GONE);
+        } else {
             mSummary.setText(getString(R.string.wifi_dpp_scan_qr_code_with_another_device,
                     wifiNetworkConfig.getSsid()));
+
+            if (wifiNetworkConfig.isHotspot()) {
+               mPasswordView.setText(getString(R.string.wifi_dpp_hotspot_password, password));
+            } else {
+                mPasswordView.setText(getString(R.string.wifi_dpp_wifi_password, password));
+            }
         }
 
         mQrCode = wifiNetworkConfig.getQrCode();
index fe7af27..bf78b3f 100644 (file)
@@ -29,6 +29,8 @@ import android.os.Looper;
 import android.text.TextUtils;
 import android.util.FeatureFlagUtils;
 
+import com.android.settings.R;
+
 import com.android.settingslib.wifi.AccessPoint;
 
 import java.util.List;
@@ -273,13 +275,10 @@ public class WifiDppUtils {
      * user of the device.
      *
      * @param context The {@code Context} used to get {@code KeyguardManager} service
-     * @param title The title on lock screen
-     * @param description The description on lock screen
      * @param successRunnable The {@code Runnable} which will be executed if the user does not setup
      *                        device security or if lock screen is unlocked
      */
-    public static void showLockScreen(Context context, String title, String description,
-            Runnable successRunnable) {
+    public static void showLockScreen(Context context, Runnable successRunnable) {
         final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(
                 Context.KEYGUARD_SERVICE);
 
@@ -299,8 +298,7 @@ public class WifiDppUtils {
             };
 
             final BiometricPrompt.Builder builder = new BiometricPrompt.Builder(context)
-                    .setTitle(title)
-                    .setDescription(description);
+                    .setTitle(context.getText(R.string.wifi_dpp_lockscreen_title));
 
             if (keyguardManager.isDeviceSecure()) {
                 builder.setDeviceCredentialAllowed(true);
index 10f3e56..b7ddcae 100644 (file)
@@ -104,13 +104,7 @@ public class WifiTetherSSIDPreferenceController extends WifiTetherBasePreference
     }
 
     private void shareHotspotNetwork(Intent intent) {
-        final String title = mContext.getString(
-                R.string.lockpassword_confirm_your_pattern_header);
-        final String description = String.format(
-                mContext.getString(R.string.wifi_sharing_message), mSSID);
-
-        WifiDppUtils.showLockScreen(mContext, title, description,
-                () -> mContext.startActivity(intent));
+        WifiDppUtils.showLockScreen(mContext, () -> mContext.startActivity(intent));
     }
 
     @VisibleForTesting