plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'androidx.navigation.safeargs.kotlin'
    id 'kotlin-parcelize'
    id 'com.google.devtools.ksp'
    id 'org.jetbrains.kotlin.plugin.serialization'
}

android {
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
        coreLibraryDesugaringEnabled true
    }
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
}

android {
    namespace 'com.streamflixreborn.streamflix'
    compileSdk 36

    def properties = new Properties()
    properties.load(project.rootProject.file('local.properties').newDataInputStream())

    defaultConfig {
        applicationId "com.streamflixreborn.streamflix"
        minSdk 21
        targetSdk 35
        versionCode 153
        versionName "1.7.224"

        buildConfigField "String", "APP_LAYOUT", "\"${properties.getProperty("APP_LAYOUT")}\""
        buildConfigField "String", "TMDB_API_KEY", "\"${properties.getProperty("TMDB_API_KEY")}\""
        buildConfigField "String", "SUBDL_API_KEY", "\"${properties.getProperty("SUBDL_API_KEY")}\""
        buildConfigField "String", "RABBITSTREAM_SOURCE_API", "\"${properties.getProperty("RABBITSTREAM_SOURCE_API")}\""
    }

    sourceSets {
        main {
            def appLayout = properties.getProperty("APP_LAYOUT")
            if (appLayout == "mobile") {
                manifest.srcFile "${project.rootDir}/app/src/main/mobile/AndroidManifest.xml"
            } else if (appLayout == "tv") {
                manifest.srcFile "${project.rootDir}/app/src/main/tv/AndroidManifest.xml"
            } else {
                manifest.srcFile "${project.rootDir}/app/src/main/AndroidManifest.xml"
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            applicationIdSuffix '.debug'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        viewBinding true
        buildConfig true
    }
}

dependencies {
    implementation 'androidx.media3:media3-datasource-okhttp:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.7.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.8.8'
    implementation 'androidx.navigation:navigation-ui-ktx:2.8.8'
    implementation project(path: ':navigation')

    implementation 'androidx.core:core-ktx:1.17.0'
    implementation 'androidx.leanback:leanback:1.2.0'
    implementation 'com.github.bumptech.glide:glide:5.0.0-rc01'
    implementation 'androidx.work:work-runtime-ktx:2.10.0'
    ksp 'com.github.bumptech.glide:ksp:5.0.0-rc01'
    implementation 'com.github.bumptech.glide:okhttp3-integration:5.0.0-rc01'

    implementation 'androidx.media3:media3-exoplayer:1.8.0'
    implementation 'androidx.media3:media3-exoplayer-dash:1.8.0'
    implementation 'androidx.media3:media3-exoplayer-hls:1.8.0'
    implementation 'androidx.media3:media3-session:1.8.0'
    implementation 'androidx.media3:media3-ui:1.8.0'

    implementation 'com.squareup.retrofit2:retrofit:2.11.0'
    implementation 'com.squareup.okhttp3:okhttp:4.12.0'
    implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.12.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
    implementation 'dnsjava:dnsjava:3.6.3'
    implementation project(path: ':retrofit-jsoup-converter')
    implementation 'com.squareup.retrofit2:converter-gson:2.11.0'
    implementation 'com.squareup.retrofit2:converter-scalars:2.11.0'
    implementation 'org.jsoup:jsoup:1.19.1'

    implementation 'androidx.fragment:fragment-ktx:1.8.6'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.7'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7'
    implementation 'androidx.preference:preference-ktx:1.2.1'
    implementation 'androidx.leanback:leanback-preference:1.2.0'

    implementation 'androidx.tvprovider:tvprovider:1.1.0'

    implementation "androidx.room:room-runtime:2.7.0-rc01"
    implementation "androidx.room:room-ktx:2.7.0-rc01"
    implementation 'com.google.android.material:material:1.12.0'
    ksp 'androidx.room:room-compiler:2.7.0-rc01'

    implementation("org.mozilla:rhino:1.8.0")
    implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0")
    implementation 'org.conscrypt:conscrypt-android:2.5.2'
    implementation "androidx.browser:browser:1.7.0"
    implementation "org.nanohttpd:nanohttpd:2.3.1"
    implementation "com.google.zxing:core:3.5.1"
    implementation("org.java-websocket:Java-WebSocket:1.5.3")
    
}

ksp {
    arg("com.bumptech.glide.GlideModule", "AppGlideModule")
}
