From 8bf8383d601db45c5e35a44755bafd56803f953a Mon Sep 17 00:00:00 2001 From: Andy2 Date: Mon, 1 Nov 2010 18:56:23 -0700 Subject: [PATCH] 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. --- .../src/org/eehouse/android/xw4/FirstRunDialog.java | 6 ++++-- .../XWords4/src/org/eehouse/android/xw4/GamesList.java | 7 +++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java index 4f172dea6..01efffaf5 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/FirstRunDialog.java @@ -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 ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java index 4fa3ebd91..64128d423 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -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 ); }