plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'kotlin-parcelize'
    id 'dagger.hilt.android.plugin'
    //极光推送start
//    id 'com.google.gms.google-services'
//    id 'com.huawei.agconnect'
    //极光推送end
}

// Read values from gradle.properties or system environment variable(从gradle.properties里读取值)
def getStripeReleaseKey() {
    return findProperty('STRIPE_RELEASE_KEY') ?: ""
}

def getKey(def key) {
    return findProperty(key) ?: ""
}

android {

    compileSdkVersion 35
//    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.abbidot.tracker"
        minSdkVersion 23
        targetSdkVersion 35
        versionCode 2103
//        versionName "2.1.3"
        versionName "2.1.3-Beta1"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        ndk {
            //选择要添加的对应 cpu 类型的 .so 库。
            abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64'
        }

        manifestPlaceholders = [
                GOOGLE_MAP_KEY     : getKey("GOOGLE_MAP_KEY"),
                BAIDU_MAP_KEY      : getKey("BAIDU_MAP_KEY"),
                STRIPE_RELEASE_KEY : getStripeReleaseKey(),
                STRIPE_TEST_KEY    : getKey("STRIPE_TEST_KEY"),
                BUGLY_KEY          : getKey("BUGLY_KEY"),
                MAPBOX_ACCESS_TOKEN: getKey("MAPBOX_ACCESS_TOKEN"),
                HTTP_REQUEST_KEY   : getKey("HTTP_REQUEST_KEY"),

                JPUSH_PKGNAME      : "${applicationId}",
                JPUSH_APPKEY       : "c968a96f76fc4f52e0f764ee", //JPush 上注册的包名对应的 Appkey.
                JPUSH_CHANNEL      : "developer-default", //暂时填写默认值即可.
//                MEIZU_APPKEY  : "MZ-魅族的APPKEY",
//                MEIZU_APPID   : "MZ-魅族的APPID",
//                XIAOMI_APPID  : "MI-小米的APPID",
//                XIAOMI_APPKEY : "MI-小米的APPKEY",
//                OPPO_APPKEY   : "OP-oppo的APPKEY",
//                OPPO_APPID    : "OP-oppo的APPID",
//                OPPO_APPSECRET: "OP-oppo的APPSECRET",
//                VIVO_APPKEY   : "vivo的APPKEY",
//                VIVO_APPID    : "vivo的APPID"
        ]
    }

    // 读取local.properties文件
    Properties properties = new Properties()
    InputStream inputStream = project.rootProject.file('local.properties').newDataInputStream()
    properties.load(inputStream)
    // 读取签名文件
    def keyKeyStoreFile = file(properties.getProperty('keyStoreFile'))
    // 读取签名文件别名、密码等信息
    def keyKeyStorePassword = properties.getProperty('keyStorePassword')
    def keyKeyAlias = properties.getProperty('keyAlias')
    def keyKeyAliasPassword = properties.getProperty('keyAliasPassword')
    signingConfigs {
        release {
            storeFile keyKeyStoreFile
            storePassword keyKeyStorePassword
            keyAlias keyKeyAlias
            keyPassword keyKeyAliasPassword
        }
        debug {
            storeFile keyKeyStoreFile
            storePassword keyKeyStorePassword
            keyAlias keyKeyAlias
            keyPassword keyKeyAliasPassword
        }
    }
    buildTypes {
//        release {
//            minifyEnabled false
//            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//        }
        debug {
//            multiDexKeepProguard file('multidex-config.pro')
            debuggable true
            jniDebuggable true
            // 移除无用的资源文件
            shrinkResources false
            // ZipAlign 优化
            zipAlignEnabled false
            // 设置混淆
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.debug
        }

        release {
//            multiDexKeepProguard file('multidex-config.pro')
            debuggable false
            jniDebuggable false
            // 移除无用的资源文件
            shrinkResources false
            // ZipAlign 优化
            zipAlignEnabled true
            // 设置混淆
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }

    applicationVariants.all { variant ->

        // Apk 输出文件名配置
        variant.outputs.all { output ->
            outputFileName = 'Tracker_V' + variant.versionName + '_' + new Date().format('yyyyMMddhhmmss') + '_' + variant.buildType.name
//            if (variant.buildType.name == buildTypes.release.getName()) {
//                outputFileName += '_' + new Date().format('yyyyMMddhhmmss') + '_' + variant.buildType.name
//            }
            outputFileName += '.apk'
        }
    }

    viewBinding {
        enabled = true
    }
    lint {
        abortOnError false
        checkReleaseBuilds false
    }
    namespace 'com.abbidot.tracker'
    buildFeatures {
        viewBinding true
        buildConfig = true
    }

    //减少apk包的体积
    packagingOptions {
        //压缩动态库(对应iniLibs的配置)
        jniLibs {
            useLegacyPackaging = true
        }
        //压缩dex(对应dex的配置)
        dex {
            useLegacyPackaging = true
        }
    }
}

