Add a language option to the preference menu

This commit is contained in:
Alexander Bakker 2019-06-22 09:58:35 +02:00
parent eb29be587f
commit b014d95005
6 changed files with 68 additions and 2 deletions

View file

@ -2,8 +2,12 @@ package com.beemdevelopment.aegis;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Build;
import android.preference.PreferenceManager;
import java.util.Locale;
public class Preferences {
private SharedPreferences _prefs;
@ -70,4 +74,18 @@ public class Preferences {
public int getTimeout() {
return _prefs.getInt("pref_timeout", -1);
}
public Locale getLocale() {
String lang = _prefs.getString("pref_lang", "system");
if (lang.equals("system")) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return Resources.getSystem().getConfiguration().getLocales().get(0);
} else {
return Resources.getSystem().getConfiguration().locale;
}
}
return new Locale(lang);
}
}