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.
This commit is contained in:
Andy2 2011-06-10 06:49:32 -07:00
parent d089c29ada
commit 1d5cfd49fa
4 changed files with 19 additions and 23 deletions

View file

@ -72,9 +72,7 @@
<string name="default_host">eehouse.org</string>
<string name="dict_url">http://eehouse.org/and_dicts_hh</string>
<string name="app_version">4.4 beta 28</string>
<string name="app_market_url">https://market.android.com/search?q=pname:org.eehouse.android.xw4</string>
<!--string name="app_market_url">market://search?q=pname:org.eehouse.android.xw4</string-->
<string name="game_urlf">http://%1$s/redir.php?lang=%2$d</string>
<string name="game_url_pathf">/%1$s/redir.php</string>
<!--string name="dict_url">http://10.0.2.2/~eehouse/and_dicts</string-->

View file

@ -565,7 +565,7 @@
you haven\'t already?</string>
<string name="invite_subject">Let\'s play Crosswords</string>
<string name="invite_bodyf">Tap on this link to start a game:
%1$s. (If you don\'t have Crosswords: %2$s.)</string>
%1$s .</string>
<string name="invite_chooser">Send invitation via</string>
<string name="no_download_warning">Unable to download. Do you have

View file

@ -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 );

View file

@ -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 )