add not-again checkbox to remove-sms-from-game alert

Some people will decide to leave SMS comms in while I look for an
alternative. Maybe. Don't show them the same alert every time they open
the game. In the process removed what seemed to be a duplicate ivar.
This commit is contained in:
Eric House 2019-03-08 14:18:56 -08:00
parent f05c6862f9
commit eb33d18390
6 changed files with 24 additions and 23 deletions

View file

@ -2302,7 +2302,9 @@ public class BoardDelegate extends DelegateBase
if ( banned ) { if ( banned ) {
ActionPair pr = new ActionPair( Action.PERMS_BANNED_INFO, ActionPair pr = new ActionPair( Action.PERMS_BANNED_INFO,
R.string.button_more_info ); R.string.button_more_info );
builder.setActionPair( pr ); builder.setActionPair( pr )
.setNAKey( R.string.key_na_sms_banned )
;
} }
builder.setNegButton( R.string.remove_sms ) builder.setNegButton( R.string.remove_sms )
.show(); .show();

View file

@ -44,8 +44,6 @@ public class ConfirmThenAlert extends DlgDelegateAlert {
AlertDialog.Builder builder, AlertDialog.Builder builder,
NotAgainView naView ) NotAgainView naView )
{ {
naView.setMessage( state.m_msg );
naView.setShowNACheckbox( null != state.m_onNAChecked );
OnClickListener lstnr = mkCallbackClickListener( naView ); OnClickListener lstnr = mkCallbackClickListener( naView );
builder.setTitle( state.m_titleId == 0 ? R.string.query_title : state.m_titleId ) builder.setTitle( state.m_titleId == 0 ? R.string.query_title : state.m_titleId )

View file

@ -158,7 +158,7 @@ public class DlgDelegate {
public abstract class DlgDelegateBuilder { public abstract class DlgDelegateBuilder {
protected String m_msgString; protected String m_msgString;
protected int m_nakey; protected int m_prefsNAKey;
protected Action m_onNA; protected Action m_onNA;
protected int m_posButton = android.R.string.ok; protected int m_posButton = android.R.string.ok;
protected int m_negButton = android.R.string.cancel; protected int m_negButton = android.R.string.cancel;
@ -177,7 +177,7 @@ public class DlgDelegate {
{ m_action = action; return this; } { m_action = action; return this; }
public DlgDelegateBuilder setNAKey( int keyId ) public DlgDelegateBuilder setNAKey( int keyId )
{ m_nakey = keyId; return this; } { m_prefsNAKey = keyId; return this; }
public DlgDelegateBuilder setOnNA( Action onNA ) public DlgDelegateBuilder setOnNA( Action onNA )
{ m_onNA = onNA; return this; } { m_onNA = onNA; return this; }
@ -220,31 +220,29 @@ public class DlgDelegate {
@Override @Override
public void show() public void show()
{ {
showConfirmThen( m_nakey, m_onNA, m_msgString, m_posButton, showConfirmThen( m_prefsNAKey, m_onNA, m_msgString, m_posButton,
m_negButton, m_action, m_titleId, m_actionPair, m_negButton, m_action, m_titleId, m_actionPair,
m_params ); m_params );
} }
} }
public class NotAgainBuilder extends DlgDelegateBuilder { public class NotAgainBuilder extends DlgDelegateBuilder {
private int m_prefsKey;
public NotAgainBuilder(String msg, int key, Action action) public NotAgainBuilder(String msg, int key, Action action)
{ super(msg, action); m_prefsKey = key; } { super(msg, action); setNAKey( key ); }
public NotAgainBuilder(int msgId, int key, Action action) public NotAgainBuilder(int msgId, int key, Action action)
{ super(msgId, action); m_prefsKey = key; } { super(msgId, action); m_prefsNAKey = key; }
public NotAgainBuilder( String msg, int key ) public NotAgainBuilder( String msg, int key )
{ super( msg, Action.SKIP_CALLBACK ); m_prefsKey = key; } { super( msg, Action.SKIP_CALLBACK ); m_prefsNAKey = key; }
public NotAgainBuilder( int msgId, int key ) public NotAgainBuilder( int msgId, int key )
{ super( msgId, Action.SKIP_CALLBACK ); m_prefsKey = key; } { super( msgId, Action.SKIP_CALLBACK ); m_prefsNAKey = key; }
@Override @Override
public void show() public void show()
{ {
showNotAgainDlgThen( m_msgString, m_prefsKey, showNotAgainDlgThen( m_msgString, m_prefsNAKey,
m_action, m_actionPair, m_action, m_actionPair,
m_params ); m_params );
} }
@ -395,14 +393,16 @@ public class DlgDelegate {
if ( 0 == nakey || if ( 0 == nakey ||
! XWPrefs.getPrefsBoolean( m_activity, nakey, false ) ) { ! XWPrefs.getPrefsBoolean( m_activity, nakey, false ) ) {
DlgState state = new DlgState( DlgID.CONFIRM_THEN ) DlgState state = new DlgState( DlgID.CONFIRM_THEN )
.setOnNA(onNA) .setOnNA( onNA )
.setMsg( msg ) .setMsg( msg )
.setPosButton( posButton ) .setPosButton( posButton )
.setNegButton( negButton ) .setNegButton( negButton )
.setAction( action ) .setAction( action )
.setTitle( titleId ) .setTitle( titleId )
.setActionPair( more ) .setActionPair( more )
.setParams( params ); .setParams( params )
.setPrefsKey( nakey )
;
m_dlgt.show( state ); m_dlgt.show( state );
} }
} }

View file

@ -78,7 +78,7 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
NotAgainView naView = NotAgainView naView =
((NotAgainView)LocUtils.inflate( context, R.layout.not_again_view )) ((NotAgainView)LocUtils.inflate( context, R.layout.not_again_view ))
.setMessage( state.m_msg ) .setMessage( state.m_msg )
.setShowNACheckbox( 0 != state.m_prefsKey ); .setShowNACheckbox( 0 != state.m_prefsNAKey );
AlertDialog.Builder builder = LocUtils.makeAlertBuilder( context ) AlertDialog.Builder builder = LocUtils.makeAlertBuilder( context )
.setView( naView ) .setView( naView )
@ -123,8 +123,8 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
protected void checkNotAgainCheck( DlgState state, NotAgainView naView ) protected void checkNotAgainCheck( DlgState state, NotAgainView naView )
{ {
if ( null != naView && naView.getChecked() ) { if ( null != naView && naView.getChecked() ) {
if ( 0 != state.m_prefsKey ) { if ( 0 != state.m_prefsNAKey ) {
XWPrefs.setPrefsBoolean( getActivity(), m_state.m_prefsKey, XWPrefs.setPrefsBoolean( getActivity(), m_state.m_prefsNAKey,
true ); true );
} else if ( null != state.m_onNAChecked ) { } else if ( null != state.m_onNAChecked ) {
DlgClickNotify notify = (DlgClickNotify)getActivity(); DlgClickNotify notify = (DlgClickNotify)getActivity();

View file

@ -43,7 +43,7 @@ public class DlgState implements Parcelable {
public int m_negButton; public int m_negButton;
public Action m_action = null; public Action m_action = null;
public ActionPair m_pair = null; public ActionPair m_pair = null;
public int m_prefsKey; public int m_prefsNAKey;
// These can't be serialized!!!! // These can't be serialized!!!!
public Object[] m_params; public Object[] m_params;
public Action m_onNAChecked; public Action m_onNAChecked;
@ -57,7 +57,7 @@ public class DlgState implements Parcelable {
public DlgState setMsg( String msg ) public DlgState setMsg( String msg )
{ m_msg = msg; return this; } { m_msg = msg; return this; }
public DlgState setPrefsKey( int key ) public DlgState setPrefsKey( int key )
{ m_prefsKey = key; return this; } { m_prefsNAKey = key; return this; }
public DlgState setAction( Action action ) public DlgState setAction( Action action )
{ m_action = action; return this; } { m_action = action; return this; }
public DlgState setParams( Object... params ) public DlgState setParams( Object... params )
@ -100,7 +100,7 @@ public class DlgState implements Parcelable {
return String.format("[id: %s; msg: %s; key: %s; action: %s; pair %s; " return String.format("[id: %s; msg: %s; key: %s; action: %s; pair %s; "
+ "na: %s; pos: %d; neg: %d; title: %d; " + "na: %s; pos: %d; neg: %d; title: %d; "
+ "params: %s]", + "params: %s]",
m_id, m_msg, m_prefsKey, m_action, m_pair, m_onNAChecked, m_id, m_msg, m_prefsNAKey, m_action, m_pair, m_onNAChecked,
m_posButton, m_negButton, m_titleId, params ); m_posButton, m_negButton, m_titleId, params );
} else { } else {
return super.toString(); return super.toString();
@ -123,7 +123,7 @@ public class DlgState implements Parcelable {
&& m_negButton == other.m_negButton && m_negButton == other.m_negButton
&& m_action == other.m_action && m_action == other.m_action
&& ((null == m_pair) ? (null == other.m_pair) : m_pair.equals(other.m_pair)) && ((null == m_pair) ? (null == other.m_pair) : m_pair.equals(other.m_pair))
&& m_prefsKey == other.m_prefsKey && m_prefsNAKey == other.m_prefsNAKey
&& Arrays.deepEquals( m_params, other.m_params ) && Arrays.deepEquals( m_params, other.m_params )
&& m_onNAChecked == other.m_onNAChecked && m_onNAChecked == other.m_onNAChecked
&& m_titleId == other.m_titleId; && m_titleId == other.m_titleId;
@ -158,7 +158,7 @@ public class DlgState implements Parcelable {
out.writeInt( m_posButton ); out.writeInt( m_posButton );
out.writeInt( m_negButton ); out.writeInt( m_negButton );
out.writeInt( null == m_action ? -1 : m_action.ordinal() ); out.writeInt( null == m_action ? -1 : m_action.ordinal() );
out.writeInt( m_prefsKey ); out.writeInt( m_prefsNAKey );
out.writeInt( null == m_onNAChecked ? -1 : m_onNAChecked.ordinal() ); out.writeInt( null == m_onNAChecked ? -1 : m_onNAChecked.ordinal() );
out.writeInt( m_titleId ); out.writeInt( m_titleId );
out.writeString( m_msg ); out.writeString( m_msg );

View file

@ -143,6 +143,7 @@
<string name="key_na_comms_sms">key_na_comms_sms</string> <string name="key_na_comms_sms">key_na_comms_sms</string>
<string name="key_na_comms_relay">key_na_comms_relay</string> <string name="key_na_comms_relay">key_na_comms_relay</string>
<string name="key_na_bt_badproto">key_na_bt_badproto</string> <string name="key_na_bt_badproto">key_na_bt_badproto</string>
<string name="key_na_sms_banned">key_na_sms_banned</string>
<!-- Nor is my email address --> <!-- Nor is my email address -->
<string name="email_author_email">xwords@eehouse.org</string> <string name="email_author_email">xwords@eehouse.org</string>