mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
open json attachment and from it create a new game. Works, but there
are enough problems with attachements I may turn them off.
This commit is contained in:
parent
f4dc8a6b41
commit
ab0fb918ee
3 changed files with 31 additions and 10 deletions
|
@ -562,7 +562,7 @@ public class DBUtils {
|
|||
public static long getRowIDForOpen( Context context, Uri data )
|
||||
{
|
||||
long rowid = ROWID_NOTFOUND;
|
||||
NetLaunchInfo nli = new NetLaunchInfo( data );
|
||||
NetLaunchInfo nli = new NetLaunchInfo( context, data );
|
||||
if ( null != nli && nli.isValid() ) {
|
||||
rowid = getRowIDForOpen( context, nli );
|
||||
}
|
||||
|
|
|
@ -800,7 +800,7 @@ public class GamesList extends XWListActivity
|
|||
} else {
|
||||
Uri data = intent.getData();
|
||||
if ( null != data ) {
|
||||
nli = new NetLaunchInfo( data );
|
||||
nli = new NetLaunchInfo( this, data );
|
||||
}
|
||||
}
|
||||
if ( null != nli && nli.isValid() ) {
|
||||
|
|
|
@ -20,11 +20,15 @@
|
|||
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import java.net.URLEncoder;
|
||||
import java.io.InputStream;
|
||||
import org.json.JSONObject;
|
||||
import junit.framework.Assert;
|
||||
|
||||
|
||||
public class NetLaunchInfo {
|
||||
|
@ -63,18 +67,35 @@ public class NetLaunchInfo {
|
|||
m_valid = bundle.getBoolean( VALID );
|
||||
}
|
||||
|
||||
public NetLaunchInfo( Uri data )
|
||||
public NetLaunchInfo( Context context, Uri data )
|
||||
{
|
||||
m_valid = false;
|
||||
if ( null != data ) {
|
||||
String scheme = data.getScheme();
|
||||
try {
|
||||
room = data.getQueryParameter( "room" );
|
||||
inviteID = data.getQueryParameter( "id" );
|
||||
dict = data.getQueryParameter( "wl" );
|
||||
String langStr = data.getQueryParameter( "lang" );
|
||||
lang = Integer.decode( langStr );
|
||||
String np = data.getQueryParameter( "np" );
|
||||
nPlayersT = Integer.decode( np );
|
||||
if ( "content".equals(scheme) ) {
|
||||
Assert.assertNotNull( context );
|
||||
ContentResolver resolver = context.getContentResolver();
|
||||
InputStream is = resolver.openInputStream( data );
|
||||
int len = is.available();
|
||||
byte[] buf = new byte[len];
|
||||
is.read( buf );
|
||||
|
||||
JSONObject json = new JSONObject( new String( buf ) );
|
||||
room = json.getString( MultiService.ROOM );
|
||||
inviteID = json.getString( MultiService.INVITEID );
|
||||
lang = json.getInt( MultiService.LANG );
|
||||
dict = json.getString( MultiService.DICT );
|
||||
nPlayersT = json.getInt( MultiService.NPLAYERST );
|
||||
} else {
|
||||
room = data.getQueryParameter( "room" );
|
||||
inviteID = data.getQueryParameter( "id" );
|
||||
dict = data.getQueryParameter( "wl" );
|
||||
String langStr = data.getQueryParameter( "lang" );
|
||||
lang = Integer.decode( langStr );
|
||||
String np = data.getQueryParameter( "np" );
|
||||
nPlayersT = Integer.decode( np );
|
||||
}
|
||||
m_valid = true;
|
||||
} catch ( Exception e ) {
|
||||
DbgUtils.logf( "unable to parse \"%s\"", data.toString() );
|
||||
|
|
Loading…
Reference in a new issue