/*
 * Copyright 2017 Akhil Kedia
 * This file is part of AllTrans.
 *
 * AllTrans is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * AllTrans is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with AllTrans. If not, see <http://www.gnu.org/licenses/>.
 *
 */



apply plugin: 'com.android.application'

android {
    signingConfigs {
        publish {
            storeFile file(RELEASE_STORE_FILE)
            storePassword RELEASE_STORE_PASSWORD
            keyAlias RELEASE_KEY_ALIAS
            keyPassword RELEASE_KEY_PASSWORD
        }
    }
    compileSdk 33
//    buildToolsVersion '32.0.0'

    defaultConfig {
        applicationId "akhil.alltrans"
        minSdkVersion 19
        //noinspection ExpiredTargetSdkVersion
        targetSdkVersion 30
        versionCode 196
        versionName "1.9.6"
        multiDexEnabled true
        signingConfig signingConfigs.publish
    }
    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    namespace 'akhil.alltrans'
}

repositories {
    google()
    mavenCentral()
//    maven { url "https://jitpack.io" }
}

dependencies {
    compileOnly 'de.robv.android.xposed:api:82:sources'
    compileOnly 'de.robv.android.xposed:api:82'

    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'com.squareup.okhttp3:okhttp:4.9.1'

    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.preference:preference:1.2.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.percentlayout:percentlayout:1.0.0'

    implementation 'com.google.firebase:firebase-analytics:21.3.0'
    implementation 'com.google.firebase:firebase-crashlytics:18.4.0'
    implementation 'com.google.mlkit:translate:17.0.1'
    implementation 'com.android.support:multidex:1.0.3'

    implementation 'com.codemybrainsout.rating:ratingdialog:1.0.8'


}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'


afterEvaluate {
    installDebug.doLast {
//        updateVirtualXposedAPP.exec()
//        clearLog.exec()
//        rebootVirtualXposedAPP.exec()
//        launchVirtualXposedAPP.exec()
    }
}

task updateVirtualXposedAPP(type: Exec) {
    def pkg = android.defaultConfig.applicationId
    commandLine android.adbExecutable, 'shell', 'am', 'broadcast', '-a', 'io.va.exposed.CMD', '-e', 'cmd', 'update', '-e', 'pkg', pkg
}

task clearLog(type: Exec) {
    commandLine android.adbExecutable, 'logcat', '-c'
}

task rebootVirtualXposedAPP(type: Exec) {
    commandLine android.adbExecutable, 'shell', 'am', 'broadcast', '-a', 'io.va.exposed.CMD', '-e', 'cmd', 'reboot'
}

task launchVirtualXposedAPP(type: Exec) {
    def pkg = "com.megabox.mop" // for example: com.tencent.mm
    commandLine android.adbExecutable, 'shell', 'am', 'broadcast', '-a', 'io.va.exposed.CMD', '-e', 'cmd', 'launch', '-e', 'pkg', pkg
}