// Start. Gen by unity script AndroidProjectAction.cs, do not change this
// templatesContent

apply plugin: 'com.android.application'

def keystoreProperties = new Properties()

def keystorePropertiesFile = project.rootProject.file("key/${env}_key.properties")
if (!keystorePropertiesFile.exists()) {
    keystorePropertiesFile = project.rootProject.file('key/key.properties')
}
if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

def RELEASE_STORE_FILE = keystoreProperties.getProperty('RELEASE_STORE_FILE', project.hasProperty('RELEASE_STORE_FILE') ? project.getProperty('RELEASE_STORE_FILE') : null)
def RELEASE_STORE_PASSWORD = keystoreProperties.getProperty('RELEASE_STORE_PASSWORD', project.hasProperty('RELEASE_STORE_PASSWORD') ? project.getProperty('RELEASE_STORE_PASSWORD') : null)
def RELEASE_KEY_ALIAS = keystoreProperties.getProperty('RELEASE_KEY_ALIAS', project.hasProperty('RELEASE_KEY_ALIAS') ? project.getProperty('RELEASE_KEY_ALIAS') : null)
def RELEASE_KEY_PASSWORD = keystoreProperties.getProperty('RELEASE_KEY_PASSWORD', project.hasProperty('RELEASE_KEY_PASSWORD') ? project.getProperty('RELEASE_KEY_PASSWORD') : null)
def is_sign_config = (RELEASE_STORE_FILE != null && RELEASE_STORE_PASSWORD != null && RELEASE_KEY_ALIAS != null && RELEASE_KEY_PASSWORD != null)

android {
    buildFeatures.buildConfig true
    defaultConfig {
        // buildConfigField Start

        buildConfigField 'String', 'channel', "\"${channel}\""
        buildConfigField 'String', 'appid', '"35"'
        buildConfigField 'String', 'appname', '"read"'
        buildConfigField 'String', 'appdisplayname', '"洪恩大阅读"'
        buildConfigField 'String', 'appkey', '"987210mnbvcxzlkjhgfdsapoiuytrewq"'
        buildConfigField 'String', 'rsakey', '"-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCp7JB6i0sYAgcOlB3Qnp3l6VzxtCz2w16s6WmE9A2t9/40c/tIhbCmGxAk4DRWGcLkrZKs7DquOk7i5M7x1I7PvGwpKCahlc98XM51eBdw9t2VMCezaRQE3YuHrWCCWEpC6W8a53ansyGZQocTiKqzF35HNKz9fYvVrvcrdXO0kQIDAQAB-----END PUBLIC KEY-----"'
        buildConfigField 'String', 'ihuman_env', '"IHEnvironmentTypeStaging"'
        buildConfigField 'String', 'wxAppId', '"wx8d9ac41d612c1600"'
        buildConfigField 'String', 'buglyId', '"55b181e28c"'
        buildConfigField 'String', 'appid', '"35"'
        buildConfigField 'boolean', 'ihuman_logable', 'true'


        // buildConfigField Finish
        if (channel == CHANNEL_VIVO) {
            manifestPlaceholders.put('EXT_READ_EXTERNAL_STORAGE', 'android.permission.READ_EXTERNAL_STORAGE')
            manifestPlaceholders.put('RME_READ_EXTERNAL_STORAGE', 'permission_placeholder')

            manifestPlaceholders.put('EXT_READ_PHONE_STATE', 'android.permission.READ_PHONE_STATE')
            manifestPlaceholders.put('RME_READ_PHONE_STATE', 'permission_placeholder')

            manifestPlaceholders.put('EXT_REQUEST_INSTALL_PACKAGES', 'android.permission.REQUEST_INSTALL_PACKAGES')
            manifestPlaceholders.put('RME_REQUEST_INSTALL_PACKAGES', 'permission_placeholder')

        } else if (channel == CHANNEL_HUAWEI) {
            manifestPlaceholders.put('EXT_READ_EXTERNAL_STORAGE', 'permission_placeholder')
            manifestPlaceholders.put('RME_READ_EXTERNAL_STORAGE', 'android.permission.READ_EXTERNAL_STORAGE')

            manifestPlaceholders.put('EXT_READ_PHONE_STATE', 'permission_placeholder')
            manifestPlaceholders.put('RME_READ_PHONE_STATE', 'android.permission.READ_PHONE_STATE')

            manifestPlaceholders.put('EXT_REQUEST_INSTALL_PACKAGES', 'android.permission.REQUEST_INSTALL_PACKAGES')
            manifestPlaceholders.put('RME_REQUEST_INSTALL_PACKAGES', 'permission_placeholder')

        } else if (channel == CHANNEL_MEIZU) {
            manifestPlaceholders.put('EXT_READ_EXTERNAL_STORAGE', 'permission_placeholder')
            manifestPlaceholders.put('RME_READ_EXTERNAL_STORAGE', 'android.permission.READ_EXTERNAL_STORAGE')

            manifestPlaceholders.put('EXT_READ_PHONE_STATE', 'android.permission.READ_PHONE_STATE')
            manifestPlaceholders.put('RME_READ_PHONE_STATE', 'permission_placeholder')

            manifestPlaceholders.put('EXT_REQUEST_INSTALL_PACKAGES', 'permission_placeholder')
            manifestPlaceholders.put('RME_REQUEST_INSTALL_PACKAGES', 'android.permission.REQUEST_INSTALL_PACKAGES')

        } else {
            manifestPlaceholders.put('EXT_READ_EXTERNAL_STORAGE', 'permission_placeholder')
            manifestPlaceholders.put('RME_READ_EXTERNAL_STORAGE', 'android.permission.READ_EXTERNAL_STORAGE')

            manifestPlaceholders.put('EXT_READ_PHONE_STATE', 'permission_placeholder')
            manifestPlaceholders.put('RME_READ_PHONE_STATE', 'android.permission.READ_PHONE_STATE')

            manifestPlaceholders.put('EXT_REQUEST_INSTALL_PACKAGES', 'permission_placeholder')
            manifestPlaceholders.put('RME_REQUEST_INSTALL_PACKAGES', 'android.permission.REQUEST_INSTALL_PACKAGES')
        }

        // ② 配置路由module_name
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [AROUTER_MODULE_NAME: project.getName()]
            }
        }
    }
    signingConfigs {
        release {
            if (is_sign_config) {
                storeFile file(RELEASE_STORE_FILE)
                storePassword RELEASE_STORE_PASSWORD
                keyAlias RELEASE_KEY_ALIAS
                keyPassword RELEASE_KEY_PASSWORD
            }
        }
        debug {
            if (is_sign_config) {
                storeFile file(RELEASE_STORE_FILE)
                storePassword RELEASE_STORE_PASSWORD
                keyAlias RELEASE_KEY_ALIAS
                keyPassword RELEASE_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        debug {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

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

            signingConfig signingConfigs.release
            if(env == 'staging'){
                debuggable true
            }else{
                debuggable false
            }
        }
    }
}
dependencies {
    implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar', '*.aar'])
    implementation fileTree(dir: project(':app').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])
}

// launcher/build.gradle
apply plugin: 'com.android.application'

dependencies {
    implementation project(':unityLibrary')
    }

android {
    namespace = "com.ihuman.read"
    compileSdk 35

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdk 28
        targetSdk 35
        applicationId 'com.ihumand.read.staging'
        ndk {
            if (abiFiltersArray == null){
                abiFilters 'armeabi-v7a', 'arm64-v8a'
            } else {
                abiFilters abiFiltersArray
            }
        }
        versionCode 40829198
        versionName '1.0.0'
    }

    aaptOptions {
        noCompress = ['.unity3d', '.ress', '.resource', '.obb', '.bundle', '.unityexp'] + unityStreamingAssets.tokenize(', ')
        ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
    }

    lintOptions {
        abortOnError false
    }

    buildTypes {
        debug {
            jniDebuggable true
        }
        release {
        }
    }

    packagingOptions {
        doNotStrip '*/armeabi-v7a/*.so'
        doNotStrip '*/arm64-v8a/*.so'
    }

    bundle {
        language {
            enableSplit = false
        }
        density {
            enableSplit = false
        }
        abi {
            enableSplit = true
        }
    }
}

android { ndkVersion "21.3.6528147"}


// Finish. Gen by unity script AndroidProjectAction.cs, do not change this
