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