plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.autonomousapps.dependency-analysis'
    id 'dev.rikka.tools.refine' version '4.4.0'
    id 'org.jetbrains.kotlin.plugin.compose' version '2.2.0'
}

def hasSigningConfig = ['keystorePath', 'keystorePassword', 'keyAlias', 'keyPassword']
        .every { project.hasProperty(it) }

android {
    namespace 'com.stario.launcher'
    compileSdk 36

    defaultConfig {
        applicationId 'com.stario.launcher'
        minSdkVersion 29
        targetSdkVersion 36
        versionCode 91
        versionName '2.10'
    }

    signingConfigs {
        release {
            if (hasSigningConfig) {
                storeFile file(project.getProperty('keystorePath'))
                storePassword project.getProperty('keystorePassword')
                keyAlias project.getProperty('keyAlias')
                keyPassword project.getProperty('keyPassword')
            }
        }
    }

    buildTypes {
        release {
            debuggable false
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), "proguard-rules.txt"
            if (hasSigningConfig) {
                signingConfig signingConfigs.release
            }
        }
        debug {
            debuggable true
            applicationIdSuffix ".debug"
        }
    }

    sourceSets {
        main {
            res {
                srcDirs = ['src/main/res/common',
                           'src/main/res/themes',
                           'src/main/res/pins',
                           'src/main/res/applications',
                           'src/main/res/strings',
                           'src/main/res/extract',
                           'src/main/res/launcher',
                           'src/main/res/drawer',
                           'src/main/res/drawer_interactions',
                           'src/main/res/page_manager',
                           'src/main/res/page_manager_dialogs',
                           'src/main/res/briefing',
                           'src/main/res/briefing_configurator',
                           'src/main/res/settings',
                           'src/main/res/settings_dialogs',
                           'src/main/res/search',
                           'src/main/res/scroller',
                           'src/main/res/sheet',
                           'src/main/res/splash',
                           'src/main/res/notes',
                           'src/main/res/editor',
                           'src/main/res/interactions',
                           'src/main/res/widgets',
                           'src/main/res/media',
                           'src/main/res/weather',
                           'src/main/res/glance',
                           'src/main/res/calendar']
            }
        }
    }

    dependenciesInfo {
        includeInApk = false
        includeInBundle = false
    }

    lint {
        disable 'MissingTranslation'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }

    buildFeatures {
        compose true
        buildConfig true
    }

    kotlinOptions {
        jvmTarget = '11'
    }

    afterEvaluate {
        def versionName = android.defaultConfig.versionName

        tasks.register("getVersionName") {
            doLast {
                println versionName
            }
        }
    }
}

dependencies {
    implementation project(':hidden')

    // Transitive dependencies
    // noinspection KtxExtensionAvailable
    implementation 'androidx.activity:activity:1.10.1'
    implementation 'androidx.annotation:annotation:1.9.1'
    implementation 'androidx.appcompat:appcompat-resources:1.7.1'
    implementation 'androidx.appcompat:appcompat:1.7.1'
    implementation 'androidx.asynclayoutinflater:asynclayoutinflater:1.1.0'
    implementation 'androidx.compose.foundation:foundation:1.8.3'
    implementation 'androidx.compose.runtime:runtime:1.8.3'
    implementation 'androidx.compose.ui:ui-graphics:1.8.3'
    implementation 'androidx.compose.ui:ui-unit:1.8.3'
    implementation 'androidx.compose.ui:ui:1.8.3'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
    implementation 'androidx.coordinatorlayout:coordinatorlayout:1.3.0'
    // noinspection KtxExtensionAvailable
    implementation 'androidx.core:core:1.16.0'
    implementation 'androidx.customview:customview:1.2.0'
    // noinspection KtxExtensionAvailable
    implementation 'androidx.dynamicanimation:dynamicanimation:1.1.0'
    // noinspection KtxExtensionAvailable
    implementation 'androidx.fragment:fragment:1.8.8'
    implementation 'androidx.interpolator:interpolator:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-common:2.9.2'
    implementation 'androidx.lifecycle:lifecycle-process:2.9.2'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
    // noinspection KtxExtensionAvailable
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'androidx.transition:transition:1.6.0'
    implementation 'androidx.viewpager:viewpager:1.1.0'

    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.compose.material3:material3-android:1.3.2'
    implementation 'androidx.recyclerview:recyclerview:1.4.0'
    implementation 'tk.zielony:carbon:0.17.0'

    implementation 'me.saket.squigglyslider:squigglyslider:1.0.0'
    implementation 'com.ogaclejapan.smarttablayout:library:2.0.0@aar'

    implementation 'com.google.code.gson:gson:2.13.1'
    implementation 'org.jsoup:jsoup:1.21.1'
    implementation 'com.squareup.okhttp3:okhttp:5.1.0'

    // Hidden APIs
    implementation 'dev.rikka.tools.refine:runtime:4.4.0'
    // Temporary, until PR is approved: https://github.com/ChickenHook/RestrictionBypass/pull/18
    implementation 'com.github.breezy-weather:RestrictionBypass:86d4e2959e'

    implementation 'com.luckycatlabs:SunriseSunsetCalculator:1.2'
    implementation('com.github.sisyphsu:dateparser:1.0.11') {
        exclude group: 'org.projectlombok'
    }

    implementation 'com.github.bumptech.glide:glide:4.16.0'
    implementation 'jp.wasabeef:glide-transformations:4.3.0'

    implementation 'org.apache.geronimo.specs:geronimo-stax-api_1.2_spec:1.2'
    implementation('com.apptasticsoftware:rssreader:3.10.0') {
        exclude group: 'commons-collections', module: 'commons-collections'
    }

    runtimeOnly 'com.fasterxml.woodstox:woodstox-core:7.1.1'

    annotationProcessor 'androidx.annotation:annotation:1.9.1'
}