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

Commit 2206b391 authored by Haijie Hong's avatar Haijie Hong
Browse files

Use expressive style switch in bluetooth pairing dialog

Bug: 399532172
Test: local tested
Flag: com.android.settings.flags.enable_bluetooth_settings_expressive_design
Change-Id: I31b01de5323435420f405173e1a906a87e8d61b2
parent a0ac06fd
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -109,6 +109,17 @@
                android:gravity="center_vertical"
                android:contentDescription="@string/bluetooth_pairing_phonebook_toggle_text"
                android:switchMinWidth="48dp" />
            <com.google.android.material.materialswitch.MaterialSwitch
                android:theme="@style/Theme.Material3.DynamicColors.DayNight"
                android:id="@+id/phonebook_sharing_message_confirm_pin_expressive"
                android:layout_width="wrap_content"
                android:layout_height="48dp"
                android:gravity="center_vertical"
                android:contentDescription="@string/bluetooth_pairing_phonebook_toggle_text"
                android:switchMinWidth="48dp"
                android:focusable="true"
                android:clickable="true"
                style="@style/SettingslibSwitchStyle.Expressive" />
        </LinearLayout>
    </LinearLayout>

+18 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import androidx.appcompat.app.AlertDialog;

import com.android.settings.R;
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.flags.Flags;

/**
 * A dialogFragment used by {@link BluetoothPairingDialog} to create an appropriately styled dialog
@@ -345,8 +346,7 @@ 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);
        CompoundButton contactSharing =
                view.findViewById(R.id.phonebook_sharing_message_confirm_pin);
        CompoundButton contactSharing = getContactSharingSwitch(view);
        view.findViewById(R.id.phonebook_sharing).setVisibility(
                mPairingController.isContactSharingVisible() ? View.VISIBLE : View.GONE);
        mPairingController.setContactSharingState();
@@ -371,4 +371,20 @@ public class BluetoothPairingDialogFragment extends InstrumentedDialogFragment i
        messagePairingSet.setVisibility(setPairingMessage ? View.VISIBLE : View.GONE);
        return view;
    }

    private CompoundButton getContactSharingSwitch(View container) {
        CompoundButton legacySwitch =
                container.findViewById(R.id.phonebook_sharing_message_confirm_pin);
        CompoundButton expressiveSwitch =
                container.findViewById(R.id.phonebook_sharing_message_confirm_pin_expressive);
        if (Flags.enableBluetoothSettingsExpressiveDesign()) {
            legacySwitch.setVisibility(View.GONE);
            expressiveSwitch.setVisibility(View.VISIBLE);
            return expressiveSwitch;
        } else {
            legacySwitch.setVisibility(View.VISIBLE);
            expressiveSwitch.setVisibility(View.GONE);
            return legacySwitch;
        }
    }
}