diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java index f0673208d..2078834af 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardDelegate.java @@ -413,8 +413,9 @@ public class BoardDelegate extends DelegateBase public void onClick( DialogInterface dialog, int item ) { BoardDelegate self = curThis(); - self.showOKOnlyDialog( self.m_sentInfo - .getAsText( self.m_activity ) ); + String msg = self.m_sentInfo + .getAsText( self.m_activity ); + self.makeOkOnlyBuilder( msg ).show(); } }; @@ -926,7 +927,7 @@ public class BoardDelegate extends DelegateBase break; case R.id.board_menu_game_invites: SentInvitesInfo sentInfo = DBUtils.getInvitesFor( m_activity, m_rowid ); - showOKOnlyDialog( sentInfo.getAsText( m_activity ) ); + makeOkOnlyBuilder( sentInfo.getAsText( m_activity ) ).show(); break; case R.id.board_menu_undo_current: cmd = JNICmd.CMD_UNDO_CUR; @@ -1119,7 +1120,7 @@ public class BoardDelegate extends DelegateBase } else if ( ! NFCUtils.nfcAvail( m_activity )[1] ) { showDialog( DlgID.ENABLE_NFC ); } else { - showOKOnlyDialog( R.string.nfc_just_tap ); + makeOkOnlyBuilder( R.string.nfc_just_tap ).show(); } break; case BLUETOOTH: @@ -1211,7 +1212,7 @@ public class BoardDelegate extends DelegateBase getString( R.string.err_dup_invite_fmt, (String)args[0] ); post( new Runnable() { public void run() { - showOKOnlyDialog( msg ); + makeOkOnlyBuilder( msg ).show(); } } ); break; 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 a6a41e3be..4eb5b2f11 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DelegateBase.java @@ -46,6 +46,7 @@ import org.eehouse.android.xw4.DlgDelegate.ActionPair; import org.eehouse.android.xw4.DlgDelegate.ConfirmThenBuilder; import org.eehouse.android.xw4.DlgDelegate.DlgClickNotify; import org.eehouse.android.xw4.DlgDelegate.NotAgainBuilder; +import org.eehouse.android.xw4.DlgDelegate.OkOnlyBuilder; import org.eehouse.android.xw4.MultiService.MultiEvent; import org.eehouse.android.xw4.loc.LocUtils; @@ -501,16 +502,6 @@ public class DelegateBase implements DlgClickNotify, m_dlgDelegate.showAboutDialog(); } - public void showOKOnlyDialog( int msgID ) - { - m_dlgDelegate.showOKOnlyDialog( msgID ); - } - - public void showOKOnlyDialog( String msg ) - { - m_dlgDelegate.showOKOnlyDialog( msg ); - } - public ConfirmThenBuilder makeConfirmThenBuilder( String msg, Action action ) { return m_dlgDelegate.makeConfirmThenBuilder( msg, action ); } @@ -546,9 +537,14 @@ public class DelegateBase implements DlgClickNotify, m_dlgDelegate.showInviteChoicesThen( action, info ); } - protected void showOKOnlyDialogThen( String msg, Action action ) + public OkOnlyBuilder makeOkOnlyBuilder( int msgId ) { - m_dlgDelegate.showOKOnlyDialogThen( msg, action ); + return m_dlgDelegate.makeOkOnlyBuilder( msgId ); + } + + public OkOnlyBuilder makeOkOnlyBuilder( String msg ) + { + return m_dlgDelegate.makeOkOnlyBuilder( msg ); } protected void startProgress( int titleID, int msgID ) @@ -640,7 +636,7 @@ public class DelegateBase implements DlgClickNotify, final String msg = getString( fmtId, (String)args[0] ); runOnUiThread( new Runnable() { public void run() { - showOKOnlyDialog( msg ); + makeOkOnlyBuilder( msg ).show(); } }); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java index 554d24432..9aa9b5c5d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictBrowseDelegate.java @@ -195,7 +195,7 @@ public class DictBrowseDelegate extends ListDelegateBase // be -- then use an empty list elem and disable // search/minmax stuff. String msg = getString( R.string.alert_empty_dict_fmt, name ); - showOKOnlyDialogThen( msg, Action.FINISH_ACTION ); + makeOkOnlyBuilder(msg).setAction(Action.FINISH_ACTION).show(); } else { figureMinMax( m_browseState.m_counts ); if ( newState ) { diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java index f29df4540..a06684ca2 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DictsDelegate.java @@ -1322,7 +1322,7 @@ public class DictsDelegate extends ListDelegateBase .show(); } } else { - showOKOnlyDialog( R.string.remote_no_net ); + makeOkOnlyBuilder( R.string.remote_no_net ).show(); m_checkbox.setChecked( false ); } stopProgress(); 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 731944bca..f0c2cecd8 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java @@ -185,6 +185,20 @@ public class DlgDelegate { abstract void show(); } + public class OkOnlyBuilder extends DlgDelegateBuilder { + + public OkOnlyBuilder(String msg) { super( msg, Action.SKIP_CALLBACK ); } + public OkOnlyBuilder(int msgId) { super( msgId, Action.SKIP_CALLBACK ); } + public OkOnlyBuilder setAction( Action action ) + { m_action = action; return this; } + + @Override + public void show() + { + showOKOnlyDialogThen( m_msgString, m_action ); + } + } + public class ConfirmThenBuilder extends DlgDelegateBuilder { public ConfirmThenBuilder(String msg, Action action) {super(msg, action);} public ConfirmThenBuilder(int msgId, Action action) {super(msgId, action);} @@ -225,6 +239,15 @@ public class DlgDelegate { } } + public OkOnlyBuilder makeOkOnlyBuilder( String msg ) + { + return new OkOnlyBuilder( msg ); + } + public OkOnlyBuilder makeOkOnlyBuilder( int msgId ) + { + return new OkOnlyBuilder( msgId ); + } + public ConfirmThenBuilder makeConfirmThenBuilder( String msg, Action action ) { return new ConfirmThenBuilder( msg, action ); @@ -273,8 +296,8 @@ public class DlgDelegate { void inviteChoiceMade( Action action, InviteMeans means, Object[] params ); } public interface HasDlgDelegate { - void showOKOnlyDialog( int msgID ); - void showOKOnlyDialog( String msg ); + OkOnlyBuilder makeOkOnlyBuilder( int msgID ); + OkOnlyBuilder makeOkOnlyBuilder( String msg ); NotAgainBuilder makeNotAgainBuilder( int msgID, int prefsKey, Action action ); NotAgainBuilder makeNotAgainBuilder( int msgID, int prefsKey ); @@ -383,7 +406,7 @@ public class DlgDelegate { } } - public void showOKOnlyDialogThen( String msg, Action action ) + private void showOKOnlyDialogThen( String msg, Action action ) { // Assert.assertNull( m_dlgStates ); DlgState state = new DlgState( DlgID.DIALOG_OKONLY ).setMsg( msg ) @@ -392,16 +415,6 @@ public class DlgDelegate { showDialog( DlgID.DIALOG_OKONLY ); } - public void showOKOnlyDialog( String msg ) - { - showOKOnlyDialogThen( msg, Action.SKIP_CALLBACK ); - } - - public void showOKOnlyDialog( int msgID ) - { - showOKOnlyDialogThen( getString( msgID ), Action.SKIP_CALLBACK ); - } - public void showDictGoneFinish() { showDialog( DlgID.DLG_DICTGONE ); @@ -495,7 +508,7 @@ public class DlgDelegate { public void doSyncMenuitem() { if ( null == DBUtils.getRelayIDs( m_activity, null ) ) { - showOKOnlyDialog( R.string.no_games_to_refresh ); + makeOkOnlyBuilder( R.string.no_games_to_refresh ).show(); } else { RelayService.timerFired( m_activity ); Utils.showToast( m_activity, R.string.msgs_progress ); @@ -578,7 +591,7 @@ public class DlgDelegate { post( new Runnable() { public void run() { if ( asDlg ) { - showOKOnlyDialog( fmsg ); + makeOkOnlyBuilder( fmsg ).show(); } else { DbgUtils.showf( m_activity, fmsg ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java index f9eb36f2b..3ddce7b1d 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameConfigDelegate.java @@ -1238,7 +1238,7 @@ public class GameConfigDelegate extends DelegateBase { if ( m_conTypes.contains( CommsConnType.COMMS_CONN_RELAY ) && 0 == m_car.ip_relay_invite.length() ) { - showOKOnlyDialog( R.string.no_empty_rooms ); + makeOkOnlyBuilder( R.string.no_empty_rooms ).show(); } else { saveAndClose( forceNew ); } 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 acee2e7bb..3b55d5a48 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GamesListDelegate.java @@ -1535,7 +1535,7 @@ public class GamesListDelegate extends ListDelegateBase try { startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse( str ) ) ); } catch ( android.content.ActivityNotFoundException anf ) { - showOKOnlyDialog( R.string.no_market ); + makeOkOnlyBuilder( R.string.no_market ).show(); } break; @@ -1761,7 +1761,7 @@ public class GamesListDelegate extends ListDelegateBase final GameSummary smry = GameUtils.getSummary( m_activity, selRowIDs[0] ); if ( smry.inRelayGame() ) { - showOKOnlyDialog( R.string.no_copy_network ); + makeOkOnlyBuilder( R.string.no_copy_network ).show(); } else { dropSels = true; // will select the new game instead post( new Runnable() { @@ -1802,7 +1802,7 @@ public class GamesListDelegate extends ListDelegateBase if ( null != info ) { msg += "\n\n" + info.getAsText( m_activity ); } - showOKOnlyDialog( msg ); + makeOkOnlyBuilder( msg ).show(); break; default: @@ -1828,7 +1828,7 @@ public class GamesListDelegate extends ListDelegateBase if ( m_selGroupIDs.contains( dftGroup ) ) { msg = getString( R.string.cannot_delete_default_group_fmt, m_adapter.groupName( dftGroup ) ); - showOKOnlyDialog( msg ); + makeOkOnlyBuilder( msg ).show(); } else { Assert.assertTrue( 0 < groupIDs.length ); msg = getQuantityString( R.plurals.groups_confirm_del_fmt, @@ -2084,7 +2084,7 @@ public class GamesListDelegate extends ListDelegateBase .setParams( nli ) .show(); } else { - showOKOnlyDialog( R.string.dropped_dupe ); + makeOkOnlyBuilder( R.string.dropped_dupe ).show(); } } // startNewNetGame @@ -2167,7 +2167,7 @@ public class GamesListDelegate extends ListDelegateBase { String msg = intent.getStringExtra( ALERT_MSG ); if ( null != msg ) { - showOKOnlyDialog( msg ); + makeOkOnlyBuilder( msg ).show(); } } @@ -2238,11 +2238,6 @@ public class GamesListDelegate extends ListDelegateBase } } - private void showGotDictForLang( String lang ) - { - showOKOnlyDialog( String.format( "got dict for %s", lang ) ); - } - private void updateField() { String newField = CommonPrefs.getSummaryField( m_activity ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java index 0c6df5bf6..fb1ceb826 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsActivity.java @@ -30,6 +30,7 @@ import junit.framework.Assert; import org.eehouse.android.xw4.DlgDelegate.Action; import org.eehouse.android.xw4.DlgDelegate.ConfirmThenBuilder; import org.eehouse.android.xw4.DlgDelegate.NotAgainBuilder; +import org.eehouse.android.xw4.DlgDelegate.OkOnlyBuilder; import org.eehouse.android.xw4.loc.LocUtils; public class PrefsActivity extends PreferenceActivity @@ -100,14 +101,14 @@ public class PrefsActivity extends PreferenceActivity m_dlgt.prepareDialog( DlgID.values()[id], dialog ); } - public void showOKOnlyDialog( int msgID ) + public OkOnlyBuilder makeOkOnlyBuilder( int msgId ) { - m_dlgt.showOKOnlyDialog( msgID ); + return m_dlgt.makeOkOnlyBuilder( msgId ); } - public void showOKOnlyDialog( String msg ) + public OkOnlyBuilder makeOkOnlyBuilder( String msg ) { - m_dlgt.showOKOnlyDialog( msg ); + return m_dlgt.makeOkOnlyBuilder( msg ); } public NotAgainBuilder makeNotAgainBuilder(int msgId, int key, Action action) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsDelegate.java index 6d33b4afc..39ce38aae 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/PrefsDelegate.java @@ -232,7 +232,7 @@ public class PrefsDelegate extends DelegateBase RelayService.enabledChanged( m_activity ); break; case R.string.key_enable_dualpane: - showOKOnlyDialog( R.string.after_restart ); + makeOkOnlyBuilder( R.string.after_restart ).show(); break; default: Assert.fail(); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java index ab1a7786b..1a0cd69f5 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/StudyListDelegate.java @@ -372,7 +372,7 @@ public class StudyListDelegate extends ListDelegateBase } if ( null != msg ) { - dlg.showOKOnlyDialog( msg ); + dlg.makeOkOnlyBuilder( msg ).show(); } } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConnAddrPreference.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConnAddrPreference.java index 4481c46b2..2c3a76a81 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConnAddrPreference.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWConnAddrPreference.java @@ -101,7 +101,9 @@ public class XWConnAddrPreference extends DialogPreference { new ConnViaViewLayout.SetEmptyWarner() { public void typeSetEmpty() { PrefsActivity activity = (PrefsActivity)m_context; - activity.showOKOnlyDialog( R.string.warn_no_comms ); + activity + .makeOkOnlyBuilder( R.string.warn_no_comms ) + .show(); } }, activity ); } diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java index 043a83caf..f59ce2590 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/loc/LocItemEditDelegate.java @@ -161,7 +161,7 @@ public class LocItemEditDelegate extends DelegateBase implements TextWatcher { ok = m_keyFmts.equals( getFmtSet( cs.toString(), null ) ); if ( !ok ) { - showOKOnlyDialog( R.string.loc_fmts_mismatch ); + makeOkOnlyBuilder( R.string.loc_fmts_mismatch ).show(); } } return ok;