cleanup code

This commit is contained in:
Conny Duck 2019-03-08 21:10:48 +01:00
parent bac131c6d5
commit 028db440ee
5 changed files with 4 additions and 14 deletions

View File

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

View File

@ -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;

View File

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

View File

@ -91,5 +91,4 @@
<item>ja</item>
</string-array>
<string name="pref_title_language_settings">Language</string>
</resources>

View File

@ -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