apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'kotlin-parcelize'

android {
    compileSdk 31

    defaultConfig {
        minSdk 21
        targetSdk 31

        vectorDrawables.useSupportLibrary = true

        applicationId "code.name.monkey.retromusic"
        versionCode 10573
        versionName '5.8.0'

        buildConfigField("String", "GOOGLE_PLAY_LICENSING_KEY", "\"${getProperty(getProperties('../public.properties'), 'GOOGLE_PLAY_LICENSE_KEY')}\"")
    }
    signingConfigs {
        release {
            Properties properties = getProperties('retro.properties')
            storeFile file(getProperty(properties, 'storeFile'))
            keyAlias getProperty(properties, 'keyAlias')
            storePassword getProperty(properties, 'storePassword')
            keyPassword getProperty(properties, 'keyPassword')
        }
    }
    buildTypes {
        release {
            versionNameSuffix "_" + getDate()
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
        debug {
            applicationIdSuffix '.debug'
            versionNameSuffix ' DEBUG'
        }
    }

    buildFeatures{
        viewBinding true
    }
    packagingOptions {
        resources {
            excludes += ['META-INF/LICENSE', 'META-INF/NOTICE', 'META-INF/java.properties']
        }
    }
    lint {
        abortOnError false
        disable 'MissingTranslation', 'InvalidPackage'
    }
    compileOptions {
        coreLibraryDesugaringEnabled true

        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

    configurations.all {
        resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
    }
}

def getProperties(String fileName) {
    final Properties properties = new Properties()
    def file = rootProject.file(fileName)
    if (file.exists()) {
        file.withInputStream { stream -> properties.load(stream) }
    }
    return properties
}

static def getProperty(Properties properties, String name) {
    return properties.getProperty(name) ?: "$name missing"
}

static def getDate() {
    new Date().format('MMddyyyyss')
}

dependencies {
    implementation project(':appthemehelper')
    implementation "androidx.gridlayout:gridlayout:1.0.0"
    implementation "androidx.cardview:cardview:1.0.0"
    implementation "androidx.appcompat:appcompat:$appcompat_version"
    implementation 'androidx.annotation:annotation:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation "androidx.preference:preference-ktx:$preference_version"
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.palette:palette-ktx:1.0.0'

    //Cast Dependencies
    implementation 'androidx.mediarouter:mediarouter:1.3.0-rc01'
    implementation 'com.google.android.gms:play-services-cast-framework:21.0.1'
    //WebServer by NanoHttpd
    implementation "org.nanohttpd:nanohttpd:2.3.1"

    implementation "androidx.navigation:navigation-runtime-ktx:$navigation_version"
    implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
    implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"

    def room_version = '2.4.2'
    implementation "androidx.room:room-runtime:$room_version"
    implementation "androidx.room:room-ktx:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    def lifecycle_version = "2.4.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

    implementation "androidx.core:core-splashscreen:1.0.0-beta02"

    implementation 'com.google.android.play:core-ktx:1.8.1'
    implementation "com.google.android.material:material:$mdc_version"

    def retrofit_version = '2.9.0'
    implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
    implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.6'

    def material_dialog_version = "3.3.0"
    implementation "com.afollestad.material-dialogs:core:$material_dialog_version"
    implementation "com.afollestad.material-dialogs:input:$material_dialog_version"
    implementation "com.afollestad.material-dialogs:color:$material_dialog_version"
    implementation "com.afollestad.material-dialogs:bottomsheets:$material_dialog_version"

    implementation 'com.afollestad:material-cab:2.0.1'

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    def kotlin_coroutines_version = '1.6.1'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"

    def koin_version = '3.2.0-beta-1'
    implementation "io.insert-koin:koin-core:$koin_version"
    implementation "io.insert-koin:koin-android:$koin_version"

    def glide_version = '4.13.1'
    implementation "com.github.bumptech.glide:glide:$glide_version"
    kapt "com.github.bumptech.glide:compiler:$glide_version"
    implementation "com.github.bumptech.glide:okhttp3-integration:$glide_version"

    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'

    implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0'

    implementation 'com.github.bosphere.android-fadingedgelayout:fadingedgelayout:1.0.0'

    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:3.0.0-RC3'
    implementation 'com.github.jetradarmobile:android-snowfall:1.2.1'

    implementation "dev.chrisbanes.insetter:insetter:0.6.1"

    implementation 'org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5'
    implementation 'com.github.Adonai:jaudiotagger:2.3.15'
    implementation 'com.anjlab.android.iab.v3:library:2.0.3'
    implementation 'com.r0adkll:slidableactivity:2.1.0'
    implementation 'com.heinrichreimersoftware:material-intro:2.0.0'
    implementation 'com.github.dhaval2404:imagepicker:2.1'
    implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
    implementation 'cat.ereza:customactivityoncrash:2.3.0'
    implementation 'me.tankery.lib:circularSeekBar:1.3.2'
    debugImplementation 'com.github.amitshekhariitbhu:Android-Debug-Database:1.0.6'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8.1'
}