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

Commit 7b3a7c04 authored by Fabián Kozynski's avatar Fabián Kozynski
Browse files

Remove clickable from tiles that cannot be clicked

There's an open issue in a11y, where removing the action is not enough
to make a node not clickable. Make sure that we mark it as not clickable
when needed.

Test: atest TileAdapterDelegateTest
Fixes: 319784882
Flag: NONE

Change-Id: I4d7d7ee1ea9c3a66b9175ee241db8b8561876c0d
parent 68eda146
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -119,6 +119,8 @@ class TileAdapterDelegate extends AccessibilityDelegateCompat {
                    info.removeAction(listOfActions.get(i));
                }
            }
            // We really don't want it to be clickable in this case.
            info.setClickable(false);
            return;
        }

@@ -126,6 +128,7 @@ class TileAdapterDelegate extends AccessibilityDelegateCompat {
                new AccessibilityNodeInfoCompat.AccessibilityActionCompat(
                        AccessibilityNodeInfo.ACTION_CLICK, clickActionString);
        info.addAction(action);
        info.setClickable(true);
    }

    private void maybeAddActionMoveToPosition(
+5 −2
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ import android.view.accessibility.AccessibilityNodeInfo;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.test.filters.SmallTest;

import com.android.systemui.res.R;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.res.R;

import org.junit.Before;
import org.junit.Test;
@@ -136,6 +136,7 @@ public class TileAdapterDelegateTest extends SysuiTestCase {
        AccessibilityNodeInfoCompat.AccessibilityActionCompat action =
                getActionForId(mInfo, AccessibilityNodeInfo.ACTION_CLICK);
        assertThat(action.getLabel().toString()).contains(expectedString);
        assertThat(mInfo.isClickable()).isTrue();
    }

    @Test
@@ -152,10 +153,11 @@ public class TileAdapterDelegateTest extends SysuiTestCase {
        AccessibilityNodeInfoCompat.AccessibilityActionCompat action =
                getActionForId(mInfo, AccessibilityNodeInfo.ACTION_CLICK);
        assertThat(action.getLabel().toString()).contains(expectedString);
        assertThat(mInfo.isClickable()).isTrue();
    }

    @Test
    public void testNoClickAction() {
    public void testNoClickActionAndNotClickable() {
        mView.setTag(mHolder);
        when(mHolder.canTakeAccessibleAction()).thenReturn(true);
        when(mHolder.canAdd()).thenReturn(false);
@@ -167,6 +169,7 @@ public class TileAdapterDelegateTest extends SysuiTestCase {
        AccessibilityNodeInfoCompat.AccessibilityActionCompat action =
                getActionForId(mInfo, AccessibilityNodeInfo.ACTION_CLICK);
        assertThat(action).isNull();
        assertThat(mInfo.isClickable()).isFalse();
    }

    @Test