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

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

Merge "Improve Bluetooth pairing dialog & contact sharing toggle" into main

parents a0d28287 21b07577
Loading
Loading
Loading
Loading
+28 −6
Original line number Diff line number Diff line
@@ -76,15 +76,37 @@
            android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
            android:visibility="gone" />

        <CheckBox
            android:id="@+id/phonebook_sharing_message_confirm_pin"
            android:layout_width="wrap_content"
        <LinearLayout
            android:id="@+id/phonebook_sharing"
            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_marginEnd="@dimen/bluetooth_dialog_padding"
            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>

</ScrollView>
+6 −0
Original line number Diff line number Diff line
@@ -1538,6 +1538,12 @@
    <!-- Checkbox message in pairing dialogs.  [CHAR LIMIT=NONE] -->
    <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. -->
    <string name="bluetooth_error_title"></string>
+1 −0
Original line number Diff line number Diff line
@@ -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);
+3 −4
Original line number Diff line number Diff line
@@ -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;
@@ -341,11 +342,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());
+10 −11
Original line number Diff line number Diff line
@@ -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