/* Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.google.audio_to_tactile"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags '-std=c++11'
            }
        }
    }

    buildTypes {
        debug {}
        release {
            signingConfig signingConfigs.debug
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    buildTypes.all {
        buildConfigField("String", "BUILD_TIME", "\""
                + System.currentTimeMillis().intdiv(1000).toString() + "\"")
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    externalNativeBuild {
        cmake {
            path file('../cpp/CMakeLists.txt')
        }
    }
    ndkVersion '23.1.7779620'

    applicationVariants.all { variant ->
        variant.outputs.all { output ->
            def datestamp = (new Date()).format('yyyyMMdd')
            outputFileName = new File(
                "AudioToTactile-${variant.name}-${datestamp}.apk")
        }
    }

    sourceSets {
        main {
            manifest.srcFile '../java/com/google/audio_to_tactile/AndroidManifest.xml'
            java.srcDirs = ['../java']
            res.srcDirs = ['../java/com/google/audio_to_tactile/res']
        }
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.activity:activity-ktx:1.4.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.fragment:fragment-ktx:1.3.6'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.google.dagger:hilt-android:2.40.1'
    implementation 'javax.inject:javax.inject:1'
    implementation 'no.nordicsemi.android:dfu:1.12.0'
    kapt 'com.google.dagger:hilt-compiler:2.40.1'

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    testImplementation 'junit:junit:4.13.2'
}
