to deal with case where somebody invites a friend who doesn't have

Crosswords installed, add a URL to texts that will show up if it makes
it to an inbox and takes user to an explanation and download URL.
This commit is contained in:
Eric House 2012-03-31 10:05:31 -07:00
parent fff4116d24
commit 51cfbb196e

View file

@ -45,7 +45,9 @@ import org.eehouse.android.xw4.jni.XwJNI;
public class SMSService extends Service {
private static final String PUBLIC_HEADER = "_XW4";
private static final String PUBLIC_HEADER = "-XW4 ";
private static final String INSTALL_URL = "http://eehouse.org/_/aa.htm ";
private static final int MAX_SMS_LEN = 140; // ??? differs by network
private static final int MAX_LEN_TEXT = 100;
private static final int HANDLE = 1;
@ -116,14 +118,21 @@ public class SMSService extends Service {
public static String toPublicFmt( String msg )
{
return PUBLIC_HEADER + msg;
String result;
int msglen = msg.length() + PUBLIC_HEADER.length();
int urllen = INSTALL_URL.length();
result = String.format( "%s%s%s", PUBLIC_HEADER,
msglen + urllen < MAX_SMS_LEN ? INSTALL_URL : "",
msg );
return result;
}
public static String fromPublicFmt( String msg )
{
String result = null;
if ( msg.startsWith( PUBLIC_HEADER ) ) {
result = msg.substring( PUBLIC_HEADER.length() );
int index = msg.lastIndexOf( " " );
result = msg.substring( index + 1 );
}
return result;
}