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

Commit ce5dcc46 authored by David Liu's avatar David Liu
Browse files

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

[Fix Forward} Revert^2 "Use an interface OnScreenWidgetMixin to add extra padding to FootPreference, IntroPreference, and TopIntroPreference"

This reverts commit 3d89203f.

Reason for revert: Fix forward with golden screens update

Bug: 409555871
Test: Manually Test the widget paddings are correct
Flag: com.android.settingslib.widget.theme.flags.is_expressive_design_enabled

Change-Id: Ic251709428d208ff47c0525758f5117975fa29dd
parent 746e5a94
Loading
Loading
Loading
Loading
+2 −1
Original line number 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
 * 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";

    public static final String KEY_FOOTER = "footer_preference";
+3 −1
Original line number Diff line number Diff line
@@ -31,7 +31,9 @@ constructor(
    attrs: AttributeSet? = null,
    defStyleAttr: 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 minLines: Int = DEFAULT_MIN_LINES
+25 −0
Original line number 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 Diff line number Diff line
@@ -199,6 +199,12 @@ open class SettingsPreferenceGroupAdapter(preferenceGroup: PreferenceGroup) :
        return when {
            // This item handles edge to edge itself
            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
            // GroupSectionDividerMixin or PreferenceCategory, which is design to have normal
+3 −1
Original line number Diff line number Diff line
@@ -31,7 +31,9 @@ constructor(
    attrs: AttributeSet? = null,
    defStyleAttr: 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 minLines: Int = 2