mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-14 18:57:30 +00:00
Delete prev stackstrace files on version update
This commit is contained in:
parent
05fd58405c
commit
dc6f60e70d
@ -14,6 +14,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awaisomereport.CrashReporterHelper;
|
||||
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
|
||||
@ -70,7 +71,7 @@ public final class FlavorTown {
|
||||
}
|
||||
|
||||
public static void changelogCheck(@NonNull final Context context) {
|
||||
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) < BuildConfig.VERSION_CODE) {
|
||||
if (settingsHelper.getInteger(Constants.PREV_INSTALL_VERSION) >= BuildConfig.VERSION_CODE) return;
|
||||
int appUaCode = settingsHelper.getInteger(Constants.APP_UA_CODE);
|
||||
int browserUaCode = settingsHelper.getInteger(Constants.BROWSER_UA_CODE);
|
||||
if (browserUaCode == -1 || browserUaCode >= UserAgentUtils.browsers.length) {
|
||||
@ -85,8 +86,8 @@ public final class FlavorTown {
|
||||
settingsHelper.putString(Constants.APP_UA, appUa);
|
||||
final String browserUa = UserAgentUtils.generateBrowserUA(browserUaCode);
|
||||
settingsHelper.putString(Constants.BROWSER_UA, browserUa);
|
||||
CrashReporterHelper.deleteAllStacktraceFiles(context);
|
||||
Toast.makeText(context, R.string.updated, Toast.LENGTH_SHORT).show();
|
||||
settingsHelper.putInteger(Constants.PREV_INSTALL_VERSION, BuildConfig.VERSION_CODE);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,16 +8,16 @@ import java.util.*
|
||||
|
||||
// taken from my app TESV Console Codes
|
||||
object LocaleUtils {
|
||||
private var defaultLocale: Locale? = null
|
||||
private lateinit var defaultLocale: Locale
|
||||
|
||||
@JvmStatic
|
||||
var currentLocale: Locale? = null
|
||||
lateinit var currentLocale: Locale
|
||||
private set
|
||||
|
||||
@JvmStatic
|
||||
fun setLocale(baseContext: Context) {
|
||||
var baseContext1 = baseContext
|
||||
if (defaultLocale == null) defaultLocale = Locale.getDefault()
|
||||
defaultLocale = Locale.getDefault()
|
||||
if (baseContext1 is ContextThemeWrapper) baseContext1 = baseContext1.baseContext
|
||||
if (Utils.settingsHelper == null) Utils.settingsHelper = SettingsHelper(baseContext1)
|
||||
val appLanguageSettings = Utils.settingsHelper.getString(PreferenceKeys.APP_LANGUAGE)
|
||||
@ -30,7 +30,7 @@ object LocaleUtils {
|
||||
}
|
||||
else -> Locale(lang)
|
||||
}
|
||||
currentLocale?.let {
|
||||
currentLocale.let {
|
||||
Locale.setDefault(it)
|
||||
val res = baseContext1.resources
|
||||
val config = res.configuration
|
||||
@ -43,7 +43,7 @@ object LocaleUtils {
|
||||
|
||||
@JvmStatic
|
||||
fun updateConfig(wrapper: ContextThemeWrapper) {
|
||||
if (currentLocale == null) return
|
||||
if (!this::currentLocale.isInitialized) return
|
||||
val configuration = Configuration()
|
||||
// configuration.locale = currentLocale
|
||||
configuration.setLocale(currentLocale)
|
||||
|
@ -126,4 +126,20 @@ object CrashReporterHelper {
|
||||
Log.e(TAG, "", e)
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun deleteAllStacktraceFiles(context: Context) {
|
||||
val filePath = context.filesDir.absolutePath
|
||||
val errorFileList: Array<File>? = try {
|
||||
val dir = File(filePath)
|
||||
if (dir.exists() && !dir.isDirectory) {
|
||||
dir.delete()
|
||||
}
|
||||
dir.mkdirs()
|
||||
dir.listFiles { _: File?, name: String -> name.endsWith(".stacktrace") }
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
errorFileList?.forEach { it.delete() }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user