mirror of
https://github.com/status-im/react-native.git
synced 2025-02-21 13:48:13 +00:00
Backed out changeset 708058c5f244
Reviewed By: dmmiller Differential Revision: D3496881 fbshipit-source-id: 0f2e0d5769d09e0c70feceda7ff7d959e3a9ef2e
This commit is contained in:
parent
cbd8214b43
commit
f0f2645ec7
@ -9,7 +9,6 @@ DEPS = [
|
|||||||
react_native_target('java/com/facebook/react/modules/debug:debug'),
|
react_native_target('java/com/facebook/react/modules/debug:debug'),
|
||||||
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
|
react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'),
|
||||||
react_native_target('java/com/facebook/react/modules/toast:toast'),
|
react_native_target('java/com/facebook/react/modules/toast:toast'),
|
||||||
react_native_target('java/com/facebook/react/views/imagehelper:imagehelper'),
|
|
||||||
react_native_target('java/com/facebook/react/uimanager:uimanager'),
|
react_native_target('java/com/facebook/react/uimanager:uimanager'),
|
||||||
react_native_dep('java/com/facebook/systrace:systrace'),
|
react_native_dep('java/com/facebook/systrace:systrace'),
|
||||||
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
|
react_native_dep('libraries/fbcore/src/main/java/com/facebook/common/logging:logging'),
|
||||||
|
@ -61,7 +61,6 @@ import com.facebook.react.devsupport.ReactInstanceDevCommandsHandler;
|
|||||||
import com.facebook.react.devsupport.RedBoxHandler;
|
import com.facebook.react.devsupport.RedBoxHandler;
|
||||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||||
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
|
||||||
import com.facebook.react.uimanager.AppRegistry;
|
import com.facebook.react.uimanager.AppRegistry;
|
||||||
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
||||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||||
@ -563,8 +562,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.RUN_JS_BUNDLE_START
|
|||||||
mHasStartedCreatingInitialContext = false;
|
mHasStartedCreatingInitialContext = false;
|
||||||
}
|
}
|
||||||
mCurrentActivity = null;
|
mCurrentActivity = null;
|
||||||
|
|
||||||
ResourceDrawableIdHelper.getInstance().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveToResumedLifecycleState(boolean force) {
|
private void moveToResumedLifecycleState(boolean force) {
|
||||||
|
@ -63,7 +63,6 @@ import com.facebook.react.devsupport.RedBoxHandler;
|
|||||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
||||||
import com.facebook.react.modules.debug.DeveloperSettings;
|
import com.facebook.react.modules.debug.DeveloperSettings;
|
||||||
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
|
||||||
import com.facebook.react.uimanager.AppRegistry;
|
import com.facebook.react.uimanager.AppRegistry;
|
||||||
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
||||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||||
@ -548,8 +547,6 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
|||||||
mHasStartedCreatingInitialContext = false;
|
mHasStartedCreatingInitialContext = false;
|
||||||
}
|
}
|
||||||
mCurrentActivity = null;
|
mCurrentActivity = null;
|
||||||
|
|
||||||
ResourceDrawableIdHelper.getInstance().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveToResumedLifecycleState(boolean force) {
|
private void moveToResumedLifecycleState(boolean force) {
|
||||||
|
@ -9,7 +9,6 @@ android_library(
|
|||||||
react_native_target('java/com/facebook/csslayout:csslayout'),
|
react_native_target('java/com/facebook/csslayout:csslayout'),
|
||||||
react_native_target('java/com/facebook/react/uimanager:uimanager'),
|
react_native_target('java/com/facebook/react/uimanager:uimanager'),
|
||||||
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
|
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
|
||||||
react_native_target('java/com/facebook/react/views/imagehelper:imagehelper'),
|
|
||||||
react_native_dep('libraries/fresco/fresco-react-native:fbcore'),
|
react_native_dep('libraries/fresco/fresco-react-native:fbcore'),
|
||||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-react-native'),
|
react_native_dep('libraries/fresco/fresco-react-native:fresco-react-native'),
|
||||||
react_native_dep('libraries/fresco/fresco-react-native:fresco-drawee'),
|
react_native_dep('libraries/fresco/fresco-react-native:fresco-drawee'),
|
||||||
|
@ -37,6 +37,7 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
|
|||||||
return REACT_CLASS;
|
return REACT_CLASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResourceDrawableIdHelper mResourceDrawableIdHelper;
|
||||||
private @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
|
private @Nullable AbstractDraweeControllerBuilder mDraweeControllerBuilder;
|
||||||
private final @Nullable Object mCallerContext;
|
private final @Nullable Object mCallerContext;
|
||||||
|
|
||||||
@ -45,12 +46,14 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
|
|||||||
Object callerContext) {
|
Object callerContext) {
|
||||||
mDraweeControllerBuilder = draweeControllerBuilder;
|
mDraweeControllerBuilder = draweeControllerBuilder;
|
||||||
mCallerContext = callerContext;
|
mCallerContext = callerContext;
|
||||||
|
mResourceDrawableIdHelper = new ResourceDrawableIdHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReactImageManager() {
|
public ReactImageManager() {
|
||||||
// Lazily initialize as FrescoModule have not been initialized yet
|
// Lazily initialize as FrescoModule have not been initialized yet
|
||||||
mDraweeControllerBuilder = null;
|
mDraweeControllerBuilder = null;
|
||||||
mCallerContext = null;
|
mCallerContext = null;
|
||||||
|
mResourceDrawableIdHelper = new ResourceDrawableIdHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractDraweeControllerBuilder getDraweeControllerBuilder() {
|
public AbstractDraweeControllerBuilder getDraweeControllerBuilder() {
|
||||||
@ -69,7 +72,8 @@ public class ReactImageManager extends SimpleViewManager<ReactImageView> {
|
|||||||
return new ReactImageView(
|
return new ReactImageView(
|
||||||
context,
|
context,
|
||||||
getDraweeControllerBuilder(),
|
getDraweeControllerBuilder(),
|
||||||
getCallerContext());
|
getCallerContext(),
|
||||||
|
mResourceDrawableIdHelper);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In JS this is Image.props.source
|
// In JS this is Image.props.source
|
||||||
|
@ -59,7 +59,6 @@ import com.facebook.react.common.SystemClock;
|
|||||||
import com.facebook.react.uimanager.PixelUtil;
|
import com.facebook.react.uimanager.PixelUtil;
|
||||||
import com.facebook.react.uimanager.UIManagerModule;
|
import com.facebook.react.uimanager.UIManagerModule;
|
||||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||||
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class around Fresco's GenericDraweeView, enabling persisting props across multiple view
|
* Wrapper class around Fresco's GenericDraweeView, enabling persisting props across multiple view
|
||||||
@ -191,7 +190,7 @@ public class ReactImageView extends GenericDraweeView {
|
|||||||
// ignore malformed uri, then attempt to extract resource ID.
|
// ignore malformed uri, then attempt to extract resource ID.
|
||||||
}
|
}
|
||||||
if (mUri == null) {
|
if (mUri == null) {
|
||||||
mUri = ResourceDrawableIdHelper.getInstance().getResourceDrawableUri(getContext(), mSource);
|
mUri = mResourceDrawableIdHelper.getResourceDrawableUri(getContext(), mSource);
|
||||||
mIsLocalImage = true;
|
mIsLocalImage = true;
|
||||||
} else {
|
} else {
|
||||||
mIsLocalImage = false;
|
mIsLocalImage = false;
|
||||||
@ -199,6 +198,7 @@ public class ReactImageView extends GenericDraweeView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final ResourceDrawableIdHelper mResourceDrawableIdHelper;
|
||||||
private final List<ImageSource> mSources;
|
private final List<ImageSource> mSources;
|
||||||
|
|
||||||
private @Nullable ImageSource mImageSource;
|
private @Nullable ImageSource mImageSource;
|
||||||
@ -229,12 +229,14 @@ public class ReactImageView extends GenericDraweeView {
|
|||||||
public ReactImageView(
|
public ReactImageView(
|
||||||
Context context,
|
Context context,
|
||||||
AbstractDraweeControllerBuilder draweeControllerBuilder,
|
AbstractDraweeControllerBuilder draweeControllerBuilder,
|
||||||
@Nullable Object callerContext) {
|
@Nullable Object callerContext,
|
||||||
|
ResourceDrawableIdHelper resourceDrawableIdHelper) {
|
||||||
super(context, buildHierarchy(context));
|
super(context, buildHierarchy(context));
|
||||||
mScaleType = ImageResizeMode.defaultValue();
|
mScaleType = ImageResizeMode.defaultValue();
|
||||||
mDraweeControllerBuilder = draweeControllerBuilder;
|
mDraweeControllerBuilder = draweeControllerBuilder;
|
||||||
mRoundedCornerPostprocessor = new RoundedCornerPostprocessor();
|
mRoundedCornerPostprocessor = new RoundedCornerPostprocessor();
|
||||||
mCallerContext = callerContext;
|
mCallerContext = callerContext;
|
||||||
|
mResourceDrawableIdHelper = resourceDrawableIdHelper;
|
||||||
mSources = new LinkedList<>();
|
mSources = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -342,7 +344,7 @@ public class ReactImageView extends GenericDraweeView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLoadingIndicatorSource(@Nullable String name) {
|
public void setLoadingIndicatorSource(@Nullable String name) {
|
||||||
Drawable drawable = ResourceDrawableIdHelper.getInstance().getResourceDrawable(getContext(), name);
|
Drawable drawable = mResourceDrawableIdHelper.getResourceDrawable(getContext(), name);
|
||||||
mLoadingImageDrawable =
|
mLoadingImageDrawable =
|
||||||
drawable != null ? (Drawable) new AutoRotateDrawable(drawable, 1000) : null;
|
drawable != null ? (Drawable) new AutoRotateDrawable(drawable, 1000) : null;
|
||||||
mIsDirty = true;
|
mIsDirty = true;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Copyright 2004-present Facebook. All Rights Reserved.
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||||
|
|
||||||
package com.facebook.react.views.imagehelper;
|
package com.facebook.react.views.image;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -11,31 +11,19 @@ import android.content.Context;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import com.facebook.common.util.UriUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class for obtaining information about local images.
|
* Helper class for obtaining information about local images.
|
||||||
*/
|
*/
|
||||||
public class ResourceDrawableIdHelper {
|
/* package */ class ResourceDrawableIdHelper {
|
||||||
|
|
||||||
private Map<String, Integer> mResourceDrawableIdMap;
|
private Map<String, Integer> mResourceDrawableIdMap;
|
||||||
|
|
||||||
private static final String LOCAL_RESOURCE_SCHEME = "res";
|
public ResourceDrawableIdHelper() {
|
||||||
private static ResourceDrawableIdHelper sResourceDrawableIdHelper;
|
|
||||||
|
|
||||||
private ResourceDrawableIdHelper() {
|
|
||||||
mResourceDrawableIdMap = new HashMap<String, Integer>();
|
mResourceDrawableIdMap = new HashMap<String, Integer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResourceDrawableIdHelper getInstance() {
|
|
||||||
if (sResourceDrawableIdHelper == null) {
|
|
||||||
sResourceDrawableIdHelper = new ResourceDrawableIdHelper();
|
|
||||||
}
|
|
||||||
return sResourceDrawableIdHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
mResourceDrawableIdMap.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getResourceDrawableId(Context context, @Nullable String name) {
|
public int getResourceDrawableId(Context context, @Nullable String name) {
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -60,7 +48,7 @@ public class ResourceDrawableIdHelper {
|
|||||||
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
|
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
|
||||||
int resId = getResourceDrawableId(context, name);
|
int resId = getResourceDrawableId(context, name);
|
||||||
return resId > 0 ? new Uri.Builder()
|
return resId > 0 ? new Uri.Builder()
|
||||||
.scheme(LOCAL_RESOURCE_SCHEME)
|
.scheme(UriUtil.LOCAL_RESOURCE_SCHEME)
|
||||||
.path(String.valueOf(resId))
|
.path(String.valueOf(resId))
|
||||||
.build() : Uri.EMPTY;
|
.build() : Uri.EMPTY;
|
||||||
}
|
}
|
@ -1,17 +0,0 @@
|
|||||||
include_defs('//ReactAndroid/DEFS')
|
|
||||||
|
|
||||||
android_library(
|
|
||||||
name = 'imagehelper',
|
|
||||||
srcs = glob(['*.java']),
|
|
||||||
deps = [
|
|
||||||
react_native_dep('third-party/java/infer-annotations:infer-annotations'),
|
|
||||||
react_native_dep('third-party/java/jsr-305:jsr-305'),
|
|
||||||
],
|
|
||||||
visibility = [
|
|
||||||
'PUBLIC',
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
project_config(
|
|
||||||
src_target = ':imagehelper',
|
|
||||||
)
|
|
@ -12,7 +12,6 @@ android_library(
|
|||||||
react_native_target('java/com/facebook/react/modules/core:core'),
|
react_native_target('java/com/facebook/react/modules/core:core'),
|
||||||
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
|
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
|
||||||
react_native_target('java/com/facebook/react/uimanager:uimanager'),
|
react_native_target('java/com/facebook/react/uimanager:uimanager'),
|
||||||
react_native_target('java/com/facebook/react/views/imagehelper:imagehelper'),
|
|
||||||
react_native_target('java/com/facebook/react/views/text:text'),
|
react_native_target('java/com/facebook/react/views/text:text'),
|
||||||
react_native_target('java/com/facebook/react/views/view:view'),
|
react_native_target('java/com/facebook/react/views/view:view'),
|
||||||
],
|
],
|
||||||
|
@ -43,7 +43,6 @@ import com.facebook.react.uimanager.ViewDefaults;
|
|||||||
import com.facebook.react.uimanager.ViewProps;
|
import com.facebook.react.uimanager.ViewProps;
|
||||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||||
import com.facebook.react.uimanager.events.EventDispatcher;
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
||||||
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
|
|
||||||
import com.facebook.react.views.text.DefaultStyleValuesUtil;
|
import com.facebook.react.views.text.DefaultStyleValuesUtil;
|
||||||
import com.facebook.react.views.text.ReactTextUpdate;
|
import com.facebook.react.views.text.ReactTextUpdate;
|
||||||
import com.facebook.react.views.text.TextInlineImageSpan;
|
import com.facebook.react.views.text.TextInlineImageSpan;
|
||||||
@ -326,7 +325,8 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
|||||||
|
|
||||||
@ReactProp(name = "inlineImageLeft")
|
@ReactProp(name = "inlineImageLeft")
|
||||||
public void setInlineImageLeft(ReactEditText view, @Nullable String resource) {
|
public void setInlineImageLeft(ReactEditText view, @Nullable String resource) {
|
||||||
int id = ResourceDrawableIdHelper.getInstance().getResourceDrawableId(view.getContext(), resource);
|
// TODO: t11992069 fix this after `ResourceDrawableIdHelper` gets fixed
|
||||||
|
int id = 0;//ResourceDrawableIdHelper.getInstance().getResourceDrawableId(view.getContext(), resource);
|
||||||
view.setCompoundDrawablesWithIntrinsicBounds(id, 0, 0, 0);
|
view.setCompoundDrawablesWithIntrinsicBounds(id, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user