-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(a11y): Physical Keyboard Navigation #7010
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
Open
OtavioStasiak
wants to merge
51
commits into
develop
Choose a base branch
from
fix.android-inverted-keyboard-navigation
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+27,041
−20,809
Open
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
59e4a04
fix: inverted navigation
OtavioStasiak 4eb8bf2
fix: just invert list content
OtavioStasiak 9b639da
fix: lint
OtavioStasiak cf4cb85
test: inverted just in the inverted
OtavioStasiak 3f38334
fix: code
OtavioStasiak a33f49d
fix: invert just the flatlist content
OtavioStasiak 4e86354
fix: switch tab
OtavioStasiak e3dccec
Merge branch 'develop' into fix.android-inverted-keyboard-navigation
OtavioStasiak 32d0b75
try to reverse just the flatlist content
OtavioStasiak 48609f2
Merge branch 'develop' into fix.android-inverted-keyboard-navigation
OtavioStasiak 037d5c6
fix: inverted list direction
OtavioStasiak 8886ec3
chore: format code and fix lint issues
OtavioStasiak c1bbde2
fix: list issues
OtavioStasiak 4db3a04
rollback List
OtavioStasiak 846b8ba
revert unused changes on module
OtavioStasiak 2341565
try native module approach
OtavioStasiak 98ea3b5
test: invert navigation
OtavioStasiak 083f4d7
chore: format code and fix lint issues
OtavioStasiak bde3b23
space
OtavioStasiak bb3556d
fix: build
OtavioStasiak cdd5ef8
fix: keyboard navigation still working on different rooms
OtavioStasiak b07d06b
fix: last item focus
OtavioStasiak 425187b
chore: format code and fix lint issues
OtavioStasiak 4731276
fix: change focus
OtavioStasiak 311cddc
Merge branch 'develop' into fix.android-inverted-keyboard-navigation
OtavioStasiak 0c311b2
fix: lint
OtavioStasiak b591ecf
fix: merge issues
OtavioStasiak ec27cc9
Merge branch 'develop' into fix.android-inverted-keyboard-navigation
OtavioStasiak 8064b66
fix: lint
OtavioStasiak f4b730e
chore: format code and fix lint issues
OtavioStasiak 4b51b7c
rollback focus change
OtavioStasiak b87b186
focus inside of roomView!
OtavioStasiak f4c87c2
Merge branch 'develop' into fix.android-inverted-keyboard-navigation
OtavioStasiak e546f31
rollback: useScrollContainer
OtavioStasiak 4d25dd3
test: use a RNLike scrolview
OtavioStasiak 2ecf157
Merge branch 'develop' into fix.android-inverted-keyboard-navigation
OtavioStasiak a2abc14
fix: Pressable issues
OtavioStasiak 0b051b1
fix: tests
OtavioStasiak 3fee8cf
use rectButton
OtavioStasiak e728b66
update snapshot
OtavioStasiak 4098eed
fix: unit tests
OtavioStasiak 5fae357
fix: use Pressable to able to focus on iOS and keep it working on tru…
OtavioStasiak 0907cc1
chore: install react-native-external-keyboard
OtavioStasiak e45b714
fix: focus on thread and reactions
OtavioStasiak 9cf9ad0
feat: onThreadPress to open threads on keyboard
OtavioStasiak 506ee19
feat: usePressable gh
OtavioStasiak 7f3c952
fix: gesture handler iOS focusable on keyboard
OtavioStasiak ac854d3
fix: patch package cleanup
OtavioStasiak ef439b8
fix: improve switch navigation
OtavioStasiak 6f21bba
fix: tests
OtavioStasiak bfb8ed9
fix: test
OtavioStasiak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
android/app/src/main/java/chat/rocket/reactnative/a11y/KeyboardA11yModule.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package chat.rocket.reactnative.a11y; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
|
|
||
| import com.facebook.react.bridge.Promise; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.bridge.WritableMap; | ||
| import com.facebook.react.module.annotations.ReactModule; | ||
|
|
||
| @ReactModule(name = KeyboardA11ySpec.NAME) | ||
| public class KeyboardA11yModule extends KeyboardA11ySpec { | ||
|
|
||
| private static volatile boolean sEnabled = false; | ||
| @Nullable | ||
| private static volatile String sScope = null; | ||
|
|
||
| public KeyboardA11yModule(ReactApplicationContext reactContext) { | ||
| super(reactContext); | ||
| } | ||
|
|
||
| public static boolean isEnabled() { | ||
| return sEnabled; | ||
| } | ||
|
|
||
| @Nullable | ||
| public static String getScope() { | ||
| return sScope; | ||
| } | ||
|
|
||
| @Override | ||
| public void enable(String scope) { | ||
| sEnabled = true; | ||
| sScope = scope; | ||
| } | ||
|
|
||
| @Override | ||
| public void disable() { | ||
| sEnabled = false; | ||
| sScope = null; | ||
| } | ||
OtavioStasiak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @Override | ||
| public void getState(Promise promise) { | ||
| WritableMap state = com.facebook.react.bridge.Arguments.createMap(); | ||
| state.putBoolean("enabled", sEnabled); | ||
| state.putString("scope", sScope); | ||
| promise.resolve(state); | ||
| } | ||
| } | ||
|
|
||
31 changes: 31 additions & 0 deletions
31
android/app/src/main/java/chat/rocket/reactnative/a11y/KeyboardA11ySpec.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package chat.rocket.reactnative.a11y; | ||
|
|
||
| import com.facebook.react.bridge.Promise; | ||
| import com.facebook.react.bridge.ReactApplicationContext; | ||
| import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
| import com.facebook.react.bridge.ReactMethod; | ||
| import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
|
|
||
| public abstract class KeyboardA11ySpec extends ReactContextBaseJavaModule implements TurboModule { | ||
|
|
||
| public static final String NAME = "KeyboardA11y"; | ||
|
|
||
| public KeyboardA11ySpec(ReactApplicationContext reactContext) { | ||
| super(reactContext); | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return NAME; | ||
| } | ||
|
|
||
| @ReactMethod | ||
| public abstract void enable(String scope); | ||
|
|
||
| @ReactMethod | ||
| public abstract void disable(); | ||
|
|
||
| @ReactMethod | ||
| public abstract void getState(Promise promise); | ||
| } | ||
|
|
30 changes: 30 additions & 0 deletions
30
android/app/src/main/java/chat/rocket/reactnative/scroll/FocusUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package chat.rocket.reactnative.scroll; | ||
|
|
||
| import android.view.View; | ||
| import android.view.ViewParent; | ||
| import chat.rocket.reactnative.R; | ||
|
|
||
| /** | ||
| * Utilities for focus-related queries inside custom scroll views. | ||
| */ | ||
| public final class FocusUtils { | ||
|
|
||
| private FocusUtils() {} | ||
|
|
||
| public static boolean hasInvertedParent(View view) { | ||
| if (view == null) { | ||
| return false; | ||
| } | ||
| ViewParent parent = view.getParent(); | ||
| while (parent instanceof View) { | ||
| View parentView = (View) parent; | ||
| Object tag = parentView.getTag(R.id.tag_inverted_list); | ||
| if (tag instanceof Boolean && (Boolean) tag) { | ||
| return true; | ||
| } | ||
| parent = parentView.getParent(); | ||
| } | ||
| return false; | ||
| } | ||
| } | ||
|
|
58 changes: 57 additions & 1 deletion
58
android/app/src/main/java/chat/rocket/reactnative/scroll/InvertedScrollContentView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,79 @@ | ||
| package chat.rocket.reactnative.scroll; | ||
|
|
||
| import android.graphics.Rect; | ||
| import android.view.View; | ||
| import com.facebook.react.views.view.ReactViewGroup; | ||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import chat.rocket.reactnative.R; | ||
|
|
||
| /** | ||
| * Content view for inverted FlatLists. Reports its children to accessibility in reversed order so | ||
| * TalkBack traversal matches the visual order (newest-first) when used inside InvertedScrollView. | ||
| */ | ||
| public class InvertedScrollContentView extends ReactViewGroup { | ||
|
|
||
| private boolean mIsInvertedContent = false; | ||
|
|
||
| public InvertedScrollContentView(android.content.Context context) { | ||
| super(context); | ||
| } | ||
|
|
||
| public void setIsInvertedContent(boolean isInverted) { | ||
| mIsInvertedContent = isInverted; | ||
| if (isInverted) { | ||
| setTag(R.id.tag_inverted_list, true); | ||
| } else { | ||
| setTag(R.id.tag_inverted_list, null); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void addChildrenForAccessibility(ArrayList<View> outChildren) { | ||
| super.addChildrenForAccessibility(outChildren); | ||
| Collections.reverse(outChildren); | ||
| if (mIsInvertedContent) { | ||
| Collections.reverse(outChildren); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { | ||
| if (mIsInvertedContent) { | ||
| for (int i = getChildCount() - 1; i >= 0; i--) { | ||
| View child = getChildAt(i); | ||
| if (child.getVisibility() == VISIBLE) { | ||
| if (child.requestFocus(direction, previouslyFocusedRect)) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| return super.onRequestFocusInDescendants(direction, previouslyFocusedRect); | ||
OtavioStasiak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| public void addFocusables(ArrayList<View> views, int direction, int focusableMode) { | ||
| super.addFocusables(views, direction, focusableMode); | ||
| if (mIsInvertedContent) { | ||
| // Find indices of focusables that are children of this view | ||
| ArrayList<Integer> childIndices = new ArrayList<>(); | ||
| for (int i = 0; i < views.size(); i++) { | ||
| View v = views.get(i); | ||
| if (v.getParent() == this) { | ||
| childIndices.add(i); | ||
| } | ||
| } | ||
| // Reverse only the sublist of children focusables | ||
| int n = childIndices.size(); | ||
| for (int i = 0; i < n / 2; i++) { | ||
| int idx1 = childIndices.get(i); | ||
| int idx2 = childIndices.get(n - 1 - i); | ||
| View temp = views.get(idx1); | ||
| views.set(idx1, views.get(idx2)); | ||
| views.set(idx2, temp); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.