diff --git a/android/build.gradle b/android/build.gradle index db952374e..a008e17d7 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -72,6 +72,7 @@ android { } else { java.srcDirs += 'src/main/mapbox-v11-compat/v10' } + java.srcDirs += 'src/main/rn-compat/rn75' if (safeExtGet("RNMapboxMapsUseV11", false)) { logger.warn("RNMapboxMapsUseV11 is deprecated, just set RNMapboxMapsVersion to 11.*") } @@ -164,9 +165,9 @@ dependencies { // Dependencies customizableDependencies('RNMapboxMapsSupportLibs') { - implementation "com.android.support:support-vector-drawable:28.0.0" + //implementation "com.android.support:support-vector-drawable:28.0.0" implementation "com.android.support:support-annotations:28.0.0" - implementation "com.android.support:appcompat-v7:28.0.0" + //implementation "com.android.support:appcompat-v7:28.0.0" } customizableDependencies('RNMapboxMapsOkHTTPLibs') { implementation "com.squareup.okhttp3:okhttp:4.9.0" diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt index 09728867e..9523702b7 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/camera/RNMBXCameraManager.kt @@ -13,6 +13,7 @@ import com.rnmapbox.rnmbx.utils.ViewTagResolver import com.rnmapbox.rnmbx.utils.extensions.asBooleanOrNull import com.rnmapbox.rnmbx.utils.extensions.asDoubleOrNull import com.rnmapbox.rnmbx.utils.extensions.asStringOrNull +import com.rnmapbox.rnmbx.rncompat.dynamic.* class RNMBXCameraManager(private val mContext: ReactApplicationContext, val viewTagResolver: ViewTagResolver) : AbstractEventEmitter( diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt index 67c865631..a9e2b683c 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImagesManager.kt @@ -15,6 +15,7 @@ import com.mapbox.maps.ImageStretches import com.rnmapbox.rnmbx.components.AbstractEventEmitter import com.rnmapbox.rnmbx.events.constants.EventKeys import com.rnmapbox.rnmbx.events.constants.eventMapOf +import com.rnmapbox.rnmbx.rncompat.dynamic.* import com.rnmapbox.rnmbx.utils.ImageEntry import com.rnmapbox.rnmbx.utils.Logger import com.rnmapbox.rnmbx.utils.ResourceUtils @@ -202,15 +203,13 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) : images.setNativeImages(nativeImages) } - override fun customEvents(): Map? { - return eventMapOf( + override fun customEvents(): Map? { return eventMapOf( EventKeys.IMAGES_MISSING to "onImageMissing" ) } // region RNMBXImage children - - override fun addView(parent: RNMBXImages?, childView: View?, childPosition: Int) { + override fun addView(parent: RNMBXImages, childView: View, childPosition: Int) { if (parent == null || childView == null) { Logger.e("RNMBXImages", "addView: parent or childView is null") return @@ -225,7 +224,7 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) : childView.nativeImageUpdater = parent } - override fun removeView(parent: RNMBXImages?, view: View?) { + override fun removeView(parent: RNMBXImages, view: View) { if (parent == null || view == null) { Logger.e("RNMBXImages", "removeView: parent or view is null") return @@ -234,7 +233,7 @@ class RNMBXImagesManager(private val mContext: ReactApplicationContext) : parent.mImageViews.remove(view) } - override fun removeAllViews(parent: RNMBXImages?) { + override fun removeAllViews(parent: RNMBXImages) { if (parent == null) { Logger.e("RNMBXImages", "removeAllViews parent is null") return diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt index 5ff144b10..67145d1c2 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXCustomLocationProviderManager.kt @@ -6,8 +6,10 @@ import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewGroupManager import com.facebook.react.uimanager.annotations.ReactProp import com.facebook.react.viewmanagers.RNMBXCustomLocationProviderManagerInterface +import com.rnmapbox.rnmbx.rncompat.dynamic.* import com.rnmapbox.rnmbx.utils.Logger + class RNMBXCustomLocationProviderManager : ViewGroupManager(), RNMBXCustomLocationProviderManagerInterface { override fun getName(): String { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt index 26fba5c49..2869ce62a 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt @@ -11,6 +11,7 @@ import com.google.gson.Gson import com.google.gson.stream.JsonWriter import com.mapbox.bindgen.Value import com.mapbox.maps.extension.style.expressions.generated.Expression +import com.rnmapbox.rnmbx.rncompat.dynamic.* import com.rnmapbox.rnmbx.utils.Logger import com.rnmapbox.rnmbx.utils.extensions.toJsonArray import java.io.StringWriter diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt index ef529ef14..27253a567 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt @@ -143,22 +143,22 @@ class NativeMapViewModule(context: ReactApplicationContext, val viewTagResolver: override fun setHandledMapChangedEvents( viewRef: ViewRefTag?, - events: ReadableArray, - promise: Promise + events: ReadableArray?, + promise: Promise? ) { - withMapViewOnUIThread(viewRef, promise) { - it.setHandledMapChangedEvents(events.asArrayString()) + withMapViewOnUIThread(viewRef, promise!!) { + it.setHandledMapChangedEvents(events!!.asArrayString()) promise.resolve(null) } } - +/* public fun setHandledMapChangedEvents( viewRef: Double?, events: ReadableArray, - promise: Promise + promise: Promise? ) { setHandledMapChangedEvents(viewRef?.toInt(), events, promise) - } + } */ override fun clearData(viewRef: ViewRefTag?, promise: Promise) { withMapViewOnUIThread(viewRef, promise) { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt index 98febe73a..860128694 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt @@ -86,19 +86,19 @@ open class RNMBXMapViewManager(context: ReactApplicationContext, val viewTagReso } } - override fun addView(mapView: RNMBXMapView?, childView: View?, childPosition: Int) { + override fun addView(mapView: RNMBXMapView, childView: View, childPosition: Int) { mapView!!.addFeature(childView, childPosition) } - override fun getChildCount(mapView: RNMBXMapView?): Int { + override fun getChildCount(mapView: RNMBXMapView): Int { return mapView!!.featureCount } - override fun getChildAt(mapView: RNMBXMapView?, index: Int): View? { + override fun getChildAt(mapView: RNMBXMapView, index: Int): View? { return mapView!!.getFeatureAt(index) } - override fun removeViewAt(mapView: RNMBXMapView?, index: Int) { + override fun removeViewAt(mapView: RNMBXMapView, index: Int) { mapView!!.removeFeatureAt(index) } diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleImportManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleImportManager.kt index 833997fd2..fafc00bef 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleImportManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleImportManager.kt @@ -11,6 +11,7 @@ import com.facebook.react.viewmanagers.RNMBXStyleImportManagerInterface import com.rnmapbox.rnmbx.components.AbstractEventEmitter import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView import com.mapbox.bindgen.Value +import com.rnmapbox.rnmbx.rncompat.dynamic.* import com.rnmapbox.rnmbx.utils.Logger import com.rnmapbox.rnmbx.utils.extensions.toValueHashMap import org.json.JSONObject diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValue.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValue.kt index e886cc763..db13128f3 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValue.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleValue.kt @@ -8,6 +8,7 @@ import com.mapbox.maps.extension.style.types.StyleTransition import com.rnmapbox.rnmbx.components.styles.RNMBXStyleFactory import com.mapbox.maps.extension.style.expressions.generated.Expression import com.mapbox.maps.extension.style.light.LightPosition +import com.rnmapbox.rnmbx.rncompat.dynamic.* import com.rnmapbox.rnmbx.utils.ExpressionParser import com.rnmapbox.rnmbx.utils.Logger import java.util.ArrayList diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXImageSource.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXImageSource.kt index be2207289..16a455d80 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXImageSource.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXImageSource.kt @@ -5,6 +5,7 @@ import android.net.Uri import android.util.Log import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper import com.mapbox.maps.extension.style.sources.generated.ImageSource +import com.rnmapbox.rnmbx.rncompat.resourcedrawableidhelper.* import com.rnmapbox.rnmbx.utils.LatLngQuad import java.net.URL @@ -66,4 +67,5 @@ class RNMBXImageSource(context: Context?) : RNMBXSource(context) { companion object { const val LOG_TAG = "RNMBXImageSource" } -} \ No newline at end of file +} + diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXShapeSourceModule.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXShapeSourceModule.kt index 63984974e..03c18298c 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXShapeSourceModule.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXShapeSourceModule.kt @@ -44,8 +44,8 @@ class RNMBXShapeSourceModule(reactContext: ReactApplicationContext?, private val override fun getClusterLeaves( viewRef: ViewRefTag?, featureJSON: String, - number: Int, - offset: Int, + number: Double, + offset: Double, promise: Promise ) { withShapeSourceOnUIThread(viewRef, promise) { diff --git a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt index 767d27b5c..e18cbcfc0 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXTileSourceManager.kt @@ -10,19 +10,19 @@ import com.rnmapbox.rnmbx.components.AbstractEventEmitter abstract class RNMBXTileSourceManager?> internal constructor( reactApplicationContext: ReactApplicationContext ) : AbstractEventEmitter(reactApplicationContext) { - override fun getChildAt(source: T, childPosition: Int): View { + override fun getChildAt(source: T & Any, childPosition: Int): View { return source!!.getChildAt(childPosition) } - override fun getChildCount(source: T): Int { + override fun getChildCount(source: T & Any): Int { return source!!.childCount } - override fun addView(source: T, childView: View, childPosition: Int) { + override fun addView(source: T & Any, childView: View, childPosition: Int) { source!!.addLayer(childView, childPosition) } - override fun removeViewAt(source: T, childPosition: Int) { + override fun removeViewAt(source: T & Any, childPosition: Int) { source!!.removeLayer(childPosition) } diff --git a/android/src/main/java/com/rnmapbox/rnmbx/utils/ViewTagResolver.kt b/android/src/main/java/com/rnmapbox/rnmbx/utils/ViewTagResolver.kt index 07bac4da4..f45cc25da 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/utils/ViewTagResolver.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/utils/ViewTagResolver.kt @@ -16,7 +16,7 @@ data class ViewTagWaiter( const val LOG_TAG = "ViewTagResolver" -typealias ViewRefTag = Int +typealias ViewRefTag = Double // see https://github.com/rnmapbox/maps/pull/3074 open class ViewTagResolver(val context: ReactApplicationContext) { private val createdViews: HashSet = hashSetOf() diff --git a/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt b/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt index a4966048e..d52fa211d 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt @@ -5,6 +5,7 @@ import com.facebook.react.bridge.ReadableArray import com.facebook.react.bridge.ReadableMap import com.facebook.react.bridge.ReadableType import com.mapbox.bindgen.Value +import com.rnmapbox.rnmbx.rncompat.dynamic.* fun ReadableMap.toValueHashMap(): HashMap { var result = hashMapOf() diff --git a/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableMap.kt b/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableMap.kt index 2882e0dab..c69ef8c22 100644 --- a/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableMap.kt +++ b/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableMap.kt @@ -17,6 +17,7 @@ import com.mapbox.geojson.MultiPolygon import com.mapbox.geojson.Point import com.mapbox.geojson.Polygon import com.mapbox.maps.EdgeInsets +import com.rnmapbox.rnmbx.rncompat.readable_map.* import com.rnmapbox.rnmbx.utils.ConvertUtils import com.rnmapbox.rnmbx.utils.Logger diff --git a/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/Dynamic.kt b/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/Dynamic.kt new file mode 100644 index 000000000..ee7c4e8df --- /dev/null +++ b/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/Dynamic.kt @@ -0,0 +1,10 @@ +package com.rnmapbox.rnmbx.rncompat.dynamic + +import com.facebook.react.bridge.Dynamic +import com.facebook.react.bridge.ReadableType + +val Dynamic.type: ReadableType + get() { return this.getType() } + +val Dynamic.isNull: Boolean + get() { return this.isNull() } diff --git a/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ReadableMap.kt b/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ReadableMap.kt new file mode 100644 index 000000000..d9559c9b0 --- /dev/null +++ b/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ReadableMap.kt @@ -0,0 +1,5 @@ +package com.rnmapbox.rnmbx.rncompat.readable_map +import com.facebook.react.bridge.ReadableMap + +val ReadableMap.entryIterator: Iterator> + get() { return this.getEntryIterator() } \ No newline at end of file diff --git a/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt b/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt new file mode 100644 index 000000000..0bb9b81ab --- /dev/null +++ b/android/src/main/rn-compat/rn75/com/rnmapbox/rnmbx/rncompat/ResourceDrawableIdHelper.kt @@ -0,0 +1,7 @@ +package com.rnmapbox.rnmbx.rncompat.resourcedrawableidhelper; + +import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper + +public fun ResourceDrawableIdHelper.Companion.getInstance(): ResourceDrawableIdHelper { + return this.instance +} \ No newline at end of file diff --git a/package.json b/package.json index de0e8e606..996deed17 100644 --- a/package.json +++ b/package.json @@ -126,11 +126,6 @@ "name": "rnmapbox_maps_specs", "type": "all", "jsSrcsDir": "src/specs", - "includesGeneratedCode": true, - "outputDir": { - "android": "android/src/main/codegen", - "ios": "ios/codegen" - }, "android": { "javaPackageName": "com.rnmapbox.rnmbx" }