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

Commit 2a6c1fab authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Change view type for better a11y

Otherwise Talkback would announce it as a button,
even though it doesn't have any action.

Fixes: 148990123
Test: visual
Test: talkback
Test: KeyguardSliceViewTest
Change-Id: Ie95d1541bc01fcc89397269effbaf07c21f65b7b
parent 9832359c
Loading
Loading
Loading
Loading
+8 −9
Original line number Original line Diff line number Diff line
@@ -42,7 +42,6 @@ import android.util.Log;
import android.util.TypedValue;
import android.util.TypedValue;
import android.view.View;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView;


@@ -251,9 +250,9 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
            SliceItem item = rc.getSliceItem();
            SliceItem item = rc.getSliceItem();
            final Uri itemTag = item.getSlice().getUri();
            final Uri itemTag = item.getSlice().getUri();
            // Try to reuse the view if already exists in the layout
            // Try to reuse the view if already exists in the layout
            KeyguardSliceButton button = mRow.findViewWithTag(itemTag);
            KeyguardSliceTextView button = mRow.findViewWithTag(itemTag);
            if (button == null) {
            if (button == null) {
                button = new KeyguardSliceButton(mContext);
                button = new KeyguardSliceTextView(mContext);
                button.setTextColor(blendedColor);
                button.setTextColor(blendedColor);
                button.setTag(itemTag);
                button.setTag(itemTag);
                final int viewIndex = i - (mHasHeader ? 1 : 0);
                final int viewIndex = i - (mHasHeader ? 1 : 0);
@@ -316,8 +315,8 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
        int childCount = mRow.getChildCount();
        int childCount = mRow.getChildCount();
        for (int i = 0; i < childCount; i++) {
        for (int i = 0; i < childCount; i++) {
            View v = mRow.getChildAt(i);
            View v = mRow.getChildAt(i);
            if (v instanceof Button) {
            if (v instanceof TextView) {
                ((Button) v).setTextColor(blendedColor);
                ((TextView) v).setTextColor(blendedColor);
            }
            }
        }
        }
    }
    }
@@ -500,8 +499,8 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
            int childCount = getChildCount();
            int childCount = getChildCount();
            for (int i = 0; i < childCount; i++) {
            for (int i = 0; i < childCount; i++) {
                View child = getChildAt(i);
                View child = getChildAt(i);
                if (child instanceof KeyguardSliceButton) {
                if (child instanceof KeyguardSliceTextView) {
                    ((KeyguardSliceButton) child).setMaxWidth(width / childCount);
                    ((KeyguardSliceTextView) child).setMaxWidth(width / childCount);
                }
                }
            }
            }
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
@@ -527,13 +526,13 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
     * Representation of an item that appears under the clock on main keyguard message.
     * Representation of an item that appears under the clock on main keyguard message.
     */
     */
    @VisibleForTesting
    @VisibleForTesting
    static class KeyguardSliceButton extends Button implements
    static class KeyguardSliceTextView extends TextView implements
            ConfigurationController.ConfigurationListener {
            ConfigurationController.ConfigurationListener {


        @StyleRes
        @StyleRes
        private static int sStyleId = R.style.TextAppearance_Keyguard_Secondary;
        private static int sStyleId = R.style.TextAppearance_Keyguard_Secondary;


        public KeyguardSliceButton(Context context) {
        KeyguardSliceTextView(Context context) {
            super(context, null /* attrs */, 0 /* styleAttr */, sStyleId);
            super(context, null /* attrs */, 0 /* styleAttr */, sStyleId);
            onDensityOrFontScaleChanged();
            onDensityOrFontScaleChanged();
            setEllipsize(TruncateAt.END);
            setEllipsize(TruncateAt.END);