Merge pull request #141 from alexbakker/pref-lang

Add a language option to the preference menu
This commit is contained in:
Michael Schättgen 2019-08-01 21:17:30 +02:00 committed by GitHub
commit 37c9b033c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;
@ -71,4 +75,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);
}
}