Commit bc3b4aaf authored by Edward Wang's avatar Edward Wang

Add a locale-testing feature for debugging

parent 22ba9319
......@@ -121,6 +121,9 @@
<string name="quit">Quit application</string>
<string name="clear_media_db">Clear media database</string>
<string name="media_db_cleared">Media database cleared!</string>
<string name="set_locale">Set locale</string>
<string name="set_locale_detail">Leave blank to reset</string>
<string name="set_locale_popup">Quit and reset VLC for changes to take effect.</string>
<string name="detect_headset">Detect headset</string>
<string name="detect_headset_detail">Pause on headset removed; resume on headset inserted</string>
<string name="enable_wheel_bar">Enable wheel bar</string>
......
......@@ -61,6 +61,11 @@
android:title="@string/clear_media_db"
android:key="clear_media_db"
android:enabled="true" />
<EditTextPreference
android:title="@string/set_locale"
android:summary="@string/set_locale_detail"
android:key="set_locale"
android:defaultValue="" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen>
......@@ -19,9 +19,14 @@
*****************************************************************************/
package org.videolan.vlc;
import java.util.Locale;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;
public class VLCApplication extends Application {
private static VLCApplication instance;
......@@ -29,6 +34,25 @@ public class VLCApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Are we using advanced debugging - locale?
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
String p = pref.getString("set_locale", "");
if (p != null && !p.equals("")) {
Locale locale;
// workaround due to region code
if(p.startsWith("zh")) {
locale = Locale.CHINA;
} else {
locale = new Locale(p);
}
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
}
instance = this;
}
......
......@@ -32,6 +32,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
......@@ -170,6 +171,15 @@ public class PreferencesActivity extends PreferenceActivity {
return true;
}
});
EditTextPreference setLocalePref = (EditTextPreference) findPreference("set_locale");
setLocalePref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Toast.makeText(getBaseContext(), R.string.set_locale_popup, Toast.LENGTH_SHORT).show();
return true;
}
});
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment