mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-29 17:15:40 +00:00
Android: Add language override setting
This commit is contained in:
parent
98766a490f
commit
300510f20a
|
@ -9,6 +9,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class AndroidHostInterface {
|
public class AndroidHostInterface {
|
||||||
public final static int DISPLAY_ALIGNMENT_TOP_OR_LEFT = 0;
|
public final static int DISPLAY_ALIGNMENT_TOP_OR_LEFT = 0;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import android.content.ClipboardManager;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -30,6 +32,7 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
@ -42,6 +45,25 @@ public class MainActivity extends AppCompatActivity {
|
||||||
private ListView mGameListView;
|
private ListView mGameListView;
|
||||||
private boolean mHasExternalStoragePermissions = false;
|
private boolean mHasExternalStoragePermissions = false;
|
||||||
|
|
||||||
|
private void setLanguage() {
|
||||||
|
String language = PreferenceManager.getDefaultSharedPreferences(this).getString("Main/Language", "none");
|
||||||
|
if (language == null || language.equals("none")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] parts = language.split("-");
|
||||||
|
if (parts.length < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Locale locale = new Locale(parts[0], parts[1]);
|
||||||
|
Locale.setDefault(locale);
|
||||||
|
|
||||||
|
Resources res = getResources();
|
||||||
|
Configuration config = res.getConfiguration();
|
||||||
|
config.setLocale(locale);
|
||||||
|
res.updateConfiguration(config, res.getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldResumeStateByDefault() {
|
private boolean shouldResumeStateByDefault() {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
return prefs.getBoolean("Main/SaveStateOnExit", true);
|
return prefs.getBoolean("Main/SaveStateOnExit", true);
|
||||||
|
@ -59,6 +81,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
setLanguage();
|
||||||
|
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
|
|
@ -421,4 +421,16 @@
|
||||||
<item>portrait</item>
|
<item>portrait</item>
|
||||||
<item>landscape</item>
|
<item>landscape</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="settings_language_entries">
|
||||||
|
<item>Use Device Setting</item>
|
||||||
|
<item>English</item>
|
||||||
|
<item>Portuguese (pt) in Brazil (BR)</item>
|
||||||
|
<item>Italian (it)</item>
|
||||||
|
</string-array>
|
||||||
|
<string-array name="settings_language_values">
|
||||||
|
<item>none</item>
|
||||||
|
<item>en-EN</item>
|
||||||
|
<item>pt-rBR</item>
|
||||||
|
<item>it-IT</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -151,4 +151,5 @@
|
||||||
<string name="main_activity_copy">Copy</string>
|
<string name="main_activity_copy">Copy</string>
|
||||||
<string name="settings_gpu_thread">Threaded GPU Rendering</string>
|
<string name="settings_gpu_thread">Threaded GPU Rendering</string>
|
||||||
<string name="settings_summary_gpu_thread">Uses a second thread for drawing graphics. Currently only available for the software renderer, but can provide a significant speed improvement, and is safe to use.</string>
|
<string name="settings_summary_gpu_thread">Uses a second thread for drawing graphics. Currently only available for the software renderer, but can provide a significant speed improvement, and is safe to use.</string>
|
||||||
|
<string name="settings_language">Language (restart to apply)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -15,6 +15,14 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<ListPreference
|
||||||
|
app:key="Main/Language"
|
||||||
|
app:title="@string/settings_language"
|
||||||
|
app:defaultValue="none"
|
||||||
|
app:entries="@array/settings_language_entries"
|
||||||
|
app:entryValues="@array/settings_language_values"
|
||||||
|
app:useSimpleSummaryProvider="true"
|
||||||
|
app:iconSpaceReserved="false" />
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:key="CPU/Overclock"
|
app:key="CPU/Overclock"
|
||||||
app:title="@string/settings_cpu_overclocking"
|
app:title="@string/settings_cpu_overclocking"
|
||||||
|
|
Loading…
Reference in a new issue