plugins {
    id "com.android.application"
    // START: FlutterFire Configuration
    id 'com.google.gms.google-services'
    id 'com.google.firebase.crashlytics'
    // END: FlutterFire Configuration
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}


def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    namespace "com.camelsoft.wanisclient"
    compileSdkVersion 35
    ndkVersion "27.0.12077973"
    packagingOptions {
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'

        jniLibs {
            useLegacyPackaging = true
        }
    }
    compileOptions {
        coreLibraryDesugaringEnabled true
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }


    kotlinOptions {
        jvmTarget = '1.8'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.camelsoft.wanisclient"
        minSdkVersion 26
        targetSdk 35
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        ndk {
            abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
        }
        externalNativeBuild {
            cmake {
                arguments "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
            }
        }
    }
    signingConfigs {
        release {
            // Use the keystore you just created:
            storeFile file("keystore/upload-keystore.jks")
            storePassword "manM3423M"         // ← the keystore password you entered
            keyAlias "upload"       // ← the alias you chose
            keyPassword "manM3423M"           // ← the key password (you used the same as keystore)
        }
    }
    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

        }
    }
}

flutter {
    source = "../.."
}
dependencies {
    implementation platform('com.google.firebase:firebase-bom:32.7.1')
    implementation 'com.google.firebase:firebase-messaging:23.4.1'
    implementation "com.google.firebase:firebase-core:21.1.1"
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
    implementation 'androidx.window:window:1.2.0'
    implementation 'androidx.window:window-java:1.2.0'
    implementation 'com.facebook.android:facebook-android-sdk:18.0.0'
    implementation 'androidx.annotation:annotation:1.3.0'
    implementation 'org.microg:safe-parcel:1.7.1'
    implementation 'com.google.firebase:firebase-crashlytics'
    implementation 'com.google.android.gms:play-services-location:21.0.1'


}

repositories {
    maven {
        url 'https://api.mapbox.com/downloads/v2/releases/maven'
        authentication {
            basic(BasicAuthentication)
        }
        credentials {
            username = "mapbox"
            password = project.hasProperty('pk.eyJ1IjoibW9oYW1lZGtoYWJpciIsImEiOiJjbW5vY2VncWwwMHoyMnJzNHZ6a3Z1ajFmIn0.xflZkpM2P8tqixCFy5tD4w') ? project.property('pk.eyJ1IjoibW9oYW1lZGtoYWJpciIsImEiOiJjbW5vY2VncWwwMHoyMnJzNHZ6a3Z1ajFmIn0.xflZkpM2P8tqixCFy5tD4w') : ""
        }
    }
}