From 8a388763e12c8803f33aeb4d0c61389e4550386f Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Wed, 15 May 2024 14:34:58 +0200 Subject: [PATCH 1/2] feat(android): improve accessibility text --- .../titanium/proxy/TiViewProxy.java | 3 ++- .../appcelerator/titanium/view/TiUIView.java | 24 +++++++++++++++++++ apidoc/Titanium/UI/View.yml | 10 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java index d99dee6cac8..77a86fafa7f 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java +++ b/android/titanium/src/java/org/appcelerator/titanium/proxy/TiViewProxy.java @@ -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 { diff --git a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java index 520b611193b..73630f0c02a 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java +++ b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java @@ -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; @@ -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 @@ -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); + } + }); + } } diff --git a/apidoc/Titanium/UI/View.yml b/apidoc/Titanium/UI/View.yml index 522308f2c80..2233fe4011e 100644 --- a/apidoc/Titanium/UI/View.yml +++ b/apidoc/Titanium/UI/View.yml @@ -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: | From 9d76ac6a9c9588cda8e110d56c9157b78890b556 Mon Sep 17 00:00:00 2001 From: Michael Gangolf Date: Wed, 15 May 2024 20:39:23 +0200 Subject: [PATCH 2/2] missing file --- android/titanium/src/java/org/appcelerator/titanium/TiC.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/titanium/src/java/org/appcelerator/titanium/TiC.java b/android/titanium/src/java/org/appcelerator/titanium/TiC.java index a09ba8969b5..58beebdde16 100644 --- a/android/titanium/src/java/org/appcelerator/titanium/TiC.java +++ b/android/titanium/src/java/org/appcelerator/titanium/TiC.java @@ -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";