Improvements:

* Force LTR by prefixing language names with the LRM marker
* Add Polish
* Cleanup
This commit is contained in:
goapunk
2018-06-07 10:00:50 +02:00
parent 1834146ad0
commit 8bc28f99c1
3 changed files with 4 additions and 13 deletions

View File

@@ -22,10 +22,8 @@ public class Localizer {
private static Localizer INSTANCE;
@Nullable
private final Locale locale;
private final SharedPreferences sharedPreferences;
private Localizer(SharedPreferences prefs) {
this.sharedPreferences = prefs;
private Localizer(SharedPreferences sharedPreferences) {
locale = getLocaleFromTag(
sharedPreferences.getString(LANGUAGE, "default"));
}
@@ -41,10 +39,6 @@ public class Localizer {
return INSTANCE;
}
public SharedPreferences getSharedPreferences() {
return sharedPreferences;
}
// Get Locale from BCP-47 tag
@Nullable
public static Locale getLocaleFromTag(String tag) {

View File

@@ -4,7 +4,6 @@ import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
@@ -211,8 +210,9 @@ public class SettingsFragment extends PreferenceFragmentCompat
if (!tmp.isEmpty() && !tmp.equals(nativeName))
nativeName = tmp;
}
// Prefix with LRM marker to prevent any RTL direction
nativeNames[i] =
nativeName.substring(0, 1).toUpperCase() +
"\u200E" + nativeName.substring(0, 1).toUpperCase() +
nativeName.substring(1);
}
language.setEntries(nativeNames);
@@ -397,10 +397,6 @@ public class SettingsFragment extends PreferenceFragmentCompat
builder.setPositiveButton(R.string.sign_out_button,
(dialogInterface, i) -> {
language.setValue(newValue);
SharedPreferences prefs =
Localizer.getInstance().getSharedPreferences();
prefs.edit().putString(LANGUAGE, newValue)
.commit();
Intent intent = new Intent(getContext(),
NavDrawerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

View File

@@ -41,6 +41,7 @@
<item>nb</item>
<item>nl</item>
<item>oc</item>
<item>pl</item>
<item>pt-BR</item>
<item>ro</item>
<item>ru</item>