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

Unverified Commit 8e490031 authored by DaVinci9196's avatar DaVinci9196 Committed by GitHub
Browse files

HMS Maps: Add dark mode style (#2928)

parent f633baa2
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ fun runOnMainLooper(forceQueue: Boolean = false, method: () -> Unit) {

class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions) : IGoogleMapDelegate.Stub() {

    internal val mapContext = MapContext(context)

    val view: FrameLayout
    var map: HuaweiMap? = null
        private set
@@ -94,7 +96,6 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
    val markers = mutableMapOf<String, MarkerImpl>()

    init {
        val mapContext = MapContext(context)
        BitmapDescriptorFactoryImpl.initialize(context.resources)
        runOnMainLooper {
            MapsInitializer.setApiKey(BuildConfig.HMSMAP_KEY)
@@ -257,8 +258,13 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
    override fun stopAnimation() = map?.stopAnimation() ?: Unit

    override fun setMapStyle(options: MapStyleOptions?): Boolean {
        Log.d(TAG, "unimplemented Method: setMapStyle ${options?.getJson()}")
        return true
        Log.d(TAG, "setMapStyle: ")
        val bool = options?.toHms(mapContext).let {
            Log.d(TAG, "setMapStyle: option: ${it?.json}")
            map?.setMapStyle(it)
        }
        Log.d(TAG, "setMapStyle: bool: $bool")
        return true == bool
    }

    override fun setMinZoomPreference(minZoom: Float) = afterInitialize {
@@ -652,7 +658,6 @@ class GoogleMapImpl(private val context: Context, var options: GoogleMapOptions)
    override fun onCreate(savedInstanceState: Bundle?) {
        if (!created) {
            Log.d(TAG_LOGO, "create: ${context.packageName},\n$options")
            val mapContext = MapContext(context)
            MapsInitializer.initialize(mapContext)
            val mapView = MapView(mapContext, options.toHms()).apply { visibility = View.INVISIBLE }
            this.mapView = mapView
+11 −1
Original line number Diff line number Diff line
@@ -5,14 +5,15 @@

package org.microg.gms.maps.hms.utils

import android.content.res.Configuration
import android.os.Bundle
import android.util.Log
import com.google.android.gms.dynamic.unwrap
import com.google.android.gms.maps.GoogleMapOptions
import com.google.android.gms.maps.internal.ICancelableCallback
import com.huawei.hms.maps.HuaweiMap
import com.huawei.hms.maps.HuaweiMapOptions
import com.huawei.hms.maps.model.*
import org.microg.gms.maps.hms.R
import com.google.android.gms.maps.model.CameraPosition as GmsCameraPosition
import com.google.android.gms.maps.model.CircleOptions as GmsCircleOptions
import com.google.android.gms.maps.model.Dash as GmsDash
@@ -21,6 +22,7 @@ import com.google.android.gms.maps.model.Gap as GmsGap
import com.google.android.gms.maps.model.GroundOverlayOptions as GmsGroundOverlayOptions
import com.google.android.gms.maps.model.LatLng as GmsLatLng
import com.google.android.gms.maps.model.LatLngBounds as GmsLatLngBounds
import com.google.android.gms.maps.model.MapStyleOptions as GmsMapStyleOptions
import com.google.android.gms.maps.model.MarkerOptions as GmsMarkerOptions
import com.google.android.gms.maps.model.PatternItem as GmsPatternItem
import com.google.android.gms.maps.model.PolygonOptions as GmsPolygonOptions
@@ -227,3 +229,11 @@ fun Bundle.toGms(): Bundle {
    newBundle.classLoader = oldLoader
    return newBundle
}

fun GmsMapStyleOptions.toHms(context: MapContext): MapStyleOptions {
    val nightMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
    if (nightMode == Configuration.UI_MODE_NIGHT_YES) {
        return MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_night_hms)
    }
    return MapStyleOptions.loadRawResourceStyle(context, R.raw.mapstyle_grayscale_hms)
}
 No newline at end of file
+101 −0
Original line number Diff line number Diff line
[
  {
    "featureType": "all",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#f5f5f5"
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.icon",
    "stylers": [
      {
        "saturation": -100
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.text",
    "stylers": [
      {
        "saturation": -100
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#eeeeee"
      }
    ]
  },
  {
    "featureType": "poi.park",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#e5e5e5"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#ffffff"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#dadada"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "labels.icon",
    "stylers": [
      {
        "lightness": 30
      }
    ]
  },
  {
    "featureType": "transit.line",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#e5e5e5"
      }
    ]
  },
  {
    "featureType": "transit.station",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#eeeeee"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#c9c9c9"
      }
    ]
  }
]
 No newline at end of file
+376 −0
Original line number Diff line number Diff line
[
  {
    "mapFeature": "all",
    "options": "geometry",
    "paint": {
      "color": "#25292B"
    }
  },
  {
    "mapFeature": "all",
    "options": "labels.text.stroke",
    "paint": {
      "color": "#25292B"
    }
  },
  {
    "mapFeature": "all",
    "options": "labels.icon",
    "paint": {
      "icon-type": "night"
    }
  },
  {
    "mapFeature": "administrative",
    "options": "labels.text.fill",
    "paint": {
      "color": "#E0D5C7"
    }
  },
  {
    "mapFeature": "administrative.country",
    "options": "geometry",
    "paint": {
      "color": "#787272"
    }
  },
  {
    "mapFeature": "administrative.province",
    "options": "geometry",
    "paint": {
      "color": "#666262"
    }
  },
  {
    "mapFeature": "administrative.province",
    "options": "labels.text.fill",
    "paint": {
      "color": "#928C82"
    }
  },
  {
    "mapFeature": "administrative.district",
    "options": "labels.text.fill",
    "paint": {
      "color": "#AAA59E"
    }
  },
  {
    "mapFeature": "administrative.locality",
    "options": "labels.text.fill",
    "paint": {
      "color": "#928C82"
    }
  },
  {
    "mapFeature": "landcover.parkland.natural",
    "visibility": false,
    "options": "geometry",
    "paint": {
      "color": "#25292B"
    }
  },
  {
    "mapFeature": "landcover.parkland.public-garden",
    "options": "geometry",
    "paint": {
      "color": "#283631"
    }
  },
  {
    "mapFeature": "landcover.parkland.human-made",
    "visibility": false,
    "options": "geometry",
    "paint": {
      "color": "#25292B"
    }
  },
  {
    "mapFeature": "landcover.parkland.public-garden",
    "options": "labels.text.fill",
    "paint": {
      "color": "#8BAA7F"
    }
  },
  {
    "mapFeature": "landcover.hospital",
    "options": "geometry",
    "paint": {
      "color": "#382B2B"
    }
  },
  {
    "mapFeature": "landcover",
    "options": "labels.text.fill",
    "paint": {
      "color": "#928C82"
    }
  },
  {
    "mapFeature": "poi.shopping",
    "options": "labels.text.fill",
    "paint": {
      "color": "#9C8C5F"
    }
  },
  {
    "mapFeature": "landcover.human-made.building",
    "visibility": false,
    "options": "labels.text.fill",
    "paint": {
      "color": "#000000"
    }
  },
  {
    "mapFeature": "poi.tourism",
    "options": "labels.text.fill",
    "paint": {
      "color": "#578C8C"
    }
  },
  {
    "mapFeature": "poi.beauty",
    "options": "labels.text.fill",
    "paint": {
      "color": "#9E7885"
    }
  },
  {
    "mapFeature": "poi.leisure",
    "options": "labels.text.fill",
    "paint": {
      "color": "#916A91"
    }
  },
  {
    "mapFeature": "poi.eating&drinking",
    "options": "labels.text.fill",
    "paint": {
      "color": "#996E50"
    }
  },
  {
    "mapFeature": "poi.lodging",
    "options": "labels.text.fill",
    "paint": {
      "color": "#A3678F"
    }
  },
  {
    "mapFeature": "poi.health-care",
    "options": "labels.text.fill",
    "paint": {
      "color": "#B07373"
    }
  },
  {
    "mapFeature": "poi.public-service",
    "options": "labels.text.fill",
    "paint": {
      "color": "#5F7299"
    }
  },
  {
    "mapFeature": "poi.business",
    "options": "labels.text.fill",
    "paint": {
      "color": "#6B6B9D"
    }
  },
  {
    "mapFeature": "poi.automotive",
    "options": "labels.text.fill",
    "paint": {
      "color": "#6B6B9D"
    }
  },
  {
    "mapFeature": "poi.sports.outdoor",
    "options": "labels.text.fill",
    "paint": {
      "color": "#597A52"
    }
  },
  {
    "mapFeature": "poi.sports.other",
    "options": "labels.text.fill",
    "paint": {
      "color": "#3E90AB"
    }
  },
  {
    "mapFeature": "poi.natural",
    "options": "labels.text.fill",
    "paint": {
      "color": "#597A52"
    }
  },
  {
    "mapFeature": "poi.miscellaneous",
    "options": "labels.text.fill",
    "paint": {
      "color": "#A7ADB0"
    }
  },
  {
    "mapFeature": "road.highway",
    "options": "labels.text.fill",
    "paint": {
      "color": "#E3CAA2"
    }
  },
  {
    "mapFeature": "road.national",
    "options": "labels.text.fill",
    "paint": {
      "color": "#A7ADB0"
    }
  },
  {
    "mapFeature": "road.province",
    "options": "labels.text.fill",
    "paint": {
      "color": "#A7ADB0"
    }
  },
  {
    "mapFeature": "road.city-arterial",
    "options": "labels.text.fill",
    "paint": {
      "color": "#808689"
    }
  },
  {
    "mapFeature": "road.minor-road",
    "options": "labels.text.fill",
    "paint": {
      "color": "#808689"
    }
  },
  {
    "mapFeature": "road.sidewalk",
    "options": "labels.text.fill",
    "paint": {
      "color": "#808689"
    }
  },
  {
    "mapFeature": "road.highway.country",
    "options": "geometry.fill",
    "paint": {
      "color": "#8C7248"
    }
  },
  {
    "mapFeature": "road.highway.city",
    "options": "geometry.fill",
    "paint": {
      "color": "#706148"
    }
  },
  {
    "mapFeature": "road.national",
    "options": "geometry.fill",
    "paint": {
      "color": "#444A4D"
    }
  },
  {
    "mapFeature": "road.province",
    "options": "geometry.fill",
    "paint": {
      "color": "#444A4D"
    }
  },
  {
    "mapFeature": "road.city-arterial",
    "options": "geometry.fill",
    "paint": {
      "color": "#434B4F"
    }
  },
  {
    "mapFeature": "road.minor-road",
    "options": "geometry.fill",
    "paint": {
      "color": "#434B4F"
    }
  },
  {
    "mapFeature": "road.sidewalk",
    "options": "geometry.fill",
    "paint": {
      "color": "#434B4F"
    }
  },
  {
    "mapFeature": "transit",
    "options": "labels.text.fill",
    "paint": {
      "color": "#4F81B3"
    }
  },
  {
    "mapFeature": "transit.railway",
    "options": "geometry",
    "paint": {
      "color": "#5B2E57"
    }
  },
  {
    "mapFeature": "transit.ferry-line",
    "options": "geometry",
    "paint": {
      "color": "#364D67"
    }
  },
  {
    "mapFeature": "transit.airport",
    "options": "geometry",
    "paint": {
      "color": "#2C3235"
    }
  },
  {
    "mapFeature": "water",
    "options": "geometry",
    "paint": {
      "color": "#243850"
    }
  },
  {
    "mapFeature": "water",
    "options": "labels.text.fill",
    "paint": {
      "color": "#4C6481"
    }
  },
  {
    "mapFeature": "trafficInfo.smooth",
    "options": "geometry",
    "paint": {
      "color": "#348734"
    }
  },
  {
    "mapFeature": "trafficInfo.amble",
    "options": "geometry",
    "paint": {
      "color": "#947000"
    }
  },
  {
    "mapFeature": "trafficInfo.congestion",
    "options": "geometry",
    "paint": {
      "color": "#A4281E"
    }
  },
  {
    "mapFeature": "trafficInfo.extremelycongestion",
    "options": "geometry",
    "paint": {
      "color": "#7A120B"
    }
  }
]
 No newline at end of file