add relay2 game URL to clip without requiring button

Dumb to require launching browser I'm not going to use
This commit is contained in:
Eric House 2022-05-07 19:22:36 -07:00
parent 4332368a2e
commit 8d285cfd3c
2 changed files with 22 additions and 6 deletions

View file

@ -458,6 +458,9 @@ public abstract class DelegateBase implements DlgClickNotify,
if ( conTypes.contains( CommsConnType.COMMS_CONN_MQTT ) ) {
buttonTxt = R.string.list_item_relaypage;
final int gameID = summary.gameID;
if ( BuildConfig.NON_RELEASE ) {
NetUtils.gameURLToClip( m_activity, gameID );
}
lstnr = new OnClickListener() {
@Override
public void onClick( DialogInterface dlg, int whichButton ) {

View file

@ -48,6 +48,8 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.SocketFactory;
import org.eehouse.android.xw4.jni.XwJNI;
public class NetUtils {
private static final String TAG = NetUtils.class.getSimpleName();
@ -125,19 +127,30 @@ public class NetUtils {
}
}
private static String urlForGameID( Context context, int gameID )
{
String host = XWPrefs.getPrefsString( context, R.string.key_mqtt_host );
String myID = XwJNI.dvc_getMQTTDevID( null );
String url = String.format( "https://%s/xw4/ui/games?gameid=%d&d1=%s",
host, gameID, myID );
return url;
}
static void gameURLToClip( Context context, int gameID )
{
String url = urlForGameID( context, gameID );
Utils.stringToClip( context, url );
Utils.showToast( context, R.string.relaypage_url_copied );
}
static void copyAndLaunchGamePage( Context context, int gameID )
{
// Requires a login, so only of use to me right now....
String host = XWPrefs.getPrefsString( context, R.string.key_mqtt_host );
String url = String.format( "https://%s/xw4/ui/games?gameid=%d",
host, gameID );
String url = urlForGameID( context, gameID );
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
if ( null != intent.resolveActivity( context.getPackageManager() ) ) {
context.startActivity( intent );
}
Utils.stringToClip( context, url );
Utils.showToast( context, R.string.relaypage_url_copied );
}
public static byte[][][] queryRelay( Context context, String[] ids )