Fix for server drop down on fresh installs

This commit is contained in:
Joshua Bahnsen 2013-05-04 22:29:14 -07:00
parent d2452c3212
commit ad5180c007
3 changed files with 25 additions and 5 deletions

View File

@ -2,8 +2,8 @@
<manifest xmlns:a="http://schemas.android.com/apk/res/android" <manifest xmlns:a="http://schemas.android.com/apk/res/android"
package="com.thejoshwa.ultrasonic.androidapp" package="com.thejoshwa.ultrasonic.androidapp"
a:installLocation="auto" a:installLocation="auto"
a:versionCode="15" a:versionCode="16"
a:versionName="1.1.0.11" > a:versionName="1.1.0.12" >
<uses-permission a:name="android.permission.INTERNET" /> <uses-permission a:name="android.permission.INTERNET" />
<uses-permission a:name="android.permission.READ_PHONE_STATE" /> <uses-permission a:name="android.permission.READ_PHONE_STATE" />

View File

@ -103,12 +103,23 @@ public class MainActivity extends SubsonicTabActivity {
final View dummyView = findViewById(R.id.main_dummy); final View dummyView = findViewById(R.id.main_dummy);
boolean shouldShowDialog = false;
if (!getActiveServerEnabled()) { if (!getActiveServerEnabled()) {
shouldShowDialog = true;
Util.setActiveServer(this, 0); Util.setActiveServer(this, 0);
} }
int instance = Util.getActiveServer(this); int instance = Util.getActiveServer(this);
String name = Util.getServerName(this, instance); String name = Util.getServerName(this, instance);
if (name == null) {
shouldShowDialog = true;
Util.setActiveServer(this, 0);
instance = Util.getActiveServer(this);
name = Util.getServerName(this, instance);
}
serverTextView.setText(name); serverTextView.setText(name);
ListView list = (ListView) findViewById(R.id.main_list); ListView list = (ListView) findViewById(R.id.main_list);
@ -172,7 +183,7 @@ public class MainActivity extends SubsonicTabActivity {
// Remember the current theme. // Remember the current theme.
theme = Util.getTheme(this); theme = Util.getTheme(this);
showInfoDialog(); showInfoDialog(shouldShowDialog);
} }
private void loadSettings() { private void loadSettings() {
@ -214,6 +225,10 @@ public class MainActivity extends SubsonicTabActivity {
for (int i = 0; i <= Util.getActiveServers(this); i++) { for (int i = 0; i <= Util.getActiveServers(this); i++) {
String serverName = Util.getServerName(this, i); String serverName = Util.getServerName(this, i);
if (serverName == null) {
continue;
}
if (Util.getServerEnabled(this, i)) { if (Util.getServerEnabled(this, i)) {
int menuItemNum = getMenuItem(i); int menuItemNum = getMenuItem(i);
@ -363,10 +378,11 @@ public class MainActivity extends SubsonicTabActivity {
finish(); finish();
} }
private void showInfoDialog() { private void showInfoDialog(boolean show) {
if (!infoDialogDisplayed) { if (!infoDialogDisplayed) {
infoDialogDisplayed = true; infoDialogDisplayed = true;
if (Util.getRestUrl(this, null).contains("yourhost")) {
if (show || Util.getRestUrl(this, null).contains("yourhost")) {
Util.info(this, R.string.main_welcome_title, R.string.main_welcome_text); Util.info(this, R.string.main_welcome_title, R.string.main_welcome_text);
} }
} }

View File

@ -290,6 +290,10 @@ 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) {
Util.setActiveServer(SettingsActivity.this, 0);
}
activeServers--; activeServers--;
serversCategory.removePreference(screen); serversCategory.removePreference(screen);