diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 5e4ed8147d..4fedda44f2 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -307,8 +307,6 @@ jobs: flavor: - FullRelease - MiniRelease - - FullReleaseNoGcm - - MiniReleaseNoGcm steps: - name: Checkout uses: actions/checkout@v2 @@ -374,7 +372,6 @@ jobs: - 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') @@ -386,8 +383,8 @@ jobs: path: ${{ env.APK }} upload: name: Upload debug + if: github.event.inputs.upload != 'y' runs-on: ubuntu-latest - if: ${{ !contains(github.event.head_commit.message, 'bump version') }} needs: - build - telegram-bot-api @@ -401,6 +398,10 @@ jobs: with: name: telegram-bot-api-binary path: . + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 - name: Setup Python telebot run: | pip install telebot @@ -419,10 +420,6 @@ jobs: export mini32=$(find artifacts -name "*mini-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 "*mini-arm64-v8aNoGcm.apk") - export mini32nogcm=$(find artifacts -name "*mini-armeabi-v7aNoGcm.apk") - export full64nogcm=$(find artifacts -name "*full-arm64-v8aNoGcm.apk") - export full32nogcm=$(find artifacts -name "*full-armeabi-v7aNoGcm.apk") touch ./Send_to_Telegram.py sudo cat >./Send_to_Telegram.py <> $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 d5774725f2..de739937b6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -302,8 +302,6 @@ jobs: flavor: - FullRelease - MiniRelease - - FullReleaseNoGcm - - MiniReleaseNoGcm steps: - name: Checkout uses: actions/checkout@v2 @@ -395,6 +393,13 @@ jobs: with: name: telegram-bot-api-binary path: . + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Setup Python telebot + run: | + pip install telebot - name: Send to Telegram run: | chmod +x telegram-bot-api-binary @@ -410,39 +415,23 @@ jobs: export mini32=$(find artifacts -name "*mini-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 "*mini-arm64-v8aNoGcm.apk") - export mini32nogcm=$(find artifacts -name "*mini-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 + touch ./Send_to_Telegram.py + sudo cat >./Send_to_Telegram.py </dev/null + python Send_to_Telegram.py pkill telegram-bot telegram-bot-api: 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 f7f0a17da9..d33deab04a 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -1,8 +1,15 @@ -import cn.hutool.core.util.RuntimeUtil - 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 @@ -83,12 +90,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 +125,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 { @@ -175,20 +181,6 @@ android { ndk.debugSymbolLevel = "FULL" } - 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 @@ -200,46 +192,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" - } - manifest { - srcFile "src/gservcies/AndroidManifest.xml" + srcDirs "src/main/java" } - } - - releaseNoGcm { - jni.srcDirs = [] jniLibs { srcDir "src/main/libs" } @@ -247,30 +211,12 @@ 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" @@ -293,20 +239,20 @@ android { } } - 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) @@ -318,8 +264,8 @@ android { } -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 { @@ -329,7 +275,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" @@ -343,10 +289,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' @@ -373,17 +319,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" @@ -396,13 +337,15 @@ 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' + // add for up + implementation 'com.github.UnifiedPush:android-connector:2.3.1' } apply plugin: "com.google.gms.google-services" @@ -420,17 +363,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 a0d0b8d26f..cd33e7eb97 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -112,6 +112,9 @@ + + + @@ -724,6 +727,32 @@ + + + + + + + + + + + + + + + + + + + + + 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..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; @@ -115,17 +116,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 +126,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; @@ -382,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); @@ -390,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/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 7f6958dc3d..cdd4b7eb11 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -36,12 +36,7 @@ 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 { 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/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 e137c02176..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,15 +1439,19 @@ 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); + switch (NaConfig.INSTANCE.getPushServiceType().Int()) { + case 1: { + instance = new GooglePushListenerServiceProvider(); + break; + } + case 2: { + instance = new UnifiedPushListenerServiceProvider(); + break; + } + default: { instance = new DummyPushProvider(); + break; } - } else { - instance = new DummyPushProvider(); } 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/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 563d640ea9..d7f424df1d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -3949,56 +3949,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); - return Unit.INSTANCE; - }); - switchBuilder.addRadioItem(LocaleController.getString("AutoCheckUpdatePreview", R.string.AutoCheckUpdatePreview), NekoXConfig.autoUpdateReleaseChannel == 3, (radioButtonCell) -> { - NekoXConfig.setAutoUpdateReleaseChannel(3); - switchBuilder.doRadioCheck(radioButtonCell); + builder.addItem(LocaleController.getString("CheckUpdate", R.string.CheckUpdate), R.drawable.msg_search, + (it) -> { + Browser.openUrl(context, "tg://update"); return Unit.INSTANCE; }); - showDialog(switchBuilder.create()); + + 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; + }); 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 1e4a33a604..a7c3e75fb9 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)); @@ -248,9 +260,6 @@ public NekoGeneralSettingsActivity() { if (!NekoXConfig.isDeveloper()) { cellGroup.rows.remove(hideSponsoredMessageRow); } - if (!BuildVars.isGServicesCompiled) { - cellGroup.rows.remove(mapDriftingFixForGoogleMapsRow); - } addRowsToMap(cellGroup); } @@ -480,6 +489,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); } }; @@ -868,14 +884,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/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 866cc33fb9..a3491e0df6 100644 --- a/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml +++ b/TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml @@ -127,4 +127,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 9bde121c6a..2fa4d9a2c4 100644 --- a/TMessagesProj/src/main/res/values/strings_na.xml +++ b/TMessagesProj/src/main/res/values/strings_na.xml @@ -127,4 +127,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 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 }