Skip to content

Commit 3171e14

Browse files
m1gacb1kenobi
andauthored
feat(android): improve accessibility text (#14036)
* feat(android): improve accessibility text * missing file --------- Co-authored-by: Chris Barber <[email protected]>
1 parent e1f2dc1 commit 3171e14

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

android/titanium/src/java/org/appcelerator/titanium/TiC.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ public class TiC
228228
public static final String PROPERTY_ACCESSIBILITY_HINT = "accessibilityHint";
229229
public static final String PROPERTY_ACCESSIBILITY_LABEL = "accessibilityLabel";
230230
public static final String PROPERTY_ACCESSIBILITY_VALUE = "accessibilityValue";
231+
public static final String PROPERTY_ACCESSIBILITY_DISABLE_LONG = "accessibilityDisableLongPress";
231232
public static final String PROPERTY_ACCESSORY_TYPE = "accessoryType";
232233
public static final String PROPERTY_ACTION = "action";
233234
public static final String PROPERTY_ACTION_VIEW = "actionView";

android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
TiC.PROPERTY_TOUCH_FEEDBACK_COLOR,
9595
TiC.PROPERTY_TRANSITION_NAME,
9696
TiC.PROPERTY_HIDDEN_BEHAVIOR,
97-
TiC.PROPERTY_ANCHOR_POINT
97+
TiC.PROPERTY_ANCHOR_POINT,
98+
TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG
9899
})
99100
public abstract class TiViewProxy extends KrollProxy
100101
{

android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
import android.graphics.drawable.ShapeDrawable;
4646
import android.os.Build;
4747
import androidx.annotation.NonNull;
48+
import androidx.core.view.AccessibilityDelegateCompat;
4849
import androidx.core.view.ViewCompat;
50+
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
51+
4952
import android.text.TextUtils;
5053
import android.util.Pair;
5154
import android.util.SparseArray;
@@ -1915,6 +1918,12 @@ protected void registerForTouch(final View touchable)
19151918
boolean soundEnabled = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_SOUND_EFFECTS_ENABLED), true);
19161919
touchable.setSoundEffectsEnabled(soundEnabled);
19171920
}
1921+
1922+
if (proxy.hasPropertyAndNotNull(TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG)) {
1923+
if (TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ACCESSIBILITY_DISABLE_LONG))) {
1924+
removeAccessibilityLongClick();
1925+
}
1926+
}
19181927
registerTouchEvents(touchable);
19191928

19201929
// Previously, we used the single tap handling above to fire our click event. It doesn't
@@ -2363,4 +2372,19 @@ public String composeContentDescription()
23632372
}
23642373
return composeContentDescription(proxy.getProperties());
23652374
}
2375+
2376+
public void removeAccessibilityLongClick()
2377+
{
2378+
ViewCompat.setAccessibilityDelegate(nativeView, new AccessibilityDelegateCompat()
2379+
{
2380+
@Override
2381+
public void onInitializeAccessibilityNodeInfo(@NonNull View host,
2382+
@NonNull AccessibilityNodeInfoCompat info)
2383+
{
2384+
super.onInitializeAccessibilityNodeInfo(host, info);
2385+
info.removeAction(AccessibilityNodeInfoCompat.AccessibilityActionCompat.ACTION_LONG_CLICK);
2386+
info.setLongClickable(false);
2387+
}
2388+
});
2389+
}
23662390
}

apidoc/Titanium/UI/View.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,6 +1159,16 @@ properties:
11591159
platforms: [android, iphone, ipad, macos]
11601160
type: String
11611161

1162+
- name: accessibilityDisableLongPress
1163+
summary: Boolean value to remove the long press notification for the device's accessibility service.
1164+
description: |
1165+
Will disable the "double tap and hold for long press" message when selecting an item.
1166+
since: "12.4.0"
1167+
platforms: [android]
1168+
default: true
1169+
availability: creation
1170+
type: Boolean
1171+
11621172
- name: anchorPoint
11631173
summary: Coordinate of the view about which to pivot an animation.
11641174
description: |

0 commit comments

Comments
 (0)