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
This commit is contained in:
Haijie Hong
2023-08-08 13:15:38 +08:00
parent 317bfca133
commit 21b075770e
5 changed files with 48 additions and 21 deletions

View File

@@ -76,15 +76,37 @@
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:visibility="gone" /> android:visibility="gone" />
<CheckBox <LinearLayout
android:id="@+id/phonebook_sharing_message_confirm_pin" android:id="@+id/phonebook_sharing"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/min_tap_target_size" android:layout_width="match_parent"
android:layout_marginStart="@dimen/bluetooth_dialog_padding" android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding" android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" /> android:orientation="horizontal">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bluetooth_pairing_phonebook_toggle_text"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bluetooth_pairing_phonebook_toggle_details"
android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Caption" />
</LinearLayout>
<Switch
android:id="@+id/phonebook_sharing_message_confirm_pin"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View File

@@ -1504,6 +1504,12 @@
<!-- Checkbox message in pairing dialogs. [CHAR LIMIT=NONE] --> <!-- Checkbox message in pairing dialogs. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_shares_phonebook">Allow access to your contacts and call history</string> <string name="bluetooth_pairing_shares_phonebook">Allow access to your contacts and call history</string>
<!-- Phonebook sharing toggle message in pairing dialogs. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_phonebook_toggle_text">Also allow access to contacts and call history</string>
<!-- Phonebook sharing toggle detailed message in pairing dialogs. [CHAR LIMIT=NONE] -->
<string name="bluetooth_pairing_phonebook_toggle_details">Info will be used for call announcements and more</string>
<!-- Title for BT error dialogs. --> <!-- Title for BT error dialogs. -->
<string name="bluetooth_error_title"></string> <string name="bluetooth_error_title"></string>

View File

@@ -156,6 +156,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
} else if (profile instanceof PbapServerProfile) { } else if (profile instanceof PbapServerProfile) {
profilePref.setChecked(device.getPhonebookAccessPermission() profilePref.setChecked(device.getPhonebookAccessPermission()
== BluetoothDevice.ACCESS_ALLOWED); == BluetoothDevice.ACCESS_ALLOWED);
profilePref.setSummary(profile.getSummaryResourceForDevice(mCachedDevice.getDevice()));
} else if (profile instanceof PanProfile) { } else if (profile instanceof PanProfile) {
profilePref.setChecked(profile.getConnectionStatus(device) == profilePref.setChecked(profile.getConnectionStatus(device) ==
BluetoothProfile.STATE_CONNECTED); BluetoothProfile.STATE_CONNECTED);

View File

@@ -33,6 +33,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.Switch;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
@@ -339,11 +340,9 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption); TextView pairingViewCaption = (TextView) view.findViewById(R.id.pairing_caption);
TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead); TextView pairingViewContent = (TextView) view.findViewById(R.id.pairing_subhead);
TextView messagePairing = (TextView) view.findViewById(R.id.pairing_code_message); 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); R.id.phonebook_sharing_message_confirm_pin);
contactSharing.setText(getString(R.string.bluetooth_pairing_shares_phonebook)); view.findViewById(R.id.phonebook_sharing).setVisibility(
contactSharing.setVisibility(
mPairingController.isContactSharingVisible() ? View.VISIBLE : View.GONE); mPairingController.isContactSharingVisible() ? View.VISIBLE : View.GONE);
mPairingController.setContactSharingState(); mPairingController.setContactSharingState();
contactSharing.setChecked(mPairingController.getContactSharingState()); contactSharing.setChecked(mPairingController.getContactSharingState());

View File

@@ -33,7 +33,6 @@ import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
@@ -276,7 +275,7 @@ public class BluetoothPairingDialogTest {
} }
@Test @Test
public void contactSharingCheckbox_conditionIsReady_showsUi() { public void contactSharingToggle_conditionIsReady_showsUi() {
// set the dialog variant to confirmation/consent // set the dialog variant to confirmation/consent
when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG); when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG);
// set a fake device name and pretend the profile has not been set up for it // 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 // build the fragment
BluetoothPairingDialogFragment frag = makeFragment(); BluetoothPairingDialogFragment frag = makeFragment();
// verify that the checkbox is visible and that the device name is correct // verify that the toggle is visible
CheckBox sharingCheckbox = View sharingToggle =
frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin); frag.getmDialog().findViewById(R.id.phonebook_sharing);
assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.VISIBLE); assertThat(sharingToggle.getVisibility()).isEqualTo(View.VISIBLE);
} }
@Test @Test
public void contactSharingCheckbox_conditionIsNotReady_doesNotShowUi() { public void contactSharingToggle_conditionIsNotReady_doesNotShowUi() {
// set the dialog variant to confirmation/consent // set the dialog variant to confirmation/consent
when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG); when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG);
// set a fake device name and pretend the profile has been set up for it // 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 // build the fragment
BluetoothPairingDialogFragment frag = makeFragment(); BluetoothPairingDialogFragment frag = makeFragment();
// verify that the checkbox is gone // verify that the toggle is gone
CheckBox sharingCheckbox = View sharingToggle =
frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin); frag.getmDialog().findViewById(R.id.phonebook_sharing);
assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.GONE); assertThat(sharingToggle.getVisibility()).isEqualTo(View.GONE);
} }
@Test @Test