apply plugin: 'com.android.application'

android {
    compileSdk 34

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 34
        versionCode 245
        versionName '2.5.25'

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        "resourcePackageName": "org.transdroid",
                        "androidManifestFile": file("src/main/AndroidManifest.xml").absolutePath
                ]
            }
        }
    }

    signingConfigs {
        releaseConfig {
            def propsFile = rootProject.file('keystore.properties')
            def configName = 'releaseConfig'

            if (propsFile.exists() && android.signingConfigs.hasProperty(configName)) {
                def props = new Properties()
                props.load(new FileInputStream(propsFile))
                keyAlias = props['keyAlias']
                storeFile = file(props['storeFile'])
                keyPassword = props['keyPassword']
                storePassword = props['storePassword']
            }
        }
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            versionNameSuffix '.debug'
            resValue 'string', 'app_version', "${defaultConfig.versionName}${versionNameSuffix} (${defaultConfig.versionCode})"
        }
        release {
            signingConfig signingConfigs.releaseConfig
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            resValue 'string', 'app_version', "${defaultConfig.versionName} (${defaultConfig.versionCode})"
        }
    }

    flavorDimensions "version"
    productFlavors {
        full {
            dimension "version"
            applicationId 'org.transdroid.full'
            resValue "string", "search_history_authority", applicationId + ".search.SearchHistoryProvider"
        }
        lite {
            dimension "version"
            applicationId 'org.transdroid.lite'
            resValue "string", "search_history_authority", applicationId + ".search.SearchHistoryProvider"
        }
    }


    compileOptions {
        encoding = 'UTF-8'
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    useLibrary 'org.apache.http.legacy'
    lint {
        disable 'MissingTranslation', 'ExtraTranslation', 'StringFormatInvalid', 'ValidFragment', 'Registered'
    }
    namespace 'org.transdroid'
}

dependencies {
    // Android support
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.preference:preference:1.2.1'
    implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
    implementation 'com.google.android.material:material:1.10.0'

    // Other
    implementation 'org.androidannotations:androidannotations-api:4.8.0'
    implementation 'org.androidannotations:ormlite-api:4.8.0'
    implementation 'com.j256.ormlite:ormlite-android:6.1'
    implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    implementation 'com.nispok:snackbar:2.11.0'
    implementation 'org.apache.openjpa:openjpa-lib:3.2.2'
    implementation 'net.iharder:base64:2.3.9'
    implementation('com.github.afollestad.material-dialogs:core:0.9.6.0@aar') {
        transitive = true
    }
    implementation 'androidx.work:work-runtime:2.9.0'
    implementation "androidx.lifecycle:lifecycle-viewmodel:2.6.2"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"

    annotationProcessor 'org.androidannotations:androidannotations:4.8.0'
    annotationProcessor 'org.androidannotations:ormlite:4.8.0'

    // Copied From androidSdkPath/platforms/android-31/optional/org.apache.http.legacy.jar
    // Using it as a compileOnly so this helps while developing, but is not compiled into the final
    // app, see https://developer.android.com/studio/build/dependencies#dependency_configurations
    compileOnly files('libs/org.apache.http.legacy.jar')
}
