mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
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:
parent
4332368a2e
commit
8d285cfd3c
2 changed files with 22 additions and 6 deletions
|
@ -458,6 +458,9 @@ public abstract class DelegateBase implements DlgClickNotify,
|
||||||
if ( conTypes.contains( CommsConnType.COMMS_CONN_MQTT ) ) {
|
if ( conTypes.contains( CommsConnType.COMMS_CONN_MQTT ) ) {
|
||||||
buttonTxt = R.string.list_item_relaypage;
|
buttonTxt = R.string.list_item_relaypage;
|
||||||
final int gameID = summary.gameID;
|
final int gameID = summary.gameID;
|
||||||
|
if ( BuildConfig.NON_RELEASE ) {
|
||||||
|
NetUtils.gameURLToClip( m_activity, gameID );
|
||||||
|
}
|
||||||
lstnr = new OnClickListener() {
|
lstnr = new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick( DialogInterface dlg, int whichButton ) {
|
public void onClick( DialogInterface dlg, int whichButton ) {
|
||||||
|
|
|
@ -48,6 +48,8 @@ import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
|
|
||||||
public class NetUtils {
|
public class NetUtils {
|
||||||
private static final String TAG = NetUtils.class.getSimpleName();
|
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 )
|
static void copyAndLaunchGamePage( Context context, int gameID )
|
||||||
{
|
{
|
||||||
// Requires a login, so only of use to me right now....
|
// Requires a login, so only of use to me right now....
|
||||||
String host = XWPrefs.getPrefsString( context, R.string.key_mqtt_host );
|
String url = urlForGameID( context, gameID );
|
||||||
String url = String.format( "https://%s/xw4/ui/games?gameid=%d",
|
|
||||||
host, gameID );
|
|
||||||
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
|
Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
|
||||||
if ( null != intent.resolveActivity( context.getPackageManager() ) ) {
|
if ( null != intent.resolveActivity( context.getPackageManager() ) ) {
|
||||||
context.startActivity( intent );
|
context.startActivity( intent );
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.stringToClip( context, url );
|
|
||||||
Utils.showToast( context, R.string.relaypage_url_copied );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[][][] queryRelay( Context context, String[] ids )
|
public static byte[][][] queryRelay( Context context, String[] ids )
|
||||||
|
|
Loading…
Reference in a new issue