plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'com.google.gms.google-services'
    id 'kotlin-kapt'
    id 'androidx.navigation.safeargs'
}

def relStorePassword = System.getenv("RELEASE_STORE_PASSWORD")
def relKeyPassword = System.getenv("RELEASE_KEY_PASSWORD")
def relKeyAlias = System.getenv("RELEASE_KEY_ALIAS")

def keystorePath = System.getenv('PWD') + "/app/keystore.jks"
def keystore = file(keystorePath).exists() ? file(keystorePath) : null

android {
    compileSdkVersion 31
    defaultConfig {
        applicationId "h_mal.appttude.com.driver"
        minSdkVersion 26
        targetSdkVersion 31
        versionCode 7
        versionName "2.0.0"
        testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

        boolean state = project.rootProject.file('local.properties').canRead()
        buildConfigField "boolean", "LocalState", "$state"
    }

    android {
        sourceSets {
            test {
                resources.srcDirs += ['src/test/resources']
            }
            androidTest {
                resources.srcDirs += ['src/androidTest/resources']
            }
        }
    }

    signingConfigs {
        release {
            storePassword relStorePassword
            keyPassword relKeyPassword
            keyAlias relKeyAlias
            storeFile keystore
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    buildFeatures {
        viewBinding true
    }

    flavorDimensions "Default"
    productFlavors {
        driver {
            applicationId "h_mal.appttude.com.driver"
            versionCode 7
            versionName "2.0.0"
        }
        admin {
            applicationId "h_mal.appttude.com.driver.admin"
            versionCode 4
            versionName "0.0.5"
        }
    }
    sourceSets {
        driver {
            java.srcDirs += 'src/driver/java'
            manifest {
                srcFile 'src/driver/AndroidManifest.xml'
            }
        }
        admin {
            java.srcDirs += 'src/admin/java'
            manifest {
                srcFile 'src/admin/AndroidManifest.xml'
            }
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "androidx.appcompat:appcompat:1.4.2"
    implementation "com.google.android.material:material:1.6.0"
    implementation "androidx.cardview:cardview:1.0.0"
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation "androidx.exifinterface:exifinterface:1.3.6"
    implementation "androidx.constraintlayout:constraintlayout:2.1.4"
    implementation "androidx.fragment:fragment-ktx:1.4.0"
    implementation "androidx.activity:activity-ktx:1.4.0"
    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation "androidx.navigation:navigation-fragment-ktx:2.5.3"
    implementation "androidx.navigation:navigation-ui-ktx:2.5.3"
    implementation "androidx.drawerlayout:drawerlayout:1.1.1"
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
    implementation 'androidx.viewpager:viewpager:1.0.0'
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    testImplementation "junit:junit:4.13.2"
    implementation "androidx.preference:preference-ktx:1.2.0"
    / * Android Espresso */
    def testJunitVersion = "1.1.5"
    def testRunnerVersion = "1.5.2"
    def espressoVersion = "3.5.1"
    androidTestImplementation "androidx.test.ext:junit:$testJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
    androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
    implementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
    androidTestImplementation "androidx.test:runner:$testRunnerVersion"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
    / * Google play services */
    implementation "com.google.android.gms:play-services-auth:20.4.1"
    / * Google firebase */
    def firebaseCore = "21.1.1"
    def firebaseAuth = "20.0.0"
    def firebaseStorage = "20.0.0"
    def firebaseDatabase = "19.4.0"
    implementation "com.google.firebase:firebase-core:$firebaseCore"
    implementation "com.google.firebase:firebase-auth:$firebaseAuth"
    implementation "com.google.firebase:firebase-storage:$firebaseStorage"
    implementation "com.google.firebase:firebase-database:$firebaseDatabase"
    implementation 'com.firebaseui:firebase-ui-database:8.0.2'
    / * Photoviewer */
    implementation "com.github.chrisbanes:PhotoView:2.1.0"
    / * Picasso photo loader */
    implementation "com.squareup.picasso:picasso:2.71828"
    / * Gson */
    implementation "com.google.code.gson:gson:2.8.9"
    / * coroutines support for firebase operations */
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.1"
    / * Circle Image View */
    implementation "com.mikhaellopez:circularimageview:4.3.0"
    / * Kodein Dependency Injection */
    def kodein_version = "6.2.1"
    implementation "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
    implementation "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
    / * Image Carousal */
    implementation 'com.synnapps:carouselview:0.1.5'
    / * Glide */
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
    / * OKHttp */
    implementation 'com.squareup.okhttp3:okhttp:4.10.0'
    / * Kotlin Reflect */
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.10"
    / * Retrofit2 */
    def retrofit_version = "2.9.0"
    androidTestImplementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    androidTestImplementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    / * screenshot library */
    androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
    / * Permissions dispatcher * /
    def dispatcher_ver = "4.9.2"
    implementation "com.github.permissions-dispatcher:permissionsdispatcher:${dispatcher_ver}"
    kapt "com.github.permissions-dispatcher:permissionsdispatcher-processor:${dispatcher_ver}"
    / * Date utils * /
    implementation 'net.danlew:android.joda:2.12.5'
}
