/*
 * Copyright 2020 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.
 */

apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "de.undercouch.download"

android {
    namespace 'org.tensorflow.lite.examples.classification.playservices'
    compileSdkVersion 33

    defaultConfig {
        applicationId 'org.tensorflow.lite.examples.classification.playservices'
        // ImageClassificationHelper class uses android.util.Size(), which is
        // available from SDK 21.
        minSdkVersion 21
        targetSdkVersion 33
        versionCode 1
        versionName "0.0.1"

        testApplicationId 'org.tensorflow.lite.examples.classification.playservices.test'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        all {
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility rootProject.ext.java_version
        targetCompatibility rootProject.ext.java_version
    }

    kotlinOptions {
        jvmTarget = rootProject.ext.java_version
    }

    buildFeatures {
        viewBinding true
    }

    flavorDimensions 'language'
    productFlavors {
        kotlin {
            getIsDefault().set(true)
            dimension 'language'
            applicationIdSuffix ".kotlin"
            versionNameSuffix "-kotlin"
        }
        java {
            dimension 'language'
            applicationIdSuffix ".java"
            versionNameSuffix "-java"
        }
    }
    sourceSets {
        main {
            assets {
                srcDirs 'src/main/assets'
            }
        }
        androidTest {
            assets {
                srcDirs 'src/androidTest/assets'
            }
        }
    }

    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'

    // App compat and UI things
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.activity:activity-ktx:1.4.0'

    // CameraX
    def camerax_version = "1.1.0-alpha12"
    implementation "androidx.camera:camera-core:${camerax_version}"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation "androidx.camera:camera-lifecycle:${camerax_version}"

    // CameraX View class
    implementation "androidx.camera:camera-view:1.0.0-alpha32"

    // Tensorflow Lite in Play Services dependencies
    implementation "com.google.android.gms:play-services-tflite-gpu:16.2.0"
    implementation "com.google.android.gms:play-services-tflite-java:16.1.0"
    implementation "com.google.android.gms:play-services-tflite-support:16.1.0"

    // Testing-only dependencies
    testImplementation 'org.robolectric:robolectric:4.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
    androidTestImplementation 'androidx.test:core-ktx:1.4.0'
    def androidx_version = "1.4.0"
    androidTestImplementation "androidx.test:runner:${androidx_version}"
    androidTestImplementation "androidx.test:rules:${androidx_version}"
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'com.google.truth:truth:1.1.3'
    androidTestImplementation 'com.google.android.gms:play-services-tasks:18.0.1'

}

// Download default models; if you wish to use your own models then
// place them in the "assets" directory and comment out this line.
project.ext.ASSET_DIR = projectDir.toString() + '/src/main/assets'
apply from:'download.gradle'

*image-classification 예제 사용