mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
do a builder for okonly alerts too
Might be getting carried away with this, but I like having all common dialogs built the same way.
This commit is contained in:
parent
1a56854d41
commit
232f5e1a15
12 changed files with 63 additions and 55 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -372,7 +372,7 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
}
|
||||
|
||||
if ( null != msg ) {
|
||||
dlg.showOKOnlyDialog( msg );
|
||||
dlg.makeOkOnlyBuilder( msg ).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue