mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2025-01-19 02:20:29 +01:00
Fixes
This commit is contained in:
parent
1bfe2dc0d7
commit
eb91f02681
@ -38,7 +38,7 @@ configurations {
|
||||
}
|
||||
|
||||
def okHttpVersion = '4.9.0'
|
||||
def fcmVersion = '21.0.0'
|
||||
def fcmVersion = '21.0.1'
|
||||
def crashlyticsVersion = '17.3.0'
|
||||
def playCoreVersion = '1.9.0'
|
||||
|
||||
@ -94,6 +94,9 @@ dependencies {
|
||||
compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
|
||||
compileOnly "com.google.android.play:core:$playCoreVersion"
|
||||
|
||||
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"
|
||||
@ -383,9 +386,9 @@ android {
|
||||
tasks.all { task ->
|
||||
if (task.name.startsWith('uploadCrashlyticsMappingFile')) {
|
||||
task.enabled = false
|
||||
} else if (((task.name.contains('Crashlytics'))) && !task.name.endsWith("Release")) {
|
||||
} else if (((task.name.contains('Crashlytics'))) && task.name.contains("NoGcm")) {
|
||||
task.enabled = false
|
||||
} else if (((task.name.endsWith('GoogleServices'))) && !task.name.endsWith("ReleaseGoogleServices")) {
|
||||
} else if (((task.name.endsWith('GoogleServices'))) && task.name.contains("NoGcm")) {
|
||||
task.enabled = false
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,8 @@ public class ApplicationLoader extends Application {
|
||||
|
||||
public static boolean hasPlayServices;
|
||||
|
||||
@Override public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
@Override
|
||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||
return new WarppedPref(super.getSharedPreferences(name, mode));
|
||||
}
|
||||
|
||||
@ -280,6 +281,7 @@ public class ApplicationLoader extends Application {
|
||||
}
|
||||
|
||||
SharedConfig.loadConfig();
|
||||
|
||||
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { //TODO improve account
|
||||
final int finalA = a;
|
||||
Runnable initRunnable = () -> {
|
||||
@ -315,6 +317,7 @@ public class ApplicationLoader extends Application {
|
||||
FileLog.d("app initied");
|
||||
}
|
||||
|
||||
|
||||
MediaController.getInstance();
|
||||
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) { //TODO improve account
|
||||
final int finalA = a;
|
||||
@ -381,6 +384,10 @@ public class ApplicationLoader extends Application {
|
||||
}
|
||||
|
||||
public static void startPushService() {
|
||||
UIUtil.runOnIoDispatcher(ApplicationLoader::startPushServiceInternal);
|
||||
}
|
||||
|
||||
private static void startPushServiceInternal() {
|
||||
if (ExternalGcm.checkPlayServices() || (SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2 && isNotificationListenerEnabled())) {
|
||||
return;
|
||||
}
|
||||
@ -406,21 +413,23 @@ public class ApplicationLoader extends Application {
|
||||
}
|
||||
if (enabled) {
|
||||
try {
|
||||
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));
|
||||
}
|
||||
UIUtil.runOnUIThread(() -> {
|
||||
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");
|
||||
}
|
||||
} else {
|
||||
} else UIUtil.runOnUIThread(() -> {
|
||||
applicationContext.stopService(new Intent(applicationContext, NotificationsService.class));
|
||||
PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), 0);
|
||||
AlarmManager alarm = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
alarm.cancel(pintent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isNotificationListenerEnabled() {
|
||||
|
@ -10,6 +10,7 @@ package org.telegram.messenger;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
@ -17,6 +18,7 @@ import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -137,10 +139,6 @@ public class SharedConfig {
|
||||
|
||||
public static int distanceSystemType;
|
||||
|
||||
static {
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
public static class ProxyInfo implements Comparable<ProxyInfo> {
|
||||
|
||||
public int group;
|
||||
@ -1030,7 +1028,9 @@ public class SharedConfig {
|
||||
showNotificationsForAllAccounts = preferences.getBoolean("AllAccounts", true);
|
||||
|
||||
configLoaded = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void increaseBadPasscodeTries() {
|
||||
|
@ -16,6 +16,7 @@ import com.google.android.play.core.install.model.UpdateAvailability;
|
||||
import com.google.firebase.crashlytics.FirebaseCrashlytics;
|
||||
import com.google.firebase.iid.FirebaseInstanceId;
|
||||
|
||||
import org.h2.util.IOUtils;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
@ -36,13 +37,13 @@ import tw.nekomimi.nekogram.utils.UIUtil;
|
||||
public class ExternalGcm {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
private static boolean noGcm = !"release".equals(BuildConfig.BUILD_TYPE);
|
||||
private static boolean noGcm = BuildConfig.BUILD_TYPE.contains("NoGcm");
|
||||
|
||||
private static Boolean hasPlayServices;
|
||||
|
||||
public static void initPlayServices() {
|
||||
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
UIUtil.runOnIoDispatcher(() -> {
|
||||
if (hasPlayServices = checkPlayServices()) {
|
||||
final String currentPushString = SharedConfig.pushString;
|
||||
if (!TextUtils.isEmpty(currentPushString)) {
|
||||
@ -79,7 +80,7 @@ public class ExternalGcm {
|
||||
SharedConfig.pushStringStatus = "__NO_GOOGLE_PLAY_SERVICES__";
|
||||
ConnectionsManager.setRegId(null, SharedConfig.pushStringStatus);
|
||||
}
|
||||
}, 1000);
|
||||
}, 2300);
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,9 @@ object UpdateUtil {
|
||||
MessagesController.getMainSettings(currentAccount).edit().putBoolean("update_channel_skip", true).apply()
|
||||
}
|
||||
|
||||
builder.show()
|
||||
try {
|
||||
builder.show()
|
||||
} catch (ignored: Exception) {}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user