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

Commit 14cb7c78 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Ensure root illustration container is also marked as important for accessibility" into main

parents d6ac99b0 9ac0a8df
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.settingslib.widget;

import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_YES;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
@@ -122,6 +124,8 @@ public class IllustrationPreference extends Preference {
    public void onBindViewHolder(PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);

        final FrameLayout illustrationFrame = (FrameLayout) holder.findViewById(
                R.id.illustration_frame);
        final ImageView backgroundView =
                (ImageView) holder.findViewById(R.id.background_view);
        final FrameLayout middleGroundLayout =
@@ -130,15 +134,15 @@ public class IllustrationPreference extends Preference {
                (LottieAnimationView) holder.findViewById(R.id.lottie_view);
        if (illustrationView != null && !TextUtils.isEmpty(mContentDescription)) {
            illustrationView.setContentDescription(mContentDescription);
            illustrationView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
            illustrationView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
            final View illustrationContainer = (View) illustrationFrame.getParent();
            illustrationContainer.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
        }
        // To solve the problem of non-compliant illustrations, we set the frame height
        // to 300dp and set the length of the short side of the screen to
        // the width of the frame.
        final int screenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
        final int screenHeight = getContext().getResources().getDisplayMetrics().heightPixels;
        final FrameLayout illustrationFrame = (FrameLayout) holder.findViewById(
                R.id.illustration_frame);
        final LayoutParams lp = (LayoutParams) illustrationFrame.getLayoutParams();
        lp.width = screenWidth < screenHeight ? screenWidth : screenHeight;
        illustrationFrame.setLayoutParams(lp);