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

Commit 9ac0a8df authored by Winson Chung's avatar Winson Chung
Browse files

Ensure root illustration container is also marked as important for accessibility

- The root of illustration_preference layout is not marked as important
  for accessibilty and as a result the descendants can't be focused for
  switch/voice access

Fixes: 319749921
Flag: EXEMPT bugfix
Test: Navigate the gesture settings page with talkback/switch/voice access
      and ensure the lottie image is focusable
Change-Id: I7f9fd53ce1b245b7b07f4e081b9ac708e6be4fe3
parent 5627a898
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);