mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
add name for self in peers status results
This commit is contained in:
parent
3cd73acdc2
commit
df04b55329
2 changed files with 13 additions and 5 deletions
|
@ -44,7 +44,7 @@ public class PeerStatusView extends LinearLayout {
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private boolean mFinished;
|
private boolean mFinished;
|
||||||
private int mGameID;
|
private int mGameID;
|
||||||
private String mDevID;
|
private String mSelfDevID;
|
||||||
|
|
||||||
public PeerStatusView( Context cx, AttributeSet as )
|
public PeerStatusView( Context cx, AttributeSet as )
|
||||||
{
|
{
|
||||||
|
@ -55,7 +55,7 @@ public class PeerStatusView extends LinearLayout {
|
||||||
public void configure( int gameID, String devID )
|
public void configure( int gameID, String devID )
|
||||||
{
|
{
|
||||||
mGameID = gameID;
|
mGameID = gameID;
|
||||||
mDevID = devID;
|
mSelfDevID = devID;
|
||||||
startThreadOnce();
|
startThreadOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class PeerStatusView extends LinearLayout {
|
||||||
|
|
||||||
private void startThreadOnce()
|
private void startThreadOnce()
|
||||||
{
|
{
|
||||||
if ( mFinished && null != mDevID ) {
|
if ( mFinished && null != mSelfDevID ) {
|
||||||
new Thread( new Runnable() {
|
new Thread( new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -84,7 +84,7 @@ public class PeerStatusView extends LinearLayout {
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
try {
|
try {
|
||||||
params.put( "gid16", String.format("%X", mGameID) );
|
params.put( "gid16", String.format("%X", mGameID) );
|
||||||
params.put( "devid", mDevID );
|
params.put( "devid", mSelfDevID );
|
||||||
|
|
||||||
HttpURLConnection conn = NetUtils
|
HttpURLConnection conn = NetUtils
|
||||||
.makeHttpMQTTConn( mContext, "peers" );
|
.makeHttpMQTTConn( mContext, "peers" );
|
||||||
|
@ -101,8 +101,12 @@ public class PeerStatusView extends LinearLayout {
|
||||||
String age = line.getString( "age" );
|
String age = line.getString( "age" );
|
||||||
String name = XwJNI.kplr_nameForMqttDev( mqttID );
|
String name = XwJNI.kplr_nameForMqttDev( mqttID );
|
||||||
if ( null == name ) {
|
if ( null == name ) {
|
||||||
|
if ( mSelfDevID.equals(mqttID) ) {
|
||||||
|
name = LocUtils.getString( mContext, R.string.selfName );
|
||||||
|
} else {
|
||||||
name = mqttID;
|
name = mqttID;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lines.add( String.format( "%s: %s", name, age ) );
|
lines.add( String.format( "%s: %s", name, age ) );
|
||||||
}
|
}
|
||||||
userStr = TextUtils.join( "\n", lines );
|
userStr = TextUtils.join( "\n", lines );
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
<string name="dup_allscores_fmt">All scores: %1$s</string>
|
<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
|
<!-- Debug-only: menu to remove quashed marking from a game (in case
|
||||||
the quashing was accidental) -->
|
the quashing was accidental) -->
|
||||||
|
|
Loading…
Reference in a new issue