reread preferences in case of an upgrade. Fixes bug where default

port was 0 because the new key, meant to change the value, was not
being initialized.  It's a hack to use a side-effect to determine
whether this is an upgrade, but since I'm already calculating it
didn't see any point to doing it again.
This commit is contained in:
Andy2 2010-11-01 18:56:23 -07:00
parent 1e5a856287
commit 8bf8383d60
2 changed files with 7 additions and 6 deletions

View file

@ -39,7 +39,7 @@ public class FirstRunDialog {
private static final String HIDDEN_PREFS = "xwprefs_hidden";
private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY";
static void show( Context context, boolean skipCheck )
static boolean show( Context context, boolean skipCheck )
{
int thisVersion = 0;
int shownVersion = 0;
@ -61,7 +61,8 @@ public class FirstRunDialog {
shownVersion = prefs.getInt( SHOWN_VERSION_KEY, 0 );
}
if ( skipCheck || shownVersion < thisVersion ) {
boolean isUpgrade = shownVersion < thisVersion;
if ( skipCheck || isUpgrade ) {
showDialog( context );
if ( !skipCheck ) {
@ -70,6 +71,7 @@ public class FirstRunDialog {
editor.commit();
}
}
return isUpgrade;
}
private static void showDialog( Context context )

View file

@ -64,10 +64,11 @@ public class GamesList extends XWListActivity
m_handler = new Handler();
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, false );
setContentView(R.layout.game_list);
boolean isUpgrade = FirstRunDialog.show( this, false );
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, isUpgrade );
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
registerForContextMenu( getListView() );
@ -94,8 +95,6 @@ public class GamesList extends XWListActivity
m_adapter = new GameListAdapter( this );
setListAdapter( m_adapter );
FirstRunDialog.show( this, false );
RelayReceiver.RestartTimer( this );
}