diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/BUCK index b069baf48..bcc3f9cc7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/BUCK @@ -12,7 +12,6 @@ android_library( ], deps = [ YOGA_TARGET, - react_native_dep("android_res/com/facebook/catalyst/appcompat:appcompat"), react_native_dep("libraries/fresco/fresco-react-native:fbcore"), react_native_dep("libraries/fresco/fresco-react-native:fresco-drawee"), react_native_dep("libraries/fresco/fresco-react-native:fresco-react-native"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/ReactToolbarManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/ReactToolbarManager.java index b37040a22..6521544d5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/ReactToolbarManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/toolbar/ReactToolbarManager.java @@ -9,10 +9,6 @@ package com.facebook.react.views.toolbar; -import javax.annotation.Nullable; - -import java.util.Map; - import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; @@ -20,8 +16,6 @@ import android.graphics.Color; import android.util.LayoutDirection; import android.view.MenuItem; import android.view.View; - -import com.facebook.react.R; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.common.MapBuilder; @@ -32,6 +26,8 @@ import com.facebook.react.uimanager.ViewGroupManager; import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.views.toolbar.events.ToolbarClickEvent; +import java.util.Map; +import javax.annotation.Nullable; /** * Manages instances of ReactToolbar. @@ -169,15 +165,17 @@ public class ReactToolbarManager extends ViewGroupManager { TypedArray contentInsets = null; try { - toolbarStyle = theme - .obtainStyledAttributes(new int[]{R.attr.toolbarStyle}); + toolbarStyle = + theme.obtainStyledAttributes(new int[] {getIdentifier(context, "toolbarStyle")}); int toolbarStyleResId = toolbarStyle.getResourceId(0, 0); - contentInsets = theme.obtainStyledAttributes( - toolbarStyleResId, new int[]{ - R.attr.contentInsetStart, - R.attr.contentInsetEnd, + contentInsets = + theme.obtainStyledAttributes( + toolbarStyleResId, + new int[] { + getIdentifier(context, "contentInsetStart"), + getIdentifier(context, "contentInsetEnd"), }); int contentInsetStart = contentInsets.getDimensionPixelSize(0, 0); @@ -199,14 +197,18 @@ public class ReactToolbarManager extends ViewGroupManager { TypedArray subtitleTextAppearance = null; try { - toolbarStyle = theme - .obtainStyledAttributes(new int[]{R.attr.toolbarStyle}); + toolbarStyle = + theme.obtainStyledAttributes(new int[] {getIdentifier(context, "toolbarStyle")}); + int toolbarStyleResId = toolbarStyle.getResourceId(0, 0); - textAppearances = theme.obtainStyledAttributes( - toolbarStyleResId, new int[]{ - R.attr.titleTextAppearance, - R.attr.subtitleTextAppearance, - }); + textAppearances = + theme.obtainStyledAttributes( + toolbarStyleResId, + new int[] { + getIdentifier(context, "titleTextAppearance"), + getIdentifier(context, "subtitleTextAppearance"), + }); + int titleTextAppearanceResId = textAppearances.getResourceId(0, 0); int subtitleTextAppearanceResId = textAppearances.getResourceId(1, 0); @@ -233,4 +235,13 @@ public class ReactToolbarManager extends ViewGroupManager { } } + /** + * The appcompat-v7 BUCK dep is listed as a provided_dep, which complains that + * com.facebook.react.R doesn't exist. Since the attributes provided from a parent, we can access + * those attributes dynamically. + */ + private static int getIdentifier(Context context, String name) { + return context.getResources().getIdentifier(name, "attr", context.getPackageName()); + } + }