Convert BaseActivity to Kotlin

This commit is contained in:
bemusementpark 2024-07-19 13:13:19 +09:30
parent c9f5810ea0
commit 191c287bf7
2 changed files with 33 additions and 32 deletions

View File

@ -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()));
}
}

View File

@ -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()
)
)
}
}