diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java index d8460e01b..e8f1c8d71 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/SMSService.java @@ -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; }