Loading packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml +2 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ <ImageView android:id="@android:id/icon" android:importantForAccessibility="no" style="@style/SettingsLibEntityHeaderIcon"/> <TextView Loading @@ -41,7 +42,7 @@ android:layout_height="wrap_content" android:gravity="center" android:minLines="1" app:isCollapsable="true"/> app:isCollapsable="false"/> </LinearLayout> Loading packages/SettingsLib/IntroPreference/src/com/android/settingslib/widget/IntroPreference.kt +6 −7 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ constructor( defStyleRes: Int = 0, ) : Preference(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin { private var isCollapsable: Boolean = true private var isCollapsable: Boolean = DEFAULT_COLLAPSABLE private var minLines: Int = DEFAULT_MIN_LINES private var hyperlinkListener: View.OnClickListener? = null private var learnMoreListener: View.OnClickListener? = null Loading @@ -53,13 +53,11 @@ constructor( setCollapsable(isCollapsable) setMinLines(minLines) visibility = if (summary.isNullOrEmpty()) View.GONE else View.VISIBLE setText(summary.toString()) if (hyperlinkListener != null) { setHyperlinkListener(hyperlinkListener) } if (learnMoreListener != null) { summary?.let { setText(it.toString()) } hyperlinkListener?.let { setHyperlinkListener(it) } learnMoreListener?.let { setLearnMoreText(learnMoreText) setLearnMoreAction(learnMoreListener) setLearnMoreAction(it) } } } Loading Loading @@ -124,5 +122,6 @@ constructor( companion object { private const val DEFAULT_MAX_LINES = 10 private const val DEFAULT_MIN_LINES = 1 private const val DEFAULT_COLLAPSABLE = false } } packages/SettingsLib/SettingsTheme/res/layout/settingslib_expressive_collapsable_textview.xml +24 −6 Original line number Diff line number Diff line Loading @@ -55,12 +55,30 @@ android:visibility="gone" style="@style/SettingslibTextAppearance.LinkableTextStyle.Expressive"/> <com.google.android.material.button.MaterialButton <LinearLayout android:id="@+id/collapse_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="@dimen/settingslib_expressive_space_extrasmall4" android:paddingBottom="@dimen/settingslib_expressive_space_extrasmall4" app:layout_constraintTop_toBottomOf="@id/settingslib_expressive_learn_more" app:layout_constraintStart_toStartOf="parent" android:textColor="@color/settingslib_materialColorOnSurface" android:text="@string/settingslib_expressive_text_expand" app:icon="@drawable/settingslib_expressive_icon_expand" style="@style/SettingslibTextButtonStyle.Expressive"/> android:gravity="center" android:filterTouchesWhenObscured="false"> <ImageView android:id="@android:id/icon1" android:layout_width="@dimen/settingslib_expressive_space_small4" android:layout_height="@dimen/settingslib_expressive_space_small4" android:importantForAccessibility="no" android:scaleType="centerInside"/> <TextView android:id="@android:id/text1" android:layout_marginStart="@dimen/settingslib_expressive_space_extrasmall4" style="@style/TextAppearance.SettingsLib.BodyLarge.Emphasized" android:layout_width="wrap_content" android:layout_height="@dimen/settingslib_expressive_space_small4"/> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout> packages/SettingsLib/SettingsTheme/src/com/android/settingslib/widget/CollapsableTextView.kt +11 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.util.AttributeSet import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import com.android.settingslib.widget.theme.R Loading @@ -45,7 +47,9 @@ class CollapsableTextView @JvmOverloads constructor( private var minLines: Int = DEFAULT_MIN_LINES private val titleTextView: TextView private val collapseButton: MaterialButton private val collapseButton: LinearLayout private val collapseButtonIcon: ImageView? private val collapseButtonText: TextView? private val collapseButtonResources: CollapseButtonResources private var hyperlinkListener: View.OnClickListener? = null private var learnMoreListener: View.OnClickListener? = null Loading @@ -59,6 +63,8 @@ class CollapsableTextView @JvmOverloads constructor( .inflate(R.layout.settingslib_expressive_collapsable_textview, this) titleTextView = findViewById(android.R.id.title) collapseButton = findViewById(R.id.collapse_button) collapseButtonIcon = collapseButton.findViewById(android.R.id.icon1) collapseButtonText = collapseButton.findViewById(android.R.id.text1) learnMoreTextView = findViewById(R.id.settingslib_expressive_learn_more) collapseButtonResources = CollapseButtonResources( Loading Loading @@ -223,20 +229,16 @@ class CollapsableTextView @JvmOverloads constructor( private fun updateView() { when { isCollapsed -> { collapseButton.apply { text = collapseButtonResources.expandText icon = collapseButtonResources.expandIcon } collapseButtonIcon?.setImageDrawable(collapseButtonResources.expandIcon) collapseButtonText?.text = collapseButtonResources.expandText titleTextView.maxLines = minLines titleTextView.ellipsize = null titleTextView.scrollBarSize = 0 } else -> { collapseButton.apply { text = collapseButtonResources.collapseText icon = collapseButtonResources.collapseIcon } collapseButtonIcon?.setImageDrawable(collapseButtonResources.collapseIcon) collapseButtonText?.text = collapseButtonResources.collapseText titleTextView.maxLines = DEFAULT_MAX_LINES titleTextView.ellipsize = TextUtils.TruncateAt.END } Loading packages/SettingsLib/TopIntroPreference/res/layout/settingslib_expressive_top_intro.xml +6 −3 Original line number Diff line number Diff line Loading @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout 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="wrap_content" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" Loading @@ -24,5 +25,7 @@ <com.android.settingslib.widget.CollapsableTextView android:id="@+id/collapsable_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> No newline at end of file android:layout_height="wrap_content" android:minLines="2" app:isCollapsable="false"/> </RelativeLayout> Loading
packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml +2 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ <ImageView android:id="@android:id/icon" android:importantForAccessibility="no" style="@style/SettingsLibEntityHeaderIcon"/> <TextView Loading @@ -41,7 +42,7 @@ android:layout_height="wrap_content" android:gravity="center" android:minLines="1" app:isCollapsable="true"/> app:isCollapsable="false"/> </LinearLayout> Loading
packages/SettingsLib/IntroPreference/src/com/android/settingslib/widget/IntroPreference.kt +6 −7 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ constructor( defStyleRes: Int = 0, ) : Preference(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin { private var isCollapsable: Boolean = true private var isCollapsable: Boolean = DEFAULT_COLLAPSABLE private var minLines: Int = DEFAULT_MIN_LINES private var hyperlinkListener: View.OnClickListener? = null private var learnMoreListener: View.OnClickListener? = null Loading @@ -53,13 +53,11 @@ constructor( setCollapsable(isCollapsable) setMinLines(minLines) visibility = if (summary.isNullOrEmpty()) View.GONE else View.VISIBLE setText(summary.toString()) if (hyperlinkListener != null) { setHyperlinkListener(hyperlinkListener) } if (learnMoreListener != null) { summary?.let { setText(it.toString()) } hyperlinkListener?.let { setHyperlinkListener(it) } learnMoreListener?.let { setLearnMoreText(learnMoreText) setLearnMoreAction(learnMoreListener) setLearnMoreAction(it) } } } Loading Loading @@ -124,5 +122,6 @@ constructor( companion object { private const val DEFAULT_MAX_LINES = 10 private const val DEFAULT_MIN_LINES = 1 private const val DEFAULT_COLLAPSABLE = false } }
packages/SettingsLib/SettingsTheme/res/layout/settingslib_expressive_collapsable_textview.xml +24 −6 Original line number Diff line number Diff line Loading @@ -55,12 +55,30 @@ android:visibility="gone" style="@style/SettingslibTextAppearance.LinkableTextStyle.Expressive"/> <com.google.android.material.button.MaterialButton <LinearLayout android:id="@+id/collapse_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="@dimen/settingslib_expressive_space_extrasmall4" android:paddingBottom="@dimen/settingslib_expressive_space_extrasmall4" app:layout_constraintTop_toBottomOf="@id/settingslib_expressive_learn_more" app:layout_constraintStart_toStartOf="parent" android:textColor="@color/settingslib_materialColorOnSurface" android:text="@string/settingslib_expressive_text_expand" app:icon="@drawable/settingslib_expressive_icon_expand" style="@style/SettingslibTextButtonStyle.Expressive"/> android:gravity="center" android:filterTouchesWhenObscured="false"> <ImageView android:id="@android:id/icon1" android:layout_width="@dimen/settingslib_expressive_space_small4" android:layout_height="@dimen/settingslib_expressive_space_small4" android:importantForAccessibility="no" android:scaleType="centerInside"/> <TextView android:id="@android:id/text1" android:layout_marginStart="@dimen/settingslib_expressive_space_extrasmall4" style="@style/TextAppearance.SettingsLib.BodyLarge.Emphasized" android:layout_width="wrap_content" android:layout_height="@dimen/settingslib_expressive_space_small4"/> </LinearLayout> </androidx.constraintlayout.widget.ConstraintLayout>
packages/SettingsLib/SettingsTheme/src/com/android/settingslib/widget/CollapsableTextView.kt +11 −9 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.util.AttributeSet import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView import androidx.constraintlayout.widget.ConstraintLayout import com.android.settingslib.widget.theme.R Loading @@ -45,7 +47,9 @@ class CollapsableTextView @JvmOverloads constructor( private var minLines: Int = DEFAULT_MIN_LINES private val titleTextView: TextView private val collapseButton: MaterialButton private val collapseButton: LinearLayout private val collapseButtonIcon: ImageView? private val collapseButtonText: TextView? private val collapseButtonResources: CollapseButtonResources private var hyperlinkListener: View.OnClickListener? = null private var learnMoreListener: View.OnClickListener? = null Loading @@ -59,6 +63,8 @@ class CollapsableTextView @JvmOverloads constructor( .inflate(R.layout.settingslib_expressive_collapsable_textview, this) titleTextView = findViewById(android.R.id.title) collapseButton = findViewById(R.id.collapse_button) collapseButtonIcon = collapseButton.findViewById(android.R.id.icon1) collapseButtonText = collapseButton.findViewById(android.R.id.text1) learnMoreTextView = findViewById(R.id.settingslib_expressive_learn_more) collapseButtonResources = CollapseButtonResources( Loading Loading @@ -223,20 +229,16 @@ class CollapsableTextView @JvmOverloads constructor( private fun updateView() { when { isCollapsed -> { collapseButton.apply { text = collapseButtonResources.expandText icon = collapseButtonResources.expandIcon } collapseButtonIcon?.setImageDrawable(collapseButtonResources.expandIcon) collapseButtonText?.text = collapseButtonResources.expandText titleTextView.maxLines = minLines titleTextView.ellipsize = null titleTextView.scrollBarSize = 0 } else -> { collapseButton.apply { text = collapseButtonResources.collapseText icon = collapseButtonResources.collapseIcon } collapseButtonIcon?.setImageDrawable(collapseButtonResources.collapseIcon) collapseButtonText?.text = collapseButtonResources.collapseText titleTextView.maxLines = DEFAULT_MAX_LINES titleTextView.ellipsize = TextUtils.TruncateAt.END } Loading
packages/SettingsLib/TopIntroPreference/res/layout/settingslib_expressive_top_intro.xml +6 −3 Original line number Diff line number Diff line Loading @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout 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="wrap_content" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" Loading @@ -24,5 +25,7 @@ <com.android.settingslib.widget.CollapsableTextView android:id="@+id/collapsable_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> No newline at end of file android:layout_height="wrap_content" android:minLines="2" app:isCollapsable="false"/> </RelativeLayout>