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

Commit 9fdc5f0a authored by Zoey Chen's avatar Zoey Chen Committed by Android (Google) Code Review
Browse files

Merge "[Settings] Set title and message by String to make it more flexible." into main

parents 68386c46 ef8b7a4f
Loading
Loading
Loading
Loading
+45 −2
Original line number Diff line number Diff line
@@ -34,6 +34,8 @@ import com.android.settingslib.R;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import androidx.annotation.NonNull;

/**
 * This class is used to create custom dialog with icon, title, message and custom view that are
 * horizontally centered.
@@ -190,21 +192,53 @@ public class CustomDialogHelper {
        return this;
    }

    /**
     * Sets title of the dialog by string.
     */
    @NonNull public CustomDialogHelper setTitle(@NonNull CharSequence title) {
        mDialogTitle.setText(title);
        return this;
    }

    /**
     * Sets title padding of the dialog.
     */
    @NonNull public CustomDialogHelper setTitlePadding(int left, int top, int right, int bottom) {
        mDialogTitle.setPadding(left, top, right, bottom);
        return this;
    }

    /**
     * Sets message of the dialog.
     */
    public CustomDialogHelper setMessage(@StringRes int resid) {
   @NonNull public CustomDialogHelper setMessage(@StringRes int resid) {
        mDialogMessage.setText(resid);
        return this;
    }

    /**
     * Sets message of the dialog by string.
     */
    @NonNull public CustomDialogHelper setMessage(@NonNull CharSequence message) {
        mDialogMessage.setText(message);
        return this;
    }

    /**
     * Sets message padding of the dialog.
     */
    public CustomDialogHelper setMessagePadding(int dp) {
    @NonNull public CustomDialogHelper setMessagePadding(int dp) {
        mDialogMessage.setPadding(dp, dp, dp, dp);
        return this;
    }
    /**
     * Sets message padding of the dialog.
     */
    @NonNull
    public CustomDialogHelper setMessagePadding(int left, int top, int right, int bottom) {
        mDialogMessage.setPadding(left, top, right, bottom);
        return this;
    }

    /**
     * Sets icon of the dialog.
@@ -214,6 +248,15 @@ public class CustomDialogHelper {
        return this;
    }

    /**
     * Sets icon padding of the dialog.
     */
    @NonNull
    public CustomDialogHelper setIconPadding(int left, int top, int right, int bottom) {
        mDialogIcon.setPadding(left, top, right, bottom);
        return this;
    }

    /**
     * Removes all views that were previously added to the custom layout part.
     */