From ef8b7a4fd739a1df3ab6ac14121d9b978737fcb7 Mon Sep 17 00:00:00 2001 From: Zoey Chen Date: Fri, 10 Jan 2025 04:05:59 +0000 Subject: [Settings] Set title and message by String to make it more flexible. Bug: 394542699 Test: manual Flag: EXEMPT refactor Change-Id: I65b28f8033d4d11e151461aba353b2a693b20c4a --- .../settingslib/utils/CustomDialogHelper.java | 47 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'packages/SettingsLib/src') diff --git a/packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java b/packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java index 4cf3bc23b9a0..87c7eb2d9327 100644 --- a/packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java +++ b/packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java @@ -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. @@ -185,21 +187,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. @@ -209,6 +243,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. */ -- cgit v1.2.3-59-g8ed1b