File: build.gradle

package info (click to toggle)
mediainfo 20.09-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,732 kB
  • sloc: cpp: 15,682; objc: 2,760; sh: 1,343; xml: 926; python: 259; perl: 207; makefile: 173
file content (186 lines) | stat: -rw-r--r-- 6,771 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

import com.android.build.OutputFile
import groovy.xml.XmlUtil

android {
    compileSdkVersion 29
    defaultConfig {
        applicationId "net.mediaarea.mediainfo"
        minSdkVersion 14
        targetSdkVersion 29
        versionCode 18
        versionName "20.09"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
        externalNativeBuild {
            cmake {
                cppFlags "-DUNICODE -D_UNICODE -DMEDIAINFO_ADVANCED_NO -DMEDIAINFO_REFERENCES_NO -DMEDIAINFO_FILTER_NO -DMEDIAINFO_DUPLICATE_NO -DMEDIAINFO_MACROBLOCKS_NO -DMEDIAINFO_TRACE_NO -DMEDIAINFO_TRACE_FFV1CONTENT_NO -DMEDIAINFO_IBI_NO -DMEDIAINFO_DIRECTORY_NO -DMEDIAINFO_LIBCURL_NO -DMEDIAINFO_LIBMMS_NO -DMEDIAINFO_DVDIF_ANALYZE_NO -DMEDIAINFO_MPEGTS_DUPLICATE_NO -DMEDIAINFO_READTHREAD_NO -DMEDIAINFO_MD5_NO -DMEDIAINFO_SHA1_NO -DMEDIAINFO_SHA2_NO -DMEDIAINFO_EVENTS_NO -DMEDIAINFO_DEMUX_NO -DMEDIAINFO_AES_NO -DMEDIAINFO_FIXITY_NO -DMEDIAINFO_READER_NO -DMEDIAINFO_NEXTPACKET_NO"
            }
        }
        if(project.hasProperty("RELEASE_STORE_FILE")) {
            signingConfigs {
                release {
                    storeFile file(RELEASE_STORE_FILE)
                    storePassword RELEASE_STORE_PASSWORD
                    keyAlias RELEASE_KEY_ALIAS
                    keyPassword RELEASE_KEY_PASSWORD
                }
            }
        }
    }
    buildTypes {
        release {
            if(project.hasProperty("RELEASE_STORE_FILE")) {
                signingConfig signingConfigs.release
            }
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"
        }
    }
    splits {
        abi {
            enable true
            universalApk true
        }
    }

    def abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3, 'x86_64':4]
    android.applicationVariants.all { variant ->
        // Assigns a different version code for each output APK.
        variant.outputs.each {
            output ->
                def abiName = output.getFilter(OutputFile.ABI)
                output.versionCodeOverride = variant.versionCode * 10 + abiCodes.get(abiName, 0)
        }
    }
}

task copyLocales(type: DefaultTask) {
    def locales = [:]

    fileTree("../../../../Source/Resource/Plugin/Language").visit { FileVisitDetails details ->
        def locale = details.file.name.replace(".csv", "").replace("-", "-r")

        // copy localized csv into raw resources
        def raw = "src/main/res/raw-" + locale

        if (details.file.name == "en.csv") {
            raw = "src/main/res/raw"
        }

        mkdir raw
        copy {
            from details.file
            into raw
            rename { "lang.csv" }
        }

        //  update translations xml
        def csv = [:]
        file(details.file).splitEachLine(";") {
            if(it.size()==2 && it[0].size() && it[1].size()) {
                csv[it[0]] = it[1]
            }
        }
        def xml = new XmlParser().parse(file("src/main/res/values/strings.xml"))
        xml.string.each {
            if (it.@translatable == "false" || it.@csv == null || !csv.containsKey(it.@csv)) {
                xml.remove(it)
            }
            else {
                it.value = csv[it.@csv].replaceAll("\\\\r", "").replaceAll("'", "\\\\'").replaceAll("\"", "\\\\\"")
            }
        }

        if (xml.children().size()) {
            def values = "src/main/res/values-" + locale
            mkdir values

            def writer = file(values + "/strings.xml").newPrintWriter("UTF-8") // PrintWriter truncates file before write
            new XmlUtil().serialize(xml, writer)
            writer.close()
            //add locale to list
            locales[csv["  Language_Name"]] = locale
        }
    }

    // update translations list
    def xml = new XmlParser().parse(file("src/main/res/values/arrays.xml"))
    def locales_array = xml.find { it."@name" == "locales" }
    def locales_values_array = xml.find { it."@name" == "locales_values" }

    locales_array.item.each {
        if (locales_array.children().indexOf(it) > 0) {
            locales_array.remove(it)
        }
    }

    locales_values_array.item.each {
        if (locales_values_array.children().indexOf(it) > 0) {
            locales_values_array.remove(it)
        }
    }

    locales.sort().each { lang ->
        def name = new NodeBuilder().item(lang.key)
        locales_array.append(name)

        def value = new NodeBuilder().item(lang.value)
        locales_values_array.append(value)
    }

    def writer = file("src/main/res/values/arrays.xml").newPrintWriter("UTF-8") // PrintWriter truncates file before write
    new XmlUtil().serialize(xml, writer)
    writer.close()
}

preBuild.dependsOn copyLocales

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.android.material:material:1.2.0-alpha05'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.preference:preference:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.android.support:design:29.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    // Android Room
    implementation 'androidx.room:room-runtime:2.2.5'
    implementation 'androidx.room:room-rxjava2:2.2.5'
    kapt 'androidx.room:room-compiler:2.2.5'
    //RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.2.9'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
    // Android Lifecycle
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    kapt "androidx.lifecycle:lifecycle-common-java8:2.2.0"
    // Legacy file picker
    implementation 'com.github.angads25:filepicker:1.1.1'
    // Google Billing
    implementation "com.android.billingclient:billing:1.2.2"
    // KotlinX Coroutines
    api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
    // Locales manager
    implementation 'com.github.YarikSOffice:lingver:1.2.1'
}