[Android] Add a locale-testing feature for debugging
Edward Wang
git at videolan.org
Thu Aug 2 04:20:26 CEST 2012
android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Aug 1 22:14:52 2012 -0400| [bc3b4aaf05af28abb0635156e337a9f5ccbf19bc] | committer: Edward Wang
Add a locale-testing feature for debugging
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=bc3b4aaf05af28abb0635156e337a9f5ccbf19bc
---
vlc-android/res/values/strings.xml | 3 +++
vlc-android/res/xml/preferences.xml | 5 ++++
.../src/org/videolan/vlc/VLCApplication.java | 24 ++++++++++++++++++++
.../org/videolan/vlc/gui/PreferencesActivity.java | 10 ++++++++
4 files changed, 42 insertions(+)
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index 84d12fa..e34cf59 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -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>
diff --git a/vlc-android/res/xml/preferences.xml b/vlc-android/res/xml/preferences.xml
index ffa92ce..1512e32 100644
--- a/vlc-android/res/xml/preferences.xml
+++ b/vlc-android/res/xml/preferences.xml
@@ -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>
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 1d39479..649ec21 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -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;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index fa1fb5d..e3f9266 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -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
More information about the Android
mailing list