def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

apply plugin: 'com.mob.sdk'

apply plugin: 'com.huawei.agconnect'

MobSDK {
    appKey "m33ee7650da86a"
    appSecret "876f2eaebfd2a88c89d5fc294397838c"
    spEdition "fp"

    ShareSDK {

        devInfo {
            Wechat {
                id 4
                sortId 4
                appId "wx3b269e795ed23e5f"
                appSecret "64020361b8ec4c99936c0e3999a9f249"
                userName "gh_afb25ac019c9"
                path "pages/index/index.html?id=1"
                withShareTicket true
                miniprogramType 0
                bypassApproval false
                enable true
            }
            WechatMoments {
                id 3
                sortId 3
                appId "wx3b269e795ed23e5f"
                appSecret "64020361b8ec4c99936c0e3999a9f249"
                bypassApproval false
                enable true
            }
            Facebook {
                id 8
                sortId 8
                appKey "523308712059457"
                appSecret "d3a1b6377100871799d8973fbe84794a"
                callbackUri "https://mob.com"
                shareByAppClient true
                enable true
            }
            Line {
                id 2
                sortId 2
//                appKey "1656257249"
//                appSecret "7f160c9686672a50b5952364a8553f99"
                appKey "1656257047"
                appSecret "fd93cb8f12b285b80c7c67bdee8bd091"
                callbackUri "https://mob.com"
                callbackscheme "huixiang"
                shareByAppClient true
                enable true
            }
        }
    }
}

def mfph = [
        //宿主包名
        "apk.applicationId" : "com.zsw.huixiang",
        XG_ACCESS_ID : "1580005689",  // 信鸽官网注册所得ACCESS_ID
        XG_ACCESS_KEY : "A1HKKUUWI7WI",
]

android {
    compileSdkVersion 30

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        main{
            jniLibs.srcDirs = ['libs']
        }
    }

    lintOptions {
        checkReleaseBuilds false
    }

    defaultConfig {
        applicationId "com.zsw.huixiang"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

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

        manifestPlaceholders = mfph
    }

    signingConfigs {
        config {
            keyAlias 'huixiang'
            keyPassword 'huixiang'
            storeFile file('huixiang.jks')
            storePassword 'huixiang'
            v1SigningEnabled true //兼容v1
            v2SigningEnabled true //兼容v2
        }
        debug {//debug版签名配置
            keyAlias 'huixiang'
            keyPassword 'huixiang'
            storeFile file('huixiang.jks')
            storePassword 'huixiang'
            v1SigningEnabled true //兼容v1
            v2SigningEnabled true //兼容v2
        }

    }

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

    packagingOptions {
        exclude 'assets/cfg/a/DVDirectory.cfg'
        exclude 'assets/cfg/a/DVHotcity.cfg'
        exclude 'assets/main_icon_zoomin.png'
        exclude 'assets/cfg/a/mode_1/reduct.sty'
        exclude 'assets/SDK_Default_Traffic_Texture_SevereCongestion.png'
    }
    aaptOptions {
        additionalParameters '--auto-add-overlay'
        ignoreAssetsPattern "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"
    }

}



flutter {
    source '../..'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.6.5'

    implementation fileTree(include: ['*.aar'], dir: 'libs')
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.facebook.fresco:fresco:1.13.0'
    implementation "com.facebook.fresco:animated-gif:1.13.0"
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    implementation 'com.alibaba:fastjson:1.2.54'

    implementation 'com.tencent.tpns:xiaomi:1.2.7.1-release'

    implementation 'com.tencent.tpns:huawei:1.2.6.0-release'
    // HMS Core Push 模块依赖包
    implementation 'com.huawei.hms:push:5.3.0.304'
}