From 1d5cfd49fa3a5b15d33185368e4db16fb0df68ec Mon Sep 17 00:00:00 2001 From: Andy2 Date: Fri, 10 Jun 2011 06:49:32 -0700 Subject: [PATCH] remove second URL that was meant to allow user to install Crosswords if it's not installed (because SMS apps confuses with the way it presents multiple URLs.) Will try to do the same thing with the redirect .php script whose output will stick around if the redirect fails. Also, use URI.Builder instead of a format string to build the redirect URL. It's cleaner. Still need to have a space in the format string to keep sentence-finishing period from becoming part of the room name. Not sure how to fix that without moving to html messages which I assume don't work in SMS. --- .../XWords4/res/values/common_rsrc.xml | 4 +-- .../android/XWords4/res/values/strings.xml | 2 +- .../org/eehouse/android/xw4/GameUtils.java | 10 +++---- .../eehouse/android/xw4/NetLaunchInfo.java | 26 +++++++++---------- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/xwords4/android/XWords4/res/values/common_rsrc.xml b/xwords4/android/XWords4/res/values/common_rsrc.xml index 500622bee..4919fe1c0 100644 --- a/xwords4/android/XWords4/res/values/common_rsrc.xml +++ b/xwords4/android/XWords4/res/values/common_rsrc.xml @@ -72,9 +72,7 @@ eehouse.org http://eehouse.org/and_dicts_hh 4.4 beta 28 - https://market.android.com/search?q=pname:org.eehouse.android.xw4 - - http://%1$s/redir.php?lang=%2$d + /%1$s/redir.php diff --git a/xwords4/android/XWords4/res/values/strings.xml b/xwords4/android/XWords4/res/values/strings.xml index 319df69ee..3c9c3d811 100644 --- a/xwords4/android/XWords4/res/values/strings.xml +++ b/xwords4/android/XWords4/res/values/strings.xml @@ -565,7 +565,7 @@ you haven\'t already? Let\'s play Crosswords Tap on this link to start a game: - %1$s. (If you don\'t have Crosswords: %2$s.) + %1$s . Send invitation via Unable to download. Do you have diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java index e3c6aaf9d..162992655 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/GameUtils.java @@ -23,6 +23,7 @@ package org.eehouse.android.xw4; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.net.Uri; import android.os.Environment; import java.io.File; import java.io.FileInputStream; @@ -392,18 +393,17 @@ public class GameUtils { int lang ) { Random random = new Random(); - String gameUrl = NetLaunchInfo.makeLaunchURL( context, room, - lang, 2 ); + Uri gameUri = NetLaunchInfo.makeLaunchUri( context, room, + lang, 2 ); - if ( null != gameUrl ) { + if ( null != gameUri ) { Intent intent = new Intent( Intent.ACTION_SEND ); intent.setType( "text/plain" ); intent.putExtra( Intent.EXTRA_SUBJECT, context.getString( R.string.invite_subject ) ); String format = context.getString( R.string.invite_bodyf ); - String appUrl = context.getString( R.string.app_market_url ); - String message = String.format( format, gameUrl, appUrl ); + String message = String.format( format, gameUri.toString() ); intent.putExtra( Intent.EXTRA_TEXT, message ); String chooserMsg = context.getString( R.string.invite_chooser ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java index 7a8e61b63..09b5a01dd 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/NetLaunchInfo.java @@ -22,6 +22,7 @@ package org.eehouse.android.xw4; import android.content.Context; import android.net.Uri; +import android.net.Uri.Builder; import java.net.URLEncoder; import org.eehouse.android.xw4.jni.CommonPrefs; @@ -34,22 +35,19 @@ public class NetLaunchInfo { private boolean m_valid; - public static String makeLaunchURL( Context context, String room, + public static Uri makeLaunchUri( Context context, String room, int lang, int nPlayers ) { - String format = context.getString( R.string.game_urlf ); - String host = CommonPrefs.getDefaultRelayHost( context ); - StringBuilder query = - new StringBuilder( String.format( format, host, lang, room ) ); - query.append( "&room=" ); - String result = null; - try { - query.append( URLEncoder.encode(room, "UTF-8") ); - result = query.toString(); - } catch ( java.io.UnsupportedEncodingException uee ) { - Utils.logf( "%s", uee.toString() ); - } - return result; + Builder ub = new Builder(); + ub.scheme( "http" ); + String format = context.getString( R.string.game_url_pathf ); + ub.path( String.format( format, + CommonPrefs.getDefaultRelayHost( context ) ) ); + + ub.appendQueryParameter( "lang", String.format("%d", lang ) ); + ub.appendQueryParameter( "np", String.format( "%d", nPlayers ) ); + ub.appendQueryParameter( "room", room ); + return ub.build(); } public NetLaunchInfo( Uri data )