Fix QR code scanner layout in "Pair devices over Wi-Fi" page.
The toolbar needs to be disabled to remove the empty space at the top
of the page. Also added the landscape layout xml.
Bug: 193602141
Test: atest SettingsUnitTests and manual
Change-Id: I30368835979b360a8f09e16f70adf57064784517
(cherry picked from commit fd009229e5
)
This commit is contained in:
@@ -2188,6 +2188,8 @@
|
|||||||
<activity android:name=".development.AppPicker"
|
<activity android:name=".development.AppPicker"
|
||||||
android:label="@string/select_application" />
|
android:label="@string/select_application" />
|
||||||
|
|
||||||
|
<activity android:name=".development.AdbQrCodeActivity" />
|
||||||
|
|
||||||
<activity android:name=".development.DSULoader"
|
<activity android:name=".development.DSULoader"
|
||||||
android:label="Select DSU Package"
|
android:label="Select DSU Package"
|
||||||
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" />
|
android:theme="@android:style/Theme.DeviceDefault.Light.Dialog" />
|
||||||
|
97
res/layout-land/adb_qrcode_scanner_fragment.xml
Normal file
97
res/layout-land/adb_qrcode_scanner_fragment.xml
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2018 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<com.google.android.setupdesign.GlifLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:icon="@drawable/ic_scan_32dp"
|
||||||
|
app:sudDescriptionText="@string/adb_wireless_qrcode_pairing_description">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
style="@style/SudContentFrame"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/camera_layout">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_width="@dimen/qrcode_preview_size"
|
||||||
|
android:layout_height="@dimen/qrcode_preview_size"
|
||||||
|
android:clipChildren="true">
|
||||||
|
<TextureView
|
||||||
|
android:id="@+id/preview_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
<com.android.settings.wifi.qrcode.QrDecorateView
|
||||||
|
android:id="@+id/decorate_view"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/error_message"
|
||||||
|
style="@style/TextAppearance.ErrorText"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginStart="?attr/sudMarginStart"
|
||||||
|
android:layout_marginEnd="?attr/sudMarginEnd"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:visibility="invisible"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
The spinner indicating that the device is waiting for pairing
|
||||||
|
after getting valid QR code
|
||||||
|
-->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/verifying_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/verifying_progress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/verifying_textview"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
style="@style/adb_wireless_item_progress_text"
|
||||||
|
android:text="@string/adb_wireless_verifying_qrcode_text"
|
||||||
|
android:accessibilityLiveRegion="polite"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</com.google.android.setupdesign.GlifLayout>
|
||||||
|
|
@@ -17,10 +17,11 @@
|
|||||||
|
|
||||||
<com.google.android.setupdesign.GlifLayout
|
<com.google.android.setupdesign.GlifLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:theme="@style/GlifV3Theme"
|
android:icon="@drawable/ic_scan_32dp"
|
||||||
android:icon="@drawable/ic_scan_32dp">
|
app:sudDescriptionText="@string/adb_wireless_qrcode_pairing_description">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
style="@style/SudContentFrame"
|
style="@style/SudContentFrame"
|
||||||
@@ -29,28 +30,12 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center_horizontal">
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center_horizontal"
|
|
||||||
android:id="@+id/camera_layout">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@android:id/summary"
|
|
||||||
style="@style/TextAppearance.SudGlifBody"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="?attr/sudMarginStart"
|
|
||||||
android:layout_marginEnd="?attr/sudMarginEnd"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:accessibilityLiveRegion="polite"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/camera_layout">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -79,8 +64,6 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
The spinner indicating that the device is waiting for pairing
|
The spinner indicating that the device is waiting for pairing
|
||||||
after getting valid QR code
|
after getting valid QR code
|
||||||
@@ -109,4 +92,5 @@
|
|||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.setupdesign.GlifLayout>
|
</com.google.android.setupdesign.GlifLayout>
|
||||||
|
75
src/com/android/settings/development/AdbQrCodeActivity.java
Normal file
75
src/com/android/settings/development/AdbQrCodeActivity.java
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.settings.development;
|
||||||
|
|
||||||
|
import android.app.settings.SettingsEnums;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.wifi.dpp.WifiDppBaseActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To scan an ADB QR code to pair a device.
|
||||||
|
*
|
||||||
|
* To use intent action {@code ACTION_ADB_QR_CODE_SCANNER}.
|
||||||
|
*/
|
||||||
|
public class AdbQrCodeActivity extends WifiDppBaseActivity {
|
||||||
|
private static final String TAG = "AdbQrCodeActivity";
|
||||||
|
|
||||||
|
static final String TAG_FRAGMENT_ADB_QR_CODE_SCANNER = "adb_qr_code_scanner_fragment";
|
||||||
|
|
||||||
|
public static final String ACTION_ADB_QR_CODE_SCANNER =
|
||||||
|
"android.settings.ADB_QR_CODE_SCANNER";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMetricsCategory() {
|
||||||
|
return SettingsEnums.SETTINGS_ADB_WIRELESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle icicle) {
|
||||||
|
super.onCreate(icicle);
|
||||||
|
AdbQrcodeScannerFragment fragment =
|
||||||
|
(AdbQrcodeScannerFragment) mFragmentManager.findFragmentByTag(
|
||||||
|
TAG_FRAGMENT_ADB_QR_CODE_SCANNER);
|
||||||
|
|
||||||
|
if (fragment == null) {
|
||||||
|
fragment = new AdbQrcodeScannerFragment();
|
||||||
|
} else {
|
||||||
|
if (fragment.isVisible()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the fragment in back stack but not on top of the stack, we can simply pop
|
||||||
|
// stack because current fragment transactions are arranged in an order
|
||||||
|
mFragmentManager.popBackStackImmediate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
|
||||||
|
|
||||||
|
fragmentTransaction.replace(R.id.fragment_container, fragment,
|
||||||
|
TAG_FRAGMENT_ADB_QR_CODE_SCANNER);
|
||||||
|
fragmentTransaction.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleIntent(Intent intent) {
|
||||||
|
}
|
||||||
|
}
|
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package com.android.settings.development;
|
package com.android.settings.development;
|
||||||
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.debug.IAdbManager;
|
import android.debug.IAdbManager;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
@@ -28,7 +28,6 @@ import androidx.fragment.app.Fragment;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
import com.android.settings.core.BasePreferenceController;
|
import com.android.settings.core.BasePreferenceController;
|
||||||
import com.android.settings.core.SubSettingLauncher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the "Pair device with QR code" preference in the Wireless debugging
|
* Controller for the "Pair device with QR code" preference in the Wireless debugging
|
||||||
@@ -68,12 +67,9 @@ public class AdbQrCodePreferenceController extends BasePreferenceController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
new SubSettingLauncher(preference.getContext())
|
final Intent intent = new Intent(mContext, AdbQrCodeActivity.class);
|
||||||
.setDestination(AdbQrcodeScannerFragment.class.getName())
|
mParentFragment.startActivityForResult(intent,
|
||||||
.setSourceMetricsCategory(SettingsEnums.SETTINGS_ADB_WIRELESS)
|
WirelessDebuggingFragment.PAIRING_DEVICE_REQUEST);
|
||||||
.setResultListener(mParentFragment,
|
|
||||||
WirelessDebuggingFragment.PAIRING_DEVICE_REQUEST)
|
|
||||||
.launch();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,12 +44,15 @@ import android.widget.TextView;
|
|||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.SetupWizardUtils;
|
||||||
import com.android.settings.wifi.dpp.AdbQrCode;
|
import com.android.settings.wifi.dpp.AdbQrCode;
|
||||||
import com.android.settings.wifi.dpp.WifiDppQrCodeBaseFragment;
|
import com.android.settings.wifi.dpp.WifiDppQrCodeBaseFragment;
|
||||||
import com.android.settings.wifi.dpp.WifiNetworkConfig;
|
import com.android.settings.wifi.dpp.WifiNetworkConfig;
|
||||||
import com.android.settings.wifi.qrcode.QrCamera;
|
import com.android.settings.wifi.qrcode.QrCamera;
|
||||||
import com.android.settings.wifi.qrcode.QrDecorateView;
|
import com.android.settings.wifi.qrcode.QrDecorateView;
|
||||||
|
|
||||||
|
import com.google.android.setupdesign.util.ThemeHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment shown when clicking on the "Pair by QR code" preference in
|
* Fragment shown when clicking on the "Pair by QR code" preference in
|
||||||
* the Wireless Debugging fragment.
|
* the Wireless Debugging fragment.
|
||||||
@@ -144,6 +147,9 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
Context context = getContext();
|
||||||
|
context.setTheme(SetupWizardUtils.getTheme(context, getActivity().getIntent()));
|
||||||
|
ThemeHelper.trySetDynamicColor(getContext());
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
mIntentFilter = new IntentFilter(AdbManager.WIRELESS_DEBUG_PAIRING_RESULT_ACTION);
|
mIntentFilter = new IntentFilter(AdbManager.WIRELESS_DEBUG_PAIRING_RESULT_ACTION);
|
||||||
@@ -158,6 +164,7 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
|
|||||||
@Override
|
@Override
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
mSummary = view.findViewById(R.id.sud_layout_subtitle);
|
||||||
|
|
||||||
mTextureView = (TextureView) view.findViewById(R.id.preview_view);
|
mTextureView = (TextureView) view.findViewById(R.id.preview_view);
|
||||||
mTextureView.setSurfaceTextureListener(this);
|
mTextureView.setSurfaceTextureListener(this);
|
||||||
@@ -165,8 +172,6 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
|
|||||||
mDecorateView = view.findViewById(R.id.decorate_view);
|
mDecorateView = view.findViewById(R.id.decorate_view);
|
||||||
setProgressBarShown(false);
|
setProgressBarShown(false);
|
||||||
|
|
||||||
setHeaderIconImageResource(R.drawable.ic_scan_24dp);
|
|
||||||
|
|
||||||
mQrCameraView = view.findViewById(R.id.camera_layout);
|
mQrCameraView = view.findViewById(R.id.camera_layout);
|
||||||
mVerifyingView = view.findViewById(R.id.verifying_layout);
|
mVerifyingView = view.findViewById(R.id.verifying_layout);
|
||||||
mVerifyingTextView = view.findViewById(R.id.verifying_textview);
|
mVerifyingTextView = view.findViewById(R.id.verifying_textview);
|
||||||
@@ -181,12 +186,18 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
restartCamera();
|
||||||
|
|
||||||
mAdbManager = IAdbManager.Stub.asInterface(ServiceManager.getService(Context.ADB_SERVICE));
|
mAdbManager = IAdbManager.Stub.asInterface(ServiceManager.getService(Context.ADB_SERVICE));
|
||||||
getActivity().registerReceiver(mReceiver, mIntentFilter);
|
getActivity().registerReceiver(mReceiver, mIntentFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
if (mCamera != null) {
|
||||||
|
mCamera.stop();
|
||||||
|
}
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
getActivity().unregisterReceiver(mReceiver);
|
getActivity().unregisterReceiver(mReceiver);
|
||||||
@@ -195,8 +206,6 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
|
|||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Unable to cancel pairing");
|
Log.e(TAG, "Unable to cancel pairing");
|
||||||
}
|
}
|
||||||
getActivity().setResult(Activity.RESULT_CANCELED);
|
|
||||||
getActivity().finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -213,7 +222,6 @@ public class AdbQrcodeScannerFragment extends WifiDppQrCodeBaseFragment implemen
|
|||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
getActivity().getActionBar().hide();
|
|
||||||
// setTitle for TalkBack
|
// setTitle for TalkBack
|
||||||
getActivity().setTitle(R.string.wifi_dpp_scan_qr_code);
|
getActivity().setTitle(R.string.wifi_dpp_scan_qr_code);
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
import com.android.settings.core.InstrumentedActivity;
|
import com.android.settings.core.InstrumentedActivity;
|
||||||
|
|
||||||
abstract class WifiDppBaseActivity extends InstrumentedActivity {
|
public abstract class WifiDppBaseActivity extends InstrumentedActivity {
|
||||||
protected FragmentManager mFragmentManager;
|
protected FragmentManager mFragmentManager;
|
||||||
|
|
||||||
protected abstract void handleIntent(Intent intent);
|
protected abstract void handleIntent(Intent intent);
|
||||||
|
Reference in New Issue
Block a user