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

Commit f5cc0119 authored by Chun-Ku Lin's avatar Chun-Ku Lin Committed by Daniel Norman
Browse files

workaround(expressive): Fix padding issues Setup > Vision settings

- Works around issue where Setup and Settings libraries are clashing
  when applying their new expressive themes at the same time.
- Updates illustration prefs to match parent width. Otherwise this new
  padding workaround causes the images to get clipped.

Fix: 390545391
Bug: 400479388
Test: manual only; see screenshots
Flag: EXEMPT using custom flagging from Setup ThemeHelper lib
Change-Id: Ie00cdf3e68a2ff7c40aedd04eb5bed0adaa9cf84
parent f257978c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:paddingBottom="?android:attr/listPreferredItemPaddingEnd">
    android:paddingVertical="20dp">

    <CheckBox
        android:id="@android:id/checkbox"
+9 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.view.accessibility.AccessibilityManager;

import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;

import com.android.settings.R;
@@ -110,6 +111,14 @@ public class AccessibilitySettingsForSetupWizard extends DashboardFragment
        }
    }

    @Override
    protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
        if (ThemeHelper.shouldApplyGlifExpressiveStyle(getContext())) {
            return new PreferenceAdapterInSuw(preferenceScreen);
        }
        return super.onCreateAdapter(preferenceScreen);
    }

    @Override
    public RecyclerView onCreateRecyclerView(LayoutInflater inflater, ViewGroup parent,
            Bundle savedInstanceState) {
+48 −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.settings.accessibility;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceViewHolder;

import com.android.settingslib.widget.SettingsPreferenceGroupAdapter;

import com.google.android.setupdesign.util.ItemStyler;

public class PreferenceAdapterInSuw extends SettingsPreferenceGroupAdapter {

    public PreferenceAdapterInSuw(@NonNull PreferenceGroup preferenceGroup) {
        super(preferenceGroup);
    }

    @Override
    public void onBindViewHolder(@NonNull PreferenceViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        View view = holder.itemView;
        int paddingStart = view.getPaddingStart();
        int paddingTop = view.getPaddingTop();
        int paddingEnd = view.getPaddingEnd();
        int paddingBottom = view.getPaddingBottom();
        ItemStyler.applyPartnerCustomizationItemViewLayoutStyle(view);
        view.setPaddingRelative(view.getPaddingStart() + paddingStart,
                paddingTop, view.getPaddingEnd() + paddingEnd,
                paddingBottom);
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.preference.PreferenceScreen;
import androidx.recyclerview.widget.RecyclerView;

import com.android.internal.annotations.VisibleForTesting;
@@ -35,6 +36,7 @@ import com.android.settingslib.Utils;

import com.google.android.setupcompat.template.FooterBarMixin;
import com.google.android.setupdesign.GlifPreferenceLayout;
import com.google.android.setupdesign.util.ThemeHelper;

/**
 * A {@link androidx.preference.PreferenceFragmentCompat} that displays the settings page related
@@ -96,6 +98,14 @@ public class TextReadingPreferenceFragmentForSetupWizard extends TextReadingPref
        return super.onCreateRecyclerView(inflater, parent, savedInstanceState);
    }

    @Override
    protected RecyclerView.Adapter onCreateAdapter(PreferenceScreen preferenceScreen) {
        if (ThemeHelper.shouldApplyGlifExpressiveStyle(getContext())) {
            return new PreferenceAdapterInSuw(preferenceScreen);
        }
        return super.onCreateAdapter(preferenceScreen);
    }

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.SUW_ACCESSIBILITY_TEXT_READING_OPTIONS;
+15 −1
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceViewHolder;
import androidx.recyclerview.widget.RecyclerView;

import com.android.internal.accessibility.common.ShortcutConstants;
@@ -71,6 +72,7 @@ import com.android.settingslib.widget.IllustrationPreference;
import com.android.settingslib.widget.TopIntroPreference;

import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.android.setupdesign.util.ThemeHelper;

import java.util.ArrayList;
import java.util.List;
@@ -426,7 +428,19 @@ public abstract class ToggleFeaturePreferenceFragment extends DashboardFragment
        return drawable;
    }
    private void initAnimatedImagePreference() {
        initAnimatedImagePreference(mImageUri, new IllustrationPreference(getPrefContext()));
        initAnimatedImagePreference(mImageUri, new IllustrationPreference(getPrefContext()) {
            @Override
            public void onBindViewHolder(PreferenceViewHolder holder) {
                super.onBindViewHolder(holder);
                if (ThemeHelper.shouldApplyGlifExpressiveStyle(getContext())
                        && isAnySetupWizard()) {
                    View illustrationFrame = holder.findViewById(R.id.illustration_frame);
                    final ViewGroup.LayoutParams lp = illustrationFrame.getLayoutParams();
                    lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
                    illustrationFrame.setLayoutParams(lp);
                }
            }
        });
    }

    @VisibleForTesting
Loading