diff --git a/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java b/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java deleted file mode 100644 index 31d146c45f..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (C) 2013 Open Whisper Systems - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -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 org.thoughtcrime.securesms.util.Util; -import org.thoughtcrime.securesms.util.VersionTracker; - -public class DatabaseUpgradeActivity extends BaseActivity { - - @Override - public void onCreate(Bundle bundle) { - super.onCreate(bundle); - VersionTracker.updateLastSeenVersion(this); - updateNotifications(this); - startActivity((Intent)getIntent().getParcelableExtra("next_intent")); - finish(); - } - - public static boolean isUpdate(Context context) { - int currentVersionCode = Util.getCanonicalVersionCode(); - int previousVersionCode = VersionTracker.getLastSeenVersion(context); - - return previousVersionCode < currentVersionCode; - } - - @SuppressLint("StaticFieldLeak") - private void updateNotifications(final Context context) { - new AsyncTask() { - @Override - protected Void doInBackground(Void... params) { - ApplicationContext.getInstance(context).messageNotifier.updateNotification(context); - return null; - } - }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt new file mode 100644 index 0000000000..8fa008f03e --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/DatabaseUpgradeActivity.kt @@ -0,0 +1,56 @@ +/** + * Copyright (C) 2013 Open Whisper Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see //www.gnu.org/licenses/>. + */ +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 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) + updateLastSeenVersion(this) + updateNotifications(this) + 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 { + fun isUpdate(context: Context?): Boolean { + val currentVersionCode = Util.getCanonicalVersionCode() + val previousVersionCode = getLastSeenVersion(context!!) + + return previousVersionCode < currentVersionCode + } + } +}