apply plugin: 'com.android.library'

group = 'expo.modules.gaodemap.navigation'
version = '2.0.13'

def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
apply from: expoModulesCorePlugin
applyKotlinExpoModulesCorePlugin()
useCoreDependencies()
useExpoPublishing()

def useManagedAndroidSdkVersions = false
if (useManagedAndroidSdkVersions) {
  useDefaultAndroidSdkVersions()
} else {
  buildscript {
    ext.safeExtGet = { prop, fallback ->
      rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
    }
  }
  project.android {
    compileSdkVersion safeExtGet("compileSdkVersion", 36)
    defaultConfig {
      minSdkVersion safeExtGet("minSdkVersion", 24)
      targetSdkVersion safeExtGet("targetSdkVersion", 36)
    }
  }
}

logger.warn("[expo-gaode-map-navigation] Thank you for using expo-gaode-map-navigation ❤️")
logger.warn("[expo-gaode-map-navigation] If you enjoy using expo-gaode-map-navigation, please consider sponsoring this project: https://github.com/TomWq")

android {
  namespace "expo.modules.gaodemap.navigation"
  defaultConfig {
    versionCode 1
    versionName "2.0.13"
  }
  lintOptions {
    abortOnError false
  }
}

dependencies {
    def customSdkPath = null
    println "ExpoGaodeMapNavigation: Checking for custom SDK property in rootProject: ${rootProject.name}"
    if (rootProject.hasProperty("EXPO_GAODE_MAP_CUSTOM_SDK_PATH")) {
        customSdkPath = rootProject.property("EXPO_GAODE_MAP_CUSTOM_SDK_PATH")
        println "ExpoGaodeMapNavigation: Found custom SDK path property: ${customSdkPath}"
    }

    if (customSdkPath) {
        def sdkFile = rootProject.file(customSdkPath)
        if (!sdkFile.exists()) {
             sdkFile = new File(rootProject.projectDir.parentFile, customSdkPath)
        }
        
        if (sdkFile.exists()) {
            println "ExpoGaodeMapNavigation: Using custom Map SDK from ${sdkFile.absolutePath}"
            implementation files(sdkFile)
        } else {
            println "ExpoGaodeMapNavigation: Custom SDK path configured but file not found, falling back to Maven dependency."
            implementation 'com.amap.api:navi-3dmap-location-search:10.1.600_3dmap10.1.600_loc6.5.1_sea9.7.4'

        }
    } else {
        // 10.1.600 is the last Android 3D map SDK line that supports offline
        // map downloads without the separate 11.x offline-download permission.
        implementation 'com.amap.api:navi-3dmap-location-search:10.1.600_3dmap10.1.600_loc6.5.1_sea9.7.4'

    }

    // Live Update APIs on NotificationCompat.Builder
    // setRequestPromotedOngoing / setShortCriticalText were added in androidx.core 1.17.0.
    implementation 'androidx.core:core-ktx:1.17.0'
}
