summaryrefslogtreecommitdiff
path: root/packages/SettingsLib/src
diff options
context:
space:
mode:
author Zoey Chen <zoeychen@google.com> 2025-02-12 17:28:40 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-02-12 17:28:40 -0800
commit9fdc5f0a8f3a287da482b6c4b5d20373ecee62af (patch)
treeb79d02fc57dba016cb9e2204e36d59ee033883c8 /packages/SettingsLib/src
parent68386c46b1b4aa78a8d5e6141587fcdfa56d4d22 (diff)
parentef8b7a4fd739a1df3ab6ac14121d9b978737fcb7 (diff)
Merge "[Settings] Set title and message by String to make it more flexible." into main
Diffstat (limited to 'packages/SettingsLib/src')
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java47
1 files changed, 45 insertions, 2 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java b/packages/SettingsLib/src/com/android/settingslib/utils/CustomDialogHelper.java
index 6e64c597f5cc..34e08af18f93 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.
@@ -191,20 +193,52 @@ public class CustomDialogHelper {
}
/**
+ * 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.
@@ -215,6 +249,15 @@ public class CustomDialogHelper {
}
/**
+ * 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.
*/
public CustomDialogHelper clearCustomLayout() {