From 19034c0b8ebd33f3ee9af59dea987ee961f6b66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 24 Dec 2020 22:22:07 +0800 Subject: [PATCH] Replace firebase crashlytics with acra --- TMessagesProj/build.gradle | 9 +++++---- .../telegram/messenger/ApplicationLoader.java | 18 +++++++++++++----- .../src/main/res/values/strings_nekox.xml | 3 +++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 8004227fa..22ae5c965 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -39,8 +39,8 @@ configurations { def okHttpVersion = '4.9.0' def fcmVersion = '21.0.1' -def crashlyticsVersion = '17.3.0' def playCoreVersion = '1.9.0' +def acraVersion = '5.7.0' repositories { @@ -93,16 +93,17 @@ dependencies { compileOnly files('libs/libv2ray.aar') compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" - 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" + implementation "ch.acra:acra-mail:$acraVersion" + implementation "ch.acra:acra-notification:$acraVersion" + implementation "ch.acra:acra-limiter:$acraVersion" + testImplementation 'junit:junit:4.13.1' testImplementation 'androidx.test:core:1.3.0' testImplementation "org.robolectric:robolectric:4.4" diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index 083982345..0583fb101 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -32,6 +32,10 @@ import android.util.Log; import androidx.core.app.NotificationManagerCompat; import androidx.multidex.MultiDex; +import org.acra.ACRA; +import org.acra.annotation.AcraCore; +import org.acra.annotation.AcraMailSender; +import org.acra.annotation.AcraNotification; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.ForegroundDetector; @@ -51,6 +55,14 @@ import tw.nekomimi.nekogram.utils.UIUtil; import static android.os.Build.VERSION.SDK_INT; +@AcraCore(buildConfigClass = BuildConfig.class) +@AcraMailSender(mailTo = "nekohashizuku@gmail.com") +@AcraNotification( + resIcon = R.drawable.notification, + resTitle = R.string.NekoX, + resText = R.string.AcraText, + resChannelName = R.string.AcraChannel +) public class ApplicationLoader extends Application { @SuppressLint("StaticFieldLeak") @@ -74,11 +86,6 @@ public class ApplicationLoader extends Application { public static boolean hasPlayServices; - @Override - public SharedPreferences getSharedPreferences(String name, int mode) { - return new WarppedPref(super.getSharedPreferences(name, mode)); - } - @Override protected void attachBaseContext(Context base) { if (SDK_INT >= Build.VERSION_CODES.P) { @@ -88,6 +95,7 @@ public class ApplicationLoader extends Application { if (SDK_INT < Build.VERSION_CODES.LOLLIPOP) { MultiDex.install(this); } + ACRA.init(this); } /** diff --git a/TMessagesProj/src/main/res/values/strings_nekox.xml b/TMessagesProj/src/main/res/values/strings_nekox.xml index 58b98113c..b3ab4aa43 100644 --- a/TMessagesProj/src/main/res/values/strings_nekox.xml +++ b/TMessagesProj/src/main/res/values/strings_nekox.xml @@ -268,4 +268,7 @@ Simplified Chinese (China) New Japanese Kanji (Shinjitai) + Sorrt, this applacation crashed. Please send a report to the developers + + \ No newline at end of file