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