diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml index df676fc2a21..8ee2fbaff19 100644 --- a/res/layout/wifi_dialog.xml +++ b/res/layout/wifi_dialog.xml @@ -56,6 +56,7 @@ @@ -291,6 +291,7 @@ @@ -299,12 +300,11 @@ android:id="@+id/password_scanner_button" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" android:layout_centerVertical="true" android:layout_margin="5dp" android:background="@null" android:src="@drawable/ic_scan_24dp" - android:visibility="gone" android:contentDescription="@string/wifi_add_network" /> diff --git a/src/com/android/settings/wifi/AddNetworkFragment.java b/src/com/android/settings/wifi/AddNetworkFragment.java index 8df15a5e4d1..656f8efe6a4 100644 --- a/src/com/android/settings/wifi/AddNetworkFragment.java +++ b/src/com/android/settings/wifi/AddNetworkFragment.java @@ -40,6 +40,7 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf final static int SUBMIT_BUTTON_ID = android.R.id.button1; @VisibleForTesting final static int CANCEL_BUTTON_ID = android.R.id.button2; + final static int SCANNER_BUTTON_ID = R.id.ssid_scanner_button; private WifiConfigController mUIController; private Button mSubmitBtn; @@ -62,20 +63,12 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf mSubmitBtn = rootView.findViewById(SUBMIT_BUTTON_ID); mCancelBtn = rootView.findViewById(CANCEL_BUTTON_ID); + final ImageButton scannerButton = rootView.findViewById(SCANNER_BUTTON_ID); mSubmitBtn.setOnClickListener(this); mCancelBtn.setOnClickListener(this); + scannerButton.setOnClickListener(this); mUIController = new WifiConfigController(this, rootView, null, getMode()); - final ImageButton scannerButton = rootView.findViewById(R.id.ssid_scanner_button); - if (scannerButton != null) { - scannerButton.setVisibility(View.VISIBLE); - scannerButton.setOnClickListener((View v) -> { - // Launch QR code scanner to join a network. - getContext().startActivity( - WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null)); - }); - } - return rootView; } @@ -94,6 +87,11 @@ public class AddNetworkFragment extends InstrumentedFragment implements WifiConf case CANCEL_BUTTON_ID: handleCancelAction(); break; + case SCANNER_BUTTON_ID: + // Launch QR code scanner to join a network. + getContext().startActivity( + WifiDppUtils.getEnrolleeQrCodeScannerIntent(/* ssid */ null)); + break; } } diff --git a/src/com/android/settings/wifi/WifiDialog.java b/src/com/android/settings/wifi/WifiDialog.java index 4847f07b927..7d5f3b30f4f 100644 --- a/src/com/android/settings/wifi/WifiDialog.java +++ b/src/com/android/settings/wifi/WifiDialog.java @@ -82,7 +82,6 @@ public class WifiDialog extends AlertDialog implements WifiConfigUiBase, mView = getLayoutInflater().inflate(R.layout.wifi_dialog, /* root */ null); final ImageButton scannerButton = mView.findViewById(R.id.password_scanner_button); if (scannerButton != null) { - scannerButton.setVisibility(View.VISIBLE); scannerButton.setOnClickListener((View v) -> { String ssid = null; if (mAccessPoint != null) {