From 191c287bf7f43c86912b5c2a9234e2f2537a3614 Mon Sep 17 00:00:00 2001 From: bemusementpark Date: Fri, 19 Jul 2024 13:13:19 +0930 Subject: [PATCH] Convert BaseActivity to Kotlin --- .../thoughtcrime/securesms/BaseActivity.java | 32 ------------------ .../thoughtcrime/securesms/BaseActivity.kt | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 app/src/main/java/org/thoughtcrime/securesms/BaseActivity.java create mode 100644 app/src/main/java/org/thoughtcrime/securesms/BaseActivity.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/BaseActivity.java b/app/src/main/java/org/thoughtcrime/securesms/BaseActivity.java deleted file mode 100644 index e2897686c4..0000000000 --- a/app/src/main/java/org/thoughtcrime/securesms/BaseActivity.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.thoughtcrime.securesms; - -import android.app.ActivityManager; -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -import androidx.fragment.app.FragmentActivity; - -import org.session.libsession.messaging.MessagingModuleConfiguration; -import org.session.libsession.utilities.TextSecurePreferences; -import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper; -import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper; - -import network.loki.messenger.R; - -public abstract class BaseActivity extends FragmentActivity { - @Override - protected void onResume() { - super.onResume(); - DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage(this, MessagingModuleConfiguration.getShared().getPrefs().getLanguage()); - String name = getResources().getString(R.string.app_name); - Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_foreground); - int color = getResources().getColor(R.color.app_icon_background); - setTaskDescription(new ActivityManager.TaskDescription(name, icon, color)); - } - - @Override - protected void attachBaseContext(Context newBase) { - super.attachBaseContext(DynamicLanguageContextWrapper.updateContext(newBase, MessagingModuleConfiguration.getShared().getPrefs().getLanguage())); - } -} diff --git a/app/src/main/java/org/thoughtcrime/securesms/BaseActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/BaseActivity.kt new file mode 100644 index 0000000000..ecd004f5af --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/BaseActivity.kt @@ -0,0 +1,33 @@ +package org.thoughtcrime.securesms + +import android.app.ActivityManager.TaskDescription +import android.content.Context +import android.graphics.BitmapFactory +import androidx.fragment.app.FragmentActivity +import network.loki.messenger.R +import org.session.libsession.messaging.MessagingModuleConfiguration.Companion.shared +import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageActivityHelper +import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWrapper + +abstract class BaseActivity : FragmentActivity() { + override fun onResume() { + super.onResume() + DynamicLanguageActivityHelper.recreateIfNotInCorrectLanguage( + this, + shared.prefs.getLanguage() + ) + val name = resources.getString(R.string.app_name) + val icon = BitmapFactory.decodeResource(resources, R.drawable.ic_launcher_foreground) + val color = resources.getColor(R.color.app_icon_background) + setTaskDescription(TaskDescription(name, icon, color)) + } + + override fun attachBaseContext(newBase: Context) { + super.attachBaseContext( + DynamicLanguageContextWrapper.updateContext( + newBase, + shared.prefs.getLanguage() + ) + ) + } +}