| 7 |
| def verCode = 601 |
| 8 |
| 9 | if (System.getenv("DEBUG_BUILD") == "true") { |
| 10 | verName += "-" + RuntimeUtil.execForStr("git log --pretty=format:'%h' -n 1").trim() |
| 11 | } |
| 12 |
| 13 | def officialVer = "8.6.1" |
| 14 | def officialCode = 2594 |
| 15 |
| 16 | def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") |
| 17 |
| 18 | def beta = verName.contains("preview") |
| 19 |
| 20 | if (serviceAccountCredentialsFile.isFile()) { |
| 21 | setupPlay(beta) |
| 22 | play.serviceAccountCredentials = serviceAccountCredentialsFile |
| 23 | } else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) { |
| 24 | setupPlay(beta) |
| 25 | } |
| 26 |
| 27 | void setupPlay(boolean beta) { |
| 28 | apply plugin: "com.github.triplet.play" |
| 29 | play { |
| 30 | track = beta ? "beta" : "production" |
| 31 | defaultToAppBundles = true |
| 32 | } |
| 33 | } |
| 34 |
| 35 | configurations { |
| 36 | compile.exclude module: "support-v4" |
| 37 | } |
| 38 |
| 39 | def keystorePwd = null |
| 40 | def alias = null |
| 41 | def pwd = null |
| 42 | def disableCMakeRelWithDebInfo = System.getenv("COMPILE_NATIVE") == null |
| 43 |
| 44 | Properties properties |
| 45 | def base64 = System.getenv("LOCAL_PROPERTIES") |
| 46 | if (base64 != null && !base64.isBlank()) { |
| 47 | properties = new Properties() |
| 48 | properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) |
| 49 | } else if (project.rootProject.file("local.properties").exists()) { |
| 50 | properties = new Properties() |
| 51 | properties.load(project.rootProject.file("local.properties").newDataInputStream()) |
| 52 | } |
| 53 |
| 54 | if (properties != null) { |
| 55 | keystorePwd = properties.getProperty("KEYSTORE_PASS") |
| 56 | alias = properties.getProperty("ALIAS_NAME") |
| 57 | pwd = properties.getProperty("ALIAS_PASS") |
| 58 | } |
| 59 |
| 60 | keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS") |
| 61 | alias = alias ?: System.getenv("ALIAS_NAME") |
| 62 | pwd = pwd ?: System.getenv("ALIAS_PASS") |
| 63 |
| 64 | def targetTask = "" |
| 65 | if (!gradle.startParameter.taskNames.isEmpty()) { |
| 66 | if (gradle.startParameter.taskNames.size == 1) { |
| 67 | targetTask = gradle.startParameter.taskNames[0].toLowerCase() |
| 68 | } |
| 69 | } |
| 70 |
| 71 | def nativeTarget = System.getenv("NATIVE_TARGET") |
| 72 | if (nativeTarget == null) nativeTarget = "" |
| 73 |
| 74 | android { |
| 75 | compileSdkVersion 31 |
| 76 | buildToolsVersion "31.0.0" |
| 77 | ndkVersion rootProject.ext.ndkVersion |
| 78 |
| 79 | defaultConfig.applicationId = "xyz.nextalone.nagram" |
| 80 |
| 81 | splits { |
| 82 |
| 83 | abi { |
| 84 | if (targetTask.contains("fdroid")) { |
| 85 | enable false |
| 86 | universalApk true |
| 87 | } else { |
| 88 | enable true |
| 89 | universalApk false |
| 90 | if (!nativeTarget.isBlank()) { |
| 91 | reset() |
| 92 | include nativeTarget |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 |
| 97 | } |
| 98 |
| 99 | defaultConfig { |
| 100 | minSdkVersion 16 |
| 101 | //noinspection ExpiredTargetSdkVersion,OldTargetApi |
| 102 | targetSdkVersion 30 |
| 103 |
| 104 | versionName verName |
| 105 | versionCode verCode |
| 106 |
| 107 | def appId = "1391584" |
| 108 | def appHash = "355c91550b0d658cfb7ff89dcf91a08c" |
| 109 |
| 110 | //obtain your own keys at https://core.telegram.org/api/obtaining_api_id |
| 111 |
| 112 | if (properties != null) { |
| 113 | appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId |
| 114 | appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash |
| 115 | } |
| 116 |
| 117 |
| 118 | buildConfigField "String", "OFFICIAL_VERSION", "\"" + officialVer + "\"" |
| 119 | buildConfigField "int", "OFFICIAL_VERSION_CODE", officialCode + "" |
| 120 | buildConfigField "int", "APP_ID", appId |
| 121 | buildConfigField "String", "APP_HASH", "\"" + appHash + "\"" |
| 122 |
| 123 | externalNativeBuild { |
| 124 | cmake { |
| 125 | version "3.10.2" |
| 126 | arguments "-DANDROID_STL=c++_static", "-DANDROID_PLATFORM=android-16", "-DNDK_CCACHE=ccache", "-j=${Runtime.getRuntime().availableProcessors()}" |
| 127 | } |
| 128 | } |
| 129 |
| 130 | } |
| 131 |
| 132 | bundle { |
| 133 | language { |
| 134 | enableSplit = false |
| 135 | } |
| 136 | } |
| 137 |
| 138 | externalNativeBuild { |
| 139 | cmake { |
| 140 | path "jni/CMakeLists.txt" |
| 141 | } |
| 142 | } |
| 143 |
| 144 | lintOptions { |
| 145 | disable "MissingTranslation" |
| 146 | disable "ExtraTranslation" |
| 147 | disable "BlockedPrivateApi" |
| 148 | } |
| 149 |
| 150 | packagingOptions { |
| 151 |
| 152 | exclude "/fabric/**" |
| 153 | exclude "/META-INF/*.version" |
| 154 | exclude "/META-INF/*.kotlin_module" |
| 155 | exclude "/META-INF/native-image/**" |
| 156 | exclude "/builddef.lst" |
| 157 | exclude "/*.txt" |
| 158 | exclude "/DebugProbesKt.bin" |
| 159 | exclude "/okhttp3/internal/publicsuffix/NOTICE" |
| 160 |
| 161 | } |
| 162 |
| 163 | dexOptions { |
| 164 | jumboMode = true |
| 165 | } |
| 166 |
| 167 | compileOptions { |
| 168 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 169 | targetCompatibility JavaVersion.VERSION_1_8 |
| 170 |
| 171 | coreLibraryDesugaringEnabled true |
| 172 | } |
| 173 |
| 174 | kotlinOptions { |
| 175 | jvmTarget = JavaVersion.VERSION_1_8.toString() |
| 176 | } |
| 177 |
| 178 | testOptions { |
| 179 | unitTests.includeAndroidResources = true |
| 180 | } |
| 181 |
| 182 | signingConfigs { |
| 183 | release { |
| 184 | storeFile project.file("release.keystore") |
| 185 | storePassword keystorePwd |
| 186 | keyAlias alias |
| 187 | keyPassword pwd |
| 188 | } |
| 189 | } |
| 190 |
| 191 | buildTypes { |
| 192 | debug { |
| 193 | isDefault true |
| 194 | debuggable true |
| 195 | jniDebuggable true |
| 196 | multiDexEnabled true |
| 197 | zipAlignEnabled true; |
| 198 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 199 | ndk.debugSymbolLevel = "FULL" |
| 200 | } |
| 201 |
| 202 | releaseNoGcm { |
| 203 | debuggable false |
| 204 | jniDebuggable false |
| 205 | minifyEnabled true |
| 206 | shrinkResources true |
| 207 | multiDexEnabled true |
| 208 | zipAlignEnabled true |
| 209 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 210 | matchingFallbacks = ["release", "debug"] |
| 211 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 212 | } |
| 213 |
| 214 | release { |
| 215 | debuggable false |
| 216 | jniDebuggable false |
| 217 | minifyEnabled true |
| 218 | shrinkResources true |
| 219 | multiDexEnabled true |
| 220 | zipAlignEnabled true |
| 221 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 222 | matchingFallbacks = ["release", "debug"] |
| 223 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 224 | } |
| 225 |
| 226 | foss { |
| 227 | debuggable false |
| 228 | jniDebuggable false |
| 229 | minifyEnabled true |
| 230 | shrinkResources true |
| 231 | multiDexEnabled true |
| 232 | zipAlignEnabled true |
| 233 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 234 | matchingFallbacks = ["release", "debug"] |
| 235 | } |
| 236 |
| 237 | fdroidRelease { |
| 238 | initWith foss |
| 239 | matchingFallbacks = ["release", "debug"] |
| 240 | } |
| 241 | } |
| 242 |
| 243 | sourceSets { |
| 244 |
| 245 | main { |
| 246 | jni.srcDirs = [] |
| 247 | assets.srcDirs = ["src/main/assets", "src/emojis/twitter"] |
| 248 | } |
| 249 |
| 250 | debug { |
| 251 | java { |
| 252 | srcDirs "src/main/java", "src/gservcies/java" |
| 253 | } |
| 254 | jni.srcDirs = ["./jni/"] |
| 255 | manifest { |
| 256 | srcFile "src/gservcies/AndroidManifest.xml" |
| 257 | } |
| 258 | } |
| 259 |
| 260 | releaseNoGcm { |
| 261 | jni.srcDirs = [] |
| 262 | jniLibs { |
| 263 | srcDir "src/main/libs" |
| 264 | } |
| 265 | } |
| 266 |
| 267 | release { |
| 268 | java { |
| 269 | srcDirs "src/main/java", "src/gservcies/java" |
| 270 | } |
| 271 | jni.srcDirs = [] |
| 272 | jniLibs { |
| 273 | srcDir "src/main/libs" |
| 274 | } |
| 275 | manifest { |
| 276 | srcFile "src/gservcies/AndroidManifest.xml" |
| 277 | } |
| 278 | } |
| 279 |
| 280 | foss { |
| 281 | jni { |
| 282 | srcDirs = ["./jni/"] |
| 283 | } |
| 284 | } |
| 285 |
| 286 | fdroidRelease { |
| 287 | jni { |
| 288 | srcDirs = ["./jni/"] |
| 289 | } |
| 290 | jniLibs.srcDirs = [] |
| 291 | } |
| 292 |
| 293 | } |
| 294 |
| 295 | flavorDimensions "version" |
| 296 |
| 297 | productFlavors { |
| 298 | mini { |
| 299 | isDefault true |
| 300 | manifestPlaceholders = [is_full_version: "false"] |
| 301 | } |
| 302 | full { |
| 303 | manifestPlaceholders = [is_full_version: "true"] |
| 304 | } |
| 305 | miniPlay { |
| 306 | versionNameSuffix "-play" |
| 307 | versionCode verCode - 2 |
| 308 | manifestPlaceholders = [is_full_version: "false"] |
| 309 | } |
| 310 | } |
| 311 |
| 312 | sourceSets.all { set -> |
| 313 | if (set.name.startsWith("full")) { |
| 314 | set.dependencies { |
| 315 | implementation fileTree("libs") |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 |
| 320 | tasks.all { task -> |
| 321 | if (((task.name.endsWith("Ndk") || task.name.startsWith("generateJsonModel") || task.name.startsWith("externalNativeBuild"))) && !(task.name.contains("Debug") || task.name.contains("Foss") || task.name.contains("Fdroid"))) { |
| 322 | task.enabled = false |
| 323 | } |
| 324 | if (task.name.contains("uploadCrashlyticsMappingFile")) { |
| 325 | enabled = false |
| 326 | } |
| 327 | if (disableCMakeRelWithDebInfo && task.name.contains("CMakeRelWithDebInfo") && !targetTask.contains("fdroid")) { |
| 328 | enabled = false |
| 329 | } |
| 330 | } |
| 331 |
| 332 | applicationVariants.all { variant -> |
| 333 | variant.outputs.all { output -> |
| 334 | outputFileName = outputFileName.replace("TMessagesProj", "Nagram-v" + versionName) |
| 335 | } |
| 336 | } |
| 337 |
| 338 | } |
| 339 |
| 340 | def okHttpVersion = "5.0.0-alpha.2" |
| 341 | def fcmVersion = "21.1.0" |
| 342 | def crashlyticsVersion = "18.2.0" |
| 343 | def playCoreVersion = "1.10.1" |
| 344 |
| 345 | dependencies { |
| 346 |
| 347 | implementation "androidx.browser:browser:1.4.0" |
| 348 | implementation "androidx.core:core-ktx:1.7.0" |
| 349 | implementation "androidx.palette:palette-ktx:1.0.0" |
| 350 | implementation "androidx.viewpager:viewpager:1.0.0" |
| 351 | implementation "androidx.exifinterface:exifinterface:1.3.3" |
| 352 | implementation "androidx.interpolator:interpolator:1.0.0" |
| 353 | implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" |
| 354 | implementation "androidx.multidex:multidex:2.0.1" |
| 355 | implementation "androidx.sharetarget:sharetarget:1.1.0" |
| 356 |
| 357 | compileOnly "org.checkerframework:checker-qual:3.16.0" |
| 358 | compileOnly "org.checkerframework:checker-compat-qual:2.5.5" |
| 359 |
| 360 | // don"t change this :) |
| 361 | //noinspection GradleDependency |
| 362 | implementation "com.googlecode.mp4parser:isoparser:1.0.6" |
| 363 |
| 364 | implementation "com.google.code.gson:gson:2.8.8" |
| 365 | implementation "org.osmdroid:osmdroid-android:6.1.10" |
| 366 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.30" |
| 367 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2" |
| 368 |
| 369 | implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" |
| 370 | implementation 'dnsjava:dnsjava:3.4.1' |
| 371 | implementation "org.dizitart:nitrite:3.4.3" |
| 372 |
| 373 | implementation "cn.hutool:hutool-core:5.7.13" |
| 374 | implementation "cn.hutool:hutool-crypto:5.7.13" |
| 375 | implementation 'cn.hutool:hutool-http:5.7.5' |
| 376 | implementation "com.jakewharton:process-phoenix:2.1.2" |
| 377 |
| 378 | compileOnly 'org.yaml:snakeyaml:1.29' |
| 379 | fullImplementation 'org.yaml:snakeyaml:1.29' |
| 380 |
| 381 | implementation project(":openpgp-api") |
| 382 |
| 383 | compileOnly fileTree("libs") |
| 384 |
| 385 | compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" |
| 386 | compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 387 | compileOnly "com.google.android.play:core:$playCoreVersion" |
| 388 |
| 389 | debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 390 | debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 391 | debugImplementation "com.google.android.play:core:$playCoreVersion" |
| 392 | releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 393 | releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 394 | releaseImplementation "com.google.android.play:core:$playCoreVersion" |
| 395 |
| 396 | testImplementation "junit:junit:4.13.2" |
| 397 | testImplementation "androidx.test:core:1.4.0" |
| 398 | testImplementation "org.robolectric:robolectric:4.5.1" |
| 399 |
| 400 | coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" |
| 401 |
| 402 | } |
| 403 |
| 404 | apply plugin: "com.google.gms.google-services" |
| 405 | apply plugin: "com.google.firebase.crashlytics" |
| 406 |
| 407 | android { |
| 408 |
| 409 | tasks.all { task -> |
| 410 | if (task.name.startsWith("uploadCrashlyticsMappingFile")) { |
| 411 | task.enabled = false |
| 412 | } else if (task.name.contains("Crashlytics") && task.name.contains("NoGcm")) { |
| 413 | task.enabled = false |
| 414 | } else if (task.name.endsWith("GoogleServices") && task.name.contains("NoGcm")) { |
| 415 | task.enabled = false |
| 416 | } |
| 417 | } |
| 418 |
| 419 | } |
| 420 |