plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

def keystorePropertiesFile = rootProject.file("signing.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

android {
    namespace 'com.github.digitallyrefined.androidipcamera'
    compileSdk 34

    defaultConfig {
        applicationId "com.github.digitallyrefined.androidipcamera"
        minSdk 24
        targetSdk 34
        versionCode 1
        versionName "0.0.8"
    }

    signingConfigs {
        release {
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
        }
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            splits {
                abi {
                    enable true
                    reset()
                    include "armeabi-v7a", "arm64-v8a"
                    universalApk true
                }
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    buildFeatures {
        viewBinding true
    }

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def versionName = variant.versionName
            def abi = output.getFilter(com.android.build.OutputFile.ABI) ?: "universal"
            def buildType = variant.buildType.name

            def newApkName = "${project.rootProject.name}-${versionName}-${abi}-${buildType}.apk"
            outputFileName = newApkName
        }
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.12.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.10.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    implementation "androidx.preference:preference-ktx:1.2.1"

    // CameraX dependencies
    implementation 'androidx.camera:camera-core:1.3.0'
    implementation 'androidx.camera:camera-camera2:1.3.0'
    implementation 'androidx.camera:camera-lifecycle:1.3.0'
    implementation 'androidx.camera:camera-view:1.3.0'


    // Coroutines for asynchronous operations
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
}

