buildscript {
    ext.kotlin_version = '1.9.21'

    dependencies {
        classpath 'com.android.tools.build:gradle:8.10.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

android {
    namespace "com.ferg.awfulapp"
    compileSdk 34

    buildFeatures {
        viewBinding = true
        buildConfig = true
    }

    defaultConfig {
        applicationId = "com.ferg.awfulapp"
        minSdkVersion 24
        targetSdkVersion 34
        resourceConfigurations += ['en']

        // Stops the Gradle plugin’s automatic rasterization of vectors
        vectorDrawables.useSupportLibrary = true

        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
        // ugh I just want to run unit tests without having to avoid logging
        // this might make things difficult when we develop a comprehensive test suiahahaha
        testOptions {
            unitTests.returnDefaultValues = true
        }
    }
    packagingOptions {
        resources {
            excludes += ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE']
        }
    }


    buildTypes{

        debug{

            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            resValue "string", "app_name", "Awful (debug)"
            minifyEnabled false
            shrinkResources false
            aaptOptions.cruncherEnabled = false // disable PNG crunching
            ext.alwaysUpdateBuildId = false // generates unique build IDs for Crashlytics, slows build
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
        }

        release{
            resValue "string", "app_name", "Awful"
            minifyEnabled false
            shrinkResources false
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_21
        targetCompatibility JavaVersion.VERSION_21
    }

    tasks.register('copyThreadTags') {
        // Run this Gradle task to import Awful thread tags into the app, renaming as necessary -
        // this is meant to be a quick way to update when tags are added to the repo
        // Call it by passing the path to the folder containing the tag files (other files and
        // subfolders are ignored)
        doFirst {
            String pathParam = 'tagFolderPath'
            if (!project.hasProperty(pathParam)) {
                println("ERROR - You need to supply a path for the source folder!\nCall this task with the parameter -P$pathParam=\"full_path\"")
                throw new StopActionException()
            }
            File srcPath = file(project.findProperty(pathParam))
            if (!srcPath.directory) {
                println("ERROR - $srcPath is not a valid directory!")
                throw new StopActionException()
            }
            println "Copying tag files from $srcPath"
            copy {
                from(srcPath) { include '**/*.png' }
                into "$projectDir/src/main/res/drawable-ldpi"
                rename { fileName -> fileName.replace("-", "_") }
                rename ~/(.).(.)stars(.*)/, 'rating_$1_$2stars$3'
            }
        }
    }
    lint {
        abortOnError false
        checkReleaseBuilds false
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation 'androidx.appcompat:appcompat:1.7.0'
    implementation 'com.google.android.material:material:1.12.0'
    // these are all needed to override some old versions that are dependencies... somewhere
    implementation 'androidx.media:media:1.7.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    // used to fix SSL issues on older devices
    implementation 'com.google.android.gms:play-services-auth:16.0.1'
    implementation 'com.android.volley:volley:1.2.1'


    implementation 'com.google.code.gson:gson:2.11.0'

    implementation 'org.jsoup:jsoup:1.18.1'
    implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'
    implementation 'com.samskivert:jmustache:1.15'

    implementation group: 'cz.msebera.android' , name: 'httpclient', version: '4.4.1.1'
    implementation ('org.apache.httpcomponents:httpmime:4.3.1') {
        exclude module: "httpclient"
    }
    implementation 'org.apache.httpcomponents:httpcore:4.3.1'

    implementation 'org.apache.commons:commons-lang3:3.8.1'
    implementation 'com.ToxicBakery.viewpager.transforms:view-pager-transforms:2.0.24@aar'
    implementation 'com.github.orangegangsters:swipy:1.2.3@aar'
    implementation 'com.bignerdranch.android:expandablerecyclerview:2.1.1'
    implementation 'com.jakewharton.timber:timber:4.7.1'

    implementation 'com.github.rubensousa:BottomSheetBuilder:1.5.1'
    implementation 'androidx.preference:preference-ktx:1.2.1'

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.hamcrest:hamcrest-library:1.3'
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'

    // updating this might cause the status and navigation bar to become blue, test for this
    implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'
}
