Remove appcompat dep from react/views/toolbar
Reviewed By: AaaChiuuu Differential Revision: D5651764 fbshipit-source-id: c8cf730bf2086d205a43a535f3f12ae2af0caa5f
This commit is contained in:
parent
73f17908e6
commit
c3b47e5523
|
@ -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"),
|
||||
|
|
|
@ -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<ReactToolbar> {
|
|||
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<ReactToolbar> {
|
|||
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<ReactToolbar> {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue