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

Commit c13fe90a authored by Chelsea Hao's avatar Chelsea Hao Committed by Android (Google) Code Review
Browse files

Merge "Use default button from alert dialog to avoid text overflow with large font size." into main

parents db657580 136715f0
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
  -->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

@@ -31,7 +30,6 @@
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="25dp"
            android:orientation="vertical">

            <ImageView
@@ -76,51 +74,5 @@
                android:visibility="gone"/>
        </LinearLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/broadcast_dialog_margin">
            <Button
                android:id="@+id/left_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                style="@style/BroadcastActionButton"
                android:featureFlag="!com.android.settings.flags.enable_bluetooth_settings_expressive_design_read_only"/>
            <Button
                android:id="@+id/right_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                style="@style/BroadcastActionButton"
                android:featureFlag="!com.android.settings.flags.enable_bluetooth_settings_expressive_design_read_only"/>
            <Button
                android:id="@+id/left_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                style="@style/Widget.SettingsLib.DialogButton.Outline"
                android:featureFlag="com.android.settings.flags.enable_bluetooth_settings_expressive_design_read_only"/>
            <Button
                android:id="@+id/right_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:visibility="gone"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                style="@style/Widget.SettingsLib.DialogButton.Outline"
                android:featureFlag="com.android.settings.flags.enable_bluetooth_settings_expressive_design_read_only"/>
        </androidx.constraintlayout.widget.ConstraintLayout>

    </LinearLayout>
</FrameLayout>
 No newline at end of file
+11 −15
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
@@ -221,8 +220,7 @@ public class AudioStreamsDialogFragment extends InstrumentedDialogFragment {
                    LayoutInflater.from(mContext)
                            .inflate(R.xml.bluetooth_audio_streams_dialog, /* parent= */ null);

            AlertDialog dialog = mBuilder.setView(rootView).setCancelable(false).create();
            dialog.setCanceledOnTouchOutside(false);
            AlertDialog.Builder dialogBuilder = mBuilder.setView(rootView).setCancelable(false);

            TextView title = rootView.requireViewById(R.id.dialog_title);
            title.setText(mTitle);
@@ -238,27 +236,25 @@ public class AudioStreamsDialogFragment extends InstrumentedDialogFragment {
                subTitle2.setVisibility(View.VISIBLE);
            }
            if (!Strings.isNullOrEmpty(mLeftButtonText)) {
                Button leftButton = rootView.requireViewById(R.id.left_button);
                leftButton.setText(mLeftButtonText);
                leftButton.setVisibility(View.VISIBLE);
                leftButton.setOnClickListener(
                        unused -> {
                dialogBuilder.setNegativeButton(mLeftButtonText,
                        (dialog, which) -> {
                            if (mLeftButtonOnClickListener != null) {
                                mLeftButtonOnClickListener.accept(dialog);
                                mLeftButtonOnClickListener.accept(
                                        (AlertDialog) dialog);
                            }
                        });
            }
            if (!Strings.isNullOrEmpty(mRightButtonText)) {
                Button rightButton = rootView.requireViewById(R.id.right_button);
                rightButton.setText(mRightButtonText);
                rightButton.setVisibility(View.VISIBLE);
                rightButton.setOnClickListener(
                        unused -> {
                dialogBuilder.setPositiveButton(mRightButtonText,
                        (dialog, which) -> {
                            if (mRightButtonOnClickListener != null) {
                                mRightButtonOnClickListener.accept(dialog);
                                mRightButtonOnClickListener.accept(
                                        (AlertDialog) dialog);
                            }
                        });
            }
            var dialog = dialogBuilder.create();
            dialog.setCanceledOnTouchOutside(false);

            return dialog;
        }