| 7 |
| 8 | repositories { |
| 9 | maven { |
| 10 | url 'https://www.jitpack.io' |
| 11 | content { |
| 12 | includeModule 'com.github.UnifiedPush', 'android-connector' |
| 13 | } |
| 14 | } |
| 15 | } |
| 16 |
| 17 | def verName = APP_VERSION_NAME |
| 18 | def verCode = 1201 |
| 19 |
| 20 |
| 21 | def officialVer = APP_VERSION_NAME |
| 22 | def officialCode = APP_VERSION_CODE |
| 23 |
| 24 | def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") |
| 25 |
| 26 | def beta = verName.contains("preview") |
| 27 |
| 28 | if (serviceAccountCredentialsFile.isFile()) { |
| 29 | setupPlay(beta) |
| 30 | play.serviceAccountCredentials = serviceAccountCredentialsFile |
| 31 | } else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) { |
| 32 | setupPlay(beta) |
| 33 | } |
| 34 |
| 35 | void setupPlay(boolean beta) { |
| 36 | apply plugin: "com.github.triplet.play" |
| 37 | play { |
| 38 | track = beta ? "beta" : "production" |
| 39 | defaultToAppBundles = true |
| 40 | } |
| 41 | } |
| 42 |
| 43 | configurations { |
| 44 | compile.exclude module: "support-v4" |
| 45 | } |
| 46 |
| 47 | def keystorePwd = null |
| 48 | def alias = null |
| 49 | def pwd = null |
| 50 | def sentry_token = System.getenv("SENTRY_AUTH_TOKEN") |
| 51 | def sentry_upload = project.rootProject.file("sentry.properties").exists() |
| 52 | def disableCMakeRelWithDebInfo = System.getenv("COMPILE_NATIVE") == null |
| 53 |
| 54 | Properties properties |
| 55 | def base64 = System.getenv("LOCAL_PROPERTIES") |
| 56 | if (base64 != null && !base64.isBlank()) { |
| 57 | properties = new Properties() |
| 58 | properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) |
| 59 | } else if (project.rootProject.file("local.properties").exists()) { |
| 60 | properties = new Properties() |
| 61 | properties.load(project.rootProject.file("local.properties").newDataInputStream()) |
| 62 | } |
| 63 |
| 64 | if (properties != null) { |
| 65 | keystorePwd = properties.getProperty("KEYSTORE_PASS") |
| 66 | alias = properties.getProperty("ALIAS_NAME") |
| 67 | pwd = properties.getProperty("ALIAS_PASS") |
| 68 | sentry_token = properties.getProperty("SENTRY_AUTH_TOKEN", sentry_token) |
| 69 | } |
| 70 |
| 71 | keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS") |
| 72 | alias = alias ?: System.getenv("ALIAS_NAME") |
| 73 | pwd = pwd ?: System.getenv("ALIAS_PASS") |
| 74 |
| 75 | def targetTask = "" |
| 76 | if (!gradle.startParameter.taskNames.isEmpty()) { |
| 77 | if (gradle.startParameter.taskNames.size == 1) { |
| 78 | targetTask = gradle.startParameter.taskNames[0].toLowerCase() |
| 79 | } |
| 80 | } |
| 81 |
| 82 | def nativeTarget = System.getenv("NATIVE_TARGET") |
| 83 | if (nativeTarget == null) nativeTarget = "" |
| 84 |
| 85 | android { |
| 86 | compileSdkVersion 34 |
| 87 | ndkVersion rootProject.ext.ndkVersion |
| 88 |
| 89 | defaultConfig.applicationId = 'com.xtaolabs.pagergram' |
| 90 |
| 91 | splits { |
| 92 |
| 93 | abi { |
| 94 | if (targetTask.contains("fdroid")) { |
| 95 | enable false |
| 96 | universalApk true |
| 97 | } else { |
| 98 | enable true |
| 99 | reset() |
| 100 | universalApk false |
| 101 | if (!nativeTarget.isBlank()) { |
| 102 | include nativeTarget |
| 103 | } else { |
| 104 | include 'arm64-v8a' |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 |
| 109 | } |
| 110 |
| 111 | defaultConfig { |
| 112 | minSdkVersion 21 |
| 113 | //noinspection ExpiredTargetSdkVersion,OldTargetApi |
| 114 | targetSdkVersion 34 |
| 115 |
| 116 | versionName verName |
| 117 | versionCode verCode |
| 118 |
| 119 | def appId = "11535358" |
| 120 | def appHash = "33d372962fadb01df47e6ceed4e33cd6" |
| 121 |
| 122 | //obtain your own keys at https://core.telegram.org/api/obtaining_api_id |
| 123 |
| 124 | if (properties != null) { |
| 125 | appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId |
| 126 | appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash |
| 127 | } |
| 128 |
| 129 | buildConfigField "String", "BUILD_VERSION_STRING", "\"" + verName + "\"" |
| 130 | buildConfigField "String", "OFFICIAL_VERSION", "\"" + officialVer + "\"" |
| 131 | buildConfigField "int", "OFFICIAL_VERSION_CODE", officialCode + "" |
| 132 | buildConfigField "int", "APP_ID", appId |
| 133 | buildConfigField "String", "APP_HASH", "\"" + appHash + "\"" |
| 134 |
| 135 | externalNativeBuild { |
| 136 | cmake { |
| 137 | arguments "-DANDROID_STL=c++_static", "-DANDROID_PLATFORM=android-21" |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 |
| 142 | bundle { |
| 143 | language { |
| 144 | enableSplit = false |
| 145 | } |
| 146 | } |
| 147 |
| 148 | externalNativeBuild { |
| 149 | cmake { |
| 150 | path "jni/CMakeLists.txt" |
| 151 | } |
| 152 | } |
| 153 |
| 154 |
| 155 | compileOptions { |
| 156 | sourceCompatibility JavaVersion.VERSION_11 |
| 157 | targetCompatibility JavaVersion.VERSION_11 |
| 158 |
| 159 | coreLibraryDesugaringEnabled true |
| 160 | } |
| 161 |
| 162 | kotlinOptions { |
| 163 | jvmTarget = JavaVersion.VERSION_11.toString() |
| 164 | } |
| 165 |
| 166 | testOptions { |
| 167 | unitTests.includeAndroidResources = true |
| 168 | } |
| 169 |
| 170 | signingConfigs { |
| 171 | release { |
| 172 | storeFile project.file("pagergram.jks") |
| 173 | storePassword keystorePwd |
| 174 | keyAlias alias |
| 175 | keyPassword pwd |
| 176 | } |
| 177 | } |
| 178 |
| 179 | buildTypes { |
| 180 | debug { |
| 181 | isDefault true |
| 182 | debuggable true |
| 183 | jniDebuggable true |
| 184 | multiDexEnabled true |
| 185 | zipAlignEnabled true |
| 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 |
| 202 | sourceSets { |
| 203 |
| 204 | main { |
| 205 | assets.srcDirs = ["src/main/assets"] |
| 206 | } |
| 207 |
| 208 | debug { |
| 209 | java { |
| 210 | srcDirs "src/main/java" |
| 211 | } |
| 212 | jniLibs { |
| 213 | srcDir "src/main/libs" |
| 214 | } |
| 215 | } |
| 216 |
| 217 | release { |
| 218 | java { |
| 219 | srcDirs "src/main/java" |
| 220 | } |
| 221 | jniLibs { |
| 222 | srcDir "src/main/libs" |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 |
| 227 | flavorDimensions "version" |
| 228 |
| 229 | tasks.configureEach { task -> |
| 230 | if (((task.name.endsWith("Ndk") || task.name.startsWith("generateJsonModel") || task.name.startsWith("externalNativeBuild"))) && !task.name.contains("Debug")) { |
| 231 | task.enabled = false |
| 232 | } |
| 233 | if (task.name.contains("uploadCrashlyticsMappingFile")) { |
| 234 | enabled = false |
| 235 | } |
| 236 | if (disableCMakeRelWithDebInfo && task.name.contains("CMakeRelWithDebInfo")) { |
| 237 | enabled = false |
| 238 | } |
| 239 | } |
| 240 |
| 241 | applicationVariants.configureEach { variant -> |
| 242 | variant.outputs.configureEach { output -> |
| 243 | String gramName = "PagerGram" |
| 244 | String first = String.format("%s-v%s(%s)", gramName, versionName, versionCode) |
| 245 | String name = outputFileName.replace("TMessagesProj", first) |
| 246 | name = name.replace("-release", "") |
| 247 | outputFileName = name |
| 248 | } |
| 249 | } |
| 250 |
| 251 | } |
| 252 |
| 253 | def fcmVersion = "23.4.1" |
| 254 | def crashlyticsVersion = "18.6.2" |
| 255 | def playCoreVersion = "1.10.3" |
| 256 |
| 257 | dependencies { |
| 258 |
| 259 | implementation "androidx.browser:browser:1.5.0" |
| 260 | implementation 'androidx.fragment:fragment:1.2.0' |
| 261 | implementation "androidx.core:core-ktx:1.9.0" |
| 262 | implementation "androidx.palette:palette-ktx:1.0.0" |
| 263 | implementation "androidx.viewpager:viewpager:1.0.0" |
| 264 | implementation "androidx.exifinterface:exifinterface:1.3.7" |
| 265 | implementation "androidx.interpolator:interpolator:1.0.0" |
| 266 | implementation 'androidx.biometric:biometric:1.1.0' |
| 267 | implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" |
| 268 | implementation "androidx.multidex:multidex:2.0.1" |
| 269 | implementation "androidx.sharetarget:sharetarget:1.2.0" |
| 270 |
| 271 | // just follow official |
| 272 | compileOnly 'org.checkerframework:checker-qual:2.5.2' |
| 273 | compileOnly 'org.checkerframework:checker-compat-qual:2.5.0' |
| 274 |
| 275 | // don"t change this :) |
| 276 | //noinspection GradleDependency |
| 277 | implementation "com.googlecode.mp4parser:isoparser:1.0.6" |
| 278 |
| 279 | implementation "com.google.code.gson:gson:2.11.0" |
| 280 | implementation "org.osmdroid:osmdroid-android:6.1.10" |
| 281 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23" |
| 282 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0" |
| 283 |
| 284 | implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.10" |
| 285 | implementation 'com.neovisionaries:nv-websocket-client:2.14' |
| 286 | implementation 'dnsjava:dnsjava:3.4.1' |
| 287 | implementation "org.dizitart:nitrite:3.4.3" |
| 288 |
| 289 | implementation "cn.hutool:hutool-core:5.7.13" |
| 290 | implementation "cn.hutool:hutool-crypto:5.7.13" |
| 291 | implementation 'cn.hutool:hutool-http:5.7.5' |
| 292 | implementation "com.jakewharton:process-phoenix:2.1.2" |
| 293 | implementation 'com.google.guava:guava:31.1-android' |
| 294 |
| 295 | implementation 'com.google.android.play:integrity:1.3.0' |
| 296 |
| 297 | implementation 'com.google.android.gms:play-services-mlkit-subject-segmentation:16.0.0-beta1' |
| 298 | implementation 'com.google.android.gms:play-services-mlkit-image-labeling:16.0.8' |
| 299 |
| 300 | implementation project(":openpgp-api") |
| 301 |
| 302 | compileOnly fileTree("libs") |
| 303 |
| 304 | compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" |
| 305 | compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 306 | compileOnly "com.google.android.play:core:$playCoreVersion" |
| 307 |
| 308 | implementation 'com.google.android.gms:play-services-vision:20.1.3' |
| 309 | implementation 'com.google.android.gms:play-services-maps:18.2.0' |
| 310 | implementation 'com.google.android.gms:play-services-location:21.2.0' |
| 311 | implementation 'com.google.android.gms:play-services-wallet:19.1.0' |
| 312 |
| 313 | implementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 314 | implementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 315 | // implementation "com.google.android.play:core:$playCoreVersion" |
| 316 |
| 317 | implementation 'com.stripe:stripe-android:2.0.2' |
| 318 | implementation 'com.android.billingclient:billing:6.0.1' |
| 319 |
| 320 | testImplementation "junit:junit:4.13.2" |
| 321 | testImplementation "androidx.test:core:1.5.0" |
| 322 | testImplementation "org.robolectric:robolectric:4.5.1" |
| 323 |
| 324 | coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.2.0" |
| 325 |
| 326 | } |
| 327 | dependencies { |
| 328 | // add for undo and redo |
| 329 | implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3' |
| 330 | // add splash screen |
| 331 | implementation("androidx.core:core-splashscreen:1.0.1") |
| 332 | // add for auto translate |
| 333 | implementation 'com.google.mlkit:language-id:17.0.5' |
| 334 | // add for emoji |
| 335 | implementation 'com.jaredrummler:truetypeparser-light:1.0.0' |
| 336 | // add for up |
| 337 | implementation 'com.github.UnifiedPush:android-connector:2.3.1' |
| 338 | } |
| 339 |
| 340 | apply plugin: "com.google.gms.google-services" |
| 341 | apply plugin: "com.google.firebase.crashlytics" |
| 342 |
| 343 | android { |
| 344 |
| 345 |
| 346 | packagingOptions { |
| 347 | jniLibs { |
| 348 | excludes += ['/fabric/**', '/META-INF/native-image/**'] |
| 349 | useLegacyPackaging true |
| 350 | } |
| 351 | resources { |
| 352 | excludes += ['/fabric/**', '/META-INF/*.version', '/META-INF/*.kotlin_module', '/META-INF/native-image/**', '/builddef.lst', '/*.txt', '/DebugProbesKt.bin', '/okhttp3/internal/publicsuffix/NOTICE'] |
| 353 | } |
| 354 |
| 355 | def lib = "libtmessages.*.so" |
| 356 | pickFirst "lib/armeabi-v7a/$lib" |
| 357 | pickFirst "lib/arm64-v8a/$lib" |
| 358 | } |
| 359 | namespace "org.telegram.messenger" |
| 360 | lint { |
| 361 | disable 'MissingTranslation', 'ExtraTranslation', 'BlockedPrivateApi' |
| 362 | } |
| 363 | buildFeatures { |
| 364 | buildConfig true |
| 365 | } |
| 366 |
| 367 | tasks.configureEach { task -> |
| 368 | if (task.name.startsWith("uploadCrashlyticsMappingFile")) { |
| 369 | task.enabled = false |
| 370 | } else if (task.name.contains("Crashlytics") && task.name.contains("NoGcm")) { |
| 371 | task.enabled = false |
| 372 | } else if (task.name.endsWith("GoogleServices") && task.name.contains("NoGcm")) { |
| 373 | task.enabled = false |
| 374 | } |
| 375 | } |
| 376 |
| 377 | } |
| 378 |
| 379 | sentry { |
| 380 | // Disables or enables debug log output, e.g. for for sentry-cli. |
| 381 | // Default is disabled. |
| 382 | debug = false |
| 383 |
| 384 | // The slug of the Sentry organization to use for uploading proguard mappings/source contexts. |
| 385 | org = "pagermaid" |
| 386 |
| 387 | // The slug of the Sentry project to use for uploading proguard mappings/source contexts. |
| 388 | projectName = "nagram" |
| 389 |
| 390 | // The authentication token to use for uploading proguard mappings/source contexts. |
| 391 | // WARNING: Do not expose this token in your build.gradle files, but rather set an environment |
| 392 | // variable and read it into this property. |
| 393 | authToken = sentry_token |
| 394 |
| 395 | // The url of your Sentry instance. If you're using SAAS (not self hosting) you do not have to |
| 396 | // set this. If you are self hosting you can set your URL here |
| 397 | url = null |
| 398 |
| 399 | // Disables or enables the handling of Proguard mapping for Sentry. |
| 400 | // If enabled the plugin will generate a UUID and will take care of |
| 401 | // uploading the mapping to Sentry. If disabled, all the logic |
| 402 | // related to proguard mapping will be excluded. |
| 403 | // Default is enabled. |
| 404 | includeProguardMapping = sentry_upload |
| 405 |
| 406 | // Whether the plugin should attempt to auto-upload the mapping file to Sentry or not. |
| 407 | // If disabled the plugin will run a dry-run and just generate a UUID. |
| 408 | // The mapping file has to be uploaded manually via sentry-cli in this case. |
| 409 | // Default is enabled. |
| 410 | autoUploadProguardMapping = sentry_upload |
| 411 |
| 412 | // Experimental flag to turn on support for GuardSquare's tools integration (Dexguard and External Proguard). |
| 413 | // If enabled, the plugin will try to consume and upload the mapping file produced by Dexguard and External Proguard. |
| 414 | // Default is disabled. |
| 415 | dexguardEnabled = false |
| 416 |
| 417 | // Disables or enables the automatic configuration of Native Symbols |
| 418 | // for Sentry. This executes sentry-cli automatically so |
| 419 | // you don't need to do it manually. |
| 420 | // Default is disabled. |
| 421 | uploadNativeSymbols = sentry_upload |
| 422 |
| 423 | // Whether the plugin should attempt to auto-upload the native debug symbols to Sentry or not. |
| 424 | // If disabled the plugin will run a dry-run. |
| 425 | // Default is enabled. |
| 426 | autoUploadNativeSymbols = sentry_upload |
| 427 |
| 428 | // Does or doesn't include the source code of native code for Sentry. |
| 429 | // This executes sentry-cli with the --include-sources param. automatically so |
| 430 | // you don't need to do it manually. |
| 431 | // This option has an effect only when [uploadNativeSymbols] is enabled. |
| 432 | // Default is disabled. |
| 433 | includeNativeSources = false |
| 434 |
| 435 | // Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry. |
| 436 | // This enables source context, allowing you to see your source |
| 437 | // code as part of your stack traces in Sentry. |
| 438 | includeSourceContext = sentry_upload |
| 439 |
| 440 | // Configure additional directories to be included in the source bundle which is used for |
| 441 | // source context. The directories should be specified relative to the Gradle module/project's |
| 442 | // root. For example, if you have a custom source set alongside 'main', the parameter would be |
| 443 | // 'src/custom/java'. |
| 444 | additionalSourceDirsForSourceContext = [] |
| 445 |
| 446 | // Enable or disable the tracing instrumentation. |
| 447 | // Does auto instrumentation for specified features through bytecode manipulation. |
| 448 | // Default is enabled. |
| 449 | tracingInstrumentation { |
| 450 | enabled = true |
| 451 |
| 452 | // Specifies a set of instrumentation features that are eligible for bytecode manipulation. |
| 453 | // Defaults to all available values of InstrumentationFeature enum class. |
| 454 | features = [InstrumentationFeature.DATABASE, InstrumentationFeature.FILE_IO, InstrumentationFeature.OKHTTP, InstrumentationFeature.COMPOSE] |
| 455 |
| 456 | // Enable or disable logcat instrumentation through bytecode manipulation. |
| 457 | // Default is enabled. |
| 458 | logcat { |
| 459 | enabled = true |
| 460 |
| 461 | // Specifies a minimum log level for the logcat breadcrumb logging. |
| 462 | // Defaults to LogcatLevel.WARNING. |
| 463 | minLevel = LogcatLevel.WARNING |
| 464 | } |
| 465 |
| 466 | // The set of glob patterns to exclude from instrumentation. Classes matching any of these |
| 467 | // patterns in the project's sources and dependencies JARs won't be instrumented by the Sentry |
| 468 | // Gradle plugin. |
| 469 | // |
| 470 | // Don't include the file extension. Filtering is done on compiled classes and |
| 471 | // the .class suffix isn't included in the pattern matching. |
| 472 | // |
| 473 | // Example usage: |
| 474 | // ``` |
| 475 | // excludes = ['com/example/donotinstrument/**', '**/*Test'] |
| 476 | // ``` |
| 477 | // |
| 478 | // Only supported when using Android Gradle plugin (AGP) version 7.4.0 and above. |
| 479 | excludes = [] |
| 480 | } |
| 481 |
| 482 | // Enable auto-installation of Sentry components (sentry-android SDK and okhttp, timber and fragment integrations). |
| 483 | // Default is enabled. |
| 484 | // Only available v3.1.0 and above. |
| 485 | autoInstallation { |
| 486 | enabled = true |
| 487 |
| 488 | // Specifies a version of the sentry-android SDK and fragment, timber and okhttp integrations. |
| 489 | // |
| 490 | // This is also useful, when you have the sentry-android SDK already included into a transitive dependency/module and want to |
| 491 | // align integration versions with it (if it's a direct dependency, the version will be inferred). |
| 492 | // |
| 493 | // NOTE: if you have a higher version of the sentry-android SDK or integrations on the classpath, this setting will have no effect |
| 494 | // as Gradle will resolve it to the latest version. |
| 495 | // |
| 496 | // Defaults to the latest published Sentry version. |
| 497 | sentryVersion = '7.8.0' |
| 498 | } |
| 499 |
| 500 | // Disables or enables dependencies metadata reporting for Sentry. |
| 501 | // If enabled, the plugin will collect external dependencies and |
| 502 | // upload them to Sentry as part of events. If disabled, all the logic |
| 503 | // related to the dependencies metadata report will be excluded. |
| 504 | // |
| 505 | // Default is enabled. |
| 506 | includeDependenciesReport = true |
| 507 |
| 508 | // Whether the plugin should send telemetry data to Sentry. |
| 509 | // If disabled the plugin won't send telemetry data. |
| 510 | // This is auto disabled if running against a self hosted instance of Sentry. |
| 511 | // Default is enabled. |
| 512 | telemetry = true |
| 513 | } |
| 514 |