mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-29 10:26:36 +01:00
split DlgDelegate interface in three
replace dlgButtonClicked() with separate methods for positive and negative buttons and alert dismissal. I was making too many mistakes because the old method was getting called twice (e.g. for negative and then dismissal) and I hadn't needed to differentiate until adding that new Action. There should be no behavior change with this, but it's pervasive and replaces some spaghetti.
This commit is contained in:
parent
dc7ed9bfb2
commit
86e7142687
15 changed files with 473 additions and 475 deletions
|
@ -168,16 +168,14 @@ public class BTInviteDelegate extends InviteDelegate {
|
|||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
switch( action ) {
|
||||
case OPEN_BT_PREFS_ACTION:
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
BTService.openBTSettings( m_activity );
|
||||
}
|
||||
BTService.openBTSettings( m_activity );
|
||||
break;
|
||||
default:
|
||||
super.dlgButtonClicked( action, which, params );
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -909,7 +909,7 @@ public class BoardDelegate extends DelegateBase
|
|||
Action.COMMIT_ACTION )
|
||||
.show();
|
||||
} else {
|
||||
dlgButtonClicked( Action.COMMIT_ACTION, AlertDialog.BUTTON_POSITIVE, null );
|
||||
onPosButton( Action.COMMIT_ACTION, null );
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1026,128 +1026,133 @@ public class BoardDelegate extends DelegateBase
|
|||
//////////////////////////////////////////////////
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which,
|
||||
final Object[] params )
|
||||
{
|
||||
boolean handled = false;
|
||||
boolean positive = AlertDialog.BUTTON_POSITIVE == which;
|
||||
DbgUtils.logd( TAG, "BoardDelegate.dlgButtonClicked(%s, %b)",
|
||||
action.toString(), positive );
|
||||
|
||||
if ( Action.ENABLE_RELAY_DO_OR == action ) {
|
||||
handled = true;
|
||||
if ( positive ) {
|
||||
RelayService.setEnabled( m_activity, true );
|
||||
} else if ( AlertDialog.BUTTON_NEGATIVE == which ) {
|
||||
m_dropOnDismiss = true;
|
||||
} else if ( DlgDelegate.DISMISS_BUTTON == which && m_dropOnDismiss ) {
|
||||
@Override
|
||||
public void onPosButton( Action action, final Object[] params )
|
||||
{
|
||||
JNICmd cmd = JNICmd.CMD_NONE;
|
||||
switch ( action ) {
|
||||
case ENABLE_RELAY_DO_OR:
|
||||
RelayService.setEnabled( m_activity, true );
|
||||
break;
|
||||
case RETRY_PHONE_STATE_ACTION:
|
||||
Action stateAction = (Action)params[0];
|
||||
DBUtils.SentInvitesInfo info = (DBUtils.SentInvitesInfo)params[1];
|
||||
callInviteChoices( stateAction, info, false );
|
||||
break;
|
||||
|
||||
case UNDO_LAST_ACTION:
|
||||
cmd = JNICmd.CMD_UNDO_LAST;
|
||||
break;
|
||||
case SYNC_ACTION:
|
||||
doSyncMenuitem();
|
||||
break;
|
||||
case SMS_CONFIG_ACTION:
|
||||
Utils.launchSettings( m_activity );
|
||||
break;
|
||||
case COMMIT_ACTION:
|
||||
cmd = JNICmd.CMD_COMMIT;
|
||||
break;
|
||||
case SHOW_EXPL_ACTION:
|
||||
showToast( m_toastStr );
|
||||
m_toastStr = null;
|
||||
break;
|
||||
case BUTTON_BROWSEALL_ACTION:
|
||||
case BUTTON_BROWSE_ACTION:
|
||||
String curDict = m_gi.dictName( m_view.getCurPlayer() );
|
||||
View button = m_toolbar.getButtonFor( Buttons.BUTTON_BROWSE_DICT );
|
||||
if ( Action.BUTTON_BROWSEALL_ACTION == action &&
|
||||
DictsDelegate.handleDictsPopup( getDelegator(), button,
|
||||
curDict, m_gi.dictLang ) ){
|
||||
break;
|
||||
}
|
||||
DictBrowseDelegate.launch( getDelegator(), curDict );
|
||||
break;
|
||||
case PREV_HINT_ACTION:
|
||||
cmd = JNICmd.CMD_PREV_HINT;
|
||||
break;
|
||||
case NEXT_HINT_ACTION:
|
||||
cmd = JNICmd.CMD_NEXT_HINT;
|
||||
break;
|
||||
case JUGGLE_ACTION:
|
||||
cmd = JNICmd.CMD_JUGGLE;
|
||||
break;
|
||||
case FLIP_ACTION:
|
||||
cmd = JNICmd.CMD_FLIP;
|
||||
break;
|
||||
case UNDO_ACTION:
|
||||
cmd = JNICmd.CMD_UNDO_CUR;
|
||||
break;
|
||||
case VALUES_ACTION:
|
||||
cmd = JNICmd.CMD_VALUES;
|
||||
break;
|
||||
case CHAT_ACTION:
|
||||
startChatActivity();
|
||||
break;
|
||||
case START_TRADE_ACTION:
|
||||
showToast( R.string.entering_trade );
|
||||
cmd = JNICmd.CMD_TRADE;
|
||||
break;
|
||||
case LOOKUP_ACTION:
|
||||
launchLookup( m_words, m_gi.dictLang );
|
||||
break;
|
||||
case NFC_TO_SELF:
|
||||
GamesListDelegate.sendNFCToSelf( m_activity, makeNFCMessage() );
|
||||
break;
|
||||
case DROP_RELAY_ACTION:
|
||||
dropConViaAndRestart(CommsConnType.COMMS_CONN_RELAY);
|
||||
break;
|
||||
case DROP_SMS_ACTION:
|
||||
dropConViaAndRestart(CommsConnType.COMMS_CONN_SMS);
|
||||
break;
|
||||
|
||||
case DELETE_AND_EXIT:
|
||||
deleteAndClose();
|
||||
break;
|
||||
|
||||
case ENABLE_SMS_DO:
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
retrySMSInvites( params );
|
||||
}
|
||||
} );
|
||||
// FALLTHRU: so super gets called, before
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
|
||||
if ( JNICmd.CMD_NONE != cmd ) {
|
||||
handleViaThread( cmd );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegButton( Action action, Object[] params )
|
||||
{
|
||||
switch ( action ) {
|
||||
case ENABLE_RELAY_DO_OR:
|
||||
m_dropOnDismiss = true;
|
||||
break;
|
||||
default:
|
||||
super.onNegButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissed( Action action, Object[] params )
|
||||
{
|
||||
switch ( action ) {
|
||||
case ENABLE_RELAY_DO_OR:
|
||||
if ( m_dropOnDismiss ) {
|
||||
postDelayed( new Runnable() {
|
||||
public void run() {
|
||||
askDropRelay();
|
||||
}
|
||||
}, 10 );
|
||||
}
|
||||
} else if ( Action.RETRY_PHONE_STATE_ACTION == action ) {
|
||||
Action stateAction = (Action)params[0];
|
||||
DBUtils.SentInvitesInfo info = (DBUtils.SentInvitesInfo)params[1];
|
||||
callInviteChoices( stateAction, info, false );
|
||||
} else if ( positive ) {
|
||||
handled = true;
|
||||
JNICmd cmd = JNICmd.CMD_NONE;
|
||||
switch ( action ) {
|
||||
case UNDO_LAST_ACTION:
|
||||
cmd = JNICmd.CMD_UNDO_LAST;
|
||||
break;
|
||||
case SYNC_ACTION:
|
||||
doSyncMenuitem();
|
||||
break;
|
||||
case SMS_CONFIG_ACTION:
|
||||
Utils.launchSettings( m_activity );
|
||||
break;
|
||||
case COMMIT_ACTION:
|
||||
cmd = JNICmd.CMD_COMMIT;
|
||||
break;
|
||||
case SHOW_EXPL_ACTION:
|
||||
showToast( m_toastStr );
|
||||
m_toastStr = null;
|
||||
break;
|
||||
case BUTTON_BROWSEALL_ACTION:
|
||||
case BUTTON_BROWSE_ACTION:
|
||||
String curDict = m_gi.dictName( m_view.getCurPlayer() );
|
||||
View button = m_toolbar.getButtonFor( Buttons.BUTTON_BROWSE_DICT );
|
||||
if ( Action.BUTTON_BROWSEALL_ACTION == action &&
|
||||
DictsDelegate.handleDictsPopup( getDelegator(), button,
|
||||
curDict, m_gi.dictLang ) ){
|
||||
break;
|
||||
}
|
||||
DictBrowseDelegate.launch( getDelegator(), curDict );
|
||||
break;
|
||||
case PREV_HINT_ACTION:
|
||||
cmd = JNICmd.CMD_PREV_HINT;
|
||||
break;
|
||||
case NEXT_HINT_ACTION:
|
||||
cmd = JNICmd.CMD_NEXT_HINT;
|
||||
break;
|
||||
case JUGGLE_ACTION:
|
||||
cmd = JNICmd.CMD_JUGGLE;
|
||||
break;
|
||||
case FLIP_ACTION:
|
||||
cmd = JNICmd.CMD_FLIP;
|
||||
break;
|
||||
case UNDO_ACTION:
|
||||
cmd = JNICmd.CMD_UNDO_CUR;
|
||||
break;
|
||||
case VALUES_ACTION:
|
||||
cmd = JNICmd.CMD_VALUES;
|
||||
break;
|
||||
case CHAT_ACTION:
|
||||
startChatActivity();
|
||||
break;
|
||||
case START_TRADE_ACTION:
|
||||
showToast( R.string.entering_trade );
|
||||
cmd = JNICmd.CMD_TRADE;
|
||||
break;
|
||||
case LOOKUP_ACTION:
|
||||
launchLookup( m_words, m_gi.dictLang );
|
||||
break;
|
||||
case NFC_TO_SELF:
|
||||
GamesListDelegate.sendNFCToSelf( m_activity, makeNFCMessage() );
|
||||
break;
|
||||
case DROP_RELAY_ACTION:
|
||||
dropConViaAndRestart(CommsConnType.COMMS_CONN_RELAY);
|
||||
break;
|
||||
case DROP_SMS_ACTION:
|
||||
dropConViaAndRestart(CommsConnType.COMMS_CONN_SMS);
|
||||
break;
|
||||
|
||||
case DELETE_AND_EXIT:
|
||||
deleteAndClose();
|
||||
break;
|
||||
|
||||
case ENABLE_SMS_DO:
|
||||
handled = false; // so super gets called, before
|
||||
// retrySMSInvites
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
retrySMSInvites( params );
|
||||
}
|
||||
} );
|
||||
break;
|
||||
|
||||
default:
|
||||
handled = false;
|
||||
}
|
||||
|
||||
if ( JNICmd.CMD_NONE != cmd ) {
|
||||
handleViaThread( cmd );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ( !handled ) {
|
||||
super.dlgButtonClicked( action, which, params );
|
||||
}
|
||||
} // dlgButtonClicked
|
||||
}
|
||||
|
||||
public void inviteChoiceMade( Action action, InviteMeans means,
|
||||
Object[] params )
|
||||
|
@ -1628,8 +1633,7 @@ public class BoardDelegate extends DelegateBase
|
|||
DbgUtils.logi( TAG, "handleConndMessage(): toastStr: %s", toastStr );
|
||||
m_toastStr = toastStr;
|
||||
if ( naMsg == 0 ) {
|
||||
dlgButtonClicked( Action.SHOW_EXPL_ACTION,
|
||||
AlertDialog.BUTTON_POSITIVE, null );
|
||||
onPosButton( Action.SHOW_EXPL_ACTION, null );
|
||||
} else {
|
||||
makeNotAgainBuilder( naMsg, naKey, Action.SHOW_EXPL_ACTION )
|
||||
.show();
|
||||
|
|
|
@ -226,19 +226,17 @@ public class ChatDelegate extends DelegateBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
switch ( action ) {
|
||||
case CLEAR_ACTION:
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
DBUtils.clearChatHistory( m_activity, m_rowid );
|
||||
TableLayout layout =
|
||||
(TableLayout)findViewById( R.id.chat_history );
|
||||
layout.removeAllViews();
|
||||
}
|
||||
DBUtils.clearChatHistory( m_activity, m_rowid );
|
||||
TableLayout layout =
|
||||
(TableLayout)findViewById( R.id.chat_history );
|
||||
layout.removeAllViews();
|
||||
break;
|
||||
default:
|
||||
super.dlgButtonClicked( action, which, params );
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -636,59 +636,53 @@ public class DelegateBase implements DlgClickNotify,
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public void dlgButtonClicked( Action action, int button, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
boolean handled = false;
|
||||
if ( Action.PERMS_QUERY == action ) {
|
||||
Perms23.onGotPermsAction( button, params );
|
||||
handled = true;
|
||||
} else if ( AlertDialog.BUTTON_POSITIVE == button ) {
|
||||
switch( action ) {
|
||||
case ENABLE_SMS_ASK:
|
||||
showSMSEnableDialog( Action.ENABLE_SMS_DO, params );
|
||||
handled = true;
|
||||
break;
|
||||
case ENABLE_SMS_DO:
|
||||
XWPrefs.setSMSEnabled( m_activity, true );
|
||||
break;
|
||||
case ENABLE_BT_DO:
|
||||
BTService.enable();
|
||||
break;
|
||||
case ENABLE_RELAY_DO:
|
||||
RelayService.setEnabled( m_activity, true );
|
||||
handled = true;
|
||||
break;
|
||||
default:
|
||||
DbgUtils.logd( TAG, "unhandled action %s", action.toString() );
|
||||
Assert.fail();
|
||||
break;
|
||||
}
|
||||
DbgUtils.logd( TAG, "%s.posButtonClicked(%s)", getClass().getSimpleName(),
|
||||
action.toString() );
|
||||
switch( action ) {
|
||||
case ENABLE_SMS_ASK:
|
||||
showSMSEnableDialog( Action.ENABLE_SMS_DO, params );
|
||||
break;
|
||||
case ENABLE_SMS_DO:
|
||||
XWPrefs.setSMSEnabled( m_activity, true );
|
||||
break;
|
||||
case ENABLE_BT_DO:
|
||||
BTService.enable();
|
||||
break;
|
||||
case ENABLE_RELAY_DO:
|
||||
RelayService.setEnabled( m_activity, true );
|
||||
break;
|
||||
case PERMS_QUERY:
|
||||
Perms23.onGotPermsAction( true, params );
|
||||
break;
|
||||
default:
|
||||
DbgUtils.logd( TAG, "unhandled action %s", action.toString() );
|
||||
Assert.fail();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !handled && BuildConfig.DEBUG ) {
|
||||
String buttonName = null;
|
||||
switch( button ) {
|
||||
case AlertDialog.BUTTON_POSITIVE:
|
||||
buttonName = "positive";
|
||||
break;
|
||||
case AlertDialog.BUTTON_NEGATIVE:
|
||||
buttonName = "negative";
|
||||
break;
|
||||
case AlertDialog.BUTTON_NEUTRAL:
|
||||
buttonName = "neutral";
|
||||
break;
|
||||
case DlgDelegate.DISMISS_BUTTON:
|
||||
buttonName = "dismiss";
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
break;
|
||||
}
|
||||
DbgUtils.logi( TAG, "dlgButtonClicked(action=%s button=%s): UNHANDLED",
|
||||
action.toString(), buttonName );
|
||||
public void onNegButton( Action action, Object[] params )
|
||||
{
|
||||
// DbgUtils.logd( TAG, "%s.negButtonClicked(%s)", getClass().getSimpleName(),
|
||||
// action.toString() );
|
||||
switch ( action ) {
|
||||
case PERMS_QUERY:
|
||||
Perms23.onGotPermsAction( false, params );
|
||||
break;
|
||||
default:
|
||||
DbgUtils.logd( TAG, "onNegButton: unhandled action %s", action.toString() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onDismissed( Action action, Object[] params )
|
||||
{
|
||||
DbgUtils.logd( TAG, "%s.dlgDismissed(%s)", getClass().getSimpleName(),
|
||||
action.toString() );
|
||||
}
|
||||
|
||||
public void inviteChoiceMade( Action action, DlgClickNotify.InviteMeans means, Object[] params )
|
||||
{
|
||||
Assert.fail();
|
||||
|
|
|
@ -300,9 +300,9 @@ public class DictBrowseDelegate extends DelegateBase
|
|||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
Assert.assertTrue( Action.FINISH_ACTION == action );
|
||||
Assert.assertTrue( !BuildConfig.DEBUG || Action.FINISH_ACTION==action );
|
||||
finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -901,50 +901,41 @@ public class DictsDelegate extends ListDelegateBase
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
@Override
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
DbgUtils.logd( TAG, "dlgButtonClicked(%s)", action.toString() );
|
||||
boolean positive = DialogInterface.BUTTON_POSITIVE == which;
|
||||
switch( action ) {
|
||||
case DELETE_DICT_ACTION:
|
||||
if ( positive ) {
|
||||
XWListItem[] items = (XWListItem[])params[0];
|
||||
for ( XWListItem item : items ) {
|
||||
String name = item.getText();
|
||||
DictLoc loc = (DictLoc)item.getCached();
|
||||
deleteDict( name, loc );
|
||||
}
|
||||
clearSelections();
|
||||
mkListAdapter();
|
||||
XWListItem[] items = (XWListItem[])params[0];
|
||||
for ( XWListItem item : items ) {
|
||||
String name = item.getText();
|
||||
DictLoc loc = (DictLoc)item.getCached();
|
||||
deleteDict( name, loc );
|
||||
}
|
||||
clearSelections();
|
||||
mkListAdapter();
|
||||
break;
|
||||
case UPDATE_DICTS_ACTION:
|
||||
if ( positive ) {
|
||||
Uri[] uris = new Uri[m_needUpdates.size()];
|
||||
String[] names = new String[uris.length];
|
||||
int count = 0;
|
||||
for ( Iterator<String> iter = m_needUpdates.keySet().iterator();
|
||||
iter.hasNext(); ) {
|
||||
String name = iter.next();
|
||||
names[count] = name;
|
||||
uris[count] = m_needUpdates.get( name );
|
||||
++count;
|
||||
}
|
||||
DwnldDelegate.downloadDictsInBack( m_activity, uris, names, this );
|
||||
Uri[] uris = new Uri[m_needUpdates.size()];
|
||||
String[] names = new String[uris.length];
|
||||
int count = 0;
|
||||
for ( Iterator<String> iter = m_needUpdates.keySet().iterator();
|
||||
iter.hasNext(); ) {
|
||||
String name = iter.next();
|
||||
names[count] = name;
|
||||
uris[count] = m_needUpdates.get( name );
|
||||
++count;
|
||||
}
|
||||
DwnldDelegate.downloadDictsInBack( m_activity, uris, names, this );
|
||||
break;
|
||||
case MOVE_CONFIRMED:
|
||||
if ( positive ) {
|
||||
moveDictsWithPermission( params );
|
||||
}
|
||||
moveDictsWithPermission( params );
|
||||
break;
|
||||
case STORAGE_CONFIRMED:
|
||||
if ( positive ) {
|
||||
mkListAdapter();
|
||||
}
|
||||
mkListAdapter();
|
||||
break;
|
||||
default:
|
||||
super.dlgButtonClicked( action, which, params );
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,10 @@ public class DlgDelegate {
|
|||
public static enum InviteMeans {
|
||||
SMS, EMAIL, NFC, BLUETOOTH, CLIPBOARD, RELAY, WIFIDIRECT,
|
||||
};
|
||||
void dlgButtonClicked( Action action, int button, Object[] params );
|
||||
void onPosButton( Action action, Object[] params );
|
||||
void onNegButton( Action action, Object[] params );
|
||||
void onDismissed( Action action, Object[] params );
|
||||
|
||||
void inviteChoiceMade( Action action, InviteMeans means, Object[] params );
|
||||
}
|
||||
public interface HasDlgDelegate {
|
||||
|
@ -446,7 +449,7 @@ public class DlgDelegate {
|
|||
}
|
||||
|
||||
// Puts up alert asking to choose a reason to enable SMS, and on dismiss
|
||||
// calls dlgButtonClicked 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.
|
||||
public void showSMSEnableDialog( Action action, Object... params )
|
||||
{
|
||||
|
@ -468,9 +471,7 @@ public class DlgDelegate {
|
|||
post( new Runnable() {
|
||||
public void run() {
|
||||
m_clickCallback
|
||||
.dlgButtonClicked( action,
|
||||
AlertDialog.BUTTON_POSITIVE,
|
||||
params );
|
||||
.onPosButton( action, params );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -702,10 +703,7 @@ public class DlgDelegate {
|
|||
OnClickListener lstnr = new OnClickListener() {
|
||||
public void onClick( DialogInterface dlg, int item ) {
|
||||
checkNotAgainCheck( state, naView );
|
||||
m_clickCallback.
|
||||
dlgButtonClicked( more.action,
|
||||
AlertDialog.BUTTON_POSITIVE,
|
||||
more.params );
|
||||
m_clickCallback.onPosButton( more.action, more.params );
|
||||
}
|
||||
};
|
||||
builder.setNegativeButton( more.buttonStr, lstnr );
|
||||
|
@ -866,9 +864,7 @@ public class DlgDelegate {
|
|||
layout.findViewById( R.id.confirm_sms_reasons );
|
||||
boolean enabled = 0 < reasons.getSelectedItemPosition();
|
||||
Assert.assertTrue( enabled );
|
||||
m_clickCallback.dlgButtonClicked( state.m_action,
|
||||
AlertDialog.BUTTON_POSITIVE,
|
||||
state.m_params );
|
||||
m_clickCallback.onPosButton( state.m_action, state.m_params );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -917,9 +913,21 @@ public class DlgDelegate {
|
|||
checkNotAgainCheck( state, naView );
|
||||
|
||||
if ( Action.SKIP_CALLBACK != state.m_action ) {
|
||||
m_clickCallback.dlgButtonClicked( state.m_action,
|
||||
button,
|
||||
state.m_params );
|
||||
switch ( button ) {
|
||||
case AlertDialog.BUTTON_POSITIVE:
|
||||
m_clickCallback.onPosButton( state.m_action,
|
||||
state.m_params );
|
||||
break;
|
||||
case AlertDialog.BUTTON_NEGATIVE:
|
||||
m_clickCallback.onNegButton( state.m_action,
|
||||
state.m_params );
|
||||
break;
|
||||
default:
|
||||
DbgUtils.loge( TAG, "unexpected button %d",
|
||||
button );
|
||||
// ignore on release builds
|
||||
Assert.assertFalse( BuildConfig.DEBUG );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -948,9 +956,8 @@ public class DlgDelegate {
|
|||
public void onDismiss( DialogInterface di ) {
|
||||
dropState( state );
|
||||
if ( Action.SKIP_CALLBACK != state.m_action ) {
|
||||
m_clickCallback.dlgButtonClicked( state.m_action,
|
||||
DISMISS_BUTTON,
|
||||
state.m_params );
|
||||
m_clickCallback.onDismissed( state.m_action,
|
||||
state.m_params );
|
||||
}
|
||||
m_activity.removeDialog( id );
|
||||
}
|
||||
|
|
|
@ -346,16 +346,26 @@ public class DwnldDelegate extends ListDelegateBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
if ( Action.STORAGE_CONFIRMED == action ) {
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
doWithPermissions( (Uri[])params[0] );
|
||||
} else if ( AlertDialog.BUTTON_NEGATIVE == which ) {
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
super.dlgButtonClicked( action, which, params );
|
||||
switch ( action ) {
|
||||
case STORAGE_CONFIRMED:
|
||||
doWithPermissions( (Uri[])params[0] );
|
||||
break;
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegButton( Action action, Object[] params )
|
||||
{
|
||||
switch ( action ) {
|
||||
case STORAGE_CONFIRMED:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -684,48 +684,42 @@ public class GameConfigDelegate extends DelegateBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int button, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
boolean callSuper = false;
|
||||
Assert.assertTrue( curThis() == this );
|
||||
|
||||
if ( AlertDialog.BUTTON_POSITIVE == button ) {
|
||||
switch( action ) {
|
||||
case LOCKED_CHANGE_ACTION:
|
||||
handleLockedChange();
|
||||
break;
|
||||
case SMS_CONFIG_ACTION:
|
||||
Utils.launchSettings( m_activity );
|
||||
break;
|
||||
case DELETE_AND_EXIT:
|
||||
if ( m_isNewGame ) {
|
||||
deleteGame();
|
||||
}
|
||||
closeNoSave();
|
||||
break;
|
||||
case SET_ENABLE_PUBLIC:
|
||||
XWPrefs.setPrefsBoolean( m_activity, R.string.key_enable_pubroom,
|
||||
true );
|
||||
setupRelayStuffIf( true );
|
||||
break;
|
||||
default:
|
||||
callSuper = true;
|
||||
switch( action ) {
|
||||
case LOCKED_CHANGE_ACTION:
|
||||
handleLockedChange();
|
||||
break;
|
||||
case SMS_CONFIG_ACTION:
|
||||
Utils.launchSettings( m_activity );
|
||||
break;
|
||||
case DELETE_AND_EXIT:
|
||||
if ( m_isNewGame ) {
|
||||
deleteGame();
|
||||
}
|
||||
} else if ( AlertDialog.BUTTON_NEGATIVE == button ) {
|
||||
switch ( action ) {
|
||||
case DELETE_AND_EXIT:
|
||||
showDialog( DlgID.CHANGE_CONN );
|
||||
break;
|
||||
default:
|
||||
callSuper = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
callSuper = true;
|
||||
closeNoSave();
|
||||
break;
|
||||
case SET_ENABLE_PUBLIC:
|
||||
XWPrefs.setPrefsBoolean( m_activity, R.string.key_enable_pubroom,
|
||||
true );
|
||||
setupRelayStuffIf( true );
|
||||
break;
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
if ( callSuper ) {
|
||||
super.dlgButtonClicked( action, button, params );
|
||||
@Override
|
||||
public void onNegButton( Action action, Object[] params )
|
||||
{
|
||||
switch ( action ) {
|
||||
case DELETE_AND_EXIT:
|
||||
showDialog( DlgID.CHANGE_CONN );
|
||||
break;
|
||||
default:
|
||||
super.onNegButton( action, params );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1234,116 +1234,125 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
}
|
||||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
@Override
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
switch( action ) {
|
||||
case NEW_NET_GAME:
|
||||
m_netLaunchInfo = (NetLaunchInfo)params[0];
|
||||
if ( checkWarnNoDict( m_netLaunchInfo ) ) {
|
||||
makeNewNetGameIf();
|
||||
}
|
||||
break;
|
||||
case RESET_GAMES:
|
||||
long[] rowids = (long[])params[0];
|
||||
boolean changed = false;
|
||||
for ( long rowid : rowids ) {
|
||||
changed = GameUtils.resetGame( m_activity, rowid ) || changed;
|
||||
}
|
||||
if ( changed ) {
|
||||
mkListAdapter(); // required because position may change
|
||||
}
|
||||
break;
|
||||
case SYNC_MENU:
|
||||
doSyncMenuitem();
|
||||
break;
|
||||
case NEW_FROM:
|
||||
long curID = (Long)params[0];
|
||||
long newid = GameUtils.dupeGame( m_activity, curID );
|
||||
if ( DBUtils.ROWID_NOTFOUND != newid ) {
|
||||
m_selGames.add( newid );
|
||||
reloadGame( newid );
|
||||
}
|
||||
break;
|
||||
switch( action ) {
|
||||
case NEW_NET_GAME:
|
||||
m_netLaunchInfo = (NetLaunchInfo)params[0];
|
||||
if ( checkWarnNoDict( m_netLaunchInfo ) ) {
|
||||
makeNewNetGameIf();
|
||||
}
|
||||
break;
|
||||
case RESET_GAMES:
|
||||
long[] rowids = (long[])params[0];
|
||||
boolean changed = false;
|
||||
for ( long rowid : rowids ) {
|
||||
changed = GameUtils.resetGame( m_activity, rowid ) || changed;
|
||||
}
|
||||
if ( changed ) {
|
||||
mkListAdapter(); // required because position may change
|
||||
}
|
||||
break;
|
||||
case SYNC_MENU:
|
||||
doSyncMenuitem();
|
||||
break;
|
||||
case NEW_FROM:
|
||||
long curID = (Long)params[0];
|
||||
long newid = GameUtils.dupeGame( m_activity, curID );
|
||||
if ( DBUtils.ROWID_NOTFOUND != newid ) {
|
||||
m_selGames.add( newid );
|
||||
reloadGame( newid );
|
||||
}
|
||||
break;
|
||||
|
||||
case SET_HIDE_NEWGAME_BUTTONS:
|
||||
XWPrefs.setHideNewgameButtons(m_activity, true);
|
||||
setupButtons();
|
||||
// FALLTHRU
|
||||
case NEW_GAME_PRESSED:
|
||||
handleNewGame( m_nextIsSolo );
|
||||
break;
|
||||
case SET_HIDE_NEWGAME_BUTTONS:
|
||||
XWPrefs.setHideNewgameButtons(m_activity, true);
|
||||
setupButtons();
|
||||
// FALLTHRU
|
||||
case NEW_GAME_PRESSED:
|
||||
handleNewGame( m_nextIsSolo );
|
||||
break;
|
||||
|
||||
case DELETE_GROUPS:
|
||||
long[] groupIDs = (long[])params[0];
|
||||
for ( long groupID : groupIDs ) {
|
||||
GameUtils.deleteGroup( m_activity, groupID );
|
||||
}
|
||||
clearSelections();
|
||||
mkListAdapter();
|
||||
break;
|
||||
case DELETE_GAMES:
|
||||
deleteGames( (long[])params[0] );
|
||||
break;
|
||||
case OPEN_GAME:
|
||||
doOpenGame( params );
|
||||
break;
|
||||
case ENABLE_DUALPANE:
|
||||
makeOkOnlyBuilder( R.string.dualpane_exit_now)
|
||||
.setAction( Action.ENABLE_DUALPANE_EXIT )
|
||||
.show();
|
||||
break;
|
||||
case CLEAR_SELS:
|
||||
clearSelections();
|
||||
break;
|
||||
case DWNLD_LOC_DICT:
|
||||
String lang = (String)params[0];
|
||||
String name = (String)params[1];
|
||||
DownloadFinishedListener lstnr = new DownloadFinishedListener() {
|
||||
public void downloadFinished( String lang, String name, boolean success )
|
||||
{
|
||||
if ( success ) {
|
||||
XWPrefs.setPrefsString( m_activity,
|
||||
R.string.key_default_language,
|
||||
lang );
|
||||
name = DictUtils.removeDictExtn( name );
|
||||
int[] ids = { R.string.key_default_dict,
|
||||
R.string.key_default_robodict };
|
||||
for ( int id : ids ) {
|
||||
XWPrefs.setPrefsString( m_activity, id, name );
|
||||
}
|
||||
|
||||
XWPrefs.setPrefsBoolean( m_activity,
|
||||
R.string.key_got_langdict,
|
||||
true );
|
||||
case DELETE_GROUPS:
|
||||
long[] groupIDs = (long[])params[0];
|
||||
for ( long groupID : groupIDs ) {
|
||||
GameUtils.deleteGroup( m_activity, groupID );
|
||||
}
|
||||
clearSelections();
|
||||
mkListAdapter();
|
||||
break;
|
||||
case DELETE_GAMES:
|
||||
deleteGames( (long[])params[0] );
|
||||
break;
|
||||
case OPEN_GAME:
|
||||
doOpenGame( params );
|
||||
break;
|
||||
case ENABLE_DUALPANE:
|
||||
makeOkOnlyBuilder( R.string.dualpane_exit_now)
|
||||
.setAction( Action.ENABLE_DUALPANE_EXIT )
|
||||
.show();
|
||||
break;
|
||||
case CLEAR_SELS:
|
||||
clearSelections();
|
||||
break;
|
||||
case DWNLD_LOC_DICT:
|
||||
String lang = (String)params[0];
|
||||
String name = (String)params[1];
|
||||
DownloadFinishedListener lstnr = new DownloadFinishedListener() {
|
||||
public void downloadFinished( String lang, String name, boolean success )
|
||||
{
|
||||
if ( success ) {
|
||||
XWPrefs.setPrefsString( m_activity,
|
||||
R.string.key_default_language,
|
||||
lang );
|
||||
name = DictUtils.removeDictExtn( name );
|
||||
int[] ids = { R.string.key_default_dict,
|
||||
R.string.key_default_robodict };
|
||||
for ( int id : ids ) {
|
||||
XWPrefs.setPrefsString( m_activity, id, name );
|
||||
}
|
||||
|
||||
XWPrefs.setPrefsBoolean( m_activity,
|
||||
R.string.key_got_langdict,
|
||||
true );
|
||||
}
|
||||
};
|
||||
DwnldDelegate.downloadDictInBack( m_activity, lang, name, lstnr );
|
||||
break;
|
||||
case NEW_GAME_DFLT_NAME:
|
||||
m_newGameParams = params;
|
||||
askDefaultName();
|
||||
break;
|
||||
}
|
||||
};
|
||||
DwnldDelegate.downloadDictInBack( m_activity, lang, name, lstnr );
|
||||
break;
|
||||
case NEW_GAME_DFLT_NAME:
|
||||
m_newGameParams = params;
|
||||
askDefaultName();
|
||||
break;
|
||||
|
||||
case RETRY_REMATCH:
|
||||
startRematchWithName( (String)params[0], false );
|
||||
break;
|
||||
case RETRY_REMATCH:
|
||||
startRematchWithName( (String)params[0], false );
|
||||
break;
|
||||
|
||||
default:
|
||||
Assert.fail();
|
||||
}
|
||||
} else if ( AlertDialog.BUTTON_NEGATIVE == which ) {
|
||||
if ( Action.NEW_GAME_DFLT_NAME == action ) {
|
||||
m_newGameParams = params;
|
||||
makeThenLaunchOrConfigure();
|
||||
}
|
||||
} else if ( DlgDelegate.DISMISS_BUTTON == which ) {
|
||||
switch( action ) {
|
||||
case ENABLE_DUALPANE_EXIT:
|
||||
setDualpaneAndFinish( true );
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Assert.fail();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegButton( Action action, Object[] params )
|
||||
{
|
||||
if ( Action.NEW_GAME_DFLT_NAME == action ) {
|
||||
m_newGameParams = params;
|
||||
makeThenLaunchOrConfigure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissed( Action action, Object[] params )
|
||||
{
|
||||
switch( action ) {
|
||||
case ENABLE_DUALPANE_EXIT:
|
||||
setDualpaneAndFinish( true );
|
||||
break;
|
||||
default:
|
||||
super.onDismissed( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -178,30 +178,25 @@ public class Perms23 {
|
|||
}
|
||||
builder.asyncQuery( m_delegate.getActivity(), new PermCbck() {
|
||||
public void onPermissionResult( Map<Perm, Boolean> perms ) {
|
||||
int button = perms.get( m_perm )
|
||||
? AlertDialog.BUTTON_POSITIVE
|
||||
: AlertDialog.BUTTON_NEGATIVE;
|
||||
// DbgUtils.logd( TAG, "doIt() calling dlgButtonClicked(%s)",
|
||||
// m_action.toString() );
|
||||
m_cbck.dlgButtonClicked( m_action, button, m_params );
|
||||
if ( perms.get( m_perm ) ) {
|
||||
m_cbck.onPosButton( m_action, m_params );
|
||||
} else {
|
||||
m_cbck.onNegButton( m_action, m_params );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
// Post this in case we're called from inside dialog dismiss
|
||||
// code. Better to unwind the stack...
|
||||
private void handleButton( final int button )
|
||||
private void handleButton( final boolean positive )
|
||||
{
|
||||
m_delegate.post( new Runnable() {
|
||||
public void run() {
|
||||
if ( AlertDialog.BUTTON_POSITIVE == button ) {
|
||||
if ( positive ) {
|
||||
doIt( false );
|
||||
} else if ( AlertDialog.BUTTON_NEGATIVE == button ) {
|
||||
// DbgUtils.logd( TAG, "handleButton calling dlgButtonClicked(%s)",
|
||||
// m_action.toString() );
|
||||
m_cbck.dlgButtonClicked( m_action,
|
||||
AlertDialog.BUTTON_NEGATIVE,
|
||||
m_params );
|
||||
} else {
|
||||
m_cbck.onNegButton( m_action, m_params );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
@ -221,11 +216,11 @@ public class Perms23 {
|
|||
.doIt( true );
|
||||
}
|
||||
|
||||
public static void onGotPermsAction( int button, Object[] params )
|
||||
public static void onGotPermsAction( boolean positive, Object[] params )
|
||||
{
|
||||
// DbgUtils.logd( TAG, "onGotPermsAction(button=%d)", button );
|
||||
QueryInfo info = (QueryInfo)params[0];
|
||||
info.handleButton( button );
|
||||
info.handleButton( positive );
|
||||
}
|
||||
|
||||
private static Map<Integer, PermCbck> s_map = new HashMap<Integer, PermCbck>();
|
||||
|
|
|
@ -242,26 +242,19 @@ public class PrefsDelegate extends DelegateBase
|
|||
}
|
||||
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int button, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
boolean handled = AlertDialog.BUTTON_POSITIVE == button;
|
||||
if ( handled ) {
|
||||
switch ( action ) {
|
||||
case ENABLE_SMS_DO:
|
||||
XWPrefs.setSMSEnabled( m_activity, true );
|
||||
SMSCheckBoxPreference.setChecked();
|
||||
break;
|
||||
case DISABLE_RELAY_DO:
|
||||
RelayService.setEnabled( m_activity, false );
|
||||
RelayCheckBoxPreference.setChecked();
|
||||
break;
|
||||
default:
|
||||
handled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !handled ) {
|
||||
super.dlgButtonClicked( action, button, params );
|
||||
switch ( action ) {
|
||||
case ENABLE_SMS_DO:
|
||||
XWPrefs.setSMSEnabled( m_activity, true );
|
||||
SMSCheckBoxPreference.setChecked();
|
||||
break;
|
||||
case DISABLE_RELAY_DO:
|
||||
RelayService.setEnabled( m_activity, false );
|
||||
RelayCheckBoxPreference.setChecked();
|
||||
break;
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -278,27 +278,29 @@ public class RelayInviteDelegate extends InviteDelegate {
|
|||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
switch( which ) {
|
||||
case AlertDialog.BUTTON_POSITIVE:
|
||||
switch( action ) {
|
||||
case CLEAR_ACTION:
|
||||
clearSelectedImpl();
|
||||
break;
|
||||
case USE_IMMOBILE_ACTION:
|
||||
m_immobileConfirmed = true;
|
||||
break;
|
||||
}
|
||||
switch( action ) {
|
||||
case CLEAR_ACTION:
|
||||
clearSelectedImpl();
|
||||
break;
|
||||
case DlgDelegate.DISMISS_BUTTON:
|
||||
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
|
||||
makeConfirmThenBuilder( R.string.warn_unlimited,
|
||||
Action.POST_WARNING_ACTION )
|
||||
.setPosButton( R.string.button_yes )
|
||||
.show();
|
||||
}
|
||||
case USE_IMMOBILE_ACTION:
|
||||
m_immobileConfirmed = true;
|
||||
break;
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDismissed( Action action, Object[] params )
|
||||
{
|
||||
if ( Action.USE_IMMOBILE_ACTION == action && m_immobileConfirmed ) {
|
||||
makeConfirmThenBuilder( R.string.warn_unlimited,
|
||||
Action.POST_WARNING_ACTION )
|
||||
.setPosButton( R.string.button_yes )
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -187,34 +187,37 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
|
||||
// DlgDelegate.DlgClickNotify interface
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which,
|
||||
final Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
boolean isPositive = AlertDialog.BUTTON_POSITIVE == which;
|
||||
|
||||
switch ( action ) {
|
||||
case RETRY_CONTACTS_ACTION:
|
||||
askContactsPermission( false );
|
||||
break;
|
||||
case CLEAR_ACTION:
|
||||
if ( isPositive) {
|
||||
clearSelectedImpl();
|
||||
}
|
||||
break;
|
||||
case POST_WARNING_ACTION:
|
||||
if ( isPositive ) { // ???
|
||||
PhoneRec rec = new PhoneRec( (String)params[1],
|
||||
(String)params[0] );
|
||||
m_phoneRecs.add( rec );
|
||||
clearChecked();
|
||||
onItemChecked( rec, true );
|
||||
saveAndRebuild();
|
||||
}
|
||||
clearSelectedImpl();
|
||||
break;
|
||||
case USE_IMMOBILE_ACTION:
|
||||
if ( isPositive ) {
|
||||
m_immobileConfirmed = true;
|
||||
} else if ( m_immobileConfirmed ) {
|
||||
m_immobileConfirmed = true;
|
||||
break;
|
||||
case POST_WARNING_ACTION:
|
||||
PhoneRec rec = new PhoneRec( (String)params[1],
|
||||
(String)params[0] );
|
||||
m_phoneRecs.add( rec );
|
||||
clearChecked();
|
||||
onItemChecked( rec, true );
|
||||
saveAndRebuild();
|
||||
break;
|
||||
default:
|
||||
super.onPosButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNegButton( Action action, final Object[] params )
|
||||
{
|
||||
switch ( action ) {
|
||||
case USE_IMMOBILE_ACTION:
|
||||
if ( m_immobileConfirmed ) {
|
||||
// Putting up a new alert from inside another's handler
|
||||
// confuses things. So post instead.
|
||||
post( new Runnable() {
|
||||
|
@ -229,6 +232,8 @@ public class SMSInviteDelegate extends InviteDelegate {
|
|||
} );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.onNegButton( action, params );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,33 +153,31 @@ public class StudyListDelegate extends ListDelegateBase
|
|||
// DlgDelegate.DlgClickNotify interface
|
||||
//////////////////////////////////////////////////
|
||||
@Override
|
||||
public void dlgButtonClicked( Action action, int which, Object[] params )
|
||||
public void onPosButton( Action action, Object[] params )
|
||||
{
|
||||
if ( AlertDialog.BUTTON_POSITIVE == which ) {
|
||||
switch ( action ) {
|
||||
case SL_CLEAR_ACTION:
|
||||
String[] selWords = getSelWords();
|
||||
if ( selWords.length == m_words.length ) {
|
||||
selWords = null; // all: easier on DB :-)
|
||||
}
|
||||
DBUtils.studyListClear( m_activity, m_langCodes[m_langPosition],
|
||||
selWords );
|
||||
initOrFinish( null );
|
||||
break;
|
||||
case SL_COPY_ACTION:
|
||||
selWords = getSelWords();
|
||||
ClipboardManager clipboard = (ClipboardManager)
|
||||
getSystemService( Context.CLIPBOARD_SERVICE );
|
||||
clipboard.setText( TextUtils.join( "\n", selWords ) );
|
||||
|
||||
String msg = getQuantityString( R.plurals.paste_done_fmt,
|
||||
selWords.length, selWords.length );
|
||||
showToast( msg );
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
break;
|
||||
switch ( action ) {
|
||||
case SL_CLEAR_ACTION:
|
||||
String[] selWords = getSelWords();
|
||||
if ( selWords.length == m_words.length ) {
|
||||
selWords = null; // all: easier on DB :-)
|
||||
}
|
||||
DBUtils.studyListClear( m_activity, m_langCodes[m_langPosition],
|
||||
selWords );
|
||||
initOrFinish( null );
|
||||
break;
|
||||
case SL_COPY_ACTION:
|
||||
selWords = getSelWords();
|
||||
ClipboardManager clipboard = (ClipboardManager)
|
||||
getSystemService( Context.CLIPBOARD_SERVICE );
|
||||
clipboard.setText( TextUtils.join( "\n", selWords ) );
|
||||
|
||||
String msg = getQuantityString( R.plurals.paste_done_fmt,
|
||||
selWords.length, selWords.length );
|
||||
showToast( msg );
|
||||
break;
|
||||
default:
|
||||
Assert.fail();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue