Skip to content

Commit

Permalink
feat(android): improve accessibility text (#14036)
Browse files Browse the repository at this point in the history
* feat(android): improve accessibility text

* missing file

---------

Co-authored-by: Chris Barber <[email protected]>
  • Loading branch information
m1ga and cb1kenobi authored May 24, 2024
1 parent e1f2dc1 commit 3171e14
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ public class TiC
public static final String PROPERTY_ACCESSIBILITY_HINT = "accessibilityHint";
public static final String PROPERTY_ACCESSIBILITY_LABEL = "accessibilityLabel";
public static final String PROPERTY_ACCESSIBILITY_VALUE = "accessibilityValue";
public static final String PROPERTY_ACCESSIBILITY_DISABLE_LONG = "accessibilityDisableLongPress";
public static final String PROPERTY_ACCESSORY_TYPE = "accessoryType";
public static final String PROPERTY_ACTION = "action";
public static final String PROPERTY_ACTION_VIEW = "actionView";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
TiC.PROPERTY_TOUCH_FEEDBACK_COLOR,
TiC.PROPERTY_TRANSITION_NAME,
TiC.PROPERTY_HIDDEN_BEHAVIOR,
TiC.PROPERTY_ANCHOR_POINT
TiC.PROPERTY_ANCHOR_POINT,
TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG
})
public abstract class TiViewProxy extends KrollProxy
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
import android.graphics.drawable.ShapeDrawable;
import android.os.Build;
import androidx.annotation.NonNull;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;

import android.text.TextUtils;
import android.util.Pair;
import android.util.SparseArray;
Expand Down Expand Up @@ -1915,6 +1918,12 @@ protected void registerForTouch(final View touchable)
boolean soundEnabled = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_SOUND_EFFECTS_ENABLED), true);
touchable.setSoundEffectsEnabled(soundEnabled);
}

if (proxy.hasPropertyAndNotNull(TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG)) {
if (TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG))) {
removeAccessibilityLongClick();
}
}
registerTouchEvents(touchable);

// Previously, we used the single tap handling above to fire our click event. It doesn't
Expand Down Expand Up @@ -2363,4 +2372,19 @@ public String composeContentDescription()
}
return composeContentDescription(proxy.getProperties());
}

public void removeAccessibilityLongClick()
{
ViewCompat.setAccessibilityDelegate(nativeView, new AccessibilityDelegateCompat()
{
@Override
public void onInitializeAccessibilityNodeInfo(@NonNull View host,
@NonNull AccessibilityNodeInfoCompat info)
{
super.onInitializeAccessibilityNodeInfo(host, info);
info.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_LONG_CLICK);
info.setLongClickable(false);
}
});
}
}
10 changes: 10 additions & 0 deletions apidoc/Titanium/UI/View.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,16 @@ properties:
platforms: [android, iphone, ipad, macos]
type: String

- name: accessibilityDisableLongPress
summary: Boolean value to remove the long press notification for the device's accessibility service.
description: |
Will disable the "double tap and hold for long press" message when selecting an item.
since: "12.4.0"
platforms: [android]
default: true
availability: creation
type: Boolean

- name: anchorPoint
summary: Coordinate of the view about which to pivot an animation.
description: |
Expand Down

0 comments on commit 3171e14

Please sign in to comment.