diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index d680ea48d..1bf734339 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -35,6 +35,7 @@ key_default_dict key_default_phonies2 key_default_timerenabled + key_connect_frequency eehouse.org @@ -59,4 +60,24 @@ @string/phonies_disallow + + @string/connect_ten_seconds + @string/connect_fifteen_mins + @string/connect_thirty_mins + @string/connect_one_hour + @string/connect_six_hours + @string/connect_daily + @string/connect_never + + + + 10 + 900 + 1800 + 3600 + 21600 + 86400 + -1 + + diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 90c95d620..4a1876b71 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -364,4 +364,16 @@ Recent changes Recent changes + relay behavior + relay behavior summary + connect_frequency + 10 seconds + 15 minutes + 30 minutes + Hourly + Every six hours + Once every day + Never connect + + diff --git a/xwords4/android/XWords4/res/xml/xwprefs.xml b/xwords4/android/XWords4/res/xml/xwprefs.xml index 81346e76d..726a486e3 100644 --- a/xwords4/android/XWords4/res/xml/xwprefs.xml +++ b/xwords4/android/XWords4/res/xml/xwprefs.xml @@ -159,6 +159,17 @@ /> + + + + diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java index 3edd90420..fedd364ba 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DBHelper.java @@ -28,7 +28,7 @@ public class DBHelper extends SQLiteOpenHelper { public static final String TABLE_NAME = "summaries"; private static final String DB_NAME = "xwdb"; - private static final int DB_VERSION = 3; + private static final int DB_VERSION = 4; public static final String FILE_NAME = "FILE_NAME"; public static final String NUM_MOVES = "NUM_MOVES"; 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 9c82988c4..ff62f388e 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesList.java @@ -48,7 +48,6 @@ import org.eehouse.android.xw4.jni.*; public class GamesList extends ListActivity { private static final int WARN_NODICT = Utils.DIALOG_LAST + 1; private static final int CONFIRM_DELETE_ALL = Utils.DIALOG_LAST + 2; - private static final long CHECK_INTERVAL_SECONDS = 5; private GameListAdapter m_adapter; private String m_invalPath = null; @@ -142,9 +141,15 @@ public class GamesList extends ListActivity { PendingIntent intent = PendingIntent.getActivity( this, 0, new Intent(this, RelayActivity.class), 0); - am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP, - 0, // first firing - CHECK_INTERVAL_SECONDS*1000, intent ); + long interval_millis = 1000 * + CommonPrefs.getProxyInterval( this ); + if ( interval_millis > 0 ) { + am.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP, + 0, // first firing + interval_millis, intent ); + } else { + am.cancel( intent ); + } } @Override diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java index 9b3ee386e..de21a9819 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java @@ -118,6 +118,7 @@ public class PrefsActivity extends PreferenceActivity R.string.key_initial_player_minutes, R.string.key_default_dict, R.string.key_default_phonies, + R.string.key_connect_frequency, }; SharedPreferences sp @@ -190,6 +191,10 @@ public class PrefsActivity extends PreferenceActivity Preference pref = getPreferenceScreen().findPreference( key ); String value = sp.getString( key, "" ); if ( ! value.equals("") ) { + if ( pref instanceof android.preference.ListPreference ) { + Utils.logf( "%s: want to do lookup of user string here", + key ); + } pref.setSummary( value ); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java index e05a4ba3b..25d43b8b3 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/CommonPrefs.java @@ -181,6 +181,16 @@ public class CommonPrefs { } } + public static long getProxyInterval( Context context ) + { + String value = getString( context, R.string.key_connect_frequency ); + try { + return Long.parseLong( value ); + } catch ( Exception ex ) { + return 25L; + } + } + public static String getDefaultDict( Context context ) { String value = getString( context, R.string.key_default_dict );