apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.github.triplet.gradle:play-publisher:1.2.2'
    }
}

apply plugin: 'com.github.triplet.play'

android {
    def versionPropsFile = file('version.properties')  //maintains version number of apk
    Properties versionProps = new Properties()
    versionProps.load(new FileInputStream(versionPropsFile))

    def runTasks = gradle.startParameter.taskNames
    if (':app:bundleRelease' in runTasks) {  //check is release build is getting executed
        versionProps['VERSION_PATCH'] = (versionProps['VERSION_PATCH'].toInteger() + 1).toString()
        versionProps['VERSION_NUMBER'] = (versionProps['VERSION_NUMBER'].toInteger() + 1).toString()
        versionProps['VERSION_BUILD'] = (versionProps['VERSION_BUILD'].toInteger() + 1).toString()
        versionProps.store(versionPropsFile.newWriter(), null)
    }

    if (versionPropsFile.canRead()) {
        def mVersionName = "v10.0.${versionProps['VERSION_PATCH']}"
        defaultConfig {
            applicationId 'com.bhandari.music'
            minSdkVersion 24
            compileSdk 34
            targetSdkVersion 34
            versionCode versionProps['VERSION_NUMBER'].toInteger()
            versionName "${mVersionName} Build: ${versionProps['VERSION_BUILD']}"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
    } else {
        throw new FileNotFoundException("Could not read version.properties!")
    }

    signingConfigs {
        release {
            def keystorePropertiesFile = rootProject.file("keystore.properties")

            if (keystorePropertiesFile.exists()) {
                def keystoreProperties = new Properties()
                keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
            }
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            multiDexEnabled false
        }

        debug {
            applicationIdSuffix ".dev"
            multiDexEnabled true
        }
    }


    dataBinding {
        enabled = true
    }

    kapt {
        generateStubs = true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    buildFeatures {
        viewBinding = true
    }
    namespace 'com.music.player.bhandari.m'
    lint {
        abortOnError false
        disable 'MissingTranslation', 'NonConstantResourceId'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.6.1'
    //noinspection GradleCompatible
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    //noinspection GradleCompatible
    implementation 'com.google.android.material:material:1.11.0'
    //noinspection GradleCompatible
    implementation 'androidx.cardview:cardview:1.0.0'
    testImplementation 'junit:junit:4.13.2'

    //small animations for lyric loading
    implementation 'com.wang.avi:library:2.1.3'

    //slide up panel for now playing view
    implementation 'com.sothree.slidinguppanel:library:3.4.0'

    //shake detection
    implementation 'com.squareup:seismic:1.0.3'

    //glide
    //noinspection GradleDependency
    implementation 'com.github.bumptech.glide:glide:3.7.0'

    //blur images
    implementation 'jp.wasabeef:blurry:4.0.1'

    //scroll smoothly and fast scroll
    implementation 'com.nshmura:snappysmoothscroller:1.0.0'
    implementation 'com.simplecityapps:recyclerview-fastscroll:2.0.1'

    //jsoup and okhttp
    implementation 'org.jsoup:jsoup:1.17.2'
    implementation 'com.squareup.okhttp:okhttp:2.7.5'

    //first time info bubbles
    implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'

    //shine animation after clicking fav
    implementation 'com.sackcentury:shinebutton:1.0.0'

    //dialogs
    //implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    implementation project(':dialogs')

    //firebase
    implementation 'com.google.firebase:firebase-core:21.1.1'
    implementation 'com.google.firebase:firebase-messaging:23.4.0'
    implementation 'com.google.firebase:firebase-database:20.3.0'
    implementation 'com.google.firebase:firebase-config:21.6.0'

    //gson
    implementation 'com.google.code.gson:gson:2.10.1'

    //leak detection
    //debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'

    //crop images
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'

    //view binding
    //noinspection AnnotationProcessorOnCompilePath
    implementation 'com.jakewharton:butterknife:10.2.3'
    kapt 'com.jakewharton:butterknife-compiler:10.2.3'

    implementation 'io.github.inflationx:calligraphy3:3.1.1'
    implementation 'io.github.inflationx:viewpump:2.0.3'

    //flow layout
    implementation 'com.google.android:flexbox:1.0.0'

    //kotlin
    //noinspection GradleDependency,DifferentStdlibGradleVersion
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0'
}

repositories {
    maven {
        url 'https://maven.google.com'
    }
    mavenCentral()
}
apply plugin: 'com.google.gms.google-services'
