Settings: Add TextView for summary into SeekBarDialogPreference

Signed-off-by: cjybyjk <cjybyjk@zjnu.edu.cn>
Change-Id: Icff728749c3e597a4127d77646bdf3a742c35d83
diff --git a/res/layout/preference_dialog_seekbar_material.xml b/res/layout/preference_dialog_seekbar_material.xml
index 09b963a..e7c9132 100644
--- a/res/layout/preference_dialog_seekbar_material.xml
+++ b/res/layout/preference_dialog_seekbar_material.xml
@@ -26,6 +26,17 @@
         android:layout_height="wrap_content"
         android:paddingTop="?android:attr/dialogPreferredPadding" />
 
+     <TextView
+          android:id="@+id/text"
+          android:layout_width="match_parent"
+          android:layout_height="wrap_content"
+          android:focusable="false"
+          android:paddingTop="?android:attr/dialogPreferredPadding"
+          android:paddingStart="?android:attr/dialogPreferredPadding"
+          android:paddingEnd="?android:attr/dialogPreferredPadding"
+          style="@style/TextAppearance.DialogMessage"
+          android:visibility="gone"/>
+
     <SeekBar
         android:id="@+id/seekbar"
         android:layout_width="match_parent"
diff --git a/src/com/android/settings/SeekBarDialogPreference.java b/src/com/android/settings/SeekBarDialogPreference.java
index d0c8134..22cbcae 100644
--- a/src/com/android/settings/SeekBarDialogPreference.java
+++ b/src/com/android/settings/SeekBarDialogPreference.java
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2007 The Android Open Source Project
+ *           (C) 2022 Project Kaleidoscope
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,12 +19,15 @@
 
 import android.content.Context;
 import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.View;
 import android.widget.ImageView;
 import android.widget.SeekBar;
+import android.widget.TextView;
 
 import com.android.settingslib.CustomDialogPreferenceCompat;
+import com.android.settings.R;
 
 /**
  * Based on frameworks/base/core/java/android/preference/SeekBarDialogPreference.java
@@ -31,6 +35,7 @@
  */
 public class SeekBarDialogPreference extends CustomDialogPreferenceCompat {
     private final Drawable mMyIcon;
+    private TextView mTextView;
 
     public SeekBarDialogPreference(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -64,6 +69,19 @@
         } else {
             iconView.setVisibility(View.GONE);
         }
+
+        mTextView = view.findViewById(R.id.text);
+    }
+
+    public void setText(String text) {
+        if (mTextView != null) {
+            if (TextUtils.isEmpty(text)) {
+                mTextView.setVisibility(View.GONE);
+            } else {
+                mTextView.setVisibility(View.VISIBLE);
+            }
+            mTextView.setText(text);
+        }
     }
 
     protected static SeekBar getSeekBar(View dialogView) {