From 24ec7f6cc6287b1e9acb20dea92ff9fc6a3048b4 Mon Sep 17 00:00:00 2001 From: androidacy-user Date: Fri, 20 Jan 2023 21:30:50 -0500 Subject: [PATCH] bump min sdk to 24 Signed-off-by: androidacy-user --- app/build.gradle | 2 +- .../main/java/com/fox2code/mmm/MainApplication.java | 13 +++++-------- .../com/fox2code/mmm/utils/sentry/SentryMain.java | 12 ++++++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 48ec754..4f084e2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,7 @@ android { defaultConfig { applicationId "com.fox2code.mmm" - minSdk 23 + minSdk 24 targetSdk 33 versionCode 64 versionName "1.2.1" diff --git a/app/src/main/java/com/fox2code/mmm/MainApplication.java b/app/src/main/java/com/fox2code/mmm/MainApplication.java index 736331b..7e603ab 100644 --- a/app/src/main/java/com/fox2code/mmm/MainApplication.java +++ b/app/src/main/java/com/fox2code/mmm/MainApplication.java @@ -14,7 +14,6 @@ import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.annotation.RequiresApi; import androidx.annotation.StyleRes; import androidx.core.app.NotificationManagerCompat; import androidx.emoji2.text.DefaultEmojiCompatConfig; @@ -58,7 +57,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con // Warning! Locales that are't exist will crash the app // Anything that is commented out is supported but the translation is not complete to at least 60% public static HashSet supportedLocales = new HashSet<>(); - private static Locale timeFormatLocale = Resources.getSystem().getConfiguration().locale; + private static Locale timeFormatLocale = Resources.getSystem().getConfiguration().getLocales().get(0); private static SimpleDateFormat timeFormat = new SimpleDateFormat(timeFormatString, timeFormatLocale); private static SharedPreferences bootSharedPreferences; private static String relPackageName = BuildConfig.APPLICATION_ID; @@ -308,6 +307,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con Log.d("MainApplication", "Starting FoxMMM version " + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + "), commit " + BuildConfig.COMMIT_HASH); } super.onCreate(); + if (BuildConfig.DEBUG) { Log.d("MainApplication", "FoxMMM is running in debug mode"); } @@ -390,7 +390,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con @Override public void onConfigurationChanged(@NonNull Configuration newConfig) { - Locale newTimeFormatLocale = newConfig.locale; + Locale newTimeFormatLocale = newConfig.getLocales().get(0); if (timeFormatLocale != newTimeFormatLocale) { timeFormatLocale = newTimeFormatLocale; timeFormat = new SimpleDateFormat(timeFormatString, timeFormatLocale); @@ -398,17 +398,14 @@ public class MainApplication extends FoxApplication implements androidx.work.Con super.onConfigurationChanged(newConfig); } - @RequiresApi(api = Build.VERSION_CODES.N) public void clearAppData() { // Clear app data try { // Clearing app data // We have to manually delete the files and directories // because the cache directory is not cleared by the following method - File cacheDir = null; - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) { - cacheDir = this.getDataDir(); - } + File cacheDir; + cacheDir = this.getDataDir(); if (cacheDir != null && cacheDir.isDirectory()) { String[] children = cacheDir.list(); if (children != null) { diff --git a/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java b/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java index 855b412..d8db1e9 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java +++ b/app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java @@ -2,9 +2,11 @@ package com.fox2code.mmm.utils.sentry; import android.annotation.SuppressLint; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; +import com.fox2code.mmm.CrashHandler; import com.fox2code.mmm.MainApplication; import com.fox2code.mmm.androidacy.AndroidacyUtil; @@ -35,10 +37,12 @@ public class SentryMain { editor.putString("lastExitReason", "crash"); editor.putLong("lastExitTime", System.currentTimeMillis()); editor.apply(); - // If we just let the default uncaught exception handler handle the - // exception, the app will hang and never close. - // So we need to kill the app ourselves. - System.exit(1); + // open crash handler and exit + Intent intent = new Intent(mainApplication, CrashHandler.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + mainApplication.startActivity(intent); + android.os.Process.killProcess(android.os.Process.myPid()); + System.exit(10); }); SentryAndroid.init(mainApplication, options -> { // If crash reporting is disabled, stop here.