add name for self in peers status results

This commit is contained in:
Eric House 2024-02-12 20:25:46 -08:00
parent 3cd73acdc2
commit df04b55329
2 changed files with 13 additions and 5 deletions

View file

@ -44,7 +44,7 @@ public class PeerStatusView extends LinearLayout {
private Context mContext;
private boolean mFinished;
private int mGameID;
private String mDevID;
private String mSelfDevID;
public PeerStatusView( Context cx, AttributeSet as )
{
@ -55,7 +55,7 @@ public class PeerStatusView extends LinearLayout {
public void configure( int gameID, String devID )
{
mGameID = gameID;
mDevID = devID;
mSelfDevID = devID;
startThreadOnce();
}
@ -68,7 +68,7 @@ public class PeerStatusView extends LinearLayout {
private void startThreadOnce()
{
if ( mFinished && null != mDevID ) {
if ( mFinished && null != mSelfDevID ) {
new Thread( new Runnable() {
@Override
public void run() {
@ -84,7 +84,7 @@ public class PeerStatusView extends LinearLayout {
JSONObject params = new JSONObject();
try {
params.put( "gid16", String.format("%X", mGameID) );
params.put( "devid", mDevID );
params.put( "devid", mSelfDevID );
HttpURLConnection conn = NetUtils
.makeHttpMQTTConn( mContext, "peers" );
@ -101,8 +101,12 @@ public class PeerStatusView extends LinearLayout {
String age = line.getString( "age" );
String name = XwJNI.kplr_nameForMqttDev( mqttID );
if ( null == name ) {
if ( mSelfDevID.equals(mqttID) ) {
name = LocUtils.getString( mContext, R.string.selfName );
} else {
name = mqttID;
}
}
lines.add( String.format( "%s: %s", name, age ) );
}
userStr = TextUtils.join( "\n", lines );

View file

@ -5,6 +5,10 @@
<string name="dup_allscores_fmt">All scores: %1$s</string>
<!-- In Peer Status results, if my own device comes back (as it
should) and it isn't assigned a name in Known Players, use
this. -->
<string name="selfName">This device</string>
<!-- Debug-only: menu to remove quashed marking from a game (in case
the quashing was accidental) -->