mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
for debugging, add ability to invite via text mqtt devid
Add ability to copy to clipboard and then to invite by pasting from clipboard. Makes it much easier to connect two emulator instances where neither can camera the other's QR code.
This commit is contained in:
parent
840abb4037
commit
dc4032faf8
11 changed files with 68 additions and 9 deletions
|
@ -379,6 +379,32 @@ public class BoardDelegate extends DelegateBase
|
|||
}
|
||||
break;
|
||||
|
||||
case GET_DEVID:
|
||||
final EditText et = (EditText)inflate( R.layout.edittext );
|
||||
dialog = ab
|
||||
.setTitle("paste mqtt dev id")
|
||||
.setView( et )
|
||||
.setNegativeButton( android.R.string.cancel, null )
|
||||
.setPositiveButton( android.R.string.ok,
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void
|
||||
onClick( DialogInterface dlg, int bttn ) {
|
||||
final String msg = et.getText().toString();
|
||||
post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
m_missingDevs = new String[] {msg};
|
||||
m_missingCounts = new int[] {1};
|
||||
m_missingMeans = InviteMeans.MQTT;
|
||||
tryInvites();
|
||||
}
|
||||
} );
|
||||
}
|
||||
} )
|
||||
.create();
|
||||
break;
|
||||
|
||||
case ASK_DUP_PAUSE: {
|
||||
final boolean isPause = (Boolean)params[0];
|
||||
final ConfirmPauseView pauseView =
|
||||
|
@ -1272,8 +1298,10 @@ public class BoardDelegate extends DelegateBase
|
|||
Perms23.tryGetPerms( this, Perms23.NBS_PERMS, R.string.sms_invite_rationale,
|
||||
Action.INVITE_SMS_DATA, m_mySIS.nMissing, info );
|
||||
break;
|
||||
case RELAY:
|
||||
case MQTT:
|
||||
showDialogFragment( DlgID.GET_DEVID );
|
||||
break;
|
||||
case RELAY:
|
||||
// These have been removed as options
|
||||
Assert.failDbg();
|
||||
break;
|
||||
|
@ -2691,15 +2719,18 @@ public class BoardDelegate extends DelegateBase
|
|||
case WIFIDIRECT:
|
||||
WiDirService.inviteRemote( m_activity, dev, nli );
|
||||
break;
|
||||
case RELAY:
|
||||
case MQTT:
|
||||
destAddr = new CommsAddrRec(CommsConnType.COMMS_CONN_MQTT)
|
||||
.setMQTTParams( m_missingDevs[ii] );
|
||||
break;
|
||||
case RELAY:
|
||||
default:
|
||||
Assert.failDbg(); // not getting here, right?
|
||||
break;
|
||||
}
|
||||
|
||||
if ( null != destAddr ) {
|
||||
XwJNI.comms_invite( m_jniGamePtr, nli, destAddr );
|
||||
XwJNI.comms_invite( m_jniGamePtr, nli, destAddr, true );
|
||||
} else if ( null != dev ) {
|
||||
recordInviteSent( m_missingMeans, dev );
|
||||
}
|
||||
|
@ -3019,7 +3050,7 @@ public class BoardDelegate extends DelegateBase
|
|||
private boolean tryOtherInvites( CommsAddrRec addr )
|
||||
{
|
||||
Log.d( TAG, "tryOtherInvites(%s)", addr );
|
||||
XwJNI.comms_invite( m_jniGamePtr, nliForMe(), addr );
|
||||
XwJNI.comms_invite( m_jniGamePtr, nliForMe(), addr, true );
|
||||
|
||||
// Not sure what to do about this recordInviteSent stuff
|
||||
CommsConnTypeSet conTypes = addr.conTypes;
|
||||
|
|
|
@ -70,6 +70,7 @@ public enum DlgID {
|
|||
SHOW_TILES,
|
||||
RENAME_PLAYER,
|
||||
BACKUP_LOADSTORE,
|
||||
GET_DEVID,
|
||||
;
|
||||
|
||||
private boolean m_addToStack;
|
||||
|
|
|
@ -688,7 +688,7 @@ public class GameUtils {
|
|||
XwJNI.game_summarize( gamePtr, summary );
|
||||
NetLaunchInfo nli = new NetLaunchInfo( context, summary, gi );
|
||||
Log.d( TAG, "passing %s to comms_invite()", nli );
|
||||
XwJNI.comms_invite( gamePtr, nli, invitee );
|
||||
XwJNI.comms_invite( gamePtr, nli, invitee, false );
|
||||
}
|
||||
|
||||
long rowid = DBUtils.ROWID_NOTFOUND;
|
||||
|
|
|
@ -543,6 +543,7 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
private static final int[] DEBUG_ITEMS = {
|
||||
R.id.games_menu_writegit,
|
||||
R.id.games_submenu_logs,
|
||||
R.id.games_menu_copyDevid,
|
||||
};
|
||||
private static final int[] NOSEL_ITEMS = {
|
||||
R.id.games_menu_newgroup,
|
||||
|
@ -1913,6 +1914,12 @@ public class GamesListDelegate extends ListDelegateBase
|
|||
Utils.gitInfoToClip( m_activity );
|
||||
break;
|
||||
|
||||
case R.id.games_menu_copyDevid:
|
||||
String devid = XwJNI.dvc_getMQTTDevID();
|
||||
Utils.stringToClip( m_activity, devid );
|
||||
showToast( devid );
|
||||
break;
|
||||
|
||||
case R.id.games_menu_timerStats:
|
||||
makeOkOnlyBuilder( TimerReceiver.statsStr( m_activity ) )
|
||||
.setActionPair( Action.CLEAR_INT_STATS, R.string.button_clear_stats )
|
||||
|
|
|
@ -106,6 +106,10 @@ public class InviteChoicesAlert extends DlgDelegateAlert
|
|||
if ( Utils.deviceSupportsNBS(context) ) {
|
||||
means.add( InviteMeans.SMS_DATA );
|
||||
}
|
||||
if ( BuildConfig.NON_RELEASE ) {
|
||||
means.add( InviteMeans.MQTT );
|
||||
}
|
||||
|
||||
means.add( InviteMeans.QRCODE );
|
||||
if ( BTUtils.BTAvailable() ) {
|
||||
means.add( InviteMeans.BLUETOOTH );
|
||||
|
|
|
@ -575,7 +575,7 @@ public class MQTTUtils extends Thread
|
|||
{
|
||||
CommsAddrRec destAddr = new CommsAddrRec(CommsConnType.COMMS_CONN_MQTT)
|
||||
.setMQTTParams( devID );
|
||||
XwJNI.comms_invite( game, nli, destAddr );
|
||||
XwJNI.comms_invite( game, nli, destAddr, false );
|
||||
}
|
||||
|
||||
private static void notifyNotHere( Context context, String addressee,
|
||||
|
|
|
@ -566,7 +566,7 @@ public class XwJNI {
|
|||
public static native void comms_addMQTTDevID( GamePtr gamePtr, int channelNo,
|
||||
String devID );
|
||||
public static native void comms_invite( GamePtr gamePtr, NetLaunchInfo nli,
|
||||
CommsAddrRec destAddr );
|
||||
CommsAddrRec destAddr, boolean sendNow );
|
||||
|
||||
// Used/defined (in C) for DEBUG only
|
||||
public static native void comms_setAddrDisabled( GamePtr gamePtr, CommsConnType typ,
|
||||
|
|
10
xwords4/android/app/src/main/res/layout/edittext.xml
Normal file
10
xwords4/android/app/src/main/res/layout/edittext.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<EditText xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:maxLength="16"
|
||||
android:selectAllOnFocus="true"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
/>
|
|
@ -113,6 +113,9 @@
|
|||
<item android:id="@+id/games_menu_writegit"
|
||||
android:title="@string/gamel_menu_writegit"
|
||||
/>
|
||||
<item android:id="@+id/games_menu_copyDevid"
|
||||
android:title="@string/games_menu_copyDevid"
|
||||
/>
|
||||
|
||||
<item android:id="@+id/games_submenu_logs"
|
||||
android:title="@string/gamel_menu_logs"
|
||||
|
|
|
@ -2219,6 +2219,8 @@
|
|||
<string name="mqtt_qos">MQTT QOS</string>
|
||||
<string name="name_dict_fmt">%1$s/%2$s</string>
|
||||
<string name="gamel_menu_writegit">Copy git info to clipboard</string>
|
||||
<!-- Debug builds only -->
|
||||
<string name="games_menu_copyDevid">Copy MQTT devID</string>
|
||||
<string name="enable_pending_count_title">Show Pending messages</string>
|
||||
<string name="enable_pending_count_summary">Show number not yet acknowledged</string>
|
||||
<string name="nag_intervals">Reminder intervals (minutes1,minutes2,…)</string>
|
||||
|
|
|
@ -2688,7 +2688,8 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1addMQTTDevID
|
|||
#ifdef XWFEATURE_COMMS_INVITE
|
||||
JNIEXPORT void JNICALL
|
||||
Java_org_eehouse_android_xw4_jni_XwJNI_comms_1invite
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr, jobject jnli, jobject jaddr )
|
||||
( JNIEnv* env, jclass C, GamePtrType gamePtr, jobject jnli, jobject jaddr,
|
||||
jboolean jSendNow )
|
||||
{
|
||||
XWJNI_START_GLOBALS(gamePtr);
|
||||
CommsCtxt* comms = state->game.comms;
|
||||
|
@ -2699,7 +2700,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1invite
|
|||
NetLaunchInfo nli;
|
||||
loadNLI( env, &nli, jnli );
|
||||
|
||||
comms_invite( comms, env, &nli, &destAddr, XP_FALSE );
|
||||
comms_invite( comms, env, &nli, &destAddr, jSendNow );
|
||||
}
|
||||
XWJNI_END();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue