Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): improve accessibility text #14036

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading