Skip to content

Commit

Permalink
Mark classes of package views as @nullsafe (facebook#42858)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#42858

All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

changelog: [internal] internal

Reviewed By: cortinico, rshest

Differential Revision: D53393471

fbshipit-source-id: 3f896f7d7c51f276a3f743d39dc851cb47ca538a
  • Loading branch information
mdvacca authored and facebook-github-bot committed Feb 12, 2024
1 parent 710ff5f commit 7098d34
Show file tree
Hide file tree
Showing 43 changed files with 94 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import android.content.Context;
import android.content.ContextWrapper;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;

/**
* Class containing static methods involving manipulations of Contexts and their related subclasses.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ContextUtils {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.R;

/** Class containing static methods involving manipulations of Views */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ViewUtils {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
import android.graphics.RectF;
import android.view.View;
import androidx.annotation.UiThread;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.UiThreadUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class DebuggingOverlay extends View {

private final Paint mTraceUpdatePaint = new Paint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import android.graphics.RectF;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.NoSuchKeyException;
import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
Expand All @@ -22,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;

@Nullsafe(Nullsafe.Mode.LOCAL)
@ReactModule(name = DebuggingOverlayManager.REACT_CLASS)
public class DebuggingOverlayManager extends SimpleViewManager<DebuggingOverlay> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
package com.facebook.react.views.debuggingoverlay;

import android.graphics.RectF;
import com.facebook.infer.annotation.Nullsafe;

@Nullsafe(Nullsafe.Mode.LOCAL)
public final class TraceUpdate {

private final int mId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.R;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.ReactConstants;
Expand All @@ -26,7 +27,8 @@
* Wrapper view for {@link DrawerLayout}. It manages the properties that can be set on the drawer
* and contains some ReactNative-specific functionality.
*/
/* package */ class ReactDrawerLayout extends DrawerLayout {
/* package */ @Nullsafe(Nullsafe.Mode.LOCAL)
class ReactDrawerLayout extends DrawerLayout {

public static final int DEFAULT_DRAWER_WIDTH = LayoutParams.MATCH_PARENT;
private int mDrawerPosition = Gravity.START;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import androidx.annotation.Nullable;
import androidx.drawerlayout.widget.DrawerLayout;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableArray;
Expand All @@ -37,6 +38,7 @@
import java.util.Map;

/** View Manager for {@link ReactDrawerLayout} components. */
@Nullsafe(Nullsafe.Mode.LOCAL)
@ReactModule(name = ReactDrawerLayoutManager.REACT_CLASS)
public class ReactDrawerLayoutManager extends ViewGroupManager<ReactDrawerLayout>
implements AndroidDrawerLayoutManagerInterface<ReactDrawerLayout> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

package com.facebook.react.views.drawer.events;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class DrawerClosedEvent extends Event<DrawerClosedEvent> {

public static final String EVENT_NAME = "topDrawerClose";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

package com.facebook.react.views.drawer.events;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class DrawerOpenedEvent extends Event<DrawerOpenedEvent> {

public static final String EVENT_NAME = "topDrawerOpen";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

package com.facebook.react.views.drawer.events;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;

/** Event emitted by a DrawerLayout as it is being moved open/closed. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class DrawerSlideEvent extends Event<DrawerSlideEvent> {

public static final String EVENT_NAME = "topDrawerSlide";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

package com.facebook.react.views.drawer.events;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class DrawerStateChangedEvent extends Event<DrawerStateChangedEvent> {

public static final String EVENT_NAME = "topDrawerStateChanged";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Nullsafe(Nullsafe.Mode.LOCAL)
public class ImageLoadEvent extends Event<ImageLoadEvent> {
@IntDef({ON_ERROR, ON_LOAD, ON_LOAD_END, ON_LOAD_START, ON_PROGRESS})
@Retention(RetentionPolicy.SOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

package com.facebook.react.views.image;

import com.facebook.infer.annotation.Nullsafe;

@Nullsafe(Nullsafe.Mode.LOCAL)
public enum ImageResizeMethod {
AUTO,
RESIZE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.common.ReactConstants;

/** Converts JS resize modes into Android-specific scale type. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ImageResizeMode {

private static final String RESIZE_MODE_CONTAIN = "contain";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import android.graphics.drawable.Drawable;
import com.facebook.drawee.controller.ControllerListener;
import com.facebook.drawee.drawable.ForwardingDrawable;
import com.facebook.infer.annotation.Nullsafe;
import javax.annotation.Nullable;

@Nullsafe(Nullsafe.Mode.LOCAL)
class ReactImageDownloadListener<INFO> extends ForwardingDrawable
implements ControllerListener<INFO> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import android.graphics.Matrix;
import android.graphics.Rect;
import com.facebook.drawee.drawable.ScalingUtils;
import com.facebook.infer.annotation.Nullsafe;

@Nullsafe(Nullsafe.Mode.LOCAL)
class ScaleTypeStartInside extends ScalingUtils.AbstractScaleType {
public static final ScalingUtils.ScaleType INSTANCE = new ScaleTypeStartInside();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
import androidx.annotation.Nullable;
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.core.ImagePipelineFactory;
import com.facebook.infer.annotation.Nullsafe;
import java.util.List;

/** Helper class for dealing with multisource images. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class MultiSourceHelper {

public static class MultiSourceResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import javax.annotation.concurrent.ThreadSafe;

/** Helper class for obtaining information about local images. */
@Nullsafe(Nullsafe.Mode.LOCAL)
@ThreadSafe
public class ResourceDrawableIdHelper {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import android.view.Display;
import android.view.WindowManager;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;

/** Helper class for Modals. */
/*package*/ class ModalHostHelper {
/*package*/ @Nullsafe(Nullsafe.Mode.LOCAL)
class ModalHostHelper {

private static final Point MIN_POINT = new Point();
private static final Point MAX_POINT = new Point();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.facebook.react.views.modal;

import android.graphics.Point;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.ReactShadowNodeImpl;

Expand All @@ -19,6 +20,7 @@
* to be the window size. This will then cause the children of the Modal to layout as if they can
* fill the window.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
class ModalHostShadowNode extends LayoutShadowNode {

public ModalHostShadowNode() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
package com.facebook.react.views.modal;

import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;

/** {@link Event} for dismissing a Dialog. */
/* package */ class RequestCloseEvent extends Event<RequestCloseEvent> {
/* package */ @Nullsafe(Nullsafe.Mode.LOCAL)
class RequestCloseEvent extends Event<RequestCloseEvent> {

public static final String EVENT_NAME = "topRequestClose";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
package com.facebook.react.views.modal;

import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.uimanager.common.ViewUtil;
import com.facebook.react.uimanager.events.Event;

/** {@link Event} for showing a Dialog. */
/* package */ class ShowEvent extends Event<ShowEvent> {
/* package */ @Nullsafe(Nullsafe.Mode.LOCAL)
class ShowEvent extends Event<ShowEvent> {

public static final String EVENT_NAME = "topShow";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;

/**
* Controls an enclosing ProgressBar. Exists so that the ProgressBar can be recreated if the style
* would change.
*/
/* package */ class ProgressBarContainerView extends FrameLayout {
/* package */ @Nullsafe(Nullsafe.Mode.LOCAL)
class ProgressBarContainerView extends FrameLayout {
private static final int MAX_PROGRESS = 1000;

private @Nullable Integer mColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.view.ViewGroup;
import android.widget.ProgressBar;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.yoga.YogaMeasureFunction;
Expand All @@ -26,6 +27,7 @@
* android.R.attr.progressBarStyle} for possible styles. ReactProgressBarViewManager manages how
* this style is applied to the ProgressBar.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ProgressBarShadowNode extends LayoutShadowNode implements YogaMeasureFunction {

private String mStyle = ReactProgressBarViewManager.DEFAULT_STYLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import android.widget.ProgressBar;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.module.annotations.ReactModule;
Expand All @@ -35,6 +36,7 @@
* ProgressBar changes, we have to drop the existing ProgressBar (if there is one) and create a new
* one with the style given.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@ReactModule(name = ReactProgressBarViewManager.REACT_CLASS)
public class ReactProgressBarViewManager
extends BaseViewManager<ProgressBarContainerView, ProgressBarShadowNode>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UIManager;
Expand All @@ -30,6 +31,7 @@
* <p>This uses UIManager to listen to updates and capture position of items before and after
* layout.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
class MaintainVisibleScrollPositionHelper<ScrollViewT extends ViewGroup & HasSmoothScroll>
implements UIManagerListener {
private final ScrollViewT mScrollView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
package com.facebook.react.views.scroll;

import android.os.SystemClock;
import com.facebook.infer.annotation.Nullsafe;

/**
* Android has a bug where onScrollChanged is called twice per frame with the same params during
* flings. We hack around that here by trying to detect that duplicate call and not dispatch it. See
* https://code.google.com/p/android/issues/detail?id=39473
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class OnScrollDispatchHelper {

private static final int MIN_EVENT_SEPARATION_MS = 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@

import android.content.Context;
import androidx.core.view.ViewCompat;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.views.view.ReactViewGroup;

/** Container of Horizontal scrollViews that supports RTL scrolling. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ReactHorizontalScrollContainerView extends ReactViewGroup {

private int mLayoutDirection;
Expand Down
Loading

0 comments on commit 7098d34

Please sign in to comment.