From c0fbafd19dd2595f8da50d3db8c1e543bb7cea3e Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 11 Nov 2022 10:59:56 +0100 Subject: [PATCH 01/14] trigger accessibilityUnit from MapBuffer.kt --- .../com/facebook/react/views/view/ReactMapBufferPropSetter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt index 0f5dd3fcb03b5d..669f546f1cefb3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt @@ -133,7 +133,7 @@ object ReactMapBufferPropSetter { viewManager.accessibilityState(view, entry.mapBufferValue) } VP_ACCESSIBILITY_UNIT -> { - // viewManager.accessibilityUnit(view, entry.mapBufferValue) + viewManager.accessibilityUnit(view, entry.mapBufferValue) } VP_ACCESSIBILITY_VALUE -> { viewManager.accessibilityValue(view, entry.stringValue) From ec4bc8eb5905f81cebbb4b623acda8245ee5683c Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 11 Nov 2022 16:20:49 +0100 Subject: [PATCH 02/14] Fix std::length_error: vector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SOLUTION: Clearing the cache fixed the issue ([comment](https://github.com/pyg-team/pytorch_geometric/issues/4419#issuecomment-1159528303)). The user was experiencing similar issue on arm64. It reports errors that result from attempts to exceed implementation defined length limits for some object ([link](https://en.cppreference.com/w/cpp/error/length_error)). "Adding a string prop to TextAttributes.cpp: Read error message with Android Studio ([screenshot](https://www.icloud.com/iclouddrive/053tE1XWF0rgVUMxmLhUJTJUA#terminating_std_length_error_vector)) Search online for the error message and understand the configuration mistake in the cpp type ([link](https://www.google.com/search?q=terminating+with+uncaught+exception+of+type+std::length_error:+vector))
terminating with uncaught exception of type std::length_error: vector Verify all changes from [#2](https://github.com/fabriziobertoglio1987/react-native/pull/2/files) are added in [#3](https://github.com/fabriziobertoglio1987/react-native/pull/3/files)
Verify there are no mistakes in the types Read about APIs that you added to cpp Read complete logcat errors Does it build only with the Java Changes?
Commit the java changes and stash cpp
The error std::length_error: vector indicates wrong cpp type --- Libraries/Components/View/ViewPropTypes.js | 2 +- .../com/facebook/react/uimanager/BaseViewManager.java | 2 +- .../react/uimanager/BaseViewManagerAdapter.java | 2 +- .../react/uimanager/BaseViewManagerInterface.java | 2 +- .../react/views/text/ReactTextAnchorViewManager.java | 7 ++----- .../react/views/view/ReactMapBufferPropSetter.kt | 7 ++++--- .../renderer/attributedstring/TextAttributes.cpp | 5 +++++ .../react/renderer/attributedstring/TextAttributes.h | 4 +++- .../renderer/components/view/AccessibilityProps.h | 2 +- .../components/view/AccessibilityPropsMapBuffer.cpp | 4 ++-- .../components/view/accessibilityPropsConversions.h | 11 ----------- .../js/examples/Accessibility/AccessibilityExample.js | 2 +- 12 files changed, 22 insertions(+), 28 deletions(-) diff --git a/Libraries/Components/View/ViewPropTypes.js b/Libraries/Components/View/ViewPropTypes.js index a27db9facc45dd..bec5e2aa998adb 100644 --- a/Libraries/Components/View/ViewPropTypes.js +++ b/Libraries/Components/View/ViewPropTypes.js @@ -502,7 +502,7 @@ export type ViewProps = $ReadOnly<{| * Indicates to accessibility services that UI Component is in a specific State. */ accessibilityState?: ?AccessibilityState, - accessibilityUnit?: ?AccessibilityUnit, + accessibilityUnit?: ?Stringish, accessibilityValue?: ?AccessibilityValue, /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index 5d25a0bfe3e4f2..96ed24d05e7c1d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -320,7 +320,7 @@ public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilitySta @Override @ReactProp(name = ViewProps.ACCESSIBILITY_UNIT) - public void setAccessibilityUnit(@NonNull T view, @Nullable ReadableMap accessibilityUnit) { + public void setAccessibilityUnit(@NonNull T view, @Nullable String accessibilityUnit) { // do nothing } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java index d163a5209e5622..dded0fcd37ed6a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java @@ -43,7 +43,7 @@ public void setAccessibilityCollectionItem( public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilityState) {} @Override - public void setAccessibilityUnit(@NonNull T view, @Nullable ReadableMap accessibilityUnit) {} + public void setAccessibilityUnit(@NonNull T view, @Nullable String accessibilityUnit) {} @Override public void setBackgroundColor(@NonNull T view, int backgroundColor) {} diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java index 435b4c3b499f72..02e2e153bc15d1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java @@ -34,7 +34,7 @@ public interface BaseViewManagerInterface { void setViewState(T view, @Nullable ReadableMap accessibilityState); - void setAccessibilityUnit(T view, @Nullable ReadableMap accessibilityUnit); + void setAccessibilityUnit(T view, @Nullable String accessibilityUnit); void setBackgroundColor(T view, int backgroundColor); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java index 7e4c66e3a87468..ff0591f2b3f0d0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java @@ -12,14 +12,12 @@ import android.text.Spannable; import android.text.TextUtils; import android.text.util.Linkify; -import android.util.Log; import android.view.Gravity; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.facebook.common.logging.FLog; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; -import com.facebook.react.bridge.ReadableMap; import com.facebook.react.uimanager.BaseViewManager; import com.facebook.react.uimanager.PixelUtil; import com.facebook.react.uimanager.Spacing; @@ -53,9 +51,8 @@ public void setAccessible(ReactTextView view, boolean accessible) { @Override @ReactProp(name = ViewProps.ACCESSIBILITY_UNIT) - public void setAccessibilityUnit(@NonNull T view, @Nullable ReadableMap accessibilityUnit) { - Log.w("TESTING::ReactTextAnchorViewManager", "setAccessibilityUnit"); - Log.w("TESTING::ReactTextAnchorViewManager", "accessibilityUnit: " + (accessibilityUnit)); + public void setAccessibilityUnit(@NonNull T view, @Nullable String accessibilityUnit) { + // do nothing } // maxLines can only be set in master view (block), doesn't really make sense to set in a span diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt index 669f546f1cefb3..b75d0692785302 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt @@ -133,7 +133,7 @@ object ReactMapBufferPropSetter { viewManager.accessibilityState(view, entry.mapBufferValue) } VP_ACCESSIBILITY_UNIT -> { - viewManager.accessibilityUnit(view, entry.mapBufferValue) + viewManager.accessibilityUnit(view, entry.stringValue) } VP_ACCESSIBILITY_VALUE -> { viewManager.accessibilityValue(view, entry.stringValue) @@ -283,12 +283,13 @@ object ReactMapBufferPropSetter { ViewCompat.setAccessibilityLiveRegion(this, mode) } - private fun ReactViewManager.accessibilityUnit(view: ReactViewGroup, value: MapBuffer) { + private fun ReactViewManager.accessibilityUnit(view: ReactViewGroup, value: String) { Log.w("TESTING::ReactMapBufferPropSetter", "accessibilityUnit"); + /* val accessibilityUnit = JavaOnlyMap() accessibilityUnit.putString("hours", "10") - setAccessibilityUnit(view, accessibilityUnit) + */ } private fun ReactViewManager.accessibilityState(view: ReactViewGroup, value: MapBuffer) { diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp index 24f5bbd07b8072..741dcc85d4647f 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp @@ -98,6 +98,8 @@ void TextAttributes::apply(TextAttributes textAttributes) { accessibilityRole = textAttributes.accessibilityRole.has_value() ? textAttributes.accessibilityRole : accessibilityRole; + accessibilityUnit = !textAttributes.accessibilityUnit.empty() ? textAttributes.accessibilityUnit + : accessibilityUnit; } #pragma mark - Operators @@ -122,6 +124,7 @@ bool TextAttributes::operator==(const TextAttributes &rhs) const { isHighlighted, layoutDirection, accessibilityRole, + accessibilityUnit, textTransform) == std::tie( rhs.foregroundColor, @@ -142,6 +145,7 @@ bool TextAttributes::operator==(const TextAttributes &rhs) const { rhs.isHighlighted, rhs.layoutDirection, rhs.accessibilityRole, + rhs.accessibilityUnit, rhs.textTransform) && floatEquality(opacity, rhs.opacity) && floatEquality(fontSize, rhs.fontSize) && @@ -209,6 +213,7 @@ SharedDebugStringConvertibleList TextAttributes::getDebugProps() const { debugStringConvertibleItem("isHighlighted", isHighlighted), debugStringConvertibleItem("layoutDirection", layoutDirection), debugStringConvertibleItem("accessibilityRole", accessibilityRole), + debugStringConvertibleItem("accessibilityUnit", accessibilityUnit), }; } #endif diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index 69400f2ed172f7..ca26925f76c326 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -79,6 +79,7 @@ class TextAttributes : public DebugStringConvertible { // construction. std::optional layoutDirection{}; std::optional accessibilityRole{}; + std::string accessibilityUnit{""}; #pragma mark - Operations @@ -131,7 +132,8 @@ struct hash { textAttributes.textShadowColor, textAttributes.isHighlighted, textAttributes.layoutDirection, - textAttributes.accessibilityRole); + textAttributes.accessibilityRole, + textAttributes.accessibilityUnit); } }; } // namespace std diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.h b/ReactCommon/react/renderer/components/view/AccessibilityProps.h index 387245325f24ab..27c5f4fd321ccf 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -39,7 +39,7 @@ class AccessibilityProps { bool accessible{false}; AccessibilityState accessibilityState; - AccessibilityUnit accessibilityUnit; + std::string accessibilityUnit{"1"}; std::string accessibilityLabel{""}; AccessibilityLabelledBy accessibilityLabelledBy{}; AccessibilityLiveRegion accessibilityLiveRegion{ diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp b/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp index 191dce6c7b21f9..b6aa1f3faa7784 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp @@ -141,9 +141,9 @@ void AccessibilityProps::propsDiffMapBuffer( } if (oldProps.accessibilityUnit != newProps.accessibilityUnit) { - builder.putMapBuffer( + builder.putString( AP_ACCESSIBILITY_UNIT, - convertAccessibilityUnit(newProps.accessibilityUnit)); + "10"); } if (oldProps.accessibilityValue != newProps.accessibilityValue) { diff --git a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index d2ce04e9319ca2..6659e9d7104db3 100644 --- a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -170,17 +170,6 @@ inline void fromRawValue( } } -inline void fromRawValue( - const PropsParserContext &context, - const RawValue &value, - AccessibilityUnit &result) { - auto map = (butter::map)value; - auto hours = map.find("hours"); - if (hours != map.end()) { - fromRawValue(context, hours->second, result.hours); - } -} - inline std::string toString( const ImportantForAccessibility &importantForAccessibility) { switch (importantForAccessibility) { diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index a42b43dce995d0..3b5b8c6d8bb601 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -172,7 +172,7 @@ class AccessibilityExample extends React.Component<{}> { My number is 17:00 From a96ad8ad4a8f5e6eb0ab7b2907fa298ba4f1d2bb Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 11 Nov 2022 18:33:55 +0100 Subject: [PATCH 03/14] DRAFT CPP solution to pass static string as accessibilityUnit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getOrCreateSpannableForText is not called. The method is called on the parent Text, but not on the Span Text. Review implementation of accessibilityRole in [BaseViewManager](https://github.com/fabriziobertoglio1987/react-native/blob/ec4bc8eb5905f81cebbb4b623acda8245ee5683c/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java#L247) and [ReactMapBufferPropSetter.kt](http://www.apple.com/)
Probably the method setAccessibilityRole is called directly from kotlin MapBufferPropSetter
Add required changes and debug the functionality accessibilityRole link is called, but time is not
they have the same cpp configuration, but one of them is not invoked in BaseViewManager. 
This suggest missing configs from the [accessibility link PR](https://github.com/facebook/react-native/commit/7b5b114d578142d18bf4a7a5279b179a9ac8d958), maybe accessibilityRole Link is triggered with resetAccessibilityDelegate Find logic in accessibility link PR that resets the Delegate
Before resetting the Delegate, TextLayoutManager adds the Span to the Text. The field is TextAttributes mIsAccessibilityLink. This field is set to true if accessibilityRole = link
mIsAccessibilityLink is set to true in the ReactBaseTextShadowNode #setIsAccessibilityLink sets the value Debug the value of ReactBaseTextShadowNode #setAccessibilityUnit
Verify if accessibilityUnit is retrieve in that method, because this manager is also for nested text Check if setIsAccessibiltyLink also is triggered for role time, if not understand why text does not trigger. Yes, it is triggered. We set there the accessibilityRole
- We could follow the same implementation, we add the span based on mIsAccessibilityTtsSpan
- We retrieve get spans of class ReactTtsSpan 
- We follow same implementation from accessibilityLinks Implement same logic for accessibilityRole time Verify accessibilityRole time is invoked Use resetAccessibilityDelegate to add accessibilityUnit info to child Text Copy missing changes from another prop (for ex. accessibilityRole). setAccessibilityRole is triggered, while setAccessibilityUnit is not triggered. Review missing diff with [#2](https://github.com/fabriziobertoglio1987/react-native/pull/2/files) Review the current diff with main branch Add breakpoint in cpp SOLUTION: adding the value in [attributedstring/conversion.h](https://github.com/fabriziobertoglio1987/react-native/blob/ec4bc8eb5905f81cebbb4b623acda8245ee5683c/ReactCommon/react/renderer/attributedstring/conversions.h#L1087) will then pass it to [TextAttributesProps as key 24](https://www.icloud.com/iclouddrive/0b8-oKB396zP7Astpyc3puGqQ#ACC_UNIT_passed_as_key_24) --- .../react/uimanager/BaseViewManagerDelegate.java | 3 +++ .../react/views/text/ReactBaseTextShadowNode.java | 5 +++++ .../facebook/react/views/text/TextAttributeProps.java | 11 +++++++++++ .../facebook/react/views/text/TextLayoutManager.java | 2 ++ .../react/views/view/ReactMapBufferPropSetter.kt | 9 +++------ .../react/renderer/attributedstring/conversions.h | 5 +++++ .../js/examples/Accessibility/AccessibilityExample.js | 9 +++++++++ 7 files changed, 38 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java index bb809381494e5e..9aa83a6af69f92 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java @@ -7,6 +7,7 @@ package com.facebook.react.uimanager; +import android.util.Log; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ColorPropConverter; @@ -30,6 +31,8 @@ public BaseViewManagerDelegate(U viewManager) { @Override public void setProperty(T view, String propName, @Nullable Object value) { + Log.w("TESTING::BaseViewManagerDelegate", "propName: " + (propName)); + Log.w("TESTING::BaseViewManagerDelegate", "value: " + (value)); switch (propName) { case ViewProps.ACCESSIBILITY_ACTIONS: mViewManager.setAccessibilityActions(view, (ReadableArray) value); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index 738b8ced4ac277..e03ae115366c1e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -15,6 +15,7 @@ import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.TextUtils; +import android.util.Log; import android.view.Gravity; import androidx.annotation.Nullable; import com.facebook.infer.annotation.Assertions; @@ -507,6 +508,8 @@ public void setBackgroundColor(@Nullable Integer color) { @ReactProp(name = ViewProps.ACCESSIBILITY_ROLE) public void setIsAccessibilityLink(@Nullable String accessibilityRole) { + Log.w("TESTING::ReactBaseTextShadowNode", "setIsAccessibilityLink"); + Log.w("TESTING::ReactBaseTextShadowNode", "accessibilityRole: " + (accessibilityRole)); if (isVirtual()) { String roleClassName = AccessibilityRole.getValue(AccessibilityRole.fromValue(accessibilityRole)); @@ -519,6 +522,8 @@ public void setIsAccessibilityLink(@Nullable String accessibilityRole) { @ReactProp(name = "accessibilityUnit") public void setAccessibilityUnit(@Nullable String accessibilityUnit) { + Log.w("TESTING::ReactBaseTextShadowNode", "setAccessibilityUnit"); + Log.w("TESTING::ReactBaseTextShadowNode", "accessibilityUnit: " + (accessibilityUnit)); if (isVirtual()) { markUpdated(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index 6ac85573a31337..0c0406b90e69c7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -11,6 +11,7 @@ import android.text.Layout; import android.text.TextUtils; import android.util.LayoutDirection; +import android.util.Log; import android.view.Gravity; import androidx.annotation.Nullable; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; @@ -53,6 +54,7 @@ public class TextAttributeProps { public static final short TA_KEY_IS_HIGHLIGHTED = 20; public static final short TA_KEY_LAYOUT_DIRECTION = 21; public static final short TA_KEY_ACCESSIBILITY_ROLE = 22; + public static final short TA_KEY_ACCESSIBILITY_UNIT = 47; public static final int UNSET = -1; @@ -144,6 +146,8 @@ public static TextAttributeProps fromMapBuffer(MapBuffer props) { // TODO T83483191: Review constants that are not being set! Iterator iterator = props.iterator(); + Log.w("TESTING::TextAttributeProps", "fromMapBuffer"); + Log.w("TESTING::TextAttributeProps", "props: " + (props)); while (iterator.hasNext()) { MapBuffer.Entry entry = iterator.next(); switch (entry.getKey()) { @@ -206,6 +210,9 @@ public static TextAttributeProps fromMapBuffer(MapBuffer props) { case TA_KEY_ACCESSIBILITY_ROLE: result.setAccessibilityRole(entry.getStringValue()); break; + case TA_KEY_ACCESSIBILITY_UNIT: + result.setAccessibilityUnit(entry.getStringValue()); + break; } } @@ -602,6 +609,8 @@ private void setTextTransform(@Nullable String textTransform) { private void setAccessibilityRole(@Nullable String accessibilityRole) { if (accessibilityRole != null) { + Log.w("TESTING::TextAttributeProps", "setAccessibilityRole"); + Log.w("TESTING::TextAttributeProps", "accessibilityRole: " + (accessibilityRole)); mIsAccessibilityRoleSet = true; mAccessibilityRole = AccessibilityRole.fromValue(accessibilityRole); mIsAccessibilityLink = mAccessibilityRole.equals(AccessibilityRole.LINK); @@ -613,6 +622,8 @@ private void setAccessibilityRole(@Nullable String accessibilityRole) { } private void setAccessibilityUnit(@Nullable String accessibilityUnit) { + Log.w("TESTING::TextAttributeProps", "setAccessibilityUnit"); + Log.w("TESTING::TextAttributeProps", "accessibilityUnit: " + (accessibilityUnit)); // not yet implemented } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 1f3bf935ab80ae..761e16dbd0eb65 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -19,6 +19,7 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.LayoutDirection; +import android.util.Log; import android.util.LruCache; import android.view.View; import androidx.annotation.NonNull; @@ -196,6 +197,7 @@ public static Spannable getOrCreateSpannableForText( Context context, ReadableMap attributedString, @Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) { + Log.w("TESTING::TextLayoutManager", "getOrCreateSpannableForText"); return createSpannableFromAttributedString( context, attributedString, reactTextViewManagerCallback); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt index b75d0692785302..4abc9cae783669 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt @@ -133,7 +133,7 @@ object ReactMapBufferPropSetter { viewManager.accessibilityState(view, entry.mapBufferValue) } VP_ACCESSIBILITY_UNIT -> { - viewManager.accessibilityUnit(view, entry.stringValue) + viewManager.setAccessibilityUnit(view, entry.stringValue.takeIf { it.isNotEmpty() }) } VP_ACCESSIBILITY_VALUE -> { viewManager.accessibilityValue(view, entry.stringValue) @@ -285,11 +285,8 @@ object ReactMapBufferPropSetter { private fun ReactViewManager.accessibilityUnit(view: ReactViewGroup, value: String) { Log.w("TESTING::ReactMapBufferPropSetter", "accessibilityUnit"); - /* - val accessibilityUnit = JavaOnlyMap() - accessibilityUnit.putString("hours", "10") - setAccessibilityUnit(view, accessibilityUnit) - */ + Log.w("TESTING::ReactMapBufferPropSetter", "value: " + ( value )); + setAccessibilityUnit(view,"random string") } private fun ReactViewManager.accessibilityState(view: ReactViewGroup, value: MapBuffer) { diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index 857b37a673eb28..8a74dbd1a03423 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -1083,6 +1083,7 @@ constexpr static MapBuffer::Key TA_KEY_IS_HIGHLIGHTED = 20; constexpr static MapBuffer::Key TA_KEY_LAYOUT_DIRECTION = 21; constexpr static MapBuffer::Key TA_KEY_ACCESSIBILITY_ROLE = 22; constexpr static MapBuffer::Key TA_KEY_LINE_BREAK_STRATEGY = 23; +constexpr static MapBuffer::Key TA_KEY_ACCESSIBILITY_UNIT = 47; // constants for ParagraphAttributes serialization constexpr static MapBuffer::Key PA_KEY_MAX_NUMBER_OF_LINES = 0; @@ -1226,8 +1227,12 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) { TA_KEY_LAYOUT_DIRECTION, toString(*textAttributes.layoutDirection)); } if (textAttributes.accessibilityRole.has_value()) { + + LOG(ERROR) << "TESTING:: attributedString conversions.h accessibilityRole: " << toString(*textAttributes.accessibilityRole); builder.putString( TA_KEY_ACCESSIBILITY_ROLE, toString(*textAttributes.accessibilityRole)); + builder.putString( + TA_KEY_ACCESSIBILITY_UNIT, "random unit"); } return builder.build(); } diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index 3b5b8c6d8bb601..039496f5f682b7 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -178,6 +178,15 @@ class AccessibilityExample extends React.Component<{}> { 17:00 + + This is a + + link + + From 3b165429ca9fec665045521fa3346a4b607843db Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 11 Nov 2022 19:56:08 +0100 Subject: [PATCH 04/14] passing prop accessibilityUnit as string from cpp to java "Complete draft CPP accessibilityUnit settings: Commit the changes and push Add more clear log statements and further verify value passed to accessibilityUnit Log the value passed from javascript in conversion.h Add changes from PR [#2](https://github.com/fabriziobertoglio1987/react-native/pull/2/files) Change logic in conversion.h to add the value passed from javascript" --- .../react/views/text/TextAttributeProps.java | 4 ---- .../renderer/attributedstring/TextAttributes.h | 2 +- .../react/renderer/attributedstring/conversions.h | 10 ++++++++-- .../renderer/components/text/BaseTextProps.cpp | 13 +++++++++++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index 0c0406b90e69c7..36115a8a9be8e8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -146,8 +146,6 @@ public static TextAttributeProps fromMapBuffer(MapBuffer props) { // TODO T83483191: Review constants that are not being set! Iterator iterator = props.iterator(); - Log.w("TESTING::TextAttributeProps", "fromMapBuffer"); - Log.w("TESTING::TextAttributeProps", "props: " + (props)); while (iterator.hasNext()) { MapBuffer.Entry entry = iterator.next(); switch (entry.getKey()) { @@ -609,8 +607,6 @@ private void setTextTransform(@Nullable String textTransform) { private void setAccessibilityRole(@Nullable String accessibilityRole) { if (accessibilityRole != null) { - Log.w("TESTING::TextAttributeProps", "setAccessibilityRole"); - Log.w("TESTING::TextAttributeProps", "accessibilityRole: " + (accessibilityRole)); mIsAccessibilityRoleSet = true; mAccessibilityRole = AccessibilityRole.fromValue(accessibilityRole); mIsAccessibilityLink = mAccessibilityRole.equals(AccessibilityRole.LINK); diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index ca26925f76c326..017e2d38e16ba9 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -79,7 +79,7 @@ class TextAttributes : public DebugStringConvertible { // construction. std::optional layoutDirection{}; std::optional accessibilityRole{}; - std::string accessibilityUnit{""}; + std::string accessibilityUnit{}; #pragma mark - Operations diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index 8a74dbd1a03423..89451afb84c2c7 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -1009,6 +1009,10 @@ inline folly::dynamic toDynamic(const TextAttributes &textAttributes) { _textAttributes( "accessibilityRole", toString(*textAttributes.accessibilityRole)); } + if (!textAttributes.accessibilityUnit.empty()) { + _textAttributes( + "accessibilityUnit", textAttributes.accessibilityUnit); + } return _textAttributes; } @@ -1228,11 +1232,13 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) { } if (textAttributes.accessibilityRole.has_value()) { - LOG(ERROR) << "TESTING:: attributedString conversions.h accessibilityRole: " << toString(*textAttributes.accessibilityRole); builder.putString( TA_KEY_ACCESSIBILITY_ROLE, toString(*textAttributes.accessibilityRole)); + } + if (!textAttributes.accessibilityUnit.empty()) { + builder.putString( - TA_KEY_ACCESSIBILITY_UNIT, "random unit"); + TA_KEY_ACCESSIBILITY_UNIT, textAttributes.accessibilityUnit); } return builder.build(); } diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index 6f4741ba69c9ee..3d6eddbf8ca7d1 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -177,6 +177,13 @@ static TextAttributes convertRawProp( sourceTextAttributes.accessibilityRole, defaultTextAttributes.accessibilityRole); + textAttributes.accessibilityUnit = convertRawProp( + context, + rawProps, + "accessibilityUnit", + sourceTextAttributes.accessibilityUnit, + defaultTextAttributes.accessibilityUnit); + // Color (accessed in this order by ViewProps) textAttributes.opacity = convertRawProp( context, @@ -287,6 +294,12 @@ void BaseTextProps::setProp( textAttributes, accessibilityRole, "accessibilityRole"); + REBUILD_FIELD_SWITCH_CASE( + defaults, + value, + textAttributes, + accessibilityRole, + "accessibilityUnit"); REBUILD_FIELD_SWITCH_CASE( defaults, value, textAttributes, opacity, "opacity"); REBUILD_FIELD_SWITCH_CASE( From 41173cbeba53b26a3c838d16776daa8d10e57639 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 11 Nov 2022 20:06:49 +0100 Subject: [PATCH 05/14] removing not relevant code (to be tested) --- .../react/uimanager/BaseViewManagerDelegate.java | 3 --- .../react/views/text/TextLayoutManager.java | 1 - .../react/views/view/ReactMapBufferPropSetter.kt | 13 +------------ .../renderer/components/view/AccessibilityProps.h | 2 +- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java index 9aa83a6af69f92..bb809381494e5e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerDelegate.java @@ -7,7 +7,6 @@ package com.facebook.react.uimanager; -import android.util.Log; import android.view.View; import androidx.annotation.Nullable; import com.facebook.react.bridge.ColorPropConverter; @@ -31,8 +30,6 @@ public BaseViewManagerDelegate(U viewManager) { @Override public void setProperty(T view, String propName, @Nullable Object value) { - Log.w("TESTING::BaseViewManagerDelegate", "propName: " + (propName)); - Log.w("TESTING::BaseViewManagerDelegate", "value: " + (value)); switch (propName) { case ViewProps.ACCESSIBILITY_ACTIONS: mViewManager.setAccessibilityActions(view, (ReadableArray) value); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 761e16dbd0eb65..c940dee9f6fc2d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -19,7 +19,6 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.LayoutDirection; -import android.util.Log; import android.util.LruCache; import android.view.View; import androidx.annotation.NonNull; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt index 4abc9cae783669..7218daf70cf9d7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactMapBufferPropSetter.kt @@ -6,7 +6,7 @@ */ package com.facebook.react.views.view -import android.util.Log; + import android.graphics.Color import android.graphics.Rect import androidx.core.view.ViewCompat @@ -64,7 +64,6 @@ object ReactMapBufferPropSetter { private const val VP_POINTER_OVER_CAPTURE = 44 private const val VP_BORDER_CURVES = 45 // iOS only private const val VP_FG_COLOR = 46 // iOS only? - private const val VP_ACCESSIBILITY_UNIT = 47 // Yoga values private const val YG_BORDER_WIDTH = 100 @@ -108,7 +107,6 @@ object ReactMapBufferPropSetter { private const val UNDEF_COLOR = Int.MAX_VALUE fun setProps(view: ReactViewGroup, viewManager: ReactViewManager, props: MapBuffer) { - Log.w("TESTING::ReactMapBufferPropSetter", "props: " + ( props )); for (entry in props) { when (entry.key) { VP_ACCESSIBILITY_ACTIONS -> { @@ -132,9 +130,6 @@ object ReactMapBufferPropSetter { VP_ACCESSIBILITY_STATE -> { viewManager.accessibilityState(view, entry.mapBufferValue) } - VP_ACCESSIBILITY_UNIT -> { - viewManager.setAccessibilityUnit(view, entry.stringValue.takeIf { it.isNotEmpty() }) - } VP_ACCESSIBILITY_VALUE -> { viewManager.accessibilityValue(view, entry.stringValue) } @@ -283,12 +278,6 @@ object ReactMapBufferPropSetter { ViewCompat.setAccessibilityLiveRegion(this, mode) } - private fun ReactViewManager.accessibilityUnit(view: ReactViewGroup, value: String) { - Log.w("TESTING::ReactMapBufferPropSetter", "accessibilityUnit"); - Log.w("TESTING::ReactMapBufferPropSetter", "value: " + ( value )); - setAccessibilityUnit(view,"random string") - } - private fun ReactViewManager.accessibilityState(view: ReactViewGroup, value: MapBuffer) { val accessibilityState = JavaOnlyMap() accessibilityState.putBoolean("selected", value.getBoolean(ACCESSIBILITY_STATE_SELECTED)) diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.h b/ReactCommon/react/renderer/components/view/AccessibilityProps.h index 27c5f4fd321ccf..7778ff4f2d6aed 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -39,7 +39,7 @@ class AccessibilityProps { bool accessible{false}; AccessibilityState accessibilityState; - std::string accessibilityUnit{"1"}; + std::string accessibilityUnit{""}; std::string accessibilityLabel{""}; AccessibilityLabelledBy accessibilityLabelledBy{}; AccessibilityLiveRegion accessibilityLiveRegion{ From 3357873f7100c00c9ef718f51cfaf0d788ebeafd Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Mon, 14 Nov 2022 11:07:19 +0100 Subject: [PATCH 06/14] Using CPP map instead of string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Basic working setup to use CPP Map instead of basic string type Settings copied from accessibilityState (fromRawValue) and from importantForAccessibility (toString) the CPP convertRawProps will use two functions to convert the prop: - fromRawValue which takes as param the prop RawValue - toString or toBoolean, to*** which convert the RawValue to String/Boolean/Number The error was triggered for missing conversion from RawValue (AccessibilityUnit field hours) toString. (std::string) accessibilityUnit.hours would call toString(accessibilityUnit.hours) Tasks Details: Complete draft CPP accessibilityUnit settings:Commit the changes and pushAdd more clear log statements and further verify value passed to  accessibilityUnitLog the value passed from javascript in conversion.hAdd changes from PR #2Change logic in conversion.h to add the value passed from javascript -- Change the type from String to Hash in PR #3:Plan next tasksFind a prop that uses the Hash type (for ex accessibilityState)Start with a clear git statusCopy the CPP settings from accessibilityState Parse accessibilityUnit hours value to a string type. The value is already string, but in CPP is not mapped to string.importantForAccessibility uses 2 conversions, fromRawValue and toString. fromRawValue parses the props importantForAccessibility, while toString converts the value from IMPORTANT_FOR_ACCESSIBILITY to string.Follow the same implementation fromRawValue(IMPORTANT_FOR_ACCESSIBILITY), but avoid adding their toString(Important_For_Accessibility) conversion.Pass a static string auto hours = “10”; "Complete draft CPP accessibilityUnit settings: Commit the changes and push Add more clear log statements and further verify value passed to accessibilityUnit Log the value passed from javascript in conversion.h Add changes from PR [#2](https://github.com/fabriziobertoglio1987/react-native/pull/2/files) Change logic in conversion.h to add the value passed from javascript" "Change the type from String to Hash in PR [#3](https://github.com/fabriziobertoglio1987/react-native/pull/3/files): Plan next tasks Find a prop that uses the Hash type (for ex [accessibilityState](https://github.com/fabriziobertoglio1987/react-native/blob/41173cbeba53b26a3c838d16776daa8d10e57639/ReactCommon/react/renderer/components/view/AccessibilityProps.h#L41)) Start with a clear git status Copy the CPP settings from accessibilityState" "Parse accessibilityUnit hours value to a string type. The value is already string, but in CPP is not mapped to string.
[importantForAccessibility](https://github.com/fabriziobertoglio1987/react-native/blob/41173cbeba53b26a3c838d16776daa8d10e57639/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h#L173-L209) uses 2 conversions, fromRawValue and toString. fromRawValue parses the props importantForAccessibility, while toString converts the value from IMPORTANT_FOR_ACCESSIBILITY to string. Follow the same implementation [fromRawValue(IMPORTANT_FOR_ACCESSIBILITY)](https://github.com/fabriziobertoglio1987/react-native/blob/41173cbeba53b26a3c838d16776daa8d10e57639/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h#L193), but avoid adding their toString(Important_For_Accessibility) conversion.
Pass a static string auto hours = “10”;" --- .../Components/View/ViewAccessibility.js | 2 +- .../react/views/text/TextLayoutManager.java | 1 + .../components/view/AccessibilityPrimitives.h | 2 +- .../components/view/AccessibilityProps.h | 2 +- .../view/AccessibilityPropsMapBuffer.cpp | 10 +++++----- .../view/accessibilityPropsConversions.h | 20 +++++++++++++++++++ 6 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Libraries/Components/View/ViewAccessibility.js b/Libraries/Components/View/ViewAccessibility.js index 1cd11667db1286..8b69ad2995cfa6 100644 --- a/Libraries/Components/View/ViewAccessibility.js +++ b/Libraries/Components/View/ViewAccessibility.js @@ -159,7 +159,7 @@ export type AccessibilityState = { }; export type AccessibilityUnit = { - hours?: number, + hours?: string, }; export type AccessibilityValue = $ReadOnly<{| diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index c940dee9f6fc2d..761e16dbd0eb65 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -19,6 +19,7 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.LayoutDirection; +import android.util.Log; import android.util.LruCache; import android.view.View; import androidx.annotation.NonNull; diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h index 3fed2e90f9d168..c31e318f4c1fd1 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h @@ -89,7 +89,7 @@ constexpr bool operator!=( } struct AccessibilityUnit { - std::optional hours; + std::string hours{""}; }; constexpr bool operator==( diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.h b/ReactCommon/react/renderer/components/view/AccessibilityProps.h index 7778ff4f2d6aed..387245325f24ab 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -39,7 +39,7 @@ class AccessibilityProps { bool accessible{false}; AccessibilityState accessibilityState; - std::string accessibilityUnit{""}; + AccessibilityUnit accessibilityUnit; std::string accessibilityLabel{""}; AccessibilityLabelledBy accessibilityLabelledBy{}; AccessibilityLiveRegion accessibilityLiveRegion{ diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp b/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp index b6aa1f3faa7784..37046ad7ad0cca 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp @@ -46,7 +46,6 @@ constexpr MapBuffer::Key ACCESSIBILITY_STATE_DISABLED = 1; constexpr MapBuffer::Key ACCESSIBILITY_STATE_EXPANDED = 2; constexpr MapBuffer::Key ACCESSIBILITY_STATE_SELECTED = 3; constexpr MapBuffer::Key ACCESSIBILITY_STATE_CHECKED = 4; -constexpr MapBuffer::Key ACCESSIBILITY_UNIT_HOURS = 5; MapBuffer convertAccessibilityState(AccessibilityState const &state) { MapBufferBuilder builder(5); @@ -73,9 +72,10 @@ MapBuffer convertAccessibilityState(AccessibilityState const &state) { return builder.build(); } -MapBuffer convertAccessibilityUnit(AccessibilityUnit const &state) { +constexpr MapBuffer::Key ACCESSIBILITY_UNIT_HOURS = 0; +MapBuffer convertAccessibilityUnit(AccessibilityUnit const &unit) { MapBufferBuilder builder(1); - builder.putString(ACCESSIBILITY_UNIT_HOURS, "10"); + builder.putString(ACCESSIBILITY_UNIT_HOURS, unit.hours); return builder.build(); } @@ -141,9 +141,9 @@ void AccessibilityProps::propsDiffMapBuffer( } if (oldProps.accessibilityUnit != newProps.accessibilityUnit) { - builder.putString( + builder.putMapBuffer( AP_ACCESSIBILITY_UNIT, - "10"); + convertAccessibilityUnit(newProps.accessibilityUnit)); } if (oldProps.accessibilityValue != newProps.accessibilityValue) { diff --git a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index 6659e9d7104db3..195b65563686ef 100644 --- a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -170,6 +170,26 @@ inline void fromRawValue( } } +inline void fromRawValue( + const PropsParserContext &context, + const RawValue &value, + AccessibilityUnit &result) { + auto map = (butter::map)value; + /* + auto hours = map.find("hours"); + if (hours != map.end()) { + // This probably calls toString() + fromRawValue(context, hours->second, result.hours); + } + */ + if (value.hasType()) { + auto string = "10"; + result.hours = string; + } else { + LOG(ERROR) << "Can not set type string for AccessibilityUnit field hours"; + } +} + inline std::string toString( const ImportantForAccessibility &importantForAccessibility) { switch (importantForAccessibility) { From 2fed66011bacb4385ec20cfd659a191f3ca84c1a Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Mon, 14 Nov 2022 16:16:38 +0100 Subject: [PATCH 07/14] adding toString and fromRawValue conversion to view/accessibilityPropsConversions --- .../view/accessibilityPropsConversions.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index 195b65563686ef..6314b89768603f 100644 --- a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -174,20 +174,26 @@ inline void fromRawValue( const PropsParserContext &context, const RawValue &value, AccessibilityUnit &result) { - auto map = (butter::map)value; - /* + // don't use std::string instead use RawValue and add a toString conversion + auto map = (butter::map)value; auto hours = map.find("hours"); if (hours != map.end()) { // This probably calls toString() - fromRawValue(context, hours->second, result.hours); + result.hours = hours->second; } - */ + /* if (value.hasType()) { - auto string = "10"; + auto string = toString(value); result.hours = string; } else { LOG(ERROR) << "Can not set type string for AccessibilityUnit field hours"; } + */ +} + +inline std::string toString( + const AccessibilityUnit &accessibilityUnit) { + return "default string"; } inline std::string toString( From 252e6f47b10fa00a863fc85f11fe8a8e6c9893f4 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Mon, 14 Nov 2022 16:22:47 +0100 Subject: [PATCH 08/14] Call to implicitly deleted constructor [build error](https://www.icloud.com/iclouddrive/083j4A7FWBweG3wFmAnHzDyfQ#call_to_implicitly_deleted_constructor) seems to be caused by the double declaration of primitive AccessibilityUnit: --- .../react/renderer/attributedstring/TextAttributes.cpp | 2 +- ReactCommon/react/renderer/attributedstring/TextAttributes.h | 2 +- ReactCommon/react/renderer/attributedstring/primitives.h | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp index 741dcc85d4647f..90fc6513cd226d 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp @@ -98,7 +98,7 @@ void TextAttributes::apply(TextAttributes textAttributes) { accessibilityRole = textAttributes.accessibilityRole.has_value() ? textAttributes.accessibilityRole : accessibilityRole; - accessibilityUnit = !textAttributes.accessibilityUnit.empty() ? textAttributes.accessibilityUnit + accessibilityUnit = !textAttributes.accessibilityUnit.has_value() ? textAttributes.accessibilityUnit : accessibilityUnit; } diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index 017e2d38e16ba9..4bf42586f5a173 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -79,7 +79,7 @@ class TextAttributes : public DebugStringConvertible { // construction. std::optional layoutDirection{}; std::optional accessibilityRole{}; - std::string accessibilityUnit{}; + AccessibilityUnit accessibilityUnit{}; #pragma mark - Operations diff --git a/ReactCommon/react/renderer/attributedstring/primitives.h b/ReactCommon/react/renderer/attributedstring/primitives.h index 39e8f31e18b4a6..69c7caffc4000e 100644 --- a/ReactCommon/react/renderer/attributedstring/primitives.h +++ b/ReactCommon/react/renderer/attributedstring/primitives.h @@ -135,6 +135,10 @@ enum class AccessibilityRole { Toolbar, }; +struct AccessibilityUnit { + std::string hours{""}; +}; + enum class TextTransform { None, Uppercase, From bd1824c95ef79fdf2e7fae5696051e0c17d7460f Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Mon, 14 Nov 2022 17:12:17 +0100 Subject: [PATCH 09/14] Revert "Call to implicitly deleted constructor" This reverts commit 252e6f47b10fa00a863fc85f11fe8a8e6c9893f4. --- .../react/renderer/attributedstring/TextAttributes.cpp | 2 +- ReactCommon/react/renderer/attributedstring/TextAttributes.h | 2 +- ReactCommon/react/renderer/attributedstring/primitives.h | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp index 90fc6513cd226d..741dcc85d4647f 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp @@ -98,7 +98,7 @@ void TextAttributes::apply(TextAttributes textAttributes) { accessibilityRole = textAttributes.accessibilityRole.has_value() ? textAttributes.accessibilityRole : accessibilityRole; - accessibilityUnit = !textAttributes.accessibilityUnit.has_value() ? textAttributes.accessibilityUnit + accessibilityUnit = !textAttributes.accessibilityUnit.empty() ? textAttributes.accessibilityUnit : accessibilityUnit; } diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index 4bf42586f5a173..017e2d38e16ba9 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -79,7 +79,7 @@ class TextAttributes : public DebugStringConvertible { // construction. std::optional layoutDirection{}; std::optional accessibilityRole{}; - AccessibilityUnit accessibilityUnit{}; + std::string accessibilityUnit{}; #pragma mark - Operations diff --git a/ReactCommon/react/renderer/attributedstring/primitives.h b/ReactCommon/react/renderer/attributedstring/primitives.h index 69c7caffc4000e..39e8f31e18b4a6 100644 --- a/ReactCommon/react/renderer/attributedstring/primitives.h +++ b/ReactCommon/react/renderer/attributedstring/primitives.h @@ -135,10 +135,6 @@ enum class AccessibilityRole { Toolbar, }; -struct AccessibilityUnit { - std::string hours{""}; -}; - enum class TextTransform { None, Uppercase, From e14e9ba2af29e0017cab6829c1ef6bda080107bd Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Mon, 14 Nov 2022 19:49:41 +0100 Subject: [PATCH 10/14] separating mIsAccessibilitySpan from mAccessibilityUnit --- .../react/views/text/TextAttributeProps.java | 12 ++++++------ .../react/views/text/TextLayoutManagerMapBuffer.java | 7 ++++++- .../react/renderer/components/text/BaseTextProps.cpp | 2 +- .../examples/Accessibility/AccessibilityExample.js | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index 36115a8a9be8e8..651de3eb6c3bb4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -11,7 +11,6 @@ import android.text.Layout; import android.text.TextUtils; import android.util.LayoutDirection; -import android.util.Log; import android.view.Gravity; import androidx.annotation.Nullable; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; @@ -106,6 +105,7 @@ public class TextAttributeProps { protected boolean mIsAccessibilityRoleSet = false; protected @Nullable String mAccessibilityUnit = null; protected boolean mIsAccessibilityLink = false; + protected boolean mIsAccessibilityTtsSpan = false; protected int mFontStyle = UNSET; protected int mFontWeight = UNSET; @@ -612,15 +612,15 @@ private void setAccessibilityRole(@Nullable String accessibilityRole) { mIsAccessibilityLink = mAccessibilityRole.equals(AccessibilityRole.LINK); String roleClassName = AccessibilityRole.getValue(AccessibilityRole.fromValue(accessibilityRole)); - mAccessibilityUnit = - ReactTtsSpan.SUPPORTED_UNIT_TYPES.contains(roleClassName) ? roleClassName : null; + mIsAccessibilityTtsSpan = + ReactTtsSpan.SUPPORTED_UNIT_TYPES.contains(roleClassName) && Build.VERSION.SDK_INT >= 21; } } private void setAccessibilityUnit(@Nullable String accessibilityUnit) { - Log.w("TESTING::TextAttributeProps", "setAccessibilityUnit"); - Log.w("TESTING::TextAttributeProps", "accessibilityUnit: " + (accessibilityUnit)); - // not yet implemented + if (accessibilityUnit != null) { + mAccessibilityUnit = accessibilityUnit; + } } public static int getTextBreakStrategy(@Nullable String textBreakStrategy) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java index ed321a89bfef2c..1d7027afe15596 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java @@ -19,6 +19,7 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.LayoutDirection; +import android.util.Log; import android.util.LruCache; import android.view.View; import androidx.annotation.NonNull; @@ -143,8 +144,12 @@ private static void buildSpannableFromFragment( if (textAttributes.mIsAccessibilityLink) { ops.add(new SetSpanOperation(start, end, new ReactClickableSpan(reactTag))); } - if (textAttributes.mAccessibilityUnit != null && Build.VERSION.SDK_INT >= 21) { + if (textAttributes.mIsAccessibilityTtsSpan) { + // check that textAttributes.mAccessibilityRole == "time" ReactTtsSpan.Builder builder = new ReactTtsSpan.Builder(ReactTtsSpan.TYPE_TIME); + Log.w( + "TESTING::TextLayoutManagerMapBuffer", + "textAttributes.mAccessibilityUnit: " + (textAttributes.mAccessibilityUnit)); builder.setIntArgument(ReactTtsSpan.ARG_HOURS, 10); builder.setIntArgument(ReactTtsSpan.ARG_MINUTES, 30); ops.add(new SetSpanOperation(start, end, builder.build())); diff --git a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp index 3d6eddbf8ca7d1..e1bac7373c955e 100644 --- a/ReactCommon/react/renderer/components/text/BaseTextProps.cpp +++ b/ReactCommon/react/renderer/components/text/BaseTextProps.cpp @@ -298,7 +298,7 @@ void BaseTextProps::setProp( defaults, value, textAttributes, - accessibilityRole, + accessibilityUnit, "accessibilityUnit"); REBUILD_FIELD_SWITCH_CASE( defaults, value, textAttributes, opacity, "opacity"); diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index 039496f5f682b7..e8495e18951dab 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -172,7 +172,7 @@ class AccessibilityExample extends React.Component<{}> { My number is 17:00 From d3b6ae65029c7c5ecaa6d77a67cc08e570563ded Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 15 Nov 2022 10:28:56 +0100 Subject: [PATCH 11/14] draft solution to parse accessibilityUnit in hours/minutes --- .../text/TextLayoutManagerMapBuffer.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java index 1d7027afe15596..8b0eec43c15ef4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java @@ -19,7 +19,6 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.LayoutDirection; -import android.util.Log; import android.util.LruCache; import android.view.View; import androidx.annotation.NonNull; @@ -147,11 +146,19 @@ private static void buildSpannableFromFragment( if (textAttributes.mIsAccessibilityTtsSpan) { // check that textAttributes.mAccessibilityRole == "time" ReactTtsSpan.Builder builder = new ReactTtsSpan.Builder(ReactTtsSpan.TYPE_TIME); - Log.w( - "TESTING::TextLayoutManagerMapBuffer", - "textAttributes.mAccessibilityUnit: " + (textAttributes.mAccessibilityUnit)); - builder.setIntArgument(ReactTtsSpan.ARG_HOURS, 10); - builder.setIntArgument(ReactTtsSpan.ARG_MINUTES, 30); + if (textAttributes.mAccessibilityUnit != null) { + String[] time = textAttributes.mAccessibilityUnit.split(":"); + if (time[0] != null && time[1] != null) { + try { + Integer hours = Integer.parseInt(time[0]); + Integer minutes = Integer.parseInt(time[1]); + builder.setIntArgument(ReactTtsSpan.ARG_HOURS, hours); + builder.setIntArgument(ReactTtsSpan.ARG_MINUTES, minutes); + } catch (Exception e) { + FLog.w(TAG, "TtsSpan with type Time failed to set hours and minutes. Error: " + e); + } + } + } ops.add(new SetSpanOperation(start, end, builder.build())); } if (textAttributes.mIsColorSet) { From f9d4af62244ae8d040020c6998b21addfe1fe976 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 15 Nov 2022 15:31:01 +0100 Subject: [PATCH 12/14] use accUnit as string instead of map remove not relevant logic --- .../Components/View/ViewAccessibility.js | 4 --- .../views/text/ReactBaseTextShadowNode.java | 7 ++--- .../react/views/text/TextLayoutManager.java | 2 -- .../renderer/attributedstring/conversions.h | 2 -- .../components/view/AccessibilityPrimitives.h | 16 ------------ .../components/view/AccessibilityProps.h | 2 +- .../view/AccessibilityPropsMapBuffer.cpp | 11 ++------ .../view/accessibilityPropsConversions.h | 26 ------------------- 8 files changed, 5 insertions(+), 65 deletions(-) diff --git a/Libraries/Components/View/ViewAccessibility.js b/Libraries/Components/View/ViewAccessibility.js index 8b69ad2995cfa6..c0a475f721d60f 100644 --- a/Libraries/Components/View/ViewAccessibility.js +++ b/Libraries/Components/View/ViewAccessibility.js @@ -158,10 +158,6 @@ export type AccessibilityState = { ... }; -export type AccessibilityUnit = { - hours?: string, -}; - export type AccessibilityValue = $ReadOnly<{| /** * The minimum value of this component's range. (should be an integer) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index e03ae115366c1e..d76445f35863e7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -15,7 +15,6 @@ import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.TextUtils; -import android.util.Log; import android.view.Gravity; import androidx.annotation.Nullable; import com.facebook.infer.annotation.Assertions; @@ -508,8 +507,6 @@ public void setBackgroundColor(@Nullable Integer color) { @ReactProp(name = ViewProps.ACCESSIBILITY_ROLE) public void setIsAccessibilityLink(@Nullable String accessibilityRole) { - Log.w("TESTING::ReactBaseTextShadowNode", "setIsAccessibilityLink"); - Log.w("TESTING::ReactBaseTextShadowNode", "accessibilityRole: " + (accessibilityRole)); if (isVirtual()) { String roleClassName = AccessibilityRole.getValue(AccessibilityRole.fromValue(accessibilityRole)); @@ -520,14 +517,14 @@ public void setIsAccessibilityLink(@Nullable String accessibilityRole) { } } + /* @ReactProp(name = "accessibilityUnit") public void setAccessibilityUnit(@Nullable String accessibilityUnit) { - Log.w("TESTING::ReactBaseTextShadowNode", "setAccessibilityUnit"); - Log.w("TESTING::ReactBaseTextShadowNode", "accessibilityUnit: " + (accessibilityUnit)); if (isVirtual()) { markUpdated(); } } + */ @ReactProp(name = ViewProps.FONT_FAMILY) public void setFontFamily(@Nullable String fontFamily) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java index 761e16dbd0eb65..1f3bf935ab80ae 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java @@ -19,7 +19,6 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.LayoutDirection; -import android.util.Log; import android.util.LruCache; import android.view.View; import androidx.annotation.NonNull; @@ -197,7 +196,6 @@ public static Spannable getOrCreateSpannableForText( Context context, ReadableMap attributedString, @Nullable ReactTextViewManagerCallback reactTextViewManagerCallback) { - Log.w("TESTING::TextLayoutManager", "getOrCreateSpannableForText"); return createSpannableFromAttributedString( context, attributedString, reactTextViewManagerCallback); diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h index 89451afb84c2c7..a3433c4b2ecdb2 100644 --- a/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/ReactCommon/react/renderer/attributedstring/conversions.h @@ -1231,12 +1231,10 @@ inline MapBuffer toMapBuffer(const TextAttributes &textAttributes) { TA_KEY_LAYOUT_DIRECTION, toString(*textAttributes.layoutDirection)); } if (textAttributes.accessibilityRole.has_value()) { - builder.putString( TA_KEY_ACCESSIBILITY_ROLE, toString(*textAttributes.accessibilityRole)); } if (!textAttributes.accessibilityUnit.empty()) { - builder.putString( TA_KEY_ACCESSIBILITY_UNIT, textAttributes.accessibilityUnit); } diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h index c31e318f4c1fd1..abc5df00883946 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h @@ -88,22 +88,6 @@ constexpr bool operator!=( return !(rhs == lhs); } -struct AccessibilityUnit { - std::string hours{""}; -}; - -constexpr bool operator==( - AccessibilityUnit const &lhs, - AccessibilityUnit const &rhs) { - return lhs.hours == rhs.hours; -} - -constexpr bool operator!=( - AccessibilityUnit const &lhs, - AccessibilityUnit const &rhs) { - return !(rhs == lhs); -} - struct AccessibilityLabelledBy { std::vector value{}; }; diff --git a/ReactCommon/react/renderer/components/view/AccessibilityProps.h b/ReactCommon/react/renderer/components/view/AccessibilityProps.h index 387245325f24ab..5656d52affcb53 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityProps.h +++ b/ReactCommon/react/renderer/components/view/AccessibilityProps.h @@ -39,7 +39,7 @@ class AccessibilityProps { bool accessible{false}; AccessibilityState accessibilityState; - AccessibilityUnit accessibilityUnit; + std::string accessibilityUnit; std::string accessibilityLabel{""}; AccessibilityLabelledBy accessibilityLabelledBy{}; AccessibilityLiveRegion accessibilityLiveRegion{ diff --git a/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp b/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp index 37046ad7ad0cca..9107059ccf04be 100644 --- a/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp +++ b/ReactCommon/react/renderer/components/view/AccessibilityPropsMapBuffer.cpp @@ -72,13 +72,6 @@ MapBuffer convertAccessibilityState(AccessibilityState const &state) { return builder.build(); } -constexpr MapBuffer::Key ACCESSIBILITY_UNIT_HOURS = 0; -MapBuffer convertAccessibilityUnit(AccessibilityUnit const &unit) { - MapBufferBuilder builder(1); - builder.putString(ACCESSIBILITY_UNIT_HOURS, unit.hours); - return builder.build(); -} - // TODO: Currently unsupported: nextFocusForward/Left/Up/Right/Down void AccessibilityProps::propsDiffMapBuffer( Props const *oldPropsPtr, @@ -141,9 +134,9 @@ void AccessibilityProps::propsDiffMapBuffer( } if (oldProps.accessibilityUnit != newProps.accessibilityUnit) { - builder.putMapBuffer( + builder.putString( AP_ACCESSIBILITY_UNIT, - convertAccessibilityUnit(newProps.accessibilityUnit)); + newProps.accessibilityUnit); } if (oldProps.accessibilityValue != newProps.accessibilityValue) { diff --git a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h index 6314b89768603f..6659e9d7104db3 100644 --- a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h +++ b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h @@ -170,32 +170,6 @@ inline void fromRawValue( } } -inline void fromRawValue( - const PropsParserContext &context, - const RawValue &value, - AccessibilityUnit &result) { - // don't use std::string instead use RawValue and add a toString conversion - auto map = (butter::map)value; - auto hours = map.find("hours"); - if (hours != map.end()) { - // This probably calls toString() - result.hours = hours->second; - } - /* - if (value.hasType()) { - auto string = toString(value); - result.hours = string; - } else { - LOG(ERROR) << "Can not set type string for AccessibilityUnit field hours"; - } - */ -} - -inline std::string toString( - const AccessibilityUnit &accessibilityUnit) { - return "default string"; -} - inline std::string toString( const ImportantForAccessibility &importantForAccessibility) { switch (importantForAccessibility) { From 75616866817a392962c690db4d2f7d1f2ead9e15 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 15 Nov 2022 16:02:01 +0100 Subject: [PATCH 13/14] removing not required logic for functionality from BaseViewManager --- .../react/uimanager/BaseViewManager.java | 6 ------ .../react/uimanager/BaseViewManagerAdapter.java | 3 --- .../uimanager/BaseViewManagerInterface.java | 2 -- .../views/text/ReactBaseTextShadowNode.java | 16 ---------------- .../views/text/ReactTextAnchorViewManager.java | 7 ------- 5 files changed, 34 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index 96ed24d05e7c1d..ee6ab32496e6fc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -318,12 +318,6 @@ public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilitySta } } - @Override - @ReactProp(name = ViewProps.ACCESSIBILITY_UNIT) - public void setAccessibilityUnit(@NonNull T view, @Nullable String accessibilityUnit) { - // do nothing - } - private void updateViewContentDescription(@NonNull T view) { final String accessibilityLabel = (String) view.getTag(R.id.accessibility_label); final ReadableMap accessibilityState = (ReadableMap) view.getTag(R.id.accessibility_state); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java index dded0fcd37ed6a..afd33e22eb1ba5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerAdapter.java @@ -42,9 +42,6 @@ public void setAccessibilityCollectionItem( @Override public void setViewState(@NonNull T view, @Nullable ReadableMap accessibilityState) {} - @Override - public void setAccessibilityUnit(@NonNull T view, @Nullable String accessibilityUnit) {} - @Override public void setBackgroundColor(@NonNull T view, int backgroundColor) {} diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java index 02e2e153bc15d1..0a6a9a561d5c61 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManagerInterface.java @@ -34,8 +34,6 @@ public interface BaseViewManagerInterface { void setViewState(T view, @Nullable ReadableMap accessibilityState); - void setAccessibilityUnit(T view, @Nullable String accessibilityUnit); - void setBackgroundColor(T view, int backgroundColor); void setBorderRadius(T view, float borderRadius); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index d76445f35863e7..4f4f726095bdf8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -184,13 +184,6 @@ private static void buildSpannedFromShadowNode( ops.add( new SetSpanOperation(start, end, new ReactClickableSpan(textShadowNode.getReactTag()))); } - if (textShadowNode.mAccessibilityUnit != null && Build.VERSION.SDK_INT >= 21) { - /* - ops.add( - new SetSpanOperation( - start, end, new ReactTtsSpan.Builder(textShadowNode.mAccessibilityUnit).build())); - */ - } float effectiveLetterSpacing = textAttributes.getEffectiveLetterSpacing(); if (!Float.isNaN(effectiveLetterSpacing) && (parentTextAttributes == null @@ -517,15 +510,6 @@ public void setIsAccessibilityLink(@Nullable String accessibilityRole) { } } - /* - @ReactProp(name = "accessibilityUnit") - public void setAccessibilityUnit(@Nullable String accessibilityUnit) { - if (isVirtual()) { - markUpdated(); - } - } - */ - @ReactProp(name = ViewProps.FONT_FAMILY) public void setFontFamily(@Nullable String fontFamily) { mFontFamily = fontFamily; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java index ff0591f2b3f0d0..dc874023c58425 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java @@ -14,7 +14,6 @@ import android.text.util.Linkify; import android.view.Gravity; import android.view.View; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.facebook.common.logging.FLog; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; @@ -49,12 +48,6 @@ public void setAccessible(ReactTextView view, boolean accessible) { view.setFocusable(accessible); } - @Override - @ReactProp(name = ViewProps.ACCESSIBILITY_UNIT) - public void setAccessibilityUnit(@NonNull T view, @Nullable String accessibilityUnit) { - // do nothing - } - // maxLines can only be set in master view (block), doesn't really make sense to set in a span @ReactProp(name = ViewProps.NUMBER_OF_LINES, defaultInt = ViewDefaults.NUMBER_OF_LINES) public void setNumberOfLines(ReactTextView view, int numberOfLines) { From 39b55e6e77217ea09ebe593ffc966d8522f8ef48 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Tue, 15 Nov 2022 16:06:04 +0100 Subject: [PATCH 14/14] removing example accLink --- .../js/examples/Accessibility/AccessibilityExample.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js index e8495e18951dab..cb36f060077b30 100644 --- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js +++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js @@ -178,15 +178,6 @@ class AccessibilityExample extends React.Component<{}> { 17:00 - - This is a - - link - -