Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.Canvas;
import android.graphics.Insets;
import android.graphics.Point;
Expand Down Expand Up @@ -917,12 +915,18 @@ public void onGlobalLayout() {
checkForDeviceDimensionsChanges();
}

private Activity getActivity() {
Context context = getContext();
while (!(context instanceof Activity) && context instanceof ContextWrapper) {
context = ((ContextWrapper) context).getBaseContext();
private @Nullable WindowManager.LayoutParams getWindowLayoutParams() {
View view = ReactRootView.this;
if (view.getLayoutParams() instanceof WindowManager.LayoutParams) {
return (WindowManager.LayoutParams) view.getLayoutParams();
}
return (Activity) context;
while (view.getParent() instanceof View) {
view = (View) view.getParent();
if (view.getLayoutParams() instanceof WindowManager.LayoutParams) {
return (WindowManager.LayoutParams) view.getLayoutParams();
}
}
return null;
}

@RequiresApi(api = Build.VERSION_CODES.R)
Expand All @@ -942,7 +946,13 @@ private void checkForKeyboardEvents() {
Insets barInsets = rootInsets.getInsets(WindowInsets.Type.systemBars());
int height = imeInsets.bottom - barInsets.bottom;

int softInputMode = getActivity().getWindow().getAttributes().softInputMode;
int softInputMode;
WindowManager.LayoutParams windowLayoutParams = getWindowLayoutParams();
if (windowLayoutParams != null) {
softInputMode = windowLayoutParams.softInputMode;
} else {
return;
}
int screenY =
softInputMode == WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING
? mVisibleViewArea.bottom - height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ public ColorPropSetter(ReactProp prop, Method setter, int defaultValue) {
mDefaultValue = defaultValue;
}

public ColorPropSetter(ReactPropGroup prop, Method setter, int index, int defaultValue) {
super(prop, "mixed", setter, index);
mDefaultValue = defaultValue;
}

@Override
protected Object getValueOrDefault(Object value, Context context) {
if (value == null) {
Expand Down Expand Up @@ -331,6 +336,10 @@ public BoxedColorPropSetter(ReactProp prop, Method setter) {
super(prop, "mixed", setter);
}

public BoxedColorPropSetter(ReactPropGroup prop, Method setter, int index) {
super(prop, "mixed", setter, index);
}

@Override
protected @Nullable Object getValueOrDefault(Object value, Context context) {
if (value != null) {
Expand Down Expand Up @@ -463,7 +472,11 @@ private static void createPropSetters(
}
} else if (propTypeClass == int.class) {
for (int i = 0; i < names.length; i++) {
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
if ("Color".equals(annotation.customType())) {
props.put(names[i], new ColorPropSetter(annotation, method, i, annotation.defaultInt()));
} else {
props.put(names[i], new IntPropSetter(annotation, method, i, annotation.defaultInt()));
}
}
} else if (propTypeClass == float.class) {
for (int i = 0; i < names.length; i++) {
Expand All @@ -476,7 +489,11 @@ private static void createPropSetters(
}
} else if (propTypeClass == Integer.class) {
for (int i = 0; i < names.length; i++) {
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
if ("Color".equals(annotation.customType())) {
props.put(names[i], new BoxedColorPropSetter(annotation, method, i));
} else {
props.put(names[i], new BoxedIntPropSetter(annotation, method, i));
}
}
} else {
throw new RuntimeException(
Expand Down
Loading