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

Commit b44d154e authored by David Liu's avatar David Liu Committed by Android (Google) Code Review
Browse files

Merge "[Fix Forward} Revert^2 "Use an interface OnScreenWidgetMixin to add...

Merge "[Fix Forward} Revert^2 "Use an interface OnScreenWidgetMixin to add extra padding to FootPreference, IntroPreference, and TopIntroPreference"" into main
parents bd75f06d ce5dcc46
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -43,7 +43,8 @@ import java.net.URISyntaxException;
 * A custom preference acting as "footer" of a page. It has a field for icon and text. It is added
 * A custom preference acting as "footer" of a page. It has a field for icon and text. It is added
 * to screen as the last preference.
 * to screen as the last preference.
 */
 */
public class FooterPreference extends Preference implements GroupSectionDividerMixin {
public class FooterPreference extends Preference
        implements GroupSectionDividerMixin, OnScreenWidgetMixin {
    private static final String TAG = "FooterPreference";
    private static final String TAG = "FooterPreference";


    public static final String KEY_FOOTER = "footer_preference";
    public static final String KEY_FOOTER = "footer_preference";
+3 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,9 @@ constructor(
    attrs: AttributeSet? = null,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0,
    defStyleRes: Int = 0,
) : Preference(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin {
) : Preference(context, attrs, defStyleAttr, defStyleRes),
    GroupSectionDividerMixin,
    OnScreenWidgetMixin {


    private var isCollapsable: Boolean = DEFAULT_COLLAPSABLE
    private var isCollapsable: Boolean = DEFAULT_COLLAPSABLE
    private var minLines: Int = DEFAULT_MIN_LINES
    private var minLines: Int = DEFAULT_MIN_LINES
+25 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settingslib.widget

/**
 * A base interface to indicate that a widget is placed onto the screen.
 *
 * Widget implements this interface will be treated as on-screen widget and applied proper padding.
 */
interface OnScreenWidgetMixin
+7 −1
Original line number Original line Diff line number Diff line
@@ -199,6 +199,12 @@ open class SettingsPreferenceGroupAdapter(preferenceGroup: PreferenceGroup) :
        return when {
        return when {
            // This item handles edge to edge itself
            // This item handles edge to edge itself
            item is NormalPaddingMixin && item is GroupSectionDividerMixin -> 0 to 0
            item is NormalPaddingMixin && item is GroupSectionDividerMixin -> 0 to 0
            // Item is placed directly on screen needs to have extra padding
            item is OnScreenWidgetMixin -> {
                val extraPadding = item.context.resources.getDimensionPixelSize(
                    R.dimen.settingslib_expressive_space_extrasmall4)
                mNormalPaddingStart + extraPadding to mNormalPaddingEnd + extraPadding
            }


            // According to mappingPreferenceGroup(), backgroundRes == 0 means this item is
            // According to mappingPreferenceGroup(), backgroundRes == 0 means this item is
            // GroupSectionDividerMixin or PreferenceCategory, which is design to have normal
            // GroupSectionDividerMixin or PreferenceCategory, which is design to have normal
+3 −1
Original line number Original line Diff line number Diff line
@@ -31,7 +31,9 @@ constructor(
    attrs: AttributeSet? = null,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0,
    defStyleAttr: Int = 0,
    defStyleRes: Int = 0,
    defStyleRes: Int = 0,
) : Preference(context, attrs, defStyleAttr, defStyleRes), GroupSectionDividerMixin {
) : Preference(context, attrs, defStyleAttr, defStyleRes),
    GroupSectionDividerMixin,
    OnScreenWidgetMixin {


    private var isCollapsable: Boolean = false
    private var isCollapsable: Boolean = false
    private var minLines: Int = 2
    private var minLines: Int = 2