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_square_tiles">key_square_tiles</string>
|
||||||
<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_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>
|
||||||
|
|
|
@ -2393,6 +2393,10 @@
|
||||||
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_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
|
<!-- Debugging stuff. Localize if you think your langauge users will
|
||||||
care. -->
|
care. -->
|
||||||
<string name="advanced">For debugging</string>
|
<string name="advanced">For debugging</string>
|
||||||
|
|
|
@ -231,6 +231,11 @@
|
||||||
android:summary="@string/skip_confirm_turn_summary"
|
android:summary="@string/skip_confirm_turn_summary"
|
||||||
android:defaultValue="false"
|
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"
|
<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"
|
||||||
|
|
|
@ -2073,6 +2073,9 @@
|
||||||
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_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
|
<!-- Debugging stuff. Localize if you think your langauge users will
|
||||||
care. -->
|
care. -->
|
||||||
<string name="advanced">Rof gniggubed</string>
|
<string name="advanced">Rof gniggubed</string>
|
||||||
|
|
|
@ -2073,6 +2073,9 @@
|
||||||
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_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
|
<!-- Debugging stuff. Localize if you think your langauge users will
|
||||||
care. -->
|
care. -->
|
||||||
<string name="advanced">FOR DEBUGGING</string>
|
<string name="advanced">FOR DEBUGGING</string>
|
||||||
|
|
|
@ -54,42 +54,50 @@ public class NagTurnReceiver extends BroadcastReceiver {
|
||||||
{ 60, R.plurals.nag_minutes_fmt },
|
{ 60, R.plurals.nag_minutes_fmt },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static Boolean s_nagsDisabled = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive( Context context, Intent intent )
|
public void onReceive( Context context, Intent intent )
|
||||||
{
|
{
|
||||||
// loop through all games testing who's been sitting on a turn
|
// loop through all games testing who's been sitting on a turn
|
||||||
NeedsNagInfo[] needNagging = DBUtils.getNeedNagging( context );
|
if ( !getNagsDisabled( context ) ) {
|
||||||
if ( null != needNagging ) {
|
NeedsNagInfo[] needNagging = DBUtils.getNeedNagging( context );
|
||||||
long now = new Date().getTime(); // in milliseconds
|
if ( null != needNagging ) {
|
||||||
for ( NeedsNagInfo info : needNagging ) {
|
long now = new Date().getTime(); // in milliseconds
|
||||||
Assert.assertTrue( info.m_nextNag < now );
|
for ( NeedsNagInfo info : needNagging ) {
|
||||||
info.m_nextNag = figureNextNag( context, info.m_lastMoveMillis );
|
Assert.assertTrue( info.m_nextNag < now );
|
||||||
boolean lastWarning = 0 == info.m_nextNag;
|
info.m_nextNag = figureNextNag( context,
|
||||||
|
info.m_lastMoveMillis );
|
||||||
|
boolean lastWarning = 0 == info.m_nextNag;
|
||||||
|
|
||||||
long rowid = info.m_rowid;
|
long rowid = info.m_rowid;
|
||||||
GameSummary summary = DBUtils.getSummary( context, rowid, 10 );
|
GameSummary summary = DBUtils.getSummary( context, rowid,
|
||||||
String prevPlayer = null == summary
|
10 );
|
||||||
? LocUtils.getString(context, R.string.prev_player)
|
String prevPlayer = null == summary
|
||||||
: summary.getPrevPlayer();
|
? 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,
|
DBUtils.updateNeedNagging( context, needNagging );
|
||||||
body, (int)rowid );
|
|
||||||
|
|
||||||
|
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 )
|
private static void restartTimer( Context context, long atMillis )
|
||||||
{
|
{
|
||||||
AlarmManager am =
|
if ( !getNagsDisabled( context ) ) {
|
||||||
(AlarmManager)context.getSystemService( Context.ALARM_SERVICE );
|
AlarmManager am =
|
||||||
|
(AlarmManager)context.getSystemService( Context.ALARM_SERVICE );
|
||||||
|
|
||||||
Intent intent = new Intent( context, NagTurnReceiver.class );
|
Intent intent = new Intent( context, NagTurnReceiver.class );
|
||||||
PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 );
|
PendingIntent pi = PendingIntent.getBroadcast( context, 0, intent, 0 );
|
||||||
|
|
||||||
long now = new Date().getTime(); // in milliseconds
|
long now = new Date().getTime(); // in milliseconds
|
||||||
am.set( AlarmManager.RTC, atMillis, pi );
|
am.set( AlarmManager.RTC, atMillis, pi );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNagTimer( Context context )
|
public static void setNagTimer( Context context )
|
||||||
{
|
{
|
||||||
long nextNag = DBUtils.getNextNag( context );
|
if ( !getNagsDisabled( context ) ) {
|
||||||
if ( 0 < nextNag ) {
|
long nextNag = DBUtils.getNextNag( context );
|
||||||
restartTimer( context, nextNag );
|
if ( 0 < nextNag ) {
|
||||||
|
restartTimer( context, nextNag );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +200,23 @@ public class NagTurnReceiver extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String result = TextUtils.join( ", ", results );
|
String result = TextUtils.join( ", ", results );
|
||||||
DbgUtils.logf( "formatMillis(%d) => %s", millis, result );
|
|
||||||
return 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_keyLocale;
|
||||||
private String m_keyLangs;
|
private String m_keyLangs;
|
||||||
private String m_keyFakeRadio;
|
private String m_keyFakeRadio;
|
||||||
|
private String m_keyNagsDisabled;
|
||||||
|
|
||||||
public PrefsDelegate( PreferenceActivity activity, Delegator delegator,
|
public PrefsDelegate( PreferenceActivity activity, Delegator delegator,
|
||||||
Bundle savedInstanceState )
|
Bundle savedInstanceState )
|
||||||
|
@ -136,6 +137,7 @@ 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 );
|
||||||
|
|
||||||
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() {
|
||||||
|
@ -205,6 +207,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 ) ) {
|
||||||
|
NagTurnReceiver.resetNagsDisabled( m_activity );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue