plugins {
    id 'com.android.application'
}

android {
    namespace 'com.xixun.xixunplayer'
    compileSdk 34

    defaultConfig {
        applicationId "com.xixun.xixunplayer"
        minSdk 21
        targetSdk 34
        versionCode 1
        versionName "2.1.21"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    buildFeatures {
        aidl true
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.media3:media3-exoplayer:1.2.0'
//    implementation 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8'
//    implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
    implementation files('libs/gnph.jar')
    implementation files('libs/zip4j-2.10.0.jar')
    implementation files('libs/xixun_card_settings_1.2.4.jar')
    implementation files('libs/ijkplayer-java-0.8.8.aar')
    implementation files('libs/ijkplayer-armv7a-0.8.8.aar')
    implementation files('libs/ijkplayer-arm64-0.8.8.aar')
    implementation files('libs/connService2.jar')
}

def getAppName() {
    def stringsFile = android.sourceSets.main.res.sourceFiles.find { it.name.equals 'strings.xml' }
    String s = new XmlParser().parse(stringsFile).string.find { it.@name.equals 'app_name' }.text();
    return s.replaceAll("\"", "");
}

// 修改 Apk 名
android.applicationVariants.configureEach { variant ->
    variant.outputs.configureEach {
        def fileName = "${getAppName()}-${versionName}.apk"
        outputFileName = fileName
    }
}
