Reset instances on removal, work around for Madsonic 5.0 Beta2 Build 3480
This commit is contained in:
parent
ad5180c007
commit
486b02f2e2
|
@ -290,11 +290,16 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
|
||||||
serverPasswordPreference.setText(null);
|
serverPasswordPreference.setText(null);
|
||||||
serverEnabledPreference.setChecked(true);
|
serverEnabledPreference.setChecked(true);
|
||||||
|
|
||||||
if (Util.getActiveServer(SettingsActivity.this) == instance) {
|
if (instance < activeServers) {
|
||||||
Util.setActiveServer(SettingsActivity.this, 0);
|
|
||||||
|
int activeServer = Util.getActiveServer(SettingsActivity.this);
|
||||||
|
for (int i = instance; i <= activeServers; i++) {
|
||||||
|
Util.removeInstanceName(SettingsActivity.this, i, activeServer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activeServers--;
|
activeServers--;
|
||||||
|
|
||||||
serversCategory.removePreference(screen);
|
serversCategory.removePreference(screen);
|
||||||
|
|
||||||
SharedPreferences.Editor prefEditor = settings.edit();
|
SharedPreferences.Editor prefEditor = settings.edit();
|
||||||
|
|
|
@ -30,7 +30,6 @@ import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.nio.CharBuffer;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -65,13 +64,18 @@ public class GenreParser extends AbstractParser {
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
|
|
||||||
|
// Replace double escaped ampersand (&apos;)
|
||||||
|
xml = xml.replaceAll("(?:&)(amp;|lt;|gt;|#37;|apos;)", "&$1");
|
||||||
|
|
||||||
// Replace unescaped ampersand
|
// Replace unescaped ampersand
|
||||||
xml = xml.replaceAll("&(?!amp;|lt;|gt;|#37;)", "&");
|
xml = xml.replaceAll("&(?!amp;|lt;|gt;|#37;|apos;)", "&");
|
||||||
|
|
||||||
// Replace unescaped percent symbol
|
// Replace unescaped percent symbol
|
||||||
// No replacements for <> at this time
|
// No replacements for <> at this time
|
||||||
xml = xml.replaceAll("%", "%");
|
xml = xml.replaceAll("%", "%");
|
||||||
|
|
||||||
|
xml = xml.replaceAll("'", "'");
|
||||||
|
|
||||||
sr = new StringReader(xml);
|
sr = new StringReader(xml);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.e(TAG, "Error parsing Genre XML", ioe);
|
Log.e(TAG, "Error parsing Genre XML", ioe);
|
||||||
|
|
|
@ -212,6 +212,43 @@ public class Util extends DownloadActivity {
|
||||||
public static Version getServerRestVersion(Context context) {
|
public static Version getServerRestVersion(Context context) {
|
||||||
return SERVER_REST_VERSIONS.get(getActiveServer(context));
|
return SERVER_REST_VERSIONS.get(getActiveServer(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void removeInstanceName(Context context, int instance, int activeInstance) {
|
||||||
|
SharedPreferences prefs = getPreferences(context);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
|
||||||
|
int newInstance = instance + 1;
|
||||||
|
|
||||||
|
String server = prefs.getString(Constants.PREFERENCES_KEY_SERVER + newInstance, null);
|
||||||
|
String serverName = prefs.getString(Constants.PREFERENCES_KEY_SERVER_NAME + newInstance, null);
|
||||||
|
String serverUrl = prefs.getString(Constants.PREFERENCES_KEY_SERVER_URL + newInstance, null);
|
||||||
|
String userName = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + newInstance, null);
|
||||||
|
String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + newInstance, null);
|
||||||
|
boolean serverEnabled = prefs.getBoolean(Constants.PREFERENCES_KEY_SERVER_ENABLED + newInstance, true);
|
||||||
|
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_SERVER + instance, server);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_SERVER_NAME + instance, serverName);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_SERVER_URL + instance, serverUrl);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_USERNAME + instance, userName);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_PASSWORD + instance, password);
|
||||||
|
editor.putBoolean(Constants.PREFERENCES_KEY_SERVER_ENABLED + instance, serverEnabled);
|
||||||
|
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_SERVER + newInstance, null);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_SERVER_NAME + newInstance, null);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_SERVER_URL + newInstance, null);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_USERNAME + newInstance, null);
|
||||||
|
editor.putString(Constants.PREFERENCES_KEY_PASSWORD + newInstance, null);
|
||||||
|
editor.putBoolean(Constants.PREFERENCES_KEY_SERVER_ENABLED + newInstance, true);
|
||||||
|
editor.commit();
|
||||||
|
|
||||||
|
if (instance == activeInstance) {
|
||||||
|
Util.setActiveServer(context, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newInstance == activeInstance) {
|
||||||
|
Util.setActiveServer(context, instance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setSelectedMusicFolderId(Context context, String musicFolderId) {
|
public static void setSelectedMusicFolderId(Context context, String musicFolderId) {
|
||||||
int instance = getActiveServer(context);
|
int instance = getActiveServer(context);
|
||||||
|
|
Loading…
Reference in New Issue