From 382f8dfb85cb86b477c04260a2f2ce273a7cd8b7 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 16 Mar 2024 19:08:46 +0800 Subject: [PATCH 1/3] chore: Update AGP and remove nogcm build --- .github/workflows/debug.yml | 171 ++---------------- .github/workflows/pr.yml | 8 +- .github/workflows/release.yml | 82 +-------- .gitignore | 3 +- TMessagesProj/build.gradle | 132 +++----------- .../src/gservcies/AndroidManifest.xml | 30 --- TMessagesProj/src/main/AndroidManifest.xml | 21 +++ .../nekox/messenger/NekoLocationSource.java | 2 +- .../telegram/messenger/ApplicationLoader.java | 23 +-- .../org/telegram/messenger/BuildVars.java | 7 - .../messenger/GcmPushListenerService.java | 8 +- .../messenger/GoogleLocationProvider.java | 4 + .../messenger/GoogleMapsProvider.java | 5 +- .../GooglePushListenerServiceProvider.java | 7 + .../messenger/PushListenerController.java | 11 +- .../java/org/telegram/ui/ProfileActivity.java | 84 +++++---- .../tw/nekomimi/nekogram/InternalUpdater.java | 2 +- .../java/tw/nekomimi/nekogram/NekoConfig.java | 8 +- .../nekogram/helpers/remote/UpdateHelper.java | 4 +- .../settings/NekoGeneralSettingsActivity.java | 13 +- bin/libs/native.sh | 6 +- bin/scripts/requirements.txt | 2 + bin/scripts/upload.py | 90 +++++++++ build.gradle | 8 +- openpgp-api/build.gradle | 6 +- 25 files changed, 247 insertions(+), 490 deletions(-) delete mode 100644 TMessagesProj/src/gservcies/AndroidManifest.xml rename TMessagesProj/src/{gservcies => main}/java/nekox/messenger/NekoLocationSource.java (97%) rename TMessagesProj/src/{gservcies => main}/java/org/telegram/messenger/GcmPushListenerService.java (85%) rename TMessagesProj/src/{gservcies => main}/java/org/telegram/messenger/GoogleLocationProvider.java (97%) rename TMessagesProj/src/{gservcies => main}/java/org/telegram/messenger/GoogleMapsProvider.java (99%) rename TMessagesProj/src/{gservcies => main}/java/org/telegram/messenger/GooglePushListenerServiceProvider.java (91%) create mode 100644 bin/scripts/requirements.txt create mode 100644 bin/scripts/upload.py diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 48779bf21e..ccd93ceccb 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -175,12 +175,6 @@ jobs: runs-on: ubuntu-latest needs: - native - strategy: - matrix: - flavor: -# - FullRelease - - MiniRelease - - MiniReleaseNoGcm steps: - name: Checkout uses: actions/checkout@v2 @@ -225,182 +219,41 @@ jobs: - name: Debug Build run: | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - export DEBUG_BUILD=true - ./gradlew TMessagesProj:assemble${{ matrix.flavor }} + ./gradlew TMessagesProj:assembleRelease APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: - name: ${{ matrix.flavor }} + name: Release path: ${{ env.APK }} -# build-nogcm: -# name: Gradle Build (nogcm) -# runs-on: ubuntu-latest -# needs: -# - native -# - v2ray -# - shadowsocks -# - shadowsocksr -# - build -# strategy: -# matrix: -# flavor: -# - FullReleaseNoGcm -# - MiniReleaseNoGcm -# steps: -# - name: Checkout -# uses: actions/checkout@v2 -# - name: Setup Android SDK Tools -# uses: android-actions/setup-android@v2 -# - name: Install NDK -# run: | -# echo "y" | sdkmanager --install "ndk;21.4.7075529" --sdk_root=${ANDROID_SDK_ROOT} &> /dev/null -# echo "sdk.dir=${ANDROID_HOME}" > local.properties -# echo "ndk.dir=${ANDROID_HOME}/ndk/21.4.7075529" >> local.properties -# - name: Fetch Status -# run: | -# sed -i 's/\/\///g' settings.gradle -# git submodule status TMessagesProj/jni/ffmpeg > ffmpeg_status -# git submodule status TMessagesProj/jni/boringssl > boringssl_status -# git submodule status ss-rust/src/main/rust/shadowsocks-rust > shadowsocks_status -# git submodule status 'ssr-libev/*' > shadowsocksr_status -# git submodule status v2ray > v2ray_status -# - name: Native Cache (armeabi-v7a) -# uses: actions/cache@v2 -# with: -# path: | -# TMessagesProj/src/main/libs -# key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-armeabi-v7a -# - name: Native Cache (arm64-v8a) -# uses: actions/cache@v2 -# with: -# path: | -# TMessagesProj/src/main/libs -# key: ${{ hashFiles('TMessagesProj/jni/**', 'ffmpeg_status', 'boringssl_status') }}-arm64-v8a -# - name: V2ray Cache -# uses: actions/cache@v2 -# with: -# path: | -# TMessagesProj/libs/libv2ray.aar -# key: ${{ hashFiles('bin/libs/v2ray/*', 'v2ray_status') }} -# - name: Shadowsocks Cache -# uses: actions/cache@v2 -# with: -# path: | -# TMessagesProj/libs/ss-rust-release.aar -# key: ${{ hashFiles('shadowsocks_status') }} -# - name: ShadowsocksR Cache -# uses: actions/cache@v2 -# with: -# path: | -# TMessagesProj/libs/ssr-libev-release.aar -# key: ${{ hashFiles('shadowsocksr_status') }} -# - name: Configure Gradle -# run: | -# sed -i -e "s/16384/6144/g" gradle.properties -# echo "sdk.dir=${ANDROID_HOME}" >> local.properties -# - name: Gradle cache -# uses: actions/cache@v2 -# with: -# path: ~/.gradle -# key: gradle-${{ hashFiles('**/*.gradle') }} -# - name: Debug Build -# run: | -# export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" -# export DEBUG_BUILD=true -# ./gradlew TMessagesProj:assemble${{ matrix.flavor }} -# -# APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') -# APK=$(dirname $APK) -# echo "APK=$APK" >> $GITHUB_ENV -# - uses: actions/upload-artifact@v2 -# with: -# name: ${{ matrix.flavor }} -# path: ${{ env.APK }} upload: - name: Upload debug + name: Upload release + if: github.event.inputs.upload != 'y' runs-on: ubuntu-latest - if: ${{ !contains(github.event.head_commit.message, 'bump version') }} needs: - build -# - build-nogcm - - telegram-bot-api steps: + - name: Checkout + uses: actions/checkout@v4 - name: Donwload Artifacts uses: actions/download-artifact@v2 with: path: artifacts - - name: Download Telegram Bot API Binary - uses: actions/download-artifact@master + - name: Set up Python + uses: actions/setup-python@v5 with: - name: telegram-bot-api-binary - path: . + python-version: 3.12 - name: Send to Telegram run: | - chmod +x telegram-bot-api-binary - function start() { - ./telegram-bot-api-binary --api-id=11535358 --api-hash=33d372962fadb01df47e6ceed4e33cd6 --local 2>&1 > /dev/null & - } - start - curl http://127.0.0.1:8081/ || start - curl http://127.0.0.1:8081/ || start - curl http://127.0.0.1:8081/ || start # send release via telegram bot api export mini64=$(find artifacts -name "*arm64-v8a.apk") export mini32=$(find artifacts -name "*armeabi-v7a.apk") - # export full64=$(find artifacts -name "*full-arm64-v8a.apk") - # export full32=$(find artifacts -name "*full-armeabi-v7a.apk") - export mini64nogcm=$(find artifacts -name "*arm64-v8aNoGcm.apk") - export mini32nogcm=$(find artifacts -name "*armeabi-v7aNoGcm.apk") - # export full64nogcm=$(find artifacts -name "*full-arm64-v8aNoGcm.apk") - # export full32nogcm=$(find artifacts -name "*full-armeabi-v7aNoGcm.apk") echo $mini64 echo $mini32 - # echo $full64 - # echo $full32 - echo $mini64nogcm - echo $mini32nogcm - # echo $full64nogcm - # echo $full32nogcm - curl --http0.9 http://127.0.0.1:8081/bot${{ secrets.HELPER_BOT_TOKEN }}/sendMediaGroup --form-string chat_id=${{ secrets.HELPER_BOT_TARGET }} --form apk1=@"${mini64}" --form apk2=@"${mini32}" --form apk3=@"${mini64nogcm}" --form apk4=@"${mini32nogcm}" --form-string media="[{\"type\": \"document\",\"media\": \"attach://apk1\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk2\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk3\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk4\",\"caption\": \"Test version, ${{ github.event.head_commit.message }}\",\"parse_mode\": \"Markdown\"}]" --verbose >/dev/null - - pkill telegram-bot - telegram-bot-api: - name: Telegram Bot API - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Clone Telegram Bot API - run: | - git clone --recursive https://github.com/tdlib/telegram-bot-api.git - git status telegram-bot-api >> telegram-bot-api-status - - name: Cache Bot API Binary - id: cache-bot-api - uses: actions/cache@v2 - with: - path: telegram-bot-api-binary - key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }} - - name: Compile Telegram Bot API - if: steps.cache-bot-api.outputs.cache-hit != 'true' - run: | - sudo apt-get update - sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++ - cd telegram-bot-api - rm -rf build - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. - cmake --build . --target install -j$(nproc) - cd ../.. - ls -l telegram-bot-api/bin/telegram-bot-api* - cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary - - name: Upload Binary - uses: actions/upload-artifact@master - with: - name: telegram-bot-api-binary - path: telegram-bot-api-binary + python -m pip install -r bin/scripts/requirements.txt + git log -1 --pretty=format:"%s" > artifacts/caption.txt + python bin/scripts/upload.py ${{ secrets.HELPER_BOT_TOKEN }} ${{ secrets.HELPER_BOT_TARGET }} test diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d22bb625e4..64295be254 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -173,10 +173,6 @@ jobs: runs-on: ubuntu-latest needs: - native - strategy: - matrix: - flavor: - - MiniRelease steps: - name: Checkout uses: actions/checkout@v2 @@ -223,12 +219,12 @@ jobs: export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" export DEBUG_BUILD=true sed -i 's/signingConfig signingConfigs.release//g' TMessagesProj/build.gradle - ./gradlew TMessagesProj:assemble${{ matrix.flavor }} + ./gradlew TMessagesProj:assembleRelease APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: - name: ${{ matrix.flavor }} + name: Debug path: ${{ env.APK }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ffc48e2861..1827289a82 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -178,13 +178,6 @@ jobs: runs-on: ubuntu-latest needs: - native - strategy: - matrix: - flavor: -# - FullRelease - - MiniRelease -# - FullReleaseNoGcm - - MiniReleaseNoGcm steps: - name: Checkout uses: actions/checkout@v2 @@ -229,14 +222,14 @@ jobs: - name: Release Build run: | export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}" - ./gradlew TMessagesProj:assemble${{ matrix.flavor }} + ./gradlew TMessagesProj:assembleRelease APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk') APK=$(dirname $APK) echo "APK=$APK" >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: - name: ${{ matrix.flavor }} + name: Release path: ${{ env.APK }} upload: name: Upload release @@ -244,81 +237,26 @@ jobs: runs-on: ubuntu-latest needs: - build - - telegram-bot-api steps: + - name: Checkout + uses: actions/checkout@v4 - name: Donwload Artifacts uses: actions/download-artifact@v2 with: path: artifacts - - name: Download Telegram Bot API Binary - uses: actions/download-artifact@master + - name: Set up Python + uses: actions/setup-python@v5 with: - name: telegram-bot-api-binary - path: . + python-version: 3.12 - name: Send to Telegram run: | - chmod +x telegram-bot-api-binary - function start() { - ./telegram-bot-api-binary --api-id=11535358 --api-hash=33d372962fadb01df47e6ceed4e33cd6 --local 2>&1 > /dev/null & - } - start - curl http://127.0.0.1:8081/ || start - curl http://127.0.0.1:8081/ || start - curl http://127.0.0.1:8081/ || start # send release via telegram bot api export mini64=$(find artifacts -name "*arm64-v8a.apk") export mini32=$(find artifacts -name "*armeabi-v7a.apk") - # export full64=$(find artifacts -name "*full-arm64-v8a.apk") - # export full32=$(find artifacts -name "*full-armeabi-v7a.apk") - export mini64nogcm=$(find artifacts -name "*arm64-v8aNoGcm.apk") - export mini32nogcm=$(find artifacts -name "*armeabi-v7aNoGcm.apk") - # export full64nogcm=$(find artifacts -name "*full-arm64-v8aNoGcm.apk") - # export full32nogcm=$(find artifacts -name "*full-armeabi-v7aNoGcm.apk") echo $mini64 echo $mini32 - # echo $full64 - # echo $full32 - echo $mini64nogcm - echo $mini32nogcm - # echo $full64nogcm - # echo $full32nogcm - curl --http0.9 http://127.0.0.1:8081/bot${{ secrets.HELPER_BOT_TOKEN }}/sendMediaGroup --form-string chat_id=${{ secrets.HELPER_BOT_TARGET }} --form apk1=@"${mini64}" --form apk2=@"${mini32}" --form apk3=@"${mini64nogcm}" --form apk4=@"${mini32nogcm}" --form-string media="[{\"type\": \"document\",\"media\": \"attach://apk1\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk2\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk3\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk4\",\"caption\": \"${{ github.event.head_commit.message }}\",\"parse_mode\": \"Markdown\"}]" --verbose >/dev/null - - pkill telegram-bot - telegram-bot-api: - name: Telegram Bot API - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Clone Telegram Bot API - run: | - git clone --recursive https://github.com/tdlib/telegram-bot-api.git - git status telegram-bot-api >> telegram-bot-api-status - - name: Cache Bot API Binary - id: cache-bot-api - uses: actions/cache@v2 - with: - path: telegram-bot-api-binary - key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }} - - name: Compile Telegram Bot API - if: steps.cache-bot-api.outputs.cache-hit != 'true' - run: | - sudo apt-get update - sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++ - cd telegram-bot-api - rm -rf build - mkdir build - cd build - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. - cmake --build . --target install -j$(nproc) - cd ../.. - ls -l telegram-bot-api/bin/telegram-bot-api* - cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary - - name: Upload Binary - uses: actions/upload-artifact@master - with: - name: telegram-bot-api-binary - path: telegram-bot-api-binary + python -m pip install -r bin/scripts/requirements.txt + git log -1 --pretty=format:"%s" > artifacts/caption.txt + python bin/scripts/upload.py ${{ secrets.HELPER_BOT_TOKEN }} ${{ secrets.HELPER_BOT_TARGET }} release diff --git a/.gitignore b/.gitignore index 4afc3cd0ef..4015be1241 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ build/ local.properties obj/ -service_account_credentials.json \ No newline at end of file +service_account_credentials.json +__pycache__/ diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 81a32d50b0..617a798fed 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -1,5 +1,3 @@ -import cn.hutool.core.util.RuntimeUtil - apply plugin: "com.android.application" apply plugin: "kotlin-android" @@ -83,12 +81,12 @@ android { universalApk true } else { enable true + reset() + universalApk false if (!nativeTarget.isBlank()) { - reset() include nativeTarget - universalApk false } else { - universalApk true + include 'armeabi-v7a', 'arm64-v8a' } } } @@ -118,7 +116,6 @@ android { buildConfigField "int", "OFFICIAL_VERSION_CODE", officialCode + "" buildConfigField "int", "APP_ID", appId buildConfigField "String", "APP_HASH", "\"" + appHash + "\"" - buildConfigField "int", "IS_NO_GCM", "0" externalNativeBuild { cmake { @@ -174,20 +171,6 @@ android { signingConfig signingConfigs.release } - releaseNoGcm { - debuggable false - jniDebuggable false - minifyEnabled true - shrinkResources true - multiDexEnabled true - zipAlignEnabled true - proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" - matchingFallbacks = ["release", "debug"] - signingConfig signingConfigs.release - - buildConfigField "int", "IS_NO_GCM", "1" - } - release { debuggable false jniDebuggable false @@ -199,46 +182,18 @@ android { matchingFallbacks = ["release", "debug"] signingConfig signingConfigs.release } - - foss { - debuggable false - jniDebuggable false - minifyEnabled true - shrinkResources true - multiDexEnabled true - zipAlignEnabled true - proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" - matchingFallbacks = ["release", "debug"] - } - - fdroidRelease { - initWith foss - matchingFallbacks = ["release", "debug"] - } } sourceSets { main { - jni.srcDirs = [] assets.srcDirs = ["src/main/assets", "src/emojis/twitter"] } debug { java { - srcDirs "src/main/java", "src/gservcies/java" - } - jni.srcDirs = [] - jniLibs { - srcDir "src/main/libs" + srcDirs "src/main/java" } - manifest { - srcFile "src/gservcies/AndroidManifest.xml" - } - } - - releaseNoGcm { - jni.srcDirs = [] jniLibs { srcDir "src/main/libs" } @@ -246,67 +201,42 @@ android { release { java { - srcDirs "src/main/java", "src/gservcies/java" + srcDirs "src/main/java" } - jni.srcDirs = [] jniLibs { srcDir "src/main/libs" } - manifest { - srcFile "src/gservcies/AndroidManifest.xml" - } } - - foss { - jni { - srcDirs = ["./jni/"] - } - } - - fdroidRelease { - jni { - srcDirs = ["./jni/"] - } - jniLibs.srcDirs = [] - } - } flavorDimensions "version" - productFlavors { - mini { - isDefault true - } - } - - tasks.all { task -> - 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"))) { + tasks.configureEach { task -> + if (((task.name.endsWith("Ndk") || task.name.startsWith("generateJsonModel") || task.name.startsWith("externalNativeBuild"))) && !task.name.contains("Debug")) { task.enabled = false } if (task.name.contains("uploadCrashlyticsMappingFile")) { enabled = false } - if (disableCMakeRelWithDebInfo && task.name.contains("CMakeRelWithDebInfo") && !targetTask.contains("fdroid")) { + if (disableCMakeRelWithDebInfo && task.name.contains("CMakeRelWithDebInfo")) { enabled = false } } - applicationVariants.all { variant -> - variant.outputs.all { output -> + applicationVariants.configureEach { variant -> + variant.outputs.configureEach { output -> String gramName = "Nagram" String first = String.format("%s-v%s(%s)", gramName, versionName, versionCode) String name = outputFileName.replace("TMessagesProj", first) name = name.replace("-release", "") - name = name.replace("-mini", "") outputFileName = name } } } -def fcmVersion = "23.0.7" -def crashlyticsVersion = "18.2.12" +def fcmVersion = "23.4.1" +def crashlyticsVersion = "18.6.2" def playCoreVersion = "1.10.3" dependencies { @@ -316,7 +246,7 @@ dependencies { implementation "androidx.core:core-ktx:1.9.0" implementation "androidx.palette:palette-ktx:1.0.0" implementation "androidx.viewpager:viewpager:1.0.0" - implementation "androidx.exifinterface:exifinterface:1.3.6" + implementation "androidx.exifinterface:exifinterface:1.3.7" implementation "androidx.interpolator:interpolator:1.0.0" implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" implementation "androidx.multidex:multidex:2.0.1" @@ -330,10 +260,10 @@ dependencies { //noinspection GradleDependency implementation "com.googlecode.mp4parser:isoparser:1.0.6" - implementation "com.google.code.gson:gson:2.8.9" + implementation "com.google.code.gson:gson:2.10" implementation "org.osmdroid:osmdroid-android:6.1.10" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23" + implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0" implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.10" implementation 'com.neovisionaries:nv-websocket-client:2.14' @@ -348,9 +278,6 @@ dependencies { implementation 'com.google.android.gms:play-services-mlkit-subject-segmentation:16.0.0-beta1' - compileOnly 'org.yaml:snakeyaml:1.29' - implementation 'org.yaml:snakeyaml:1.29' - implementation project(":openpgp-api") compileOnly fileTree("libs") @@ -360,17 +287,12 @@ dependencies { compileOnly "com.google.android.play:core:$playCoreVersion" implementation 'com.google.android.gms:play-services-vision:20.1.3' - debugImplementation 'com.google.android.gms:play-services-maps:18.1.0' - debugImplementation 'com.google.android.gms:play-services-location:20.0.0' - releaseImplementation 'com.google.android.gms:play-services-maps:18.1.0' - releaseImplementation 'com.google.android.gms:play-services-location:20.0.0' - - debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion" - debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" - debugImplementation "com.google.android.play:core:$playCoreVersion" - releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion" - releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" - releaseImplementation "com.google.android.play:core:$playCoreVersion" + implementation 'com.google.android.gms:play-services-maps:18.2.0' + implementation 'com.google.android.gms:play-services-location:21.2.0' + + implementation "com.google.firebase:firebase-messaging:$fcmVersion" + implementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" + implementation "com.google.android.play:core:$playCoreVersion" testImplementation "junit:junit:4.13.2" testImplementation "androidx.test:core:1.5.0" @@ -383,11 +305,11 @@ dependencies { // add for undo and redo implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3' // add splash screen - implementation("androidx.core:core-splashscreen:1.0.0-beta02") + implementation("androidx.core:core-splashscreen:1.0.1") // add for music tag flac... implementation 'org:jaudiotagger:2.0.3' // add for auto translate - implementation 'com.google.mlkit:language-id:17.0.4' + implementation 'com.google.mlkit:language-id:17.0.5' // add for emoji implementation 'com.jaredrummler:truetypeparser-light:1.0.0' } @@ -407,17 +329,13 @@ android { } def lib = "libtmessages.*.so" - pickFirst "lib/x86/$lib" - pickFirst "lib/x86_64/$lib" - pickFirst "lib/armeabi-v7a/$lib" - pickFirst "lib/arm64-v8a/$lib" } namespace "org.telegram.messenger" lint { disable 'MissingTranslation', 'ExtraTranslation', 'BlockedPrivateApi' } - tasks.all { task -> + tasks.configureEach { task -> if (task.name.startsWith("uploadCrashlyticsMappingFile")) { task.enabled = false } else if (task.name.contains("Crashlytics") && task.name.contains("NoGcm")) { diff --git a/TMessagesProj/src/gservcies/AndroidManifest.xml b/TMessagesProj/src/gservcies/AndroidManifest.xml deleted file mode 100644 index e0ea9d2fe5..0000000000 --- a/TMessagesProj/src/gservcies/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index bec5970b8f..0e663ade33 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -112,6 +112,9 @@ + + + @@ -710,6 +713,24 @@ + + + + + + + + + + + + + diff --git a/TMessagesProj/src/gservcies/java/nekox/messenger/NekoLocationSource.java b/TMessagesProj/src/main/java/nekox/messenger/NekoLocationSource.java similarity index 97% rename from TMessagesProj/src/gservcies/java/nekox/messenger/NekoLocationSource.java rename to TMessagesProj/src/main/java/nekox/messenger/NekoLocationSource.java index 64305f2a71..cd80ec24b8 100644 --- a/TMessagesProj/src/gservcies/java/nekox/messenger/NekoLocationSource.java +++ b/TMessagesProj/src/main/java/nekox/messenger/NekoLocationSource.java @@ -96,7 +96,7 @@ static class Cache extends LinkedHashMap { private static final long serialVersionUID = 1L; @Override - protected boolean removeEldestEntry(final java.util.Map.Entry eldest) { + protected boolean removeEldestEntry(final Entry eldest) { return (size() > KMaxEntries); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index 7ea32547a0..5e10ec3130 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -115,17 +115,7 @@ protected void attachBaseContext(Context base) { public static ILocationServiceProvider getLocationServiceProvider() { if (locationServiceProvider == null) { - if (BuildVars.isGServicesCompiled) { - try { - locationServiceProvider = (ILocationServiceProvider) Class.forName("org.telegram.messenger.GoogleLocationProvider").newInstance(); - locationServiceProvider.init(applicationContext); - } catch (Exception e) { - FileLog.e("Failed to load GoogleLocationService Provider from gservices", e); - locationServiceProvider = new ILocationServiceProvider.DummyLocationServiceProvider(); - } - } else { - locationServiceProvider = new ILocationServiceProvider.DummyLocationServiceProvider(); - } + locationServiceProvider = new GoogleLocationProvider(); } return locationServiceProvider; } @@ -135,16 +125,7 @@ public static IMapsProvider getMapsProvider() { if (NekoConfig.useOSMDroidMap.Bool()) mapsProvider = new OSMDroidMapsProvider(); else { - if (BuildVars.isGServicesCompiled) { - try { - mapsProvider = (IMapsProvider) Class.forName("org.telegram.messenger.GoogleMapsProvider").newInstance(); - } catch (Exception e) { - FileLog.e("Failed to load Google Maps Provider from gservices", e); - mapsProvider = new OSMDroidMapsProvider(); - } - } else { - mapsProvider = new OSMDroidMapsProvider(); - } + mapsProvider = new GoogleMapsProvider(); } } return mapsProvider; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 7f6958dc3d..8aaad603e3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -36,13 +36,6 @@ public class BuildVars { public static int TGX_APP_ID = 21724; public static String TGX_APP_HASH = "3e0cb5efcd52300aec5994fdfc5bdc16"; - public static boolean isUnknown = !BuildConfig.BUILD_TYPE.startsWith("release"); - public static boolean isPlay = BuildConfig.FLAVOR.endsWith("Play"); - public static boolean isFdroid = BuildConfig.BUILD_TYPE.toLowerCase().contains("fdroid"); - public static boolean isMini = !BuildConfig.FLAVOR.startsWith("full"); - public static boolean isGServicesCompiled = BuildConfig.BUILD_TYPE.equals("debug") || BuildConfig.BUILD_TYPE.equals("release"); - public static boolean isNoGCM = BuildConfig.IS_NO_GCM == 1; - static { try { diff --git a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GcmPushListenerService.java b/TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java similarity index 85% rename from TMessagesProj/src/gservcies/java/org/telegram/messenger/GcmPushListenerService.java rename to TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java index 37c5d8975d..af46e75c7a 100644 --- a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GcmPushListenerService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GcmPushListenerService.java @@ -13,9 +13,13 @@ import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; -import java.util.Map; +import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.BuildVars; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.PushListenerController; -import androidx.collection.LongSparseArray; +import java.util.Map; public class GcmPushListenerService extends FirebaseMessagingService { diff --git a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GoogleLocationProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/GoogleLocationProvider.java similarity index 97% rename from TMessagesProj/src/gservcies/java/org/telegram/messenger/GoogleLocationProvider.java rename to TMessagesProj/src/main/java/org/telegram/messenger/GoogleLocationProvider.java index ce73452136..5859be8bdb 100644 --- a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GoogleLocationProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GoogleLocationProvider.java @@ -21,6 +21,10 @@ import com.google.android.gms.location.LocationSettingsStatusCodes; import com.google.android.gms.location.SettingsClient; +import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.ILocationServiceProvider; +import org.telegram.messenger.PushListenerController; + @SuppressLint("MissingPermission") public class GoogleLocationProvider implements ILocationServiceProvider { private FusedLocationProviderClient locationProviderClient; diff --git a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GoogleMapsProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java similarity index 99% rename from TMessagesProj/src/gservcies/java/org/telegram/messenger/GoogleMapsProvider.java rename to TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java index af28cdfb0d..8e49ee2a10 100644 --- a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GoogleMapsProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GoogleMapsProvider.java @@ -31,13 +31,16 @@ import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.MarkerOptions; +import org.telegram.messenger.IMapsProvider; +import org.telegram.messenger.R; + +import nekox.messenger.NekoLocationSource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import tw.nekomimi.nekogram.NekoConfig; -import nekox.messenger.NekoLocationSource; public class GoogleMapsProvider implements IMapsProvider { diff --git a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GooglePushListenerServiceProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/GooglePushListenerServiceProvider.java similarity index 91% rename from TMessagesProj/src/gservcies/java/org/telegram/messenger/GooglePushListenerServiceProvider.java rename to TMessagesProj/src/main/java/org/telegram/messenger/GooglePushListenerServiceProvider.java index 1b09d039d4..0c70b0f375 100644 --- a/TMessagesProj/src/gservcies/java/org/telegram/messenger/GooglePushListenerServiceProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GooglePushListenerServiceProvider.java @@ -7,6 +7,13 @@ import com.google.android.gms.common.GoogleApiAvailability; import com.google.firebase.messaging.FirebaseMessaging; +import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.BuildVars; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.PushListenerController; +import org.telegram.messenger.SharedConfig; +import org.telegram.messenger.Utilities; + public class GooglePushListenerServiceProvider implements PushListenerController.IPushListenerServiceProvider { private Boolean hasServices; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java b/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java index e137c02176..4cb1dfc0dc 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java @@ -1435,16 +1435,7 @@ public int getPushType() { public static IPushListenerServiceProvider getProvider() { if (instance != null) return instance; - if (BuildVars.isGServicesCompiled) { - try { - instance = (IPushListenerServiceProvider) Class.forName("org.telegram.messenger.GooglePushListenerServiceProvider").newInstance(); - } catch (Exception e) { - FileLog.e(e); - instance = new DummyPushProvider(); - } - } else { - instance = new DummyPushProvider(); - } + instance = new GooglePushListenerServiceProvider(); return instance; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 0aa840adc2..e82e25499a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -3940,56 +3940,54 @@ public void openExceptions() { return Unit.INSTANCE; }); - if (!BuildVars.isFdroid && !BuildVars.isPlay) { - builder.addItem(LocaleController.getString("CheckUpdate", R.string.CheckUpdate), R.drawable.msg_search, - (it) -> { - Browser.openUrl(context, "tg://update"); - return Unit.INSTANCE; - }); - - String currentChannel = " - "; - switch (NekoXConfig.autoUpdateReleaseChannel) { - case 0: - currentChannel += LocaleController.getString("AutoCheckUpdateOFF", R.string.AutoCheckUpdateOFF); - break; - case 1: - currentChannel += LocaleController.getString("AutoCheckUpdateStable", R.string.AutoCheckUpdateStable); - break; - case 2: - currentChannel += LocaleController.getString("AutoCheckUpdateRc", R.string.AutoCheckUpdateRc); - break; - case 3: - currentChannel += LocaleController.getString("AutoCheckUpdatePreview", R.string.AutoCheckUpdatePreview); - break; - } - - builder.addItem(LocaleController.getString("AutoCheckUpdateSwitch", R.string.AutoCheckUpdateSwitch) + currentChannel, R.drawable.update_black_24, (it) -> { - BottomBuilder switchBuilder = new BottomBuilder(getParentActivity()); - switchBuilder.addTitle(LocaleController.getString("AutoCheckUpdateSwitch", R.string.AutoCheckUpdateSwitch)); - switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdateOFF", R.string.AutoCheckUpdateOFF), NekoXConfig.autoUpdateReleaseChannel == 0, (radioButtonCell) -> { - NekoXConfig.setAutoUpdateReleaseChannel(0); - switchBuilder.doRadioCheck(radioButtonCell); - return Unit.INSTANCE; - }); - switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdateStable", R.string.AutoCheckUpdateStable), NekoXConfig.autoUpdateReleaseChannel == 1, (radioButtonCell) -> { - NekoXConfig.setAutoUpdateReleaseChannel(1); - switchBuilder.doRadioCheck(radioButtonCell); - return Unit.INSTANCE; - }); - switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdateRc", R.string.AutoCheckUpdateRc), NekoXConfig.autoUpdateReleaseChannel == 2, (radioButtonCell) -> { - NekoXConfig.setAutoUpdateReleaseChannel(2); - switchBuilder.doRadioCheck(radioButtonCell); + builder.addItem(LocaleController.getString("CheckUpdate", R.string.CheckUpdate), R.drawable.msg_search, + (it) -> { + Browser.openUrl(context, "tg://update"); return Unit.INSTANCE; }); + + String currentChannel = " - "; + switch (NekoXConfig.autoUpdateReleaseChannel) { + case 0: + currentChannel += LocaleController.getString("AutoCheckUpdateOFF", R.string.AutoCheckUpdateOFF); + break; + case 1: + currentChannel += LocaleController.getString("AutoCheckUpdateStable", R.string.AutoCheckUpdateStable); + break; + case 2: + currentChannel += LocaleController.getString("AutoCheckUpdateRc", R.string.AutoCheckUpdateRc); + break; + case 3: + currentChannel += LocaleController.getString("AutoCheckUpdatePreview", R.string.AutoCheckUpdatePreview); + break; + } + + builder.addItem(LocaleController.getString("AutoCheckUpdateSwitch", R.string.AutoCheckUpdateSwitch) + currentChannel, R.drawable.update_black_24, (it) -> { + BottomBuilder switchBuilder = new BottomBuilder(getParentActivity()); + switchBuilder.addTitle(LocaleController.getString("AutoCheckUpdateSwitch", R.string.AutoCheckUpdateSwitch)); + switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdateOFF", R.string.AutoCheckUpdateOFF), NekoXConfig.autoUpdateReleaseChannel == 0, (radioButtonCell) -> { + NekoXConfig.setAutoUpdateReleaseChannel(0); + switchBuilder.doRadioCheck(radioButtonCell); + return Unit.INSTANCE; + }); + switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdateStable", R.string.AutoCheckUpdateStable), NekoXConfig.autoUpdateReleaseChannel == 1, (radioButtonCell) -> { + NekoXConfig.setAutoUpdateReleaseChannel(1); + switchBuilder.doRadioCheck(radioButtonCell); + return Unit.INSTANCE; + }); + switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdateRc", R.string.AutoCheckUpdateRc), NekoXConfig.autoUpdateReleaseChannel == 2, (radioButtonCell) -> { + NekoXConfig.setAutoUpdateReleaseChannel(2); + switchBuilder.doRadioCheck(radioButtonCell); + return Unit.INSTANCE; + }); // switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdatePreview", R.string.AutoCheckUpdatePreview), NekoXConfig.autoUpdateReleaseChannel == 3, (radioButtonCell) -> { // NekoXConfig.setAutoUpdateReleaseChannel(3); // switchBuilder.doRadioCheck(radioButtonCell); // return Unit.INSTANCE; // }); - showDialog(switchBuilder.create()); - return Unit.INSTANCE; - }); - } + showDialog(switchBuilder.create()); + return Unit.INSTANCE; + }); if (NekoXConfig.isDeveloper()) { builder.addItem(LocaleController.getString("DeveloperSettings", R.string.DeveloperSettings), R.drawable.baseline_developer_mode_24, (it) -> { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java index e2fcd1225d..a4efbc504f 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/InternalUpdater.java @@ -140,7 +140,7 @@ public static void checkUpdate(checkUpdateCallback callback) { try { TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; FileLog.d("Retrieve update messages, size:" + res.messages.size()); - final String target = metadata.versionName + "(" + metadata.versionCode + ")" + "-" + BuildConfig.FLAVOR + "-" + Build.SUPPORTED_ABIS[0].toLowerCase(Locale.ROOT) + ".apk"; + final String target = metadata.versionName + "(" + metadata.versionCode + ")" + "-" + Build.SUPPORTED_ABIS[0].toLowerCase(Locale.ROOT) + ".apk"; for (int i = 0; i < res.messages.size(); i++) { if (res.messages.get(i).media == null) continue; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index b58e8bb59f..36a6435506 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -156,7 +156,7 @@ public class NekoConfig { public static ConfigItem autoPauseVideo = addConfig("AutoPauseVideo", configTypeBool, false); public static ConfigItem disableProximityEvents = addConfig("DisableProximityEvents", configTypeBool, false); - public static ConfigItem ignoreContentRestrictions = addConfig("ignoreContentRestrictions", configTypeBool, !BuildVars.isPlay); + public static ConfigItem ignoreContentRestrictions = addConfig("ignoreContentRestrictions", configTypeBool, true); public static ConfigItem useChatAttachMediaMenu = addConfig("UseChatAttachEnterMenu", configTypeBool, true); public static ConfigItem disableLinkPreviewByDefault = addConfig("DisableLinkPreviewByDefault", configTypeBool, false); public static ConfigItem sendCommentAfterForward = addConfig("SendCommentAfterForward", configTypeBool, true); @@ -190,7 +190,7 @@ public class NekoConfig { public static ConfigItem customAudioBitrate = addConfig("customAudioBitrate", configTypeInt, 32); public static ConfigItem disableGroupVoipAudioProcessing = addConfig("disableGroupVoipAudioProcessing", configTypeBool, false); public static ConfigItem enhancedFileLoader = addConfig("enhancedFileLoader", configTypeBool, false); - public static ConfigItem useOSMDroidMap = addConfig("useOSMDroidMap", configTypeBool, !BuildVars.isGServicesCompiled); + public static ConfigItem useOSMDroidMap = addConfig("useOSMDroidMap", configTypeBool, false); public static ConfigItem mapDriftingFixForGoogleMaps = addConfig("mapDriftingFixForGoogleMaps", configTypeBool, true); // priv branch changes @@ -441,7 +441,7 @@ public static void checkMigrate(boolean force) { disableProximityEvents.setConfigBool(preferences.getBoolean("disableProximityEvents", false)); if (preferences.contains("ignoreContentRestrictions")) - ignoreContentRestrictions.setConfigBool(preferences.getBoolean("ignoreContentRestrictions", !BuildVars.isPlay)); + ignoreContentRestrictions.setConfigBool(preferences.getBoolean("ignoreContentRestrictions", true)); if (preferences.contains("useChatAttachMediaMenu")) useChatAttachMediaMenu.setConfigBool(preferences.getBoolean("useChatAttachMediaMenu", true)); if (preferences.contains("disableLinkPreviewByDefault")) @@ -498,6 +498,6 @@ public DatacenterInfo(int i) { } public static boolean fixDriftingForGoogleMaps() { - return BuildVars.isGServicesCompiled && !useOSMDroidMap.Bool() && mapDriftingFixForGoogleMaps.Bool(); + return !useOSMDroidMap.Bool() && mapDriftingFixForGoogleMaps.Bool(); } } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/UpdateHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/UpdateHelper.java index 924cccab45..d0c4e77c5e 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/UpdateHelper.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/remote/UpdateHelper.java @@ -148,9 +148,7 @@ protected void onLoadSuccess(ArrayList responses, Delegate delegate) if (update.sticker != null) { ids.put("sticker", update.sticker); } - if (update.nogcm != null && BuildVars.isNoGCM) { - ids.put("file", getPreferredAbiFile(update.nogcm)); - } else if (update.gcm != null) { + if (update.gcm != null) { ids.put("file", getPreferredAbiFile(update.gcm)); } diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java index 2a0a29e7b3..00cb887f28 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -248,9 +248,6 @@ public NekoGeneralSettingsActivity() { if (!NekoXConfig.isDeveloper()) { cellGroup.rows.remove(hideSponsoredMessageRow); } - if (!BuildVars.isGServicesCompiled) { - cellGroup.rows.remove(mapDriftingFixForGoogleMapsRow); - } addRowsToMap(cellGroup); } @@ -864,14 +861,8 @@ private void setCanNotChange() { // if (!NekoXConfig.isDeveloper()) // cellGroup.rows.remove(hideSponsoredMessageRow); - if (!BuildVars.isGServicesCompiled) { - NekoConfig.useOSMDroidMap.setConfigBool(true); - ((ConfigCellTextCheck) useOSMDroidMapRow).setEnabled(false); -// cellGroup.rows.remove(mapDriftingFixForGoogleMapsRow); - } else { - if (NekoConfig.useOSMDroidMap.Bool()) - ((ConfigCellTextCheck) mapDriftingFixForGoogleMapsRow).setEnabled(false); - } + if (NekoConfig.useOSMDroidMap.Bool()) + ((ConfigCellTextCheck) mapDriftingFixForGoogleMapsRow).setEnabled(false); if (NekoConfig.useTelegramTranslateInChat.Bool()) ((ConfigCellCustom) translationProviderRow).setEnabled(false); diff --git a/bin/libs/native.sh b/bin/libs/native.sh index d6d5634805..20b624a391 100755 --- a/bin/libs/native.sh +++ b/bin/libs/native.sh @@ -2,11 +2,11 @@ source "bin/init/env.sh" -OUT=TMessagesProj/build/intermediates/stripped_native_libs/miniFoss/out/lib +OUT=TMessagesProj/build/intermediates/stripped_native_libs/release/out/lib DIR=TMessagesProj/src/main/libs export COMPILE_NATIVE=1 -./gradlew TMessagesProj:stripMiniFossDebugSymbols || exit 1 +./gradlew TMessagesProj:stripReleaseDebugSymbols || exit 1 function install() { local ABI="$1" @@ -22,5 +22,3 @@ function install() { install armeabi-v7a install arm64-v8a -install x86 -install x86_64 \ No newline at end of file diff --git a/bin/scripts/requirements.txt b/bin/scripts/requirements.txt new file mode 100644 index 0000000000..24a0ea49e4 --- /dev/null +++ b/bin/scripts/requirements.txt @@ -0,0 +1,2 @@ +git+https://github.com/KurimuzonAkuma/pyrogram +PyroTgCrypto==1.2.6a0 diff --git a/bin/scripts/upload.py b/bin/scripts/upload.py new file mode 100644 index 0000000000..fabafff84f --- /dev/null +++ b/bin/scripts/upload.py @@ -0,0 +1,90 @@ +import contextlib +from pathlib import Path +from sys import argv + +from pyrogram import Client +from pyrogram.types import InputMediaDocument + +api_id = 11535358 +api_hash = "33d372962fadb01df47e6ceed4e33cd6" +artifacts_path = Path("artifacts") +test_version = argv[3] == "test" if len(argv) > 2 else None + + +def find_apk(abi: str) -> Path: + dirs = list(artifacts_path.glob("*")) + for dir in dirs: + if dir.is_dir(): + apks = list(dir.glob("*.apk")) + for apk in apks: + if abi in apk.name: + return apk + + +def get_thumb() -> str: + return "TMessagesProj/src/main/" + "ic_launcher_nagram_round_blue-playstore.png" + + +def get_caption() -> str: + pre = "Test version, " if test_version else "" + with open(artifacts_path / "caption.txt", "r", encoding="utf-8") as f: + return pre + f.read() + + +def get_document() -> list["InputMediaDocument"]: + return [ + InputMediaDocument( + media=str(find_apk("arm64-v8a")), + thumb=get_thumb(), + ), + InputMediaDocument( + media=str(find_apk("armeabi-v7a")), + thumb=get_thumb(), + caption=get_caption(), + ), + ] + + +def retry(func): + async def wrapper(*args, **kwargs): + for _ in range(3): + try: + return await func(*args, **kwargs) + except Exception as e: + print(e) + + return wrapper + + +@retry +async def send_to_channel(client: "Client", cid: str): + with contextlib.suppress(ValueError): + cid = int(cid) + await client.send_media_group( + cid, + media=get_document(), + ) + + +def get_client(bot_token: str): + return Client( + "helper_bot", + api_id=api_id, + api_hash=api_hash, + bot_token=bot_token, + ) + + +async def main(): + bot_token = argv[1] + chat_id = argv[2] + client = get_client(bot_token) + await client.start() + await send_to_channel(client, chat_id) + await client.log_out() + + +if __name__ == "__main__": + from asyncio import run + + run(main()) diff --git a/build.gradle b/build.gradle index fcf4f05e42..bd630f54cf 100644 --- a/build.gradle +++ b/build.gradle @@ -6,10 +6,10 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:7.3.1' - classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' - classpath 'com.google.gms:google-services:4.3.14' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' + classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0' + classpath 'com.google.gms:google-services:4.4.1' + classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9' classpath 'gradle.plugin.org.mozilla.rust-android-gradle:plugin:0.9.0' //noinspection GradleDependency classpath "com.github.triplet.gradle:play-publisher:3.6.0" diff --git a/openpgp-api/build.gradle b/openpgp-api/build.gradle index f389935ee3..0e724ad1c3 100644 --- a/openpgp-api/build.gradle +++ b/openpgp-api/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 31 + compileSdkVersion 33 defaultConfig { // API-Version . minor minSdkVersion 19 - targetSdkVersion 31 + targetSdkVersion 33 } - buildToolsVersion '31.0.0' + buildToolsVersion '33.0.0' lint { abortOnError false } From 8c78b9728ce6d523a90cecd1dc03bda600416dcd Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sun, 17 Mar 2024 00:01:07 +0800 Subject: [PATCH 2/3] ci: push changelog format --- .github/workflows/debug.yml | 4 ++-- .github/workflows/release.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index ccd93ceccb..6c0a4857e6 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -229,7 +229,7 @@ jobs: name: Release path: ${{ env.APK }} upload: - name: Upload release + name: Upload debug if: github.event.inputs.upload != 'y' runs-on: ubuntu-latest needs: @@ -255,5 +255,5 @@ jobs: echo $mini32 python -m pip install -r bin/scripts/requirements.txt - git log -1 --pretty=format:"%s" > artifacts/caption.txt + git log -1 --pretty=format:"%s%n%n%b" > artifacts/caption.txt python bin/scripts/upload.py ${{ secrets.HELPER_BOT_TOKEN }} ${{ secrets.HELPER_BOT_TARGET }} test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1827289a82..409df28b5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -258,5 +258,5 @@ jobs: echo $mini32 python -m pip install -r bin/scripts/requirements.txt - git log -1 --pretty=format:"%s" > artifacts/caption.txt + git log -1 --pretty=format:"%s%n%n%b" > artifacts/caption.txt python bin/scripts/upload.py ${{ secrets.HELPER_BOT_TOKEN }} ${{ secrets.HELPER_BOT_TARGET }} release From 9dd6335335c83f70ef42a058750d6adefef67485 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 16 Mar 2024 23:58:53 +0800 Subject: [PATCH 3/3] perf: Push Service More Type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InApp、FCM、Unified Push Co-authored-by: Timothy Redaelli --- TMessagesProj/build.gradle | 11 ++ TMessagesProj/src/main/AndroidManifest.xml | 8 ++ .../telegram/messenger/ApplicationLoader.java | 15 +-- .../messenger/NotificationsService.java | 4 +- .../messenger/PushListenerController.java | 23 +++- .../UnifiedPushListenerServiceProvider.java | 63 ++++++++++ .../messenger/UnifiedPushReceiver.java | 115 ++++++++++++++++++ .../settings/NekoGeneralSettingsActivity.java | 19 +++ .../kotlin/xyz/nextalone/nagram/NaConfig.kt | 18 +++ .../src/main/res/values-zh-rCN/strings_na.xml | 6 + .../src/main/res/values/strings_na.xml | 6 + 11 files changed, 277 insertions(+), 11 deletions(-) create mode 100644 TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushListenerServiceProvider.java create mode 100644 TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushReceiver.java diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 617a798fed..4d3f3ce6f0 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -1,6 +1,15 @@ apply plugin: "com.android.application" apply plugin: "kotlin-android" +repositories { + maven { + url 'https://www.jitpack.io' + content { + includeModule 'com.github.UnifiedPush', 'android-connector' + } + } +} + def verName = "10.9.1" def verCode = 1163 @@ -312,6 +321,8 @@ dependencies { implementation 'com.google.mlkit:language-id:17.0.5' // add for emoji implementation 'com.jaredrummler:truetypeparser-light:1.0.0' + // add for up + implementation 'com.github.UnifiedPush:android-connector:2.3.1' } apply plugin: "com.google.gms.google-services" diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index 0e663ade33..bf78c6a1f1 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -713,6 +713,14 @@ + + + + + + + + diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index 5e10ec3130..c1f97c63cf 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -65,6 +65,7 @@ import tw.nekomimi.nekogram.NekoXConfig; import tw.nekomimi.nekogram.parts.SignturesKt; import tw.nekomimi.nekogram.utils.FileUtil; +import xyz.nextalone.nagram.NaConfig; import static android.os.Build.VERSION.SDK_INT; @@ -363,6 +364,13 @@ private static void startPushServiceInternal() { if (enabled) { AndroidUtilities.runOnUIThread(() -> { try { + Log.d("TFOSS", "Starting push service..."); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && NaConfig.INSTANCE.getPushServiceTypeInAppDialog().Bool()) { + applicationContext.startForegroundService(new Intent(applicationContext, NotificationsService.class)); + } else { + applicationContext.startService(new Intent(applicationContext, NotificationsService.class)); + } + Log.d("TFOSS", "Trying to start push service every 10 minutes"); // Telegram-FOSS: unconditionally enable push service AlarmManager am = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE); @@ -371,13 +379,6 @@ private static void startPushServiceInternal() { am.cancel(pendingIntent); am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), 10 * 60 * 1000, pendingIntent); - - Log.d("TFOSS", "Starting push service..."); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - applicationContext.startForegroundService(new Intent(applicationContext, NotificationsService.class)); - } else { - applicationContext.startService(new Intent(applicationContext, NotificationsService.class)); - } } catch (Throwable e) { Log.d("TFOSS", "Failed to start push service"); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java index b31be3383d..c4ec95a50d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsService.java @@ -20,13 +20,15 @@ import androidx.core.app.NotificationCompat; +import xyz.nextalone.nagram.NaConfig; + public class NotificationsService extends Service { @Override public void onCreate() { super.onCreate(); ApplicationLoader.postInitApplication(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && NaConfig.INSTANCE.getPushServiceTypeInAppDialog().Bool()) { String CHANNEL_ID = "push_service_channel"; NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel channel = new NotificationChannel(CHANNEL_ID, LocaleController.getString("NekoXPushService", R.string.NekoXPushService), NotificationManager.IMPORTANCE_DEFAULT); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java b/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java index 4cb1dfc0dc..93f6ee8d3a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/PushListenerController.java @@ -22,13 +22,17 @@ import java.util.Locale; import java.util.concurrent.CountDownLatch; +import xyz.nextalone.nagram.NaConfig; + public class PushListenerController { public static final int PUSH_TYPE_FIREBASE = 2, + PUSH_TYPE_SIMPLE = 4, PUSH_TYPE_HUAWEI = 13; @Retention(RetentionPolicy.SOURCE) @IntDef({ PUSH_TYPE_FIREBASE, + PUSH_TYPE_SIMPLE, PUSH_TYPE_HUAWEI }) public @interface PushType {} @@ -56,7 +60,7 @@ public static void sendRegistrationToServer(@PushType int pushType, String token if (userConfig.getClientUserId() != 0) { final int currentAccount = a; if (sendStat) { - String tag = pushType == PUSH_TYPE_FIREBASE ? "fcm" : "hcm"; + String tag = pushType == PUSH_TYPE_FIREBASE ? "fcm" : (pushType == PUSH_TYPE_HUAWEI ? "hcm" : "up"); TLRPC.TL_help_saveAppLog req = new TLRPC.TL_help_saveAppLog(); TLRPC.TL_inputAppEvent event = new TLRPC.TL_inputAppEvent(); event.time = SharedConfig.pushStringGetTimeStart; @@ -84,7 +88,7 @@ public static void sendRegistrationToServer(@PushType int pushType, String token } public static void processRemoteMessage(@PushType int pushType, String data, long time) { - String tag = pushType == PUSH_TYPE_FIREBASE ? "FCM" : "HCM"; + String tag = pushType == PUSH_TYPE_FIREBASE ? "FCM" : (pushType == PUSH_TYPE_HUAWEI ? "HCM" : "UP"); if (BuildVars.LOGS_ENABLED) { FileLog.d(tag + " PRE START PROCESSING"); } @@ -1435,7 +1439,20 @@ public int getPushType() { public static IPushListenerServiceProvider getProvider() { if (instance != null) return instance; - instance = new GooglePushListenerServiceProvider(); + switch (NaConfig.INSTANCE.getPushServiceType().Int()) { + case 1: { + instance = new GooglePushListenerServiceProvider(); + break; + } + case 2: { + instance = new UnifiedPushListenerServiceProvider(); + break; + } + default: { + instance = new DummyPushProvider(); + break; + } + } return instance; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushListenerServiceProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushListenerServiceProvider.java new file mode 100644 index 0000000000..ead106d76a --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushListenerServiceProvider.java @@ -0,0 +1,63 @@ +package org.telegram.messenger; + +import android.os.SystemClock; +import android.text.TextUtils; + +import org.unifiedpush.android.connector.UnifiedPush; + +import java.util.ArrayList; +import java.util.List; + +public class UnifiedPushListenerServiceProvider implements PushListenerController.IPushListenerServiceProvider { + public UnifiedPushListenerServiceProvider(){}; + + @Override + public boolean hasServices() { + return !UnifiedPush.getDistributors(ApplicationLoader.applicationContext, new ArrayList<>()).isEmpty(); + } + + @Override + public String getLogTitle() { + return "UnifiedPush"; + } + + @Override + public void onRequestPushToken() { + String currentPushString = SharedConfig.pushString; + if (!TextUtils.isEmpty(currentPushString)) { + if (BuildVars.DEBUG_PRIVATE_VERSION && BuildVars.LOGS_ENABLED) { + FileLog.d("UnifiedPush endpoint = " + currentPushString); + } + } else { + if (BuildVars.LOGS_ENABLED) { + FileLog.d("No UnifiedPush string found"); + } + } + Utilities.globalQueue.postRunnable(() -> { + try { + SharedConfig.pushStringGetTimeStart = SystemClock.elapsedRealtime(); + SharedConfig.saveConfig(); + if (UnifiedPush.getAckDistributor(ApplicationLoader.applicationContext) == null) { + List distributors = UnifiedPush.getDistributors(ApplicationLoader.applicationContext, new ArrayList<>()); + if (distributors.size() > 0) { + String distributor = distributors.get(0); + UnifiedPush.saveDistributor(ApplicationLoader.applicationContext, distributor); + } + } + UnifiedPush.registerApp( + ApplicationLoader.applicationContext, + "default", + new ArrayList<>(), + "Telegram Simple Push" + ); + } catch (Throwable e) { + FileLog.e(e); + } + }); + } + + @Override + public int getPushType() { + return PushListenerController.PUSH_TYPE_SIMPLE; + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushReceiver.java b/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushReceiver.java new file mode 100644 index 0000000000..1faf51be87 --- /dev/null +++ b/TMessagesProj/src/main/java/org/telegram/messenger/UnifiedPushReceiver.java @@ -0,0 +1,115 @@ +package org.telegram.messenger; + +import android.content.Context; +import android.os.SystemClock; + +import androidx.annotation.NonNull; + +import org.telegram.tgnet.ConnectionsManager; + +import org.unifiedpush.android.connector.MessagingReceiver; +import org.unifiedpush.android.connector.UnifiedPush; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.util.concurrent.CountDownLatch; + +import xyz.nextalone.nagram.NaConfig; + +public class UnifiedPushReceiver extends MessagingReceiver { + + private static long lastReceivedNotification = 0; + private static long numOfReceivedNotifications = 0; + + public static long getLastReceivedNotification() { + return lastReceivedNotification; + } + + public static long getNumOfReceivedNotifications() { + return numOfReceivedNotifications; + } + + @Override + public void onNewEndpoint(Context context, String endpoint, String instance){ + Utilities.globalQueue.postRunnable(() -> { + SharedConfig.pushStringGetTimeEnd = SystemClock.elapsedRealtime(); + + String savedDistributor = UnifiedPush.getSavedDistributor(context); + + if (savedDistributor.equals("io.heckel.ntfy")) { + PushListenerController.sendRegistrationToServer(PushListenerController.PUSH_TYPE_SIMPLE, endpoint); + return; + } + + try { + PushListenerController.sendRegistrationToServer(PushListenerController.PUSH_TYPE_SIMPLE, NaConfig.INSTANCE.getPushServiceTypeUnifiedGateway().String() + URLEncoder.encode(endpoint, "UTF-8")); + } catch (UnsupportedEncodingException e) { + FileLog.e(e); + } + }); + } + + @Override + public void onMessage(Context context, byte[] message, String instance){ + final long receiveTime = SystemClock.elapsedRealtime(); + final CountDownLatch countDownLatch = new CountDownLatch(1); + + lastReceivedNotification = SystemClock.elapsedRealtime(); + numOfReceivedNotifications++; + + AndroidUtilities.runOnUIThread(() -> { + if (BuildVars.LOGS_ENABLED) { + FileLog.d("UP PRE INIT APP"); + } + ApplicationLoader.postInitApplication(); + if (BuildVars.LOGS_ENABLED) { + FileLog.d("UP POST INIT APP"); + } + Utilities.stageQueue.postRunnable(() -> { + if (BuildVars.LOGS_ENABLED) { + FileLog.d("UP START PROCESSING"); + } + for (int a : SharedConfig.activeAccounts) { + if (UserConfig.getInstance(a).isClientActivated()) { + ConnectionsManager.onInternalPushReceived(a); + ConnectionsManager.getInstance(a).resumeNetworkMaybe(); + } + } + countDownLatch.countDown(); + }); + }); + Utilities.globalQueue.postRunnable(()-> { + try { + countDownLatch.await(); + } catch (Throwable ignore) { + + } + if (BuildVars.DEBUG_VERSION) { + FileLog.d("finished UP service, time = " + (SystemClock.elapsedRealtime() - receiveTime)); + } + }); + } + + @Override + public void onRegistrationFailed(Context context, String instance){ + if (BuildVars.LOGS_ENABLED) { + FileLog.d("Failed to get endpoint"); + } + SharedConfig.pushStringStatus = "__UNIFIEDPUSH_FAILED__"; + Utilities.globalQueue.postRunnable(() -> { + SharedConfig.pushStringGetTimeEnd = SystemClock.elapsedRealtime(); + + PushListenerController.sendRegistrationToServer(PushListenerController.PUSH_TYPE_SIMPLE, null); + }); + } + + @Override + public void onUnregistered(Context context, String instance){ + SharedConfig.pushStringStatus = "__UNIFIEDPUSH_FAILED__"; + Utilities.globalQueue.postRunnable(() -> { + SharedConfig.pushStringGetTimeEnd = SystemClock.elapsedRealtime(); + + PushListenerController.sendRegistrationToServer(PushListenerController.PUSH_TYPE_SIMPLE, null); + }); + } +} diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java index 00cb887f28..8d9475e213 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoGeneralSettingsActivity.java @@ -27,11 +27,13 @@ import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.util.OpenPgpApi; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.BuildVars; import org.telegram.messenger.ContactsController; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.NotificationsService; import org.telegram.messenger.R; import org.telegram.messenger.SharedConfig; import org.telegram.messenger.UserConfig; @@ -236,6 +238,16 @@ public class NekoGeneralSettingsActivity extends BaseNekoXSettingsActivity { private final AbstractConfigCell displayPersianCalendarByLatinRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.displayPersianCalendarByLatin)); private final AbstractConfigCell divider7 = cellGroup.appendCell(new ConfigCellDivider()); + private final AbstractConfigCell headerPushService = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("Notifications", R.string.Notifications))); + private final AbstractConfigCell pushServiceTypeRow = cellGroup.appendCell(new ConfigCellSelectBox(null, NaConfig.INSTANCE.getPushServiceType(), new String[]{ + LocaleController.getString(R.string.PushServiceTypeInApp), + LocaleController.getString(R.string.PushServiceTypeFCM), + LocaleController.getString(R.string.PushServiceTypeUnified), + }, null)); + private final AbstractConfigCell pushServiceTypeInAppDialogRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getPushServiceTypeInAppDialog())); + private final AbstractConfigCell pushServiceTypeUnifiedGatewayRow = cellGroup.appendCell(new ConfigCellTextInput(null, NaConfig.INSTANCE.getPushServiceTypeUnifiedGateway(), null, null, (input) -> input.isEmpty() ? (String) NaConfig.INSTANCE.getPushServiceTypeUnifiedGateway().defaultValue : input)); + private final AbstractConfigCell divider8 = cellGroup.appendCell(new ConfigCellDivider()); + private final AbstractConfigCell headerAutoDownload = cellGroup.appendCell(new ConfigCellHeader(LocaleController.getString("AutoDownload"))); private final AbstractConfigCell win32Row = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAutoDownloadingWin32Executable)); private final AbstractConfigCell archiveRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableAutoDownloadingArchive)); @@ -476,6 +488,13 @@ public void onItemClick(int id) { cell.setEnabled(true); } listAdapter.notifyItemChanged(cellGroup.rows.indexOf(translationProviderRow)); + } else if (key.equals(NaConfig.INSTANCE.getPushServiceType().getKey())) { + restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); + } else if (key.equals(NaConfig.INSTANCE.getPushServiceTypeInAppDialog().getKey())) { + ApplicationLoader.applicationContext.stopService(new Intent(ApplicationLoader.applicationContext, NotificationsService.class)); + ApplicationLoader.startPushService(); + } else if (key.equals(NaConfig.INSTANCE.getPushServiceTypeUnifiedGateway().getKey())) { + restartTooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null); } }; diff --git a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt index 9df6a138a7..fe10945263 100644 --- a/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt +++ b/TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt @@ -548,6 +548,24 @@ object NaConfig { ConfigItem.configTypeBool, false ) + val pushServiceType = + addConfig( + "PushServiceType", + ConfigItem.configTypeInt, + 1 + ) + val pushServiceTypeInAppDialog = + addConfig( + "PushServiceTypeInAppDialog", + ConfigItem.configTypeBool, + true + ) + val pushServiceTypeUnifiedGateway = + addConfig( + "PushServiceTypeUnifiedGateway", + ConfigItem.configTypeString, + "https://p2p.belloworld.it/" + ) private fun addConfig( k: String, diff --git a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml index 293be34214..e9d451655a 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -126,4 +126,10 @@ Disable Flag Secure 标题居中 在输入框中显示快速回复按钮 + 通知推送服务 + 内置 + Google FCM + Unified Push + 显示常驻通知 + Unified Push Gateway diff --git a/TMessagesProj/src/main/res/values/strings_na.xml b/TMessagesProj/src/main/res/values/strings_na.xml index d7cc7802cc..ee733c6b0c 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -126,4 +126,10 @@ Disable Flag Secure Center title in action bar Show Quick Reply In Bot Commands + Push Service Type + In App + Google FCM + Unified Push + Show resident notifications + Unified Push Gateway