mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-09 05:24:44 +01:00
simplify dialogs
Get rid of subclasses, since there's not the clear inheritance structure I imagined. Any dialog type might want a not-again checkbox, or to have a third button offer an unexpected option. This is a big change that needs some bake time.
This commit is contained in:
parent
9ae39ffe28
commit
c8b587c29b
11 changed files with 187 additions and 222 deletions
|
@ -2488,7 +2488,7 @@ public class BoardDelegate extends DelegateBase
|
||||||
boolean banned = Perm.SEND_SMS.isBanned(m_activity);
|
boolean banned = Perm.SEND_SMS.isBanned(m_activity);
|
||||||
int explID = banned
|
int explID = banned
|
||||||
? R.string.banned_nbs_perms : R.string.missing_sms_perms;
|
? R.string.banned_nbs_perms : R.string.missing_sms_perms;
|
||||||
DlgDelegate.ConfirmThenBuilder builder =
|
DlgDelegate.Builder builder =
|
||||||
makeConfirmThenBuilder( explID, Action.DROP_SMS_ACTION );
|
makeConfirmThenBuilder( explID, Action.DROP_SMS_ACTION );
|
||||||
if ( banned ) {
|
if ( banned ) {
|
||||||
builder.setActionPair( Action.PERMS_BANNED_INFO,
|
builder.setActionPair( Action.PERMS_BANNED_INFO,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*- compile-command: "find-and-gradle.sh inXw4dDebug"; -*- */
|
/* -*- compile-command: "find-and-gradle.sh inXw4dDebug"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 by Eric House (xwords@eehouse.org). All rights reserved.
|
* Copyright 2017 - 2020 by Eric House (xwords@eehouse.org). All rights
|
||||||
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
@ -29,6 +30,7 @@ import org.eehouse.android.xw4.DlgDelegate.ActionPair;
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class ConfirmThenAlert extends DlgDelegateAlert {
|
public class ConfirmThenAlert extends DlgDelegateAlert {
|
||||||
|
private static final String TAG = ConfirmThenAlert.class.getSimpleName();
|
||||||
|
|
||||||
public static ConfirmThenAlert newInstance( DlgState state )
|
public static ConfirmThenAlert newInstance( DlgState state )
|
||||||
{
|
{
|
||||||
|
@ -46,8 +48,11 @@ public class ConfirmThenAlert extends DlgDelegateAlert {
|
||||||
NotAgainView naView = addNAView( state, builder );
|
NotAgainView naView = addNAView( state, builder );
|
||||||
OnClickListener lstnr = mkCallbackClickListener( naView );
|
OnClickListener lstnr = mkCallbackClickListener( naView );
|
||||||
|
|
||||||
builder.setTitle( state.m_titleId == 0 ? R.string.query_title : state.m_titleId )
|
if ( 0 != state.m_titleId ) {
|
||||||
.setPositiveButton( state.m_posButton, lstnr )
|
builder.setTitle( state.m_titleId );
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setPositiveButton( state.m_posButton, lstnr )
|
||||||
.setNegativeButton( state.m_negButton, lstnr );
|
.setNegativeButton( state.m_negButton, lstnr );
|
||||||
|
|
||||||
if ( null != state.m_pair ) {
|
if ( null != state.m_pair ) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class ConnViaViewLayout extends LinearLayout {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DlgDelegate.DlgDelegateBuilder builder = 0 != keyID
|
DlgDelegate.Builder builder = 0 != keyID
|
||||||
? m_dlgDlgt.makeNotAgainBuilder( msgID, keyID )
|
? m_dlgDlgt.makeNotAgainBuilder( msgID, keyID )
|
||||||
: m_dlgDlgt.makeOkOnlyBuilder( msgID )
|
: m_dlgDlgt.makeOkOnlyBuilder( msgID )
|
||||||
.setActionPair( Action.PERMS_BANNED_INFO,
|
.setActionPair( Action.PERMS_BANNED_INFO,
|
||||||
|
|
|
@ -41,10 +41,8 @@ import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.ConfirmThenBuilder;
|
import org.eehouse.android.xw4.DlgDelegate.Builder;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.DlgClickNotify;
|
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.MultiService.MultiEvent;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||||
|
@ -521,33 +519,33 @@ public class DelegateBase implements DlgClickNotify,
|
||||||
return LocUtils.makeAlertBuilder( m_activity );
|
return LocUtils.makeAlertBuilder( m_activity );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder
|
public Builder
|
||||||
makeNotAgainBuilder( String msg, int key, Action action )
|
makeNotAgainBuilder( String msg, int key, Action action )
|
||||||
{
|
{
|
||||||
return m_dlgDelegate.makeNotAgainBuilder( msg, key, action );
|
return m_dlgDelegate.makeNotAgainBuilder( msg, key, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder
|
public Builder
|
||||||
makeNotAgainBuilder( int msgId, int key, Action action )
|
makeNotAgainBuilder( int msgId, int key, Action action )
|
||||||
{
|
{
|
||||||
return m_dlgDelegate.makeNotAgainBuilder( msgId, key, action );
|
return m_dlgDelegate.makeNotAgainBuilder( msgId, key, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( String msg, int key )
|
public Builder makeNotAgainBuilder( String msg, int key )
|
||||||
{
|
{
|
||||||
return m_dlgDelegate.makeNotAgainBuilder( msg, key );
|
return m_dlgDelegate.makeNotAgainBuilder( msg, key );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( int msgId, int key )
|
public Builder makeNotAgainBuilder( int msgID, int key )
|
||||||
{
|
{
|
||||||
return m_dlgDelegate.makeNotAgainBuilder( msgId, key );
|
return m_dlgDelegate.makeNotAgainBuilder( msgID, key );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfirmThenBuilder makeConfirmThenBuilder( String msg, Action action ) {
|
public Builder makeConfirmThenBuilder( String msg, Action action ) {
|
||||||
return m_dlgDelegate.makeConfirmThenBuilder( msg, action );
|
return m_dlgDelegate.makeConfirmThenBuilder( msg, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfirmThenBuilder makeConfirmThenBuilder( int msgId, Action action ) {
|
public Builder makeConfirmThenBuilder( int msgId, Action action ) {
|
||||||
return m_dlgDelegate.makeConfirmThenBuilder( msgId, action );
|
return m_dlgDelegate.makeConfirmThenBuilder( msgId, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -578,12 +576,12 @@ public class DelegateBase implements DlgClickNotify,
|
||||||
m_dlgDelegate.showInviteChoicesThen( action, info );
|
m_dlgDelegate.showInviteChoicesThen( action, info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OkOnlyBuilder makeOkOnlyBuilder( int msgId )
|
public Builder makeOkOnlyBuilder( int msgID )
|
||||||
{
|
{
|
||||||
return m_dlgDelegate.makeOkOnlyBuilder( msgId );
|
return m_dlgDelegate.makeOkOnlyBuilder( msgID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OkOnlyBuilder makeOkOnlyBuilder( String msg )
|
public Builder makeOkOnlyBuilder( String msg )
|
||||||
{
|
{
|
||||||
return m_dlgDelegate.makeOkOnlyBuilder( msg );
|
return m_dlgDelegate.makeOkOnlyBuilder( msg );
|
||||||
}
|
}
|
||||||
|
@ -722,12 +720,10 @@ public class DelegateBase implements DlgClickNotify,
|
||||||
final int key = notAgainKey;
|
final int key = notAgainKey;
|
||||||
runOnUiThread( new Runnable() {
|
runOnUiThread( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
DlgDelegate.DlgDelegateBuilder builder;
|
Builder builder = 0 == key
|
||||||
if ( 0 == key ) {
|
? makeOkOnlyBuilder( msg )
|
||||||
builder = makeOkOnlyBuilder( msg );
|
: makeNotAgainBuilder( msg, key )
|
||||||
} else {
|
;
|
||||||
builder = makeNotAgainBuilder( msg, key );
|
|
||||||
}
|
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -154,139 +154,173 @@ public class DlgDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class DlgDelegateBuilder {
|
public class Builder {
|
||||||
protected String m_msgString;
|
private final DlgState mState;
|
||||||
protected int m_prefsNAKey;
|
|
||||||
protected Action m_onNA;
|
|
||||||
protected int m_posButton = android.R.string.ok;
|
|
||||||
protected int m_negButton = android.R.string.cancel;
|
|
||||||
protected Action m_action;
|
|
||||||
protected Object[] m_params;
|
|
||||||
protected int m_titleId = 0;
|
|
||||||
protected ActionPair m_actionPair;
|
|
||||||
|
|
||||||
public DlgDelegateBuilder( String msg, Action action )
|
Builder( DlgID dlgID ) {
|
||||||
{ m_msgString = msg; m_action = action; }
|
mState = new DlgState( dlgID )
|
||||||
|
.setPosButton( android.R.string.ok ) // default
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder( int msgId, Action action )
|
Builder setMessage( String msg )
|
||||||
{ this( getString(msgId), action );}
|
{
|
||||||
|
mState.setMsg( msg );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setAction( Action action )
|
Builder setMessageID( int msgID )
|
||||||
{ m_action = action; return this; }
|
{
|
||||||
|
mState.setMsg( getString( msgID ) );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setNAKey( int keyId )
|
Builder setActionPair( Action action, int strID )
|
||||||
{ m_prefsNAKey = keyId; return this; }
|
{
|
||||||
|
mState.setActionPair( new ActionPair( action, strID ) );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setOnNA( Action onNA )
|
Builder setAction( Action action )
|
||||||
{ m_onNA = onNA; return this; }
|
{
|
||||||
|
mState.setAction( action );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setPosButton( int id )
|
Builder setPosButton( int strID )
|
||||||
{ m_posButton = id; return this; }
|
{
|
||||||
|
mState.setPosButton( strID );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setNegButton( int id )
|
Builder setNegButton( int strID )
|
||||||
{ m_negButton = id; return this; }
|
{
|
||||||
|
mState.setNegButton( strID );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setParams( Object... params )
|
Builder setTitle( int strID )
|
||||||
{ m_params = params; return this; }
|
{
|
||||||
|
mState.setTitle( strID );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setTitle( int titleId )
|
Builder setParams( Object... params )
|
||||||
{ m_titleId = titleId; return this; }
|
{
|
||||||
|
mState.setParams( params );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setActionPair( ActionPair pr )
|
Builder setNAKey( int keyID )
|
||||||
{ m_actionPair = pr; return this; }
|
{
|
||||||
|
mState.setPrefsKey( keyID );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public DlgDelegateBuilder setActionPair( Action actn, int id )
|
Builder setOnNA( Action onNAAction )
|
||||||
{ return setActionPair( new ActionPair( actn, id ) ); }
|
{
|
||||||
|
mState.setOnNA( onNAAction );
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
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 ); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show()
|
public void show()
|
||||||
{
|
{
|
||||||
showOKOnlyDialogThen( m_msgString, m_action, m_actionPair,
|
int naKey = mState.m_prefsNAKey;
|
||||||
m_params, m_titleId );
|
final Action action = mState.m_action;
|
||||||
|
// Log.d( TAG, "show(): key: %d; action: %s", naKey, action );
|
||||||
|
|
||||||
|
if ( 0 == naKey || ! XWPrefs.getPrefsBoolean( m_activity, naKey, false ) ) {
|
||||||
|
m_dlgt.show( mState );
|
||||||
|
} else if ( Action.SKIP_CALLBACK != action ) {
|
||||||
|
post( new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Log.d( TAG, "calling onPosButton()" );
|
||||||
|
XWActivity xwact = (XWActivity)m_activity;
|
||||||
|
xwact.onPosButton( action, mState.m_params );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConfirmThenBuilder extends DlgDelegateBuilder {
|
|
||||||
public ConfirmThenBuilder(String msg, Action action) {super(msg, action);}
|
|
||||||
public ConfirmThenBuilder(int msgId, Action action) {super(msgId, action);}
|
|
||||||
|
|
||||||
@Override
|
public Builder makeOkOnlyBuilder( String msg )
|
||||||
public void show()
|
|
||||||
{
|
|
||||||
showConfirmThen( m_prefsNAKey, m_onNA, m_msgString, m_posButton,
|
|
||||||
m_negButton, m_action, m_titleId, m_actionPair,
|
|
||||||
m_params );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NotAgainBuilder extends DlgDelegateBuilder {
|
|
||||||
public NotAgainBuilder(String msg, int key, Action action)
|
|
||||||
{ super(msg, action); setNAKey( key ); }
|
|
||||||
|
|
||||||
public NotAgainBuilder(int msgId, int key, Action action)
|
|
||||||
{ super(msgId, action); m_prefsNAKey = key; }
|
|
||||||
|
|
||||||
public NotAgainBuilder( String msg, int key )
|
|
||||||
{ super( msg, Action.SKIP_CALLBACK ); m_prefsNAKey = key; }
|
|
||||||
|
|
||||||
public NotAgainBuilder( int msgId, int key )
|
|
||||||
{ super( msgId, Action.SKIP_CALLBACK ); m_prefsNAKey = key; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void show()
|
|
||||||
{
|
|
||||||
showNotAgainDlgThen( m_msgString, m_prefsNAKey,
|
|
||||||
m_action, m_actionPair,
|
|
||||||
m_params );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public OkOnlyBuilder makeOkOnlyBuilder( String msg )
|
|
||||||
{
|
{
|
||||||
return new OkOnlyBuilder( msg );
|
// return new OkOnlyBuilder( msg );
|
||||||
}
|
|
||||||
public OkOnlyBuilder makeOkOnlyBuilder( int msgId )
|
Builder builder = new Builder( DlgID.DIALOG_OKONLY )
|
||||||
{
|
.setMessage( msg )
|
||||||
return new OkOnlyBuilder( msgId );
|
;
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfirmThenBuilder makeConfirmThenBuilder( String msg, Action action )
|
public Builder makeOkOnlyBuilder( int msgID )
|
||||||
{
|
{
|
||||||
return new ConfirmThenBuilder( msg, action );
|
Builder builder = new Builder( DlgID.DIALOG_OKONLY )
|
||||||
|
.setMessageID( msgID )
|
||||||
|
;
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfirmThenBuilder makeConfirmThenBuilder(int msgId, Action action)
|
private Builder makeConfirmThenBuilder( Action action )
|
||||||
{
|
{
|
||||||
return new ConfirmThenBuilder( msgId, action );
|
return new Builder( DlgID.CONFIRM_THEN )
|
||||||
|
.setAction( action )
|
||||||
|
.setNegButton( android.R.string.cancel )
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( int msgId, int key,
|
public Builder makeConfirmThenBuilder( String msg, Action action )
|
||||||
Action action )
|
|
||||||
{
|
{
|
||||||
return new NotAgainBuilder( msgId, key, action );
|
return makeConfirmThenBuilder( action )
|
||||||
|
.setMessage( msg )
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( String msg, int key,
|
public Builder makeConfirmThenBuilder( int msgID, Action action )
|
||||||
Action action )
|
|
||||||
{
|
{
|
||||||
return new NotAgainBuilder( msg, key, action );
|
return makeConfirmThenBuilder( action )
|
||||||
|
.setMessageID( msgID )
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( String msg, int key )
|
private Builder makeNotAgainBuilder( int key )
|
||||||
{
|
{
|
||||||
return new NotAgainBuilder( msg, key );
|
return new Builder( DlgID.DIALOG_NOTAGAIN )
|
||||||
|
.setNAKey( key )
|
||||||
|
.setAction( Action.SKIP_CALLBACK )
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( int msgId, int key ) {
|
public Builder makeNotAgainBuilder( String msg, int key, Action action )
|
||||||
return new NotAgainBuilder( msgId, key );
|
{
|
||||||
|
return makeNotAgainBuilder( key )
|
||||||
|
.setMessage( msg )
|
||||||
|
.setAction( action )
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder makeNotAgainBuilder( int msgID, int key, Action action )
|
||||||
|
{
|
||||||
|
return makeNotAgainBuilder( key )
|
||||||
|
.setMessageID( msgID )
|
||||||
|
.setAction( action )
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder makeNotAgainBuilder( String msg, int key )
|
||||||
|
{
|
||||||
|
return makeNotAgainBuilder( key )
|
||||||
|
.setMessage( msg )
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder makeNotAgainBuilder( int msgID, int key )
|
||||||
|
{
|
||||||
|
return makeNotAgainBuilder( key )
|
||||||
|
.setMessageID( msgID )
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int SMS_BTN = AlertDialog.BUTTON_POSITIVE;
|
public static final int SMS_BTN = AlertDialog.BUTTON_POSITIVE;
|
||||||
|
@ -309,11 +343,10 @@ public class DlgDelegate {
|
||||||
void inviteChoiceMade( Action action, InviteMeans means, Object... params );
|
void inviteChoiceMade( Action action, InviteMeans means, Object... params );
|
||||||
}
|
}
|
||||||
public interface HasDlgDelegate {
|
public interface HasDlgDelegate {
|
||||||
OkOnlyBuilder makeOkOnlyBuilder( int msgID );
|
Builder makeOkOnlyBuilder( int msgID );
|
||||||
OkOnlyBuilder makeOkOnlyBuilder( String msg );
|
Builder makeOkOnlyBuilder( String msg );
|
||||||
NotAgainBuilder makeNotAgainBuilder( int msgID, int prefsKey,
|
Builder makeNotAgainBuilder( int msgID, int prefsKey, Action action );
|
||||||
Action action );
|
Builder makeNotAgainBuilder( int msgID, int prefsKey );
|
||||||
NotAgainBuilder makeNotAgainBuilder( int msgID, int prefsKey );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Activity m_activity;
|
private Activity m_activity;
|
||||||
|
@ -337,19 +370,6 @@ public class DlgDelegate {
|
||||||
stopProgress();
|
stopProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOKOnlyDialogThen( String msg, Action action,
|
|
||||||
ActionPair more, Object[] params,
|
|
||||||
int titleId )
|
|
||||||
{
|
|
||||||
DlgState state = new DlgState( DlgID.DIALOG_OKONLY )
|
|
||||||
.setMsg( msg )
|
|
||||||
.setParams( params )
|
|
||||||
.setTitle( titleId )
|
|
||||||
.setActionPair( more )
|
|
||||||
.setAction(action);
|
|
||||||
m_dlgt.show( state );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Puts up alert asking to choose a reason to enable SMS, and on dismiss
|
// Puts up alert asking to choose a reason to enable SMS, and on dismiss
|
||||||
// calls onPosButton/onNegButton with the action and in params a Boolean
|
// calls onPosButton/onNegButton with the action and in params a Boolean
|
||||||
// indicating whether enabling is now ok.
|
// indicating whether enabling is now ok.
|
||||||
|
@ -361,62 +381,6 @@ public class DlgDelegate {
|
||||||
m_dlgt.show( state );
|
m_dlgt.show( state );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showNotAgainDlgThen( String msg, int prefsKey,
|
|
||||||
final Action action, ActionPair more,
|
|
||||||
final Object[] params )
|
|
||||||
{
|
|
||||||
if ( 0 != prefsKey
|
|
||||||
&& XWPrefs.getPrefsBoolean( m_activity, prefsKey, false ) ) {
|
|
||||||
// If it's set, do the action without bothering with the
|
|
||||||
// dialog
|
|
||||||
if ( Action.SKIP_CALLBACK != action ) {
|
|
||||||
post( new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
XWActivity xwact = (XWActivity)m_activity;
|
|
||||||
xwact.onPosButton( action, params );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DlgState state = new DlgState( DlgID.DIALOG_NOTAGAIN )
|
|
||||||
.setMsg( msg)
|
|
||||||
.setPrefsKey( prefsKey )
|
|
||||||
.setAction( action )
|
|
||||||
.setActionPair( more )
|
|
||||||
.setParams( params );
|
|
||||||
m_dlgt.show( state );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showConfirmThen( int nakey, Action onNA, String msg,
|
|
||||||
int posButton, int negButton,
|
|
||||||
final Action action, int titleId,
|
|
||||||
ActionPair more, final Object[] params )
|
|
||||||
{
|
|
||||||
if ( 0 == nakey ||
|
|
||||||
! XWPrefs.getPrefsBoolean( m_activity, nakey, false ) ) {
|
|
||||||
DlgState state = new DlgState( DlgID.CONFIRM_THEN )
|
|
||||||
.setOnNA( onNA )
|
|
||||||
.setMsg( msg )
|
|
||||||
.setPosButton( posButton )
|
|
||||||
.setNegButton( negButton )
|
|
||||||
.setAction( action )
|
|
||||||
.setTitle( titleId )
|
|
||||||
.setActionPair( more )
|
|
||||||
.setParams( params )
|
|
||||||
.setPrefsKey( nakey )
|
|
||||||
;
|
|
||||||
m_dlgt.show( state );
|
|
||||||
} else if ( Action.SKIP_CALLBACK != action ) {
|
|
||||||
post( new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
XWActivity xwact = (XWActivity)m_activity;
|
|
||||||
xwact.onDismissed( action, params );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showInviteChoicesThen( final Action action,
|
public void showInviteChoicesThen( final Action action,
|
||||||
SentInvitesInfo info )
|
SentInvitesInfo info )
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,6 +89,10 @@ abstract class DlgDelegateAlert extends XWDialogFragment {
|
||||||
|
|
||||||
AlertDialog.Builder builder = LocUtils.makeAlertBuilder( context );
|
AlertDialog.Builder builder = LocUtils.makeAlertBuilder( context );
|
||||||
|
|
||||||
|
if ( 0 != state.m_titleId ) {
|
||||||
|
builder.setTitle( state.m_titleId );
|
||||||
|
}
|
||||||
|
|
||||||
populateBuilder( context, state, builder );
|
populateBuilder( context, state, builder );
|
||||||
|
|
||||||
return create( builder );
|
return create( builder );
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class DlgState implements Parcelable {
|
||||||
|
|
||||||
private void testCanParcelize()
|
private void testCanParcelize()
|
||||||
{
|
{
|
||||||
if (BuildConfig.DEBUG) {
|
if ( BuildConfig.DEBUG ) {
|
||||||
Parcel parcel = Parcel.obtain();
|
Parcel parcel = Parcel.obtain();
|
||||||
writeToParcel(parcel, 0);
|
writeToParcel(parcel, 0);
|
||||||
|
|
||||||
|
|
|
@ -2438,7 +2438,7 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
boolean handled = false;
|
boolean handled = false;
|
||||||
String msg = intent.getStringExtra( ALERT_MSG );
|
String msg = intent.getStringExtra( ALERT_MSG );
|
||||||
if ( null != msg ) {
|
if ( null != msg ) {
|
||||||
DlgDelegate.DlgDelegateBuilder builder =
|
DlgDelegate.Builder builder =
|
||||||
makeOkOnlyBuilder( msg );
|
makeOkOnlyBuilder( msg );
|
||||||
if ( intent.getBooleanExtra( WITH_EMAIL, false ) ) {
|
if ( intent.getBooleanExtra( WITH_EMAIL, false ) ) {
|
||||||
builder.setActionPair( Action.SEND_EMAIL,
|
builder.setActionPair( Action.SEND_EMAIL,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* -*- compile-command: "find-and-gradle.sh inXw4dDebug"; -*- */
|
/* -*- compile-command: "find-and-gradle.sh inXw4dDeb"; -*- */
|
||||||
/*
|
/*
|
||||||
* Copyright 2017 by Eric House (xwords@eehouse.org). All rights reserved.
|
* Copyright 2017 - 2020 by Eric House (xwords@eehouse.org). All rights
|
||||||
|
* reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
@ -40,9 +41,8 @@ public class OkOnlyAlert extends DlgDelegateAlert {
|
||||||
public void populateBuilder( Context context, DlgState state,
|
public void populateBuilder( Context context, DlgState state,
|
||||||
AlertDialog.Builder builder )
|
AlertDialog.Builder builder )
|
||||||
{
|
{
|
||||||
builder.setTitle( state.m_titleId == 0 ? R.string.info_title : state.m_titleId )
|
builder.setMessage( state.m_msg )
|
||||||
.setMessage( state.m_msg )
|
.setPositiveButton( state.m_posButton, null )
|
||||||
.setPositiveButton( android.R.string.ok, null )
|
|
||||||
;
|
;
|
||||||
|
|
||||||
ActionPair pair = state.m_pair;
|
ActionPair pair = state.m_pair;
|
||||||
|
|
|
@ -26,11 +26,8 @@ import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceActivity;
|
import android.preference.PreferenceActivity;
|
||||||
|
|
||||||
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.ConfirmThenBuilder;
|
import org.eehouse.android.xw4.DlgDelegate.Builder;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.NotAgainBuilder;
|
|
||||||
import org.eehouse.android.xw4.DlgDelegate.OkOnlyBuilder;
|
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class PrefsActivity extends PreferenceActivity
|
public class PrefsActivity extends PreferenceActivity
|
||||||
|
@ -102,32 +99,32 @@ public class PrefsActivity extends PreferenceActivity
|
||||||
m_dlgt.onActivityResult( rc, resultCode, data );
|
m_dlgt.onActivityResult( rc, resultCode, data );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OkOnlyBuilder makeOkOnlyBuilder( int msgId )
|
public Builder makeOkOnlyBuilder( int msgID )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeOkOnlyBuilder( msgId );
|
return m_dlgt.makeOkOnlyBuilder( msgID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OkOnlyBuilder makeOkOnlyBuilder( String msg )
|
public Builder makeOkOnlyBuilder( String msg )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeOkOnlyBuilder( msg );
|
return m_dlgt.makeOkOnlyBuilder( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder(int msgId, int key, Action action)
|
public Builder makeNotAgainBuilder(int msgID, int key, Action action)
|
||||||
{
|
{
|
||||||
return m_dlgt.makeNotAgainBuilder( msgId, key, action );
|
return m_dlgt.makeNotAgainBuilder( msgID, key, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotAgainBuilder makeNotAgainBuilder( int msgId, int key )
|
public Builder makeNotAgainBuilder( int msgID, int key )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeNotAgainBuilder( msgId, key );
|
return m_dlgt.makeNotAgainBuilder( msgID, key );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfirmThenBuilder makeConfirmThenBuilder(String msg, Action action)
|
public Builder makeConfirmThenBuilder( String msg, Action action )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeConfirmThenBuilder( msg, action );
|
return m_dlgt.makeConfirmThenBuilder( msg, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfirmThenBuilder makeConfirmThenBuilder(int msgID, Action action)
|
public Builder makeConfirmThenBuilder( int msgID, Action action )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeConfirmThenBuilder( msgID, action );
|
return m_dlgt.makeConfirmThenBuilder( msgID, action );
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,23 +204,22 @@ public class XWActivity extends FragmentActivity
|
||||||
|
|
||||||
// This are a hack! I need some way to build fragment-based alerts from
|
// This are a hack! I need some way to build fragment-based alerts from
|
||||||
// inside fragment-based alerts.
|
// inside fragment-based alerts.
|
||||||
public DlgDelegate.NotAgainBuilder makeNotAgainBuilder( String msg, int keyId )
|
public DlgDelegate.Builder makeNotAgainBuilder( String msg, int keyID )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeNotAgainBuilder( msg, keyId );
|
return m_dlgt.makeNotAgainBuilder( msg, keyID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DlgDelegate.NotAgainBuilder makeNotAgainBuilder( int msgID, int keyId )
|
public DlgDelegate.Builder makeNotAgainBuilder( int msgID, int keyID )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeNotAgainBuilder( msgID, keyId );
|
return m_dlgt.makeNotAgainBuilder( msgID, keyID );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DlgDelegate.ConfirmThenBuilder makeConfirmThenBuilder( int msgID,
|
public DlgDelegate.Builder makeConfirmThenBuilder( int msgID, Action action )
|
||||||
Action action )
|
|
||||||
{
|
{
|
||||||
return m_dlgt.makeConfirmThenBuilder( msgID, action );
|
return m_dlgt.makeConfirmThenBuilder( msgID, action );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DlgDelegate.OkOnlyBuilder makeOkOnlyBuilder( int msgID )
|
public DlgDelegate.Builder makeOkOnlyBuilder( int msgID )
|
||||||
{
|
{
|
||||||
return m_dlgt.makeOkOnlyBuilder( msgID );
|
return m_dlgt.makeOkOnlyBuilder( msgID );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue