mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-23 07:27:22 +01:00
add prefs checkbox to disable it's-your-turn notifications
This commit is contained in:
parent
bd7bfb328e
commit
2631ab1094
8 changed files with 828 additions and 777 deletions
File diff suppressed because it is too large
Load diff
|
@ -11,6 +11,7 @@
|
|||
<string name="key_square_tiles">key_square_tiles</string>
|
||||
<string name="key_explain_robot">key_explain_robot</string>
|
||||
<string name="key_skip_confirm">key_skip_confirm</string>
|
||||
<string name="key_disable_nag">key_disable_nag</string>
|
||||
<string name="key_sort_tiles">key_sort_tiles</string>
|
||||
<string name="key_peek_other">key_peek_other</string>
|
||||
<string name="key_hide_crosshairs">key_hide_crosshairs</string>
|
||||
|
|
|
@ -2393,6 +2393,10 @@
|
|||
and want them back, enable them now. You can turn them off again
|
||||
in Settings.</string>
|
||||
|
||||
<string name="disable_nag_title">Disable turn reminders</string>
|
||||
<string name="disable_nag_summary">Do not notify me no matter
|
||||
how long it\'s been my turn</string>
|
||||
|
||||
<!-- Debugging stuff. Localize if you think your langauge users will
|
||||
care. -->
|
||||
<string name="advanced">For debugging</string>
|
||||
|
|
|
@ -231,6 +231,11 @@
|
|||
android:summary="@string/skip_confirm_turn_summary"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_disable_nag"
|
||||
android:title="@string/disable_nag_title"
|
||||
android:summary="@string/disable_nag_summary"
|
||||
android:defaultValue="false"
|
||||
/>
|
||||
<CheckBoxPreference android:key="@string/key_default_loc"
|
||||
android:title="@string/default_loc"
|
||||
android:summary="@string/default_loc_summary"
|
||||
|
|
|
@ -2073,6 +2073,9 @@
|
|||
na \"decnavda\" erutaef ni siht esaeler. Fi uoy erew gnisu meht
|
||||
dna tnaw meht ,kcab elbane meht won. Uoy nac nrut meht ffo niaga
|
||||
ni Sgnittes.</string>
|
||||
<string name="disable_nag_title">Elbasid nrut srednimer</string>
|
||||
<string name="disable_nag_summary">Od ton yfiton em on rettam
|
||||
woh gnol ti\'s neeb ym nrut</string>
|
||||
<!-- Debugging stuff. Localize if you think your langauge users will
|
||||
care. -->
|
||||
<string name="advanced">Rof gniggubed</string>
|
||||
|
|
|
@ -2073,6 +2073,9 @@
|
|||
AN \"ADVANCED\" FEATURE IN THIS RELEASE. IF YOU WERE USING THEM
|
||||
AND WANT THEM BACK, ENABLE THEM NOW. YOU CAN TURN THEM OFF AGAIN
|
||||
IN SETTINGS.</string>
|
||||
<string name="disable_nag_title">DISABLE TURN REMINDERS</string>
|
||||
<string name="disable_nag_summary">DO NOT NOTIFY ME NO MATTER
|
||||
HOW LONG IT\'S BEEN MY TURN</string>
|
||||
<!-- Debugging stuff. Localize if you think your langauge users will
|
||||
care. -->
|
||||
<string name="advanced">FOR DEBUGGING</string>
|
||||
|
|
|
@ -54,42 +54,50 @@ public class NagTurnReceiver extends BroadcastReceiver {
|
|||
{ 60, R.plurals.nag_minutes_fmt },
|
||||
};
|
||||
|
||||
private static Boolean s_nagsDisabled = null;
|
||||
|
||||
@Override
|
||||
public void onReceive( Context context, Intent intent )
|
||||
{
|
||||
// loop through all games testing who's been sitting on a turn
|
||||
NeedsNagInfo[] needNagging = DBUtils.getNeedNagging( context );
|
||||
if ( null != needNagging ) {
|
||||
long now = new Date().getTime(); // in milliseconds
|
||||
for ( NeedsNagInfo info : needNagging ) {
|
||||
Assert.assertTrue( info.m_nextNag < now );
|
||||
info.m_nextNag = figureNextNag( context, info.m_lastMoveMillis );
|
||||
boolean lastWarning = 0 == info.m_nextNag;
|
||||
if ( !getNagsDisabled( context ) ) {
|
||||
NeedsNagInfo[] needNagging = DBUtils.getNeedNagging( context );
|
||||
if ( null != needNagging ) {
|
||||
long now = new Date().getTime(); // in milliseconds
|
||||
for ( NeedsNagInfo info : needNagging ) {
|
||||
Assert.assertTrue( info.m_nextNag < now );
|
||||
info.m_nextNag = figureNextNag( context,
|
||||
info.m_lastMoveMillis );
|
||||
boolean lastWarning = 0 == info.m_nextNag;
|
||||
|
||||
long rowid = info.m_rowid;
|
||||
GameSummary summary = DBUtils.getSummary( context, rowid, 10 );
|
||||
String prevPlayer = null == summary
|
||||
? LocUtils.getString(context, R.string.prev_player)
|
||||
: summary.getPrevPlayer();
|
||||
long rowid = info.m_rowid;
|
||||
GameSummary summary = DBUtils.getSummary( context, rowid,
|
||||
10 );
|
||||
String prevPlayer = null == summary
|
||||
? LocUtils.getString(context, R.string.prev_player)
|
||||
: summary.getPrevPlayer();
|
||||
|
||||
Intent msgIntent =
|
||||
GamesListDelegate.makeRowidIntent( context, rowid );
|
||||
String millis = formatMillis( context,
|
||||
now - info.m_lastMoveMillis);
|
||||
String body =
|
||||
String.format( LocUtils.getString(context,
|
||||
R.string.nag_body_fmt),
|
||||
prevPlayer, millis );
|
||||
if ( lastWarning ) {
|
||||
body = LocUtils
|
||||
.getString( context, R.string.nag_warn_last_fmt, body );
|
||||
}
|
||||
Utils.postNotification( context, msgIntent,
|
||||
R.string.nag_title, body,
|
||||
(int)rowid );
|
||||
|
||||
Intent msgIntent = GamesListDelegate.makeRowidIntent( context, rowid );
|
||||
String body =
|
||||
String.format( LocUtils.getString(context,
|
||||
R.string.nag_body_fmt),
|
||||
prevPlayer,
|
||||
formatMillis( context,
|
||||
now - info.m_lastMoveMillis) );
|
||||
if ( lastWarning ) {
|
||||
body = LocUtils
|
||||
.getString( context, R.string.nag_warn_last_fmt, body );
|
||||
}
|
||||
Utils.postNotification( context, msgIntent, R.string.nag_title,
|
||||
body, (int)rowid );
|
||||
DBUtils.updateNeedNagging( context, needNagging );
|
||||
|
||||
setNagTimer( context );
|
||||
}
|
||||
DBUtils.updateNeedNagging( context, needNagging );
|
||||
|
||||
setNagTimer( context );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,21 +108,25 @@ public class NagTurnReceiver extends BroadcastReceiver {
|
|||
|
||||
private static void restartTimer( Context context, long atMillis )
|
||||
{
|
||||
AlarmManager am =
|
||||
(AlarmManager)context.getSystemService( Context.ALARM_SERVICE );
|
||||
if ( !getNagsDisabled( context ) ) {
|
||||
AlarmManager am =
|
||||
(AlarmManager)context.getSystemService( Context.ALARM_SERVICE );
|
||||
|
||||
Intent intent = new Intent( context, NagTurnReceiver.class );
|
||||
PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 );
|
||||
Intent intent = new Intent( context, NagTurnReceiver.class );
|
||||
PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 );
|
||||
|
||||
long now = new Date().getTime(); // in milliseconds
|
||||
am.set( AlarmManager.RTC, atMillis, pi );
|
||||
long now = new Date().getTime(); // in milliseconds
|
||||
am.set( AlarmManager.RTC, atMillis, pi );
|
||||
}
|
||||
}
|
||||
|
||||
public static void setNagTimer( Context context )
|
||||
{
|
||||
long nextNag = DBUtils.getNextNag( context );
|
||||
if ( 0 < nextNag ) {
|
||||
restartTimer( context, nextNag );
|
||||
if ( !getNagsDisabled( context ) ) {
|
||||
long nextNag = DBUtils.getNextNag( context );
|
||||
if ( 0 < nextNag ) {
|
||||
restartTimer( context, nextNag );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,7 +200,23 @@ public class NagTurnReceiver extends BroadcastReceiver {
|
|||
}
|
||||
}
|
||||
String result = TextUtils.join( ", ", results );
|
||||
DbgUtils.logf( "formatMillis(%d) => %s", millis, result );
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean getNagsDisabled( Context context )
|
||||
{
|
||||
if ( null == s_nagsDisabled ) {
|
||||
boolean nagsDisabled =
|
||||
XWPrefs.getPrefsBoolean( context, R.string.key_disable_nag,
|
||||
false );
|
||||
s_nagsDisabled = new Boolean( nagsDisabled );
|
||||
}
|
||||
return s_nagsDisabled;
|
||||
}
|
||||
|
||||
public static void resetNagsDisabled( Context context )
|
||||
{
|
||||
s_nagsDisabled = null;
|
||||
restartTimer( context );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
private String m_keyLocale;
|
||||
private String m_keyLangs;
|
||||
private String m_keyFakeRadio;
|
||||
private String m_keyNagsDisabled;
|
||||
|
||||
public PrefsDelegate( PreferenceActivity activity, Delegator delegator,
|
||||
Bundle savedInstanceState )
|
||||
|
@ -136,6 +137,7 @@ public class PrefsDelegate extends DelegateBase
|
|||
m_keyLocale = getString( R.string.key_xlations_locale );
|
||||
m_keyLangs = getString( R.string.key_default_language );
|
||||
m_keyFakeRadio = getString( R.string.key_force_radio );
|
||||
m_keyNagsDisabled = getString( R.string.key_disable_nag );
|
||||
|
||||
Button button = (Button)findViewById( R.id.revert_colors );
|
||||
button.setOnClickListener( new View.OnClickListener() {
|
||||
|
@ -205,6 +207,8 @@ public class PrefsDelegate extends DelegateBase
|
|||
forceDictsMatch( sp.getString( key, null ) );
|
||||
} else if ( key.equals( m_keyFakeRadio ) ) {
|
||||
SMSService.resetPhoneInfo();
|
||||
} else if ( key.equals( m_keyNagsDisabled ) ) {
|
||||
NagTurnReceiver.resetNagsDisabled( m_activity );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue