cleanup code
This commit is contained in:
parent
bac131c6d5
commit
028db440ee
|
@ -23,7 +23,6 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import androidx.emoji.text.EmojiCompat;
|
||||
|
||||
import com.evernote.android.job.JobManager;
|
||||
|
@ -68,8 +67,6 @@ public class TuskyApplication extends Application implements HasActivityInjector
|
|||
|
||||
public static LocaleManager localeManager;
|
||||
|
||||
private final String TAG = "TuskyApplication";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.keylesspalace.tusky.viewdata.StatusViewData;
|
|||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
|
|
@ -18,28 +18,24 @@ package com.keylesspalace.tusky.util
|
|||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.preference.PreferenceManager
|
||||
|
||||
import java.util.Locale
|
||||
|
||||
import com.keylesspalace.tusky.util.getNonNullString
|
||||
|
||||
|
||||
class LocaleManager(context: Context) {
|
||||
|
||||
private var prefs: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
fun setLocale(context: Context): Context {
|
||||
val language = prefs.getNonNullString("language", "default")
|
||||
if (language.equals("default")) {
|
||||
return context;
|
||||
if (language == "default") {
|
||||
return context
|
||||
}
|
||||
val locale = Locale.forLanguageTag(language)
|
||||
Locale.setDefault(locale)
|
||||
|
||||
val res = context.getResources()
|
||||
val config = Configuration(res.getConfiguration());
|
||||
val res = context.resources
|
||||
val config = Configuration(res.configuration)
|
||||
config.setLocale(locale)
|
||||
return context.createConfigurationContext(config)
|
||||
}
|
||||
|
|
|
@ -91,5 +91,4 @@
|
|||
<item>ja</item>
|
||||
</string-array>
|
||||
|
||||
<string name="pref_title_language_settings">Language</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="@string/preferences_file_key">
|
||||
|
||||
<PreferenceCategory
|
||||
|
|
Loading…
Reference in New Issue