From 21b075770ee9ee8bcbf111a98a48a74b95028003 Mon Sep 17 00:00:00 2001 From: Haijie Hong Date: Tue, 8 Aug 2023 13:15:38 +0800 Subject: [PATCH] Improve Bluetooth pairing dialog & contact sharing toggle Before change: https://screenshot.googleplex.com/Agr29KTvgptbsag After change: https://screenshot.googleplex.com/ArjiavkFAFiuCTR Bug: 274521434 Test: RunSettingsRoboTests Change-Id: Ib896b70bc219de128b733b75249bf80e3389f221 --- res/layout/bluetooth_pin_confirm.xml | 34 +++++++++++++++---- res/values/strings.xml | 6 ++++ .../BluetoothDetailsProfilesController.java | 1 + .../BluetoothPairingDialogFragment.java | 7 ++-- .../bluetooth/BluetoothPairingDialogTest.java | 21 ++++++------ 5 files changed, 48 insertions(+), 21 deletions(-) diff --git a/res/layout/bluetooth_pin_confirm.xml b/res/layout/bluetooth_pin_confirm.xml index 7b5b04670e8..bcc47ad61b4 100644 --- a/res/layout/bluetooth_pin_confirm.xml +++ b/res/layout/bluetooth_pin_confirm.xml @@ -76,15 +76,37 @@ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" android:visibility="gone" /> - - + android:orientation="horizontal"> + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 948709baf3a..6074739f814 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1504,6 +1504,12 @@ Allow access to your contacts and call history + + Also allow access to contacts and call history + + + Info will be used for call announcements and more + diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index 1fd09a350d6..555868b9352 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -156,6 +156,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll } else if (profile instanceof PbapServerProfile) { profilePref.setChecked(device.getPhonebookAccessPermission() == BluetoothDevice.ACCESS_ALLOWED); + profilePref.setSummary(profile.getSummaryResourceForDevice(mCachedDevice.getDevice())); } else if (profile instanceof PanProfile) { profilePref.setChecked(profile.getConnectionStatus(device) == BluetoothProfile.STATE_CONNECTED); diff --git a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java index e11c275bded..1bac5981419 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingDialogFragment.java @@ -33,6 +33,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; +import android.widget.Switch; import android.widget.TextView; import androidx.annotation.VisibleForTesting; @@ -339,11 +340,9 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption); TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead); TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message); - CheckBox contactSharing = (CheckBox) view.findViewById( + Switch contactSharing = (Switch) view.findViewById( R.id.phonebook_sharing_message_confirm_pin); - contactSharing.setText(getString(R.string.bluetooth_pairing_shares_phonebook)); - - contactSharing.setVisibility( + view.findViewById(R.id.phonebook_sharing).setVisibility( mPairingController.isContactSharingVisible() ? View.VISIBLE : View.GONE); mPairingController.setContactSharingState(); contactSharing.setChecked(mPairingController.getContactSharingState()); diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java index 517b4355e6b..20448813a89 100644 --- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java +++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothPairingDialogTest.java @@ -33,7 +33,6 @@ import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.view.View; import android.view.inputmethod.InputMethodManager; -import android.widget.CheckBox; import android.widget.TextView; import androidx.appcompat.app.AlertDialog; @@ -276,7 +275,7 @@ public class BluetoothPairingDialogTest { } @Test - public void contactSharingCheckbox_conditionIsReady_showsUi() { + public void contactSharingToggle_conditionIsReady_showsUi() { // set the dialog variant to confirmation/consent when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG); // set a fake device name and pretend the profile has not been set up for it @@ -286,14 +285,14 @@ public class BluetoothPairingDialogTest { // build the fragment BluetoothPairingDialogFragment frag = makeFragment(); - // verify that the checkbox is visible and that the device name is correct - CheckBox sharingCheckbox = - frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin); - assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.VISIBLE); + // verify that the toggle is visible + View sharingToggle = + frag.getmDialog().findViewById(R.id.phonebook_sharing); + assertThat(sharingToggle.getVisibility()).isEqualTo(View.VISIBLE); } @Test - public void contactSharingCheckbox_conditionIsNotReady_doesNotShowUi() { + public void contactSharingToggle_conditionIsNotReady_doesNotShowUi() { // set the dialog variant to confirmation/consent when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG); // set a fake device name and pretend the profile has been set up for it @@ -303,10 +302,10 @@ public class BluetoothPairingDialogTest { // build the fragment BluetoothPairingDialogFragment frag = makeFragment(); - // verify that the checkbox is gone - CheckBox sharingCheckbox = - frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin); - assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.GONE); + // verify that the toggle is gone + View sharingToggle = + frag.getmDialog().findViewById(R.id.phonebook_sharing); + assertThat(sharingToggle.getVisibility()).isEqualTo(View.GONE); } @Test