From e57c1cd56cfaa835780389682f934dac8a74a799 Mon Sep 17 00:00:00 2001 From: bemusementpark Date: Fri, 19 Jul 2024 14:29:28 +0930 Subject: [PATCH] Cleanup DatabaseUpgradeActivity --- .../securesms/DatabaseUpgradeActivity.kt | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt index 8fa008f03e..5a39cd9223 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt @@ -16,36 +16,30 @@ */ package org.thoughtcrime.securesms -import android.annotation.SuppressLint import android.content.Context import android.content.Intent -import android.os.AsyncTask import android.os.Bundle import android.os.Parcelable +import androidx.lifecycle.lifecycleScope +import kotlinx.coroutines.launch import org.thoughtcrime.securesms.util.Util import org.thoughtcrime.securesms.util.VersionTracker.getLastSeenVersion import org.thoughtcrime.securesms.util.VersionTracker.updateLastSeenVersion class DatabaseUpgradeActivity : BaseActivity() { - public override fun onCreate(bundle: Bundle?) { - super.onCreate(bundle) + public override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) updateLastSeenVersion(this) - updateNotifications(this) - startActivity(intent.getParcelableExtra("next_intent") as Intent?) + lifecycleScope.launch { + ApplicationContext.getInstance(this@DatabaseUpgradeActivity) + .messageNotifier.updateNotification(this@DatabaseUpgradeActivity) + } + startActivity(intent.getParcelableExtra("next_intent") as? Intent) finish() } - @SuppressLint("StaticFieldLeak") - private fun updateNotifications(context: Context) { - object : AsyncTask() { - protected override fun doInBackground(vararg params: Void): Void? { - ApplicationContext.getInstance(context).messageNotifier.updateNotification(context) - return null - } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR) - } - companion object { + @JvmStatic fun isUpdate(context: Context?): Boolean { val currentVersionCode = Util.getCanonicalVersionCode() val previousVersionCode = getLastSeenVersion(context!!)