Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 24b0bfa9 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Maps: Add a few missing parts

parent b2f7f69f
Loading
Loading
Loading
Loading
+33 −10
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.widget.FrameLayout
import android.widget.RelativeLayout
import androidx.collection.LongSparseArray
import com.google.android.gms.dynamic.IObjectWrapper
import com.google.android.gms.dynamic.ObjectWrapper
import com.google.android.gms.maps.GoogleMapOptions
import com.google.android.gms.maps.internal.*
import com.google.android.gms.maps.model.*
@@ -51,6 +52,9 @@ import com.mapbox.mapboxsdk.plugins.annotation.*
import com.mapbox.mapboxsdk.plugins.annotation.Annotation
import com.mapbox.mapboxsdk.style.layers.Property.LINE_CAP_ROUND
import com.google.android.gms.dynamic.unwrap
import com.mapbox.android.core.location.LocationEngineCallback
import com.mapbox.android.core.location.LocationEngineRequest
import com.mapbox.android.core.location.LocationEngineResult
import org.microg.gms.maps.MapsConstants.*
import org.microg.gms.maps.mapbox.model.*
import org.microg.gms.maps.mapbox.utils.MapContext
@@ -95,6 +99,19 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
    private var mapLongClickListener: IOnMapLongClickListener? = null
    private var markerClickListener: IOnMarkerClickListener? = null
    private var markerDragListener: IOnMarkerDragListener? = null
    private var myLocationChangeListener: IOnMyLocationChangeListener? = null

    private val locationEngineCallback = object : LocationEngineCallback<LocationEngineResult> {
        override fun onSuccess(result: LocationEngineResult?) {
            result?.lastLocation?.let { location ->
                Log.d(TAG, "myLocationChanged: $location")
                myLocationChangeListener?.onMyLocationChanged(ObjectWrapper.wrap(location))
            }
        }
        override fun onFailure(e: Exception) {
            Log.w(TAG, e)
        }
    }

    var lineManager: LineManager? = null
    val pendingLines = mutableSetOf<PolylineImpl>()
@@ -130,6 +147,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)


        val fakeWatermark = View(mapContext)
        fakeWatermark.tag = "GoogleWatermark"
        fakeWatermark.layoutParams = object : RelativeLayout.LayoutParams(0, 0) {
            @SuppressLint("RtlHardcoded")
            override fun addRule(verb: Int, subject: Int) {
@@ -401,6 +419,15 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
            try {
                if (locationComponent.isLocationComponentActivated) {
                    locationComponent.isLocationComponentEnabled = myLocation
                    if (myLocation) {
                        locationComponent.locationEngine?.requestLocationUpdates(
                            locationComponent.locationEngineRequest,
                            locationEngineCallback,
                            null
                        )
                    } else {
                        locationComponent.locationEngine?.removeLocationUpdates(locationEngineCallback)
                    }
                }
            } catch (e: SecurityException) {
                Log.w(TAG, e)
@@ -411,8 +438,9 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
    }

    override fun getMyLocation(): Location? {
        Log.d(TAG, "unimplemented Method: getMyLocation")
        return null
        synchronized(mapLock) {
            return map?.locationComponent?.lastKnownLocation
        }
    }

    override fun setLocationSource(locationSource: ILocationSourceDelegate?) {
@@ -470,8 +498,7 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
    }

    override fun setOnMyLocationChangeListener(listener: IOnMyLocationChangeListener?) {
        Log.d(TAG, "unimplemented Method: setOnMyLocationChangeListener")

        myLocationChangeListener = listener
    }

    override fun setOnMyLocationButtonClickListener(listener: IOnMyLocationButtonClickListener?) {
@@ -715,13 +742,9 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
                    renderMode = RenderMode.COMPASS
                }

                setMyLocationEnabled(locationEnabled)

                synchronized(mapLock) {
                    try {
                        map.locationComponent.isLocationComponentEnabled = locationEnabled
                    } catch (e: SecurityException) {
                        Log.w(TAG, e)
                        locationEnabled = false
                    }
                    loaded = true
                    if (loadedCallback != null) {
                        Log.d(TAG, "Invoking callback delayed, as map is loaded")
+4 −1
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ package org.microg.gms.maps.mapbox.model
import android.os.Parcel
import android.util.Log
import com.google.android.gms.dynamic.IObjectWrapper
import com.google.android.gms.dynamic.ObjectWrapper
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.PatternItem
import com.google.android.gms.maps.model.PolygonOptions
@@ -143,6 +144,8 @@ class PolygonImpl(private val map: GoogleMapImpl, private val id: String, option
        clickable = click
    }

    override fun isClickable(): Boolean = clickable

    override fun setStrokeJointType(type: Int) {
        strokeJointType = type
    }
@@ -159,7 +162,7 @@ class PolygonImpl(private val map: GoogleMapImpl, private val id: String, option
        tag = obj
    }

    override fun getTag(): IObjectWrapper? = tag
    override fun getTag(): IObjectWrapper = tag ?: ObjectWrapper.wrap(null)

    override fun hashCode(): Int {
        return id.hashCode()
+32 −1
Original line number Diff line number Diff line
@@ -18,7 +18,10 @@ package org.microg.gms.maps.mapbox.model

import android.os.Parcel
import android.util.Log
import com.google.android.gms.dynamic.IObjectWrapper
import com.google.android.gms.dynamic.ObjectWrapper
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.PatternItem
import com.google.android.gms.maps.model.internal.IPolylineDelegate
import com.mapbox.mapboxsdk.plugins.annotation.Line
import com.mapbox.mapboxsdk.plugins.annotation.LineOptions
@@ -30,8 +33,12 @@ import com.google.android.gms.maps.model.PolylineOptions as GmsLineOptions
class PolylineImpl(private val map: GoogleMapImpl, private val id: String, options: GmsLineOptions) : IPolylineDelegate.Stub(), Markup<Line, LineOptions> {
    private var points = ArrayList(options.points)
    private var width = options.width
    private var jointType = options.jointType
    private var pattern = ArrayList(options.pattern.orEmpty())
    private var color = options.color
    private var visible: Boolean = options.isVisible
    private var clickable: Boolean = options.isClickable
    private var tag: IObjectWrapper? = null

    override var annotation: Line? = null
    override var removed: Boolean = false
@@ -103,6 +110,30 @@ class PolylineImpl(private val map: GoogleMapImpl, private val id: String, optio

    override fun hashCodeRemote(): Int = hashCode()

    override fun setClickable(clickable: Boolean) {
        this.clickable = clickable
    }

    override fun isClickable(): Boolean = clickable

    override fun setJointType(jointType: Int) {
        this.jointType = jointType
    }

    override fun getJointType(): Int = jointType

    override fun setPattern(pattern: MutableList<PatternItem>?) {
        this.pattern = ArrayList(pattern.orEmpty())
    }

    override fun getPattern(): MutableList<PatternItem> = pattern

    override fun setTag(tag: IObjectWrapper?) {
        this.tag = tag
    }

    override fun getTag(): IObjectWrapper = tag ?: ObjectWrapper.wrap(null)

    override fun hashCode(): Int {
        return id.hashCode()
    }
+2 −2
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.view.LayoutInflater
import org.microg.gms.common.Constants
import java.io.File

class MapContext(private val context: Context) : ContextWrapper(context.createPackageContext(Constants.GMS_PACKAGE_NAME, Context.CONTEXT_INCLUDE_CODE and Context.CONTEXT_IGNORE_SECURITY)) {
class MapContext(private val context: Context) : ContextWrapper(context.createPackageContext(Constants.GMS_PACKAGE_NAME, Context.CONTEXT_INCLUDE_CODE or Context.CONTEXT_IGNORE_SECURITY)) {
    private var layoutInflater: LayoutInflater? = null
    private val appContext: Context
        get() = context.applicationContext ?: context
Loading