plugins {
    id 'com.android.application'
    id 'com.mikepenz.aboutlibraries.plugin'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.fox2code.mmm"
        minSdk 21
        targetSdk 32
        versionCode 46
        versionName "0.5.3"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

    flavorDimensions "type"
    productFlavors {
        "default" {
            dimension "type"
            buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true"
            buildConfigField(
                "java.util.List<String>",
                "DISABLED_REPOS",
                "java.util.Arrays.asList()",
            )
        }

        fdroid {
            dimension "type"
            applicationIdSuffix ".fdroid"

            // Need to disable auto-updater for F-Droid flavor because their inclusion policy
            // forbids downloading blobs from third-party websites (and F-Droid APK isn't signed
            // with our keys, so the APK wouldn't install anyways).
            buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "false"

            // Repo with ads or tracking feature are disabled by default for the
            // F-Droid flavor.
            buildConfigField(
                "java.util.List<String>",
                "DISABLED_REPOS",
                "java.util.Arrays.asList(\"androidacy_repo\")",
            )
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    lint {
        disable 'MissingTranslation'
        disable 'TypographyEllipsis'
    }
}

aboutLibraries {
    additionalLicenses = ["LGPL_3_0_only"]
}

configurations {
    implementation.exclude group: 'org.jetbrains' , module: 'annotations'
}

dependencies {
    // UI
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'androidx.emoji2:emoji2:1.1.0'
    implementation 'androidx.emoji2:emoji2-views-helper:1.1.0'
    implementation 'androidx.preference:preference:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'androidx.webkit:webkit:1.4.0'
    implementation 'com.google.android.material:material:1.6.1'
    implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}"
    implementation "dev.rikka.rikkax.layoutinflater:layoutinflater:1.2.0"
    implementation "dev.rikka.rikkax.insets:insets:1.2.0"
    implementation 'com.github.Dimezis:BlurView:version-1.6.6'
    implementation 'com.github.KieronQuinn:MonetCompat:0.4.1'

    // Utils
    implementation 'com.squareup.okhttp3:okhttp-dnsoverhttps:4.9.3'
    implementation 'com.squareup.okhttp3:okhttp-brotli:4.9.3'
    implementation 'com.github.topjohnwu.libsu:io:5.0.1'
    implementation 'com.github.Fox2Code:RosettaX:1.0.8'
    implementation 'com.github.Fox2Code:AndroidANSI:1.0.1'

    // Markdown
    implementation "io.noties.markwon:core:4.6.2"
    implementation "io.noties.markwon:html:4.6.2"
    implementation "io.noties.markwon:image:4.6.2"
    implementation "io.noties.markwon:syntax-highlight:4.6.2"
    annotationProcessor "io.noties:prism4j-bundler:2.0.0"
    implementation "com.caverock:androidsvg:1.4"

    // Utils for compat (Needs to be outsourced ASAP)
    // compileOnly "org.robolectric:android-all:11-robolectric-6757853"

    // Test
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