dependencies {
    // 基类库
    implementation project(':baselibrary')
    implementation project(':easyPhotos')
    //蓝牙架包https://github.com/Jasonchenlijian/FastBle
//    implementation 'com.github.Jasonchenlijian:FastBle:2.4.0'
    implementation project(':FastBleLib')
    //轻量级的Android端Socket框架https://github.com/jiusetian/EasySocket
    implementation project(':easysocket')

//    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
//    implementation 'androidx.appcompat:appcompat:1.7.0'
//    implementation 'com.google.android.material:material:1.10.0'
//    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'

    // Android官方库
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.arch.core:core-common:2.2.0'
    implementation 'androidx.arch.core:core-runtime:2.2.0'
    implementation 'androidx.activity:activity-ktx:1.9.3'
    implementation 'androidx.fragment:fragment-ktx:1.5.6'
    implementation 'androidx.annotation:annotation:1.9.1'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.7'
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.8.7'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7'

    implementation 'androidx.room:room-runtime:2.5.2'
//    implementation 'androidx.room:room-rxjava2:2.3.0'
    implementation 'androidx.room:room-ktx:2.5.2'
    kapt 'androidx.room:room-compiler:2.5.2'
    //hilt依赖注入https://mvnrepository.com/artifact/com.google.dagger/hilt-android-gradle-plugin
    implementation "com.google.dagger:hilt-android:2.57"
    kapt "com.google.dagger:hilt-android-compiler:2.57"

    //Android UI 开发效率的 UI 库https://github.com/Tencent/QMUI_Android
    implementation 'com.qmuiteam:qmui:2.1.0'
    implementation 'com.qmuiteam:arch:2.1.0'
    kapt 'com.qmuiteam:arch-compiler:2.1.0'

    // 协程
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2'

    // 图片框架 https://github.com/coil-kt/coil/blob/main/README-zh.md
    implementation "io.coil-kt:coil:1.4.0"
    //选择添加
    implementation "io.coil-kt:coil-gif:1.4.0"//支持GIF

    //lottie动画https://github.com/airbnb/lottie-android
    implementation 'com.airbnb.android:lottie:6.6.7'
    //https://github.com/CymChad/BaseRecyclerViewAdapterHelper
    implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.11'
    //升级recyclerview，因BaseRecyclerViewAdapterHelper item点击事件是使用1.2.0
    implementation 'androidx.recyclerview:recyclerview:1.3.1'

    //谷歌地图
    implementation 'com.google.android.gms:play-services-maps:19.2.0'
    //地图操作工具类，添加标记等https://github.com/googlemaps/android-maps-utils
//    implementation 'com.google.maps.android:android-maps-utils:2.3.0'
//    implementation 'com.google.maps.android:maps-utils-ktx:3.2.1'
    //谷歌地图places
//    implementation 'com.google.android.libraries.places:places:2.5.0'
    //连接谷歌服务定位,登录谷歌
//    implementation 'com.google.android.gms:play-services-auth:19.2.0'
    //定位
    implementation 'com.google.android.gms:play-services-location:21.3.0'

    //动画https://github.com/daimajia/AndroidViewAnimations
    implementation 'com.daimajia.androidanimations:library:2.4@aar'

    //mapbox地图https://github.com/mapbox/mapbox-maps-android
//    implementation 'com.mapbox.maps:android:10.2.0'
    //https://github.com/mapbox/mapbox-search-android
    //用mapbox搜索SDK,地理编码 有搜索ui组件，已包括mapbox-search-android架包
    implementation "com.mapbox.search:mapbox-search-android-ui:2.5.1"
//    mapbox搜索SDK,地理编码 没有搜索ui组件
//    implementation "com.mapbox.search:mapbox-search-android:1.0.0-beta.25"
    //用于计算距离https://docs.mapbox.com/android/java/guides/turf/#available-methods
    implementation 'com.mapbox.mapboxsdk:mapbox-sdk-turf:6.15.0'
    //用于计算路线规划信息https://docs.mapbox.com/android/java/examples/dashed-directions-line/
    implementation 'com.mapbox.mapboxsdk:mapbox-sdk-services:6.3.0'

    // 权限请求框架：https://github.com/getActivity/XXPermissions
    implementation 'com.github.getActivity:XXPermissions:25.2'
    // 吐司框架：https://github.com/getActivity/ToastUtils
    implementation 'com.github.getActivity:Toaster:13.2'
    // 日志调试框架：https://github.com/getActivity/Logcat ,在debug模式下集成
    debugImplementation 'com.github.getActivity:Logcat:12.3'

    // PictureSelector图片选择器,需要compileSdkVersion=31 https://github.com/LuckSiege/PictureSelector
//    implementation 'io.github.lucksiege:pictureselector:v3.0.3'
    //拍照相册选择器、相册编辑添加水印 https://github.com/HuanTanSheng/EasyPhotos(没有适配Android13 相册)
//    implementation 'com.github.HuanTanSheng:EasyPhotos:3.1.5'
    //压缩图片 https://github.com/zetbaitsu/Compressor
    implementation 'id.zelory:compressor:3.0.1'
    //图片裁剪功能https://github.com/CanHub/Android-Image-Cropper
    implementation 'com.vanniktech:android-image-cropper:4.6.0'

    //******************************************极光推送start*****************************************************
//    https://docs.jiguang.cn/jpush/client/Android/android_guide
//    implementation 'cn.jiguang.sdk:jcore:3.1.2'  // 此处以JCore 2.7.2 版本为例。
//    implementation 'cn.jiguang.sdk:jpush:4.6.0'  // 此处以JPush 4.0.0 版本为例
    implementation 'cn.jiguang.sdk:jcore-google:5.1.0'  // 此处以JCore 2.7.2 版本为例。
    implementation 'cn.jiguang.sdk:jpush-google:5.8.0'  // 此处以JPush 4.0.0 版本为例
    // 接入华为厂商
//    implementation 'com.huawei.hms:push:6.1.0.300'
//    implementation 'cn.jiguang.sdk.plugin:huawei:4.0.0'// 极光厂商插件版本与接入 JPush 版本保持一致，下同
    // 接入 FCM 厂商
//    implementation 'com.google.firebase:firebase-messaging:23.0.0'
//    implementation 'cn.jiguang.sdk.plugin:fcm:4.6.6'
    // 接入魅族厂商
//    implementation 'cn.jiguang.sdk.plugin:meizu:4.6.0'
    // 接入 VIVO 厂商
//    implementation 'cn.jiguang.sdk.plugin:vivo:4.6.0'
    // 接入 OPPO 厂商
//    implementation 'cn.jiguang.sdk.plugin:oppo:4.6.0'
    // 接入小米厂商
//    implementation 'cn.jiguang.sdk.plugin:xiaomi:4.6.0'

    //******************************************极光推送end*******************************************************

    //其中指代最新Bugly SDK版本号，也可以指定明确的版本号，例如4.0.0
    implementation 'com.tencent.bugly:crashreport:4.1.9.3'
    //其中latest.release指代最新Bugly NDK版本号，也可以指定明确的版本号，例如3.9.2
//    implementation 'com.tencent.bugly:nativecrashreport:3.9.2'

    //braintree 信用卡支付https://github.com/braintree/braintree_android
    implementation 'com.braintreepayments.api:card:4.31.0'
    //braintree PayPal支付https://developer.paypal.com/braintree/docs/guides/client-sdk/migration/android/v4
    implementation 'com.braintreepayments.api:paypal:4.31.0'
    //Stripe 支付https://github.com/stripe/stripe-android
    implementation 'com.stripe:stripe-android:20.27.0'

    //百度地图基础定位组件
    implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.6.5.1'
    //地图组件
    implementation 'com.baidu.lbsyun:BaiduMapSDK_Map:7.5.2'
    //检索组件
    implementation 'com.baidu.lbsyun:BaiduMapSDK_Search:7.5.2'
    //工具组件
    implementation 'com.baidu.lbsyun:BaiduMapSDK_Util:7.5.2'

    //微信登录、支付
    implementation 'com.tencent.mm.opensdk:wechat-sdk-android:+'
    //支付宝支付
    implementation 'com.alipay.sdk:alipaysdk-android:+@aar'

    //dfu升级https://github.com/NordicSemiconductor/Android-DFU-Library
    implementation 'no.nordicsemi.android:dfu:2.9.0'

    //适配Android 12以下SplashScreen启动动画，闪屏图片
    implementation 'androidx.core:core-splashscreen:1.0.1'
    //优雅、万能自定义日历https://github.com/huanghaibin-dev/CalendarView
//    implementation 'com.haibin:calendarview:3.7.1'
    //https://github.com/angcyo/CalendarView
    implementation 'com.github.angcyo:CalendarView:3.7.1.43'
    //Google出品的流式布局 flexbox-layout 支持RecyclerView https://gitcode.com/google/flexbox-layout?utm_source=csdn_github_accelerator
    implementation 'com.google.android.flexbox:flexbox:3.0.0'
    //facebook分享sdk
//    implementation 'com.facebook.android:facebook-android-sdk:latest.release'

}