diff --git a/xwords4/android/XWords4/archive/R.java b/xwords4/android/XWords4/archive/R.java index f620d642e..41cd0008f 100644 --- a/xwords4/android/XWords4/archive/R.java +++ b/xwords4/android/XWords4/archive/R.java @@ -55,21 +55,21 @@ public final class R { public static final int in_arrow=0x7f020012; public static final int in_arrow_active=0x7f020013; public static final int multigame__gen=0x7f020014; - public static final int new_group__gen=0x7f020015; - public static final int next_hint=0x7f020016; - public static final int origin=0x7f020017; - public static final int out_arrow=0x7f020018; - public static final int out_arrow_active=0x7f020019; - public static final int prefs__gen=0x7f02001a; - public static final int prev_hint=0x7f02001b; - public static final int refresh=0x7f02001c; - public static final int relabel__gen=0x7f02001d; - public static final int reset__gen=0x7f02001e; - public static final int rightarrow=0x7f02001f; - public static final int save__gen=0x7f020020; - public static final int search__gen=0x7f020021; - public static final int select_all__gen=0x7f020022; - public static final int send__gen=0x7f020023; + public static final int multigame_new__gen=0x7f020015; + public static final int new_group__gen=0x7f020016; + public static final int next_hint=0x7f020017; + public static final int origin=0x7f020018; + public static final int out_arrow=0x7f020019; + public static final int out_arrow_active=0x7f02001a; + public static final int prefs__gen=0x7f02001b; + public static final int prev_hint=0x7f02001c; + public static final int refresh=0x7f02001d; + public static final int relabel__gen=0x7f02001e; + public static final int reset__gen=0x7f02001f; + public static final int rightarrow=0x7f020020; + public static final int save__gen=0x7f020021; + public static final int search__gen=0x7f020022; + public static final int select_all__gen=0x7f020023; public static final int shuffle=0x7f020024; public static final int sologame__gen=0x7f020025; public static final int stat_notify_chat=0x7f020026; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java index e94b9fc41..8477a79c2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -386,13 +386,19 @@ public class DelegateBase implements DlgClickNotify, protected void showConfirmThen( String msg, Action action, Object... params ) { - m_dlgDelegate.showConfirmThen( msg, action, params ); + m_dlgDelegate.showConfirmThen( null, msg, action, params ); + } + + protected void showConfirmThen( Runnable onNA, String msg, int posButton, + Action action, Object... params ) + { + m_dlgDelegate.showConfirmThen( onNA, msg, posButton, action, params ); } protected void showConfirmThen( String msg, int posButton, Action action, Object... params ) { - m_dlgDelegate.showConfirmThen( msg, posButton, action, params ); + m_dlgDelegate.showConfirmThen( null, msg, posButton, action, params ); } protected void showConfirmThen( int msg, int posButton, int negButton, Action action ) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java index 83bab7ad2..de4ea0d7a 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java @@ -329,47 +329,47 @@ public class DlgDelegate { public void showConfirmThen( String msg, Action action ) { - showConfirmThen( msg, R.string.button_ok, action, null ); + showConfirmThen( null, msg, R.string.button_ok, action, null ); } public void showConfirmThen( int msgID, Action action ) { - showConfirmThen( getString( msgID ), R.string.button_ok, action, null ); + showConfirmThen( null, getString( msgID ), R.string.button_ok, action, null ); } - public void showConfirmThen( String msg, Action action, Object[] params ) + public void showConfirmThen( Runnable onNA, String msg, Action action, Object[] params ) { - showConfirmThen( msg, R.string.button_ok, action, params ); + showConfirmThen( onNA, msg, R.string.button_ok, action, params ); } - public void showConfirmThen( String msg, int posButton, Action action ) + public void showConfirmThen( Runnable onNA, String msg, int posButton, Action action ) { - showConfirmThen( msg, posButton, action, null ); + showConfirmThen( onNA, msg, posButton, action, null ); } public void showConfirmThen( int msg, int posButton, int negButton, Action action ) { - showConfirmThen( getString(msg), posButton, negButton, action, null ); + showConfirmThen( null, getString(msg), posButton, negButton, action, null ); } public void showConfirmThen( int msg, int posButton, Action action, Object[] params ) { - showConfirmThen( getString(msg), posButton, R.string.button_cancel, + showConfirmThen( null, getString(msg), posButton, R.string.button_cancel, action, params ); } - public void showConfirmThen( String msg, int posButton, Action action, + public void showConfirmThen( Runnable onNA, String msg, int posButton, Action action, Object[] params ) { - showConfirmThen( msg, posButton, R.string.button_cancel, action, + showConfirmThen( onNA, msg, posButton, R.string.button_cancel, action, params ); } - public void showConfirmThen( String msg, int posButton, int negButton, - Action action, Object[] params ) + public void showConfirmThen( Runnable onNA, String msg, int posButton, + int negButton, Action action, Object[] params ) { - DlgState state = new DlgState( DlgID.CONFIRM_THEN, msg, posButton, + DlgState state = new DlgState( DlgID.CONFIRM_THEN, onNA, msg, posButton, negButton, action, 0, params ); addState( state ); showDialog( DlgID.CONFIRM_THEN ); @@ -582,13 +582,17 @@ public class DlgDelegate { private Dialog createConfirmThenDialog( DlgState state, DlgID dlgID ) { - OnClickListener lstnr = mkCallbackClickListener( state, null ); + NotAgainView naView = (NotAgainView) + LocUtils.inflate( m_activity, R.layout.not_again_view ); + naView.setMessage( state.m_msg ); + naView.setShowNACheckbox( null != state.m_onNAChecked ); + OnClickListener lstnr = mkCallbackClickListener( state, naView ); - AlertDialog.Builder builder = LocUtils.makeAlertBuilder( m_activity ); - builder.setTitle( R.string.query_title ); - builder.setMessage( state.m_msg ); - builder.setPositiveButton( state.m_posButton, lstnr ); - builder.setNegativeButton( state.m_negButton, lstnr ); + AlertDialog.Builder builder = LocUtils.makeAlertBuilder( m_activity ) + .setTitle( R.string.query_title ) + .setView( naView ) + .setPositiveButton( state.m_posButton, lstnr ) + .setNegativeButton( state.m_negButton, lstnr ); Dialog dialog = builder.create(); return setCallbackDismissListener( dialog, state, dlgID ); @@ -708,8 +712,12 @@ public class DlgDelegate { cbkOnClickLstnr = new OnClickListener() { public void onClick( DialogInterface dlg, int button ) { if ( null != naView && naView.getChecked() ) { - XWPrefs.setPrefsBoolean( m_activity, state.m_prefsKey, - true ); + if ( 0 != state.m_prefsKey ) { + XWPrefs.setPrefsBoolean( m_activity, state.m_prefsKey, + true ); + } else if ( null != state.m_onNAChecked ) { + state.m_onNAChecked.run(); + } } if ( Action.SKIP_CALLBACK != state.m_action ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java index b6c36211a..1dcb5ebeb 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgState.java @@ -35,6 +35,7 @@ public class DlgState implements Parcelable { public ActionPair m_pair = null; public int m_prefsKey; public Object[] m_params; + public Runnable m_onNAChecked; public DlgState( DlgID dlgID, String msg, Action action ) { @@ -63,14 +64,15 @@ public class DlgState implements Parcelable { public DlgState( DlgID dlgID, String msg, int posButton, Action action, int prefsKey, Object[] params ) { - this( dlgID, msg, posButton, R.string.button_cancel, + this( dlgID, null, msg, posButton, R.string.button_cancel, action, prefsKey, params ); } - public DlgState( DlgID dlgID, String msg, int posButton, int negButton, + public DlgState( DlgID dlgID, Runnable onNA, String msg, int posButton, int negButton, Action action, int prefsKey, Object[] params ) { m_id = dlgID; + m_onNAChecked = onNA; m_msg = msg; m_posButton = posButton; m_negButton = negButton; @@ -112,7 +114,7 @@ public class DlgState implements Parcelable { Action action = 0 > tmp ? null : Action.values()[tmp]; int prefsKey = in.readInt(); String msg = in.readString(); - return new DlgState( id, msg, posButton, negButton, action, prefsKey, null ); + return new DlgState( id, null, msg, posButton, negButton, action, prefsKey, null ); } public DlgState[] newArray(int size) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java index 8d1d2ac22..21c5aa5e3 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -1903,14 +1903,21 @@ public class GamesListDelegate extends ListDelegateBase int code = LocUtils.codeForLangCode( m_activity, lc ); String[] names = DictLangCache.getHaveLang( m_activity, code ); if ( 0 == names.length ) { + final Runnable onNA = new Runnable() { + public void run() { + XWPrefs.setPrefsBoolean( m_activity, R.string + .key_got_langdict, + true ); + } + }; OnGotLcDictListener lstnr = new OnGotLcDictListener() { public void gotDictInfo( boolean success, String lang, String name ) { if ( success ) { String msg = getString( R.string.confirm_get_locdict_fmt, lang ); - showConfirmThen( msg, R.string.button_download, - Action.DWNLD_LOC_DICT, lang, - name ); + showConfirmThen( onNA, msg, R.string.button_download, + Action.DWNLD_LOC_DICT, + lang, name ); } } }; diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NotAgainView.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NotAgainView.java index 792355cb7..47933b08d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NotAgainView.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NotAgainView.java @@ -22,6 +22,7 @@ package org.eehouse.android.xw4; import android.content.Context; import android.util.AttributeSet; +import android.view.View; import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.TextView; @@ -42,4 +43,10 @@ public class NotAgainView extends LinearLayout { CheckBox cbx = (CheckBox)findViewById( R.id.not_again_check ); return cbx.isChecked(); } + + public void setShowNACheckbox( boolean show ) + { + findViewById( R.id.not_again_check ) + .setVisibility( show ? View.VISIBLE : View.GONE ); + } }