From 6bc65476d029bfc971ba3ac9bc806d078a5da7f4 Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 7 Mar 2019 17:40:16 -0800 Subject: [PATCH] add a case for Signal as default SMS app --- .../org/eehouse/android/xw4/GameUtils.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java index 18a5dceb6..6642719e5 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/GameUtils.java @@ -741,15 +741,17 @@ public class GameUtils { R.string.invite_sms_fmt ); if ( null != message ) { boolean succeeded = false; + String defaultSmsPkg = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT + ? Telephony.Sms.getDefaultSmsPackage(activity) + : Settings.Secure.getString(activity.getContentResolver(), + "sms_default_application"); + Log.d( TAG, "launchSMSInviteActivity(): default app: %s", defaultSmsPkg ); + outer: for ( int ii = 0; !succeeded; ++ii ) { Intent intent; switch ( ii ) { - case 0: - String defaultSmsPkg = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT - ? Telephony.Sms.getDefaultSmsPackage(activity) - : Settings.Secure.getString(activity.getContentResolver(), - "sms_default_application"); + case 0: // test case: QKSMS intent = new Intent( Intent.ACTION_SEND ) .setPackage( defaultSmsPkg ) .setType( "text/plain" ) @@ -760,7 +762,14 @@ public class GameUtils { .setData(Uri.parse("smsto:" + phone)) ; break; - case 1: + case 1: // test case: Signal + intent = new Intent( Intent.ACTION_SENDTO, + Uri.parse("smsto:" + phone) ) + .putExtra("sms_body", message) + .setPackage( defaultSmsPkg ) + ; + break; + case 2: intent = new Intent( Intent.ACTION_VIEW ) .setData( Uri.parse("sms:" + phone) ) .putExtra( "sms_body", message ) @@ -1350,8 +1359,8 @@ public class GameUtils { if ( null != gamePtr ) { int nSent = XwJNI.comms_resendAll( gamePtr, true, m_filter, false ); - Log.d( TAG, "Resender.doInBackground(): sent %d " - + "messages for rowid %d", nSent, rowid ); + // Log.d( TAG, "Resender.doInBackground(): sent %d " + // + "messages for rowid %d", nSent, rowid ); nSentTotal += sink.numSent(); } else { Log.d( TAG, "Resender.doInBackground(): loadMakeGame()"