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