diff options
Diffstat (limited to 'src')
6 files changed, 41 insertions, 32 deletions
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java index afd6cb30..f3d564a1 100644 --- a/src/github/daneren2005/dsub/activity/SettingsActivity.java +++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java @@ -170,6 +170,8 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer SharedPreferences.Editor editor = settings.edit(); editor.putInt(Constants.PREFERENCES_KEY_SERVER_COUNT, serverCount); + // Reset set folder ID + editor.putString(Constants.PREFERENCES_KEY_MUSIC_FOLDER_ID + instance, null); editor.commit(); serverSettings.put(instance, new ServerSettings(instance)); diff --git a/src/github/daneren2005/dsub/activity/SubsonicActivity.java b/src/github/daneren2005/dsub/activity/SubsonicActivity.java index 62349480..fe477df8 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicActivity.java @@ -22,6 +22,7 @@ import android.content.Context; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
+import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.media.AudioManager;
import android.os.Build;
@@ -50,6 +51,13 @@ import android.widget.ArrayAdapter; import android.widget.ListView;
import android.widget.Spinner;
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.fragments.SubsonicFragment;
import github.daneren2005.dsub.service.DownloadService;
@@ -59,12 +67,6 @@ import github.daneren2005.dsub.util.Util; import github.daneren2005.dsub.view.DrawerAdapter;
import github.daneren2005.dsub.view.UpdateView;
-import java.io.File;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
public class SubsonicActivity extends ActionBarActivity implements OnItemSelectedListener {
private static final String TAG = SubsonicActivity.class.getSimpleName();
private static ImageLoader IMAGE_LOADER;
@@ -631,6 +633,13 @@ public class SubsonicActivity extends ActionBarActivity implements OnItemSelecte } else {
setTheme(R.style.Theme_DSub_Holo);
}
+
+ SharedPreferences prefs = Util.getPreferences(this);
+ if(prefs.getBoolean(Constants.PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE, false)) {
+ Configuration config = new Configuration();
+ config.locale = Locale.ENGLISH;
+ getResources().updateConfiguration(config,getResources().getDisplayMetrics());
+ }
}
private void applyFullscreen() {
fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false);
diff --git a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java index 0d421168..e2ae0abf 100644 --- a/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java +++ b/src/github/daneren2005/dsub/activity/SubsonicFragmentActivity.java @@ -20,6 +20,7 @@ package github.daneren2005.dsub.activity; import android.accounts.Account;
import android.accounts.AccountManager;
+import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -214,7 +215,10 @@ public class SubsonicFragmentActivity extends SubsonicActivity { ChangeLog changeLog = new ChangeLog(this, Util.getPreferences(this));
if(changeLog.isFirstRun()) {
- changeLog.getLogDialog().show();
+ Dialog log = changeLog.getLogDialog();
+ if(log != null) {
+ log.show();
+ }
}
}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 20040f97..1b6ae833 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -139,6 +139,7 @@ public final class Constants { public static final String PREFERENCES_KEY_SHARED_ENABLED = "sharedEnabled"; public static final String PREFERENCES_KEY_BROWSE_TAGS = "browseTags"; public static final String PREFERENCES_KEY_OPEN_TO_LIBRARY = "openToLibrary"; + public static final String PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE = "overrideSystemLanguage"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 5887b088..a18cc975 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -162,7 +162,6 @@ public final class Util { SharedPreferences prefs = getPreferences(context); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, instance); - editor.putString(Constants.PREFERENCES_KEY_MUSIC_FOLDER_ID + instance, null); editor.commit(); } diff --git a/src/github/daneren2005/dsub/view/ChangeLog.java b/src/github/daneren2005/dsub/view/ChangeLog.java index b847733e..5a7850ff 100644 --- a/src/github/daneren2005/dsub/view/ChangeLog.java +++ b/src/github/daneren2005/dsub/view/ChangeLog.java @@ -281,7 +281,13 @@ public class ChangeLog { protected AlertDialog getDialog(boolean full) { WebView wv = new WebView(mContext); //wv.setBackgroundColor(0); // transparent - wv.loadDataWithBaseURL(null, getLog(full), "text/html", "UTF-8", null); + String log = getLog(full); + // No changes to show + if(log == null) { + return null; + } + + wv.loadDataWithBaseURL(null, log, "text/html", "UTF-8", null); AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle( @@ -364,27 +370,11 @@ public class ChangeLog { Resources resources = mContext.getResources(); - // Read master change log from raw/changelog.xml - SparseArray<ReleaseItem> defaultChangelog; - try { - XmlPullParser xml = XmlPullParserFactory.newInstance().newPullParser(); - InputStreamReader reader = new InputStreamReader(resources.openRawResource(R.raw.changelog)); - xml.setInput(reader); - try { - defaultChangelog = readChangeLog(xml, full); - } finally { - try { reader.close(); } catch (Exception e) { /* do nothing */ } - } - } catch (XmlPullParserException e) { - Log.e(LOG_TAG, "Error reading raw/changelog.xml", e); - return null; - } - - // Read localized change log from xml[-lang]/changelog.xml + // Read master change log from xml/changelog.xml + SparseArray<ReleaseItem> changelog; XmlResourceParser resXml = mContext.getResources().getXml(R.xml.changelog); - SparseArray<ReleaseItem> changelog; try { - changelog = readChangeLog(resXml, full); + changelog = readChangeLog(resXml, full); } finally { resXml.close(); } @@ -392,21 +382,25 @@ public class ChangeLog { String versionFormat = resources.getString(R.string.changelog_version_format); // Get all version codes from the master change log... - List<Integer> versions = new ArrayList<Integer>(defaultChangelog.size()); - for (int i = 0, len = defaultChangelog.size(); i < len; i++) { - int key = defaultChangelog.keyAt(i); + List<Integer> versions = new ArrayList<Integer>(changelog.size()); + for (int i = 0, len = changelog.size(); i < len; i++) { + int key = changelog.keyAt(i); versions.add(key); } // ... and sort them (newest version first). Collections.sort(versions, Collections.reverseOrder()); + if(versions.size() == 0) { + return null; + } + for (Integer version : versions) { int key = version.intValue(); // Use release information from localized change log and fall back to the master file // if necessary. - ReleaseItem release = changelog.get(key, defaultChangelog.get(key)); + ReleaseItem release = changelog.get(key); sb.append("<div class='title'>"); sb.append(String.format(versionFormat, release.versionName)); |