Make separate turn reminder disable prefs for solo and networked

games, as some folks playing against the robot don't need to be
reminded. From a feature request submitted via sourceforge.
This commit is contained in:
Eric House 2015-09-22 07:35:02 -07:00
parent 32cd08b1dc
commit b3a93cc474
9 changed files with 881 additions and 823 deletions

File diff suppressed because it is too large Load diff

View file

@ -9,6 +9,7 @@
<string name="key_explain_robot">key_explain_robot</string> <string name="key_explain_robot">key_explain_robot</string>
<string name="key_skip_confirm">key_skip_confirm</string> <string name="key_skip_confirm">key_skip_confirm</string>
<string name="key_disable_nag">key_disable_nag</string> <string name="key_disable_nag">key_disable_nag</string>
<string name="key_disable_nag_solo">key_disable_nag_solo</string>
<string name="key_sort_tiles">key_sort_tiles</string> <string name="key_sort_tiles">key_sort_tiles</string>
<string name="key_peek_other">key_peek_other</string> <string name="key_peek_other">key_peek_other</string>
<string name="key_hide_crosshairs">key_hide_crosshairs</string> <string name="key_hide_crosshairs">key_hide_crosshairs</string>

View file

@ -2468,9 +2468,13 @@
and want them back, enable them now. You can turn them off again and want them back, enable them now. You can turn them off again
in Settings.</string> in Settings.</string>
<string name="disable_nag_title">Disable turn reminders</string> <string name="disable_nags_title">Turn reminders</string>
<string name="disable_nag_summary">Do not notify me no matter <string name="disable_nag_title">Disable reminders, network games</string>
how long it\'s been my turn</string> <string name="disable_nag_summary_net">Do not notify me no matter
how long it\'s been my turn - for networked games</string>
<string name="disable_nag_summary_solo">Do not notify me no matter
how long it\'s been my turn - for solo games</string>
<string name="disable_nag_solo_title">Disable reminders, solo games </string>
<string name="confirm_get_locdict_fmt">Your device is set up for <string name="confirm_get_locdict_fmt">Your device is set up for
%1$s. Would you like to download a wordlist so you can play %1$s. Would you like to download a wordlist so you can play

View file

@ -231,11 +231,22 @@
android:summary="@string/skip_confirm_turn_summary" android:summary="@string/skip_confirm_turn_summary"
android:defaultValue="false" android:defaultValue="false"
/> />
<PreferenceScreen android:title="@string/disable_nags_title"
>
<CheckBoxPreference android:key="@string/key_disable_nag" <CheckBoxPreference android:key="@string/key_disable_nag"
android:title="@string/disable_nag_title" android:title="@string/disable_nag_title"
android:summary="@string/disable_nag_summary" android:summary="@string/disable_nag_summary_net"
android:defaultValue="false" android:defaultValue="false"
/> />
<CheckBoxPreference android:key="@string/key_disable_nag_solo"
android:title="@string/disable_nag_solo_title"
android:summary="@string/disable_nag_summary_solo"
android:defaultValue="false"
/>
</PreferenceScreen>
<CheckBoxPreference android:key="@string/key_default_loc" <CheckBoxPreference android:key="@string/key_default_loc"
android:title="@string/default_loc" android:title="@string/default_loc"
android:summary="@string/default_loc_summary" android:summary="@string/default_loc_summary"

View file

@ -2114,9 +2114,13 @@
na \"decnavda\" erutaef ni siht esaeler. Fi uoy erew gnisu meht na \"decnavda\" erutaef ni siht esaeler. Fi uoy erew gnisu meht
dna tnaw meht ,kcab elbane meht won. Uoy nac nrut meht ffo niaga dna tnaw meht ,kcab elbane meht won. Uoy nac nrut meht ffo niaga
ni Sgnittes.</string> ni Sgnittes.</string>
<string name="disable_nag_title">Elbasid nrut srednimer</string> <string name="disable_nags_title">Nrut srednimer</string>
<string name="disable_nag_summary">Od ton yfiton em on rettam <string name="disable_nag_title">Elbasid ,srednimer krowten semag</string>
woh gnol ti\'s neeb ym nrut</string> <string name="disable_nag_summary_net">Od ton yfiton em on rettam
woh gnol ti\'s neeb ym nrut - rof dekrowten semag</string>
<string name="disable_nag_summary_solo">Od ton yfiton em on rettam
woh gnol ti\'s neeb ym nrut - rof olos semag</string>
<string name="disable_nag_solo_title">Elbasid ,srednimer olos semag </string>
<string name="confirm_get_locdict_fmt">Ruoy ecived si tes pu rof <string name="confirm_get_locdict_fmt">Ruoy ecived si tes pu rof
%1$s. Dluow uoy ekil ot daolnwod a tsildrow os uoy nac yalp %1$s. Dluow uoy ekil ot daolnwod a tsildrow os uoy nac yalp
Sdrowssorc ni %1$s?</string> Sdrowssorc ni %1$s?</string>

View file

@ -2114,9 +2114,13 @@
AN \"ADVANCED\" FEATURE IN THIS RELEASE. IF YOU WERE USING THEM AN \"ADVANCED\" FEATURE IN THIS RELEASE. IF YOU WERE USING THEM
AND WANT THEM BACK, ENABLE THEM NOW. YOU CAN TURN THEM OFF AGAIN AND WANT THEM BACK, ENABLE THEM NOW. YOU CAN TURN THEM OFF AGAIN
IN SETTINGS.</string> IN SETTINGS.</string>
<string name="disable_nag_title">DISABLE TURN REMINDERS</string> <string name="disable_nags_title">TURN REMINDERS</string>
<string name="disable_nag_summary">DO NOT NOTIFY ME NO MATTER <string name="disable_nag_title">DISABLE REMINDERS, NETWORK GAMES</string>
HOW LONG IT\'S BEEN MY TURN</string> <string name="disable_nag_summary_net">DO NOT NOTIFY ME NO MATTER
HOW LONG IT\'S BEEN MY TURN - FOR NETWORKED GAMES</string>
<string name="disable_nag_summary_solo">DO NOT NOTIFY ME NO MATTER
HOW LONG IT\'S BEEN MY TURN - FOR SOLO GAMES</string>
<string name="disable_nag_solo_title">DISABLE REMINDERS, SOLO GAMES </string>
<string name="confirm_get_locdict_fmt">YOUR DEVICE IS SET UP FOR <string name="confirm_get_locdict_fmt">YOUR DEVICE IS SET UP FOR
%1$s. WOULD YOU LIKE TO DOWNLOAD A WORDLIST SO YOU CAN PLAY %1$s. WOULD YOU LIKE TO DOWNLOAD A WORDLIST SO YOU CAN PLAY
CROSSWORDS IN %1$s?</string> CROSSWORDS IN %1$s?</string>

View file

@ -1025,10 +1025,18 @@ public class DBUtils {
public long m_rowid; public long m_rowid;
public long m_nextNag; public long m_nextNag;
public long m_lastMoveMillis; public long m_lastMoveMillis;
public NeedsNagInfo( long rowid, long nextNag, long lastMove ) { private boolean m_isSolo;
public NeedsNagInfo( long rowid, long nextNag, long lastMove,
CurGameInfo.DeviceRole role ) {
m_rowid = rowid; m_rowid = rowid;
m_nextNag = nextNag; m_nextNag = nextNag;
m_lastMoveMillis = 1000 * lastMove; m_lastMoveMillis = 1000 * lastMove;
m_isSolo = CurGameInfo.DeviceRole.SERVER_STANDALONE == role;
}
public boolean isSolo() {
return m_isSolo;
} }
} }
@ -1036,7 +1044,8 @@ public class DBUtils {
{ {
NeedsNagInfo[] result = null; NeedsNagInfo[] result = null;
long now = new Date().getTime(); // in milliseconds long now = new Date().getTime(); // in milliseconds
String[] columns = { ROW_ID, DBHelper.NEXTNAG, DBHelper.LASTMOVE }; String[] columns = { ROW_ID, DBHelper.NEXTNAG, DBHelper.LASTMOVE,
DBHelper.SERVERROLE };
// where nextnag > 0 AND nextnag < now // where nextnag > 0 AND nextnag < now
String selection = String selection =
String.format( "%s > 0 AND %s < %s", DBHelper.NEXTNAG, String.format( "%s > 0 AND %s < %s", DBHelper.NEXTNAG,
@ -1052,11 +1061,14 @@ public class DBUtils {
int rowIndex = cursor.getColumnIndex(ROW_ID); int rowIndex = cursor.getColumnIndex(ROW_ID);
int nagIndex = cursor.getColumnIndex( DBHelper.NEXTNAG ); int nagIndex = cursor.getColumnIndex( DBHelper.NEXTNAG );
int lastMoveIndex = cursor.getColumnIndex( DBHelper.LASTMOVE ); int lastMoveIndex = cursor.getColumnIndex( DBHelper.LASTMOVE );
int roleIndex = cursor.getColumnIndex( DBHelper.SERVERROLE );
for ( int ii = 0; ii < result.length && cursor.moveToNext(); ++ii ) { for ( int ii = 0; ii < result.length && cursor.moveToNext(); ++ii ) {
long rowid = cursor.getLong( rowIndex ); long rowid = cursor.getLong( rowIndex );
long nextNag = cursor.getLong( nagIndex ); long nextNag = cursor.getLong( nagIndex );
long lastMove = cursor.getLong( lastMoveIndex ); long lastMove = cursor.getLong( lastMoveIndex );
result[ii] = new NeedsNagInfo( rowid, nextNag, lastMove ); CurGameInfo.DeviceRole role =
CurGameInfo.DeviceRole.values()[cursor.getInt( roleIndex )];
result[ii] = new NeedsNagInfo( rowid, nextNag, lastMove, role );
} }
} }

View file

@ -54,7 +54,8 @@ public class NagTurnReceiver extends BroadcastReceiver {
{ 60, R.plurals.nag_minutes_fmt }, { 60, R.plurals.nag_minutes_fmt },
}; };
private static Boolean s_nagsDisabled = null; private static Boolean s_nagsDisabledNet = null;
private static Boolean s_nagsDisabledSolo = null;
@Override @Override
public void onReceive( Context context, Intent intent ) public void onReceive( Context context, Intent intent )
@ -66,6 +67,15 @@ public class NagTurnReceiver extends BroadcastReceiver {
long now = new Date().getTime(); // in milliseconds long now = new Date().getTime(); // in milliseconds
for ( NeedsNagInfo info : needNagging ) { for ( NeedsNagInfo info : needNagging ) {
Assert.assertTrue( info.m_nextNag < now ); Assert.assertTrue( info.m_nextNag < now );
// Skip processing if notifications disabled for this type
// of game
if ( s_nagsDisabledSolo && info.isSolo() ) {
continue;
} else if ( s_nagsDisabledNet && !info.isSolo() ) {
continue;
}
info.m_nextNag = figureNextNag( context, info.m_nextNag = figureNextNag( context,
info.m_lastMoveMillis ); info.m_lastMoveMillis );
boolean lastWarning = 0 == info.m_nextNag; boolean lastWarning = 0 == info.m_nextNag;
@ -205,18 +215,24 @@ public class NagTurnReceiver extends BroadcastReceiver {
private static boolean getNagsDisabled( Context context ) private static boolean getNagsDisabled( Context context )
{ {
if ( null == s_nagsDisabled ) { if ( null == s_nagsDisabledNet ) {
boolean nagsDisabled = boolean nagsDisabled =
XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag, XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag,
false ); false );
s_nagsDisabled = new Boolean( nagsDisabled ); s_nagsDisabledNet = new Boolean( nagsDisabled );
} }
return s_nagsDisabled; if ( null == s_nagsDisabledSolo ) {
boolean nagsDisabled =
XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag_solo,
s_nagsDisabledNet );
s_nagsDisabledSolo = new Boolean( nagsDisabled );
}
return s_nagsDisabledNet && s_nagsDisabledSolo;
} }
public static void resetNagsDisabled( Context context ) public static void resetNagsDisabled( Context context )
{ {
s_nagsDisabled = null; s_nagsDisabledNet = s_nagsDisabledSolo = null;
restartTimer( context ); restartTimer( context );
} }
} }

View file

@ -52,7 +52,8 @@ public class PrefsDelegate extends DelegateBase
private String m_keyLocale; private String m_keyLocale;
private String m_keyLangs; private String m_keyLangs;
private String m_keyFakeRadio; private String m_keyFakeRadio;
private String m_keyNagsDisabled; private String m_keyNagsDisabledNet;
private String m_keyNagsDisabledSolo;
public PrefsDelegate( PreferenceActivity activity, Delegator delegator, public PrefsDelegate( PreferenceActivity activity, Delegator delegator,
Bundle savedInstanceState ) Bundle savedInstanceState )
@ -137,7 +138,8 @@ public class PrefsDelegate extends DelegateBase
m_keyLocale = getString( R.string.key_xlations_locale ); m_keyLocale = getString( R.string.key_xlations_locale );
m_keyLangs = getString( R.string.key_default_language ); m_keyLangs = getString( R.string.key_default_language );
m_keyFakeRadio = getString( R.string.key_force_radio ); m_keyFakeRadio = getString( R.string.key_force_radio );
m_keyNagsDisabled = getString( R.string.key_disable_nag ); m_keyNagsDisabledNet = getString( R.string.key_disable_nag );
m_keyNagsDisabledSolo = getString( R.string.key_disable_nag_solo );
Button button = (Button)findViewById( R.id.revert_colors ); Button button = (Button)findViewById( R.id.revert_colors );
button.setOnClickListener( new View.OnClickListener() { button.setOnClickListener( new View.OnClickListener() {
@ -206,7 +208,8 @@ public class PrefsDelegate extends DelegateBase
forceDictsMatch( sp.getString( key, null ) ); forceDictsMatch( sp.getString( key, null ) );
} else if ( key.equals( m_keyFakeRadio ) ) { } else if ( key.equals( m_keyFakeRadio ) ) {
SMSService.resetPhoneInfo(); SMSService.resetPhoneInfo();
} else if ( key.equals( m_keyNagsDisabled ) ) { } else if ( key.equals( m_keyNagsDisabledNet )
|| key.equals( m_keyNagsDisabledSolo ) ) {
NagTurnReceiver.resetNagsDisabled( m_activity ); NagTurnReceiver.resetNagsDisabled( m_activity );
} }
} }