From d442be37b66eee6389e6ff7ec25b8ed1ede9d6c6 Mon Sep 17 00:00:00 2001 From: PabloG02 Date: Thu, 26 Jan 2023 14:42:53 +0100 Subject: [PATCH] Remove APK when app is opened --- app/src/main/java/emu/skyline/AppUpdater.kt | 12 ++++++------ app/src/main/java/emu/skyline/MainActivity.kt | 1 + 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/emu/skyline/AppUpdater.kt b/app/src/main/java/emu/skyline/AppUpdater.kt index 0caf8332..e9a97221 100644 --- a/app/src/main/java/emu/skyline/AppUpdater.kt +++ b/app/src/main/java/emu/skyline/AppUpdater.kt @@ -66,12 +66,6 @@ class AppUpdater : BroadcastReceiver() { downloadID = downloadManager.enqueue(request) } - init { - if (File(SkylineApplication.instance.getPublicFilesDir().canonicalPath + "/skyline.apk").exists()) { - File(SkylineApplication.instance.getPublicFilesDir().canonicalPath + "/skyline.apk").delete() - } - } - companion object { private const val baseUrl = "https://skyline-builds.alula.gay" private const val branch = "ftx1" @@ -158,5 +152,11 @@ class AppUpdater : BroadcastReceiver() { return null } } + + fun removeApk(){ + if (File(SkylineApplication.instance.getPublicFilesDir().canonicalPath + "/skyline.apk").exists()) { + File(SkylineApplication.instance.getPublicFilesDir().canonicalPath + "/skyline.apk").delete() + } + } } } diff --git a/app/src/main/java/emu/skyline/MainActivity.kt b/app/src/main/java/emu/skyline/MainActivity.kt index 881de5f4..10197c89 100644 --- a/app/src/main/java/emu/skyline/MainActivity.kt +++ b/app/src/main/java/emu/skyline/MainActivity.kt @@ -154,6 +154,7 @@ class MainActivity : AppCompatActivity() { if (BuildConfig.FLAVOR == "edge") { binding.checkUpdatesIcon.visibility = View.GONE } else { + AppUpdater.removeApk() AppUpdater.notifyUpdateBadge(context, binding.checkUpdatesIcon) binding.checkUpdatesIcon.setOnClickListener { AppUpdater.checkForUpdates(context)