Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbeb48e8 authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Update string of bluetooth pairing dialog" into main

parents 36710f7d e91600e4
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -29,6 +29,18 @@
        android:layout_width="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/pairing_confirmation_hint"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/bluetooth_dialog_padding"
            android:layout_marginBottom="12dp"
            android:layout_marginStart="@dimen/bluetooth_dialog_padding"
            android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
            android:gravity="center_vertical"
            android:visibility="gone"
            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />

        <TextView
            android:id="@+id/pairing_caption"
            android:layout_width="wrap_content"
+6 −0
Original line number Diff line number Diff line
@@ -2075,6 +2075,12 @@
    <!-- 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 the dialog to confirm PIN. [CHAR LIMIT=40] -->
    <string name="bluetooth_pairing_confirmation_title">Check pairing codes</string>
    <!-- Message for the dialog to confirm PIN. [CHAR LIMIT=NONE] -->
    <string name="bluetooth_pairing_confirmation_msg">Check if this code matches the one on <xliff:g id="device_name">%1$s</xliff:g>.\n\nFor your security, do not enter this code anywhere.</string>
    <!-- Title for BT error dialogs. -->
    <string name="bluetooth_error_title"></string>
+12 −3
Original line number Diff line number Diff line
@@ -302,8 +302,7 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
     * Creates a dialog with UI elements that allow the user to confirm a pairing request.
     */
    private AlertDialog createConfirmationDialog() {
        mBuilder.setTitle(getString(R.string.bluetooth_pairing_request,
                mPairingController.getDeviceName()));
        mBuilder.setTitle(getString(R.string.bluetooth_pairing_confirmation_title));
        mBuilder.setView(createView());
        mBuilder.setPositiveButton(
                getString(com.android.settingslib.R.string.bluetooth_pairing_accept), this);
@@ -343,6 +342,8 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
     */
    private View createView() {
        View view = getActivity().getLayoutInflater().inflate(R.layout.bluetooth_pin_confirm, null);
        TextView pairingConfirmationHint =
                (TextView) view.findViewById(R.id.pairing_confirmation_hint);
        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);
@@ -356,7 +357,15 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
        messagePairing.setVisibility(mPairingController.isDisplayPairingKeyVariant()
                ? View.VISIBLE : View.GONE);
        if (mPairingController.hasPairingContent()) {
            if (mPairingController.isDisplayPairingKeyVariant()) {
                pairingViewCaption.setVisibility(View.VISIBLE);
            } else {
                pairingConfirmationHint.setText(
                        getString(
                                R.string.bluetooth_pairing_confirmation_msg,
                                mPairingController.getDeviceName()));
                pairingConfirmationHint.setVisibility(View.VISIBLE);
            }
            pairingViewContent.setVisibility(View.VISIBLE);
            pairingViewContent.setText(mPairingController.getPairingContent());
        }
+18 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ public class BluetoothPairingDialogTest {
        // get the relevant views
        View messagePairing = frag.getmDialog().findViewById(R.id.pairing_code_message);
        TextView pairingViewContent = frag.getmDialog().findViewById(R.id.pairing_subhead);
        View pairingViewCaption = frag.getmDialog().findViewById(R.id.pairing_caption);
        TextView pairingViewCaption = frag.getmDialog().findViewById(R.id.pairing_caption);

        // check that the relevant views are visible and that the passkey is shown
        assertThat(messagePairing.getVisibility()).isEqualTo(View.VISIBLE);
@@ -403,6 +403,23 @@ public class BluetoothPairingDialogTest {
        verify(dialogActivity, times(1)).dismiss();
    }

    @Test
    public void confirmationDialog_showConfirmationMessage() {
        when(controller.getDialogType()).thenReturn(BluetoothPairingController.CONFIRMATION_DIALOG);
        when(controller.getDeviceName()).thenReturn("Device");
        when(controller.hasPairingContent()).thenReturn(true);
        when(controller.getPairingContent()).thenReturn(FILLER);

        // build the fragment
        BluetoothPairingDialogFragment frag = makeFragment();

        TextView pairingConfirmationHint =
                frag.getmDialog().findViewById(R.id.pairing_confirmation_hint);
        assertThat(pairingConfirmationHint.getText())
                .isEqualTo(frag.getString(R.string.bluetooth_pairing_confirmation_msg, "Device"));
        assertThat(pairingConfirmationHint.getVisibility()).isEqualTo(View.VISIBLE);
    }

    @Ignore
    @Test
    public void rotateDialog_nullPinText_okButtonEnabled() {