create video call mimetype for raw contacts links

This commit is contained in:
Ehren Kret 2024-05-15 09:21:59 -05:00 committed by Nicholas Tinsley
parent c4e4eaf110
commit 757c0fd2ea
7 changed files with 49 additions and 16 deletions

View file

@ -947,12 +947,18 @@
android:launchMode="singleTask"
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize">
<intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call" />
</intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.videocall" />
</intent-filter>
</activity>
<activity android:name=".mediasend.AvatarSelectionActivity"

View file

@ -86,19 +86,6 @@ class SyncSystemContactLinksJob private constructor(parameters: Parameters) : Ba
}
}
private fun buildContactLinkConfiguration(context: Context, account: Account): ContactLinkConfiguration {
return ContactLinkConfiguration(
account = account,
appName = context.getString(R.string.app_name),
messagePrompt = { e164 -> context.getString(R.string.ContactsDatabase_message_s, e164) },
callPrompt = { e164 -> context.getString(R.string.ContactsDatabase_signal_call_s, e164) },
e164Formatter = { number -> PhoneNumberFormatter.get(context).format(number) },
messageMimetype = MESSAGE_MIMETYPE,
callMimetype = CALL_MIMETYPE,
syncTag = CONTACT_TAG
)
}
class Factory : Job.Factory<SyncSystemContactLinksJob> {
override fun create(parameters: Parameters, serializedData: ByteArray?) = SyncSystemContactLinksJob(parameters)
}
@ -110,6 +97,22 @@ class SyncSystemContactLinksJob private constructor(parameters: Parameters) : Ba
private const val MESSAGE_MIMETYPE = "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.contact"
private const val CALL_MIMETYPE = "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call"
private const val VIDEO_CALL_MIMETYPE = "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.videocall"
private const val CONTACT_TAG = "__TS"
fun buildContactLinkConfiguration(context: Context, account: Account): ContactLinkConfiguration {
return ContactLinkConfiguration(
account = account,
appName = context.getString(R.string.app_name),
messagePrompt = { e164 -> context.getString(R.string.ContactsDatabase_message_s, e164) },
callPrompt = { e164 -> context.getString(R.string.ContactsDatabase_signal_call_s, e164) },
videoCallPrompt = { e164 -> context.getString(R.string.ContactsDatabase_signal_video_call_s, e164) },
e164Formatter = { number -> PhoneNumberFormatter.get(context).format(number) },
messageMimetype = MESSAGE_MIMETYPE,
callMimetype = CALL_MIMETYPE,
videoCallMimetype = VIDEO_CALL_MIMETYPE,
syncTag = CONTACT_TAG
)
}
}
}

View file

@ -17,6 +17,8 @@ public class VoiceCallShare extends Activity {
private static final String TAG = Log.tag(VoiceCallShare.class);
private static final String VIDEO_CALL_MIME_TYPE = "vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.videocall";
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@ -32,7 +34,11 @@ public class VoiceCallShare extends Activity {
SimpleTask.run(() -> Recipient.external(this, destination), recipient -> {
if (!TextUtils.isEmpty(destination)) {
if (VIDEO_CALL_MIME_TYPE.equals(getIntent().getType())) {
ApplicationDependencies.getSignalCallManager().startOutgoingVideoCall(recipient);
} else {
ApplicationDependencies.getSignalCallManager().startOutgoingAudioCall(recipient);
}
Intent activityIntent = new Intent(this, WebRtcCallActivity.class);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View file

@ -327,7 +327,8 @@
<!-- ContactsDatabase -->
<string name="ContactsDatabase_message_s">Message %s</string>
<string name="ContactsDatabase_signal_call_s">Signal Call %s</string>
<string name="ContactsDatabase_signal_call_s">Signal Voice Call %s</string>
<string name="ContactsDatabase_signal_video_call_s">Signal Video Call %s</string>
<!-- ContactNameEditActivity -->
<!-- Toolbar title for contact name edit activity -->

View file

@ -11,4 +11,9 @@
android:mimeType="vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.call"
android:summaryColumn="data2"
android:detailColumn="data3"/>
<ContactsDataKind
android:icon="@mipmap/ic_launcher"
android:mimeType="vnd.android.cursor.item/vnd.org.thoughtcrime.securesms.videocall"
android:summaryColumn="data2"
android:detailColumn="data3"/>
</ContactsSource>

View file

@ -17,8 +17,10 @@ class ContactLinkConfiguration(
val appName: String,
val messagePrompt: (String) -> String,
val callPrompt: (String) -> String,
val videoCallPrompt: (String) -> String,
val e164Formatter: (String) -> String,
val messageMimetype: String,
val callMimetype: String,
val videoCallMimetype: String,
val syncTag: String
)

View file

@ -526,6 +526,16 @@ object SystemContactsRepository {
.withYieldAllowed(true)
.build(),
// Data entry for making a video call
ContentProviderOperation.newInsert(dataUri)
.withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, operationIndex)
.withValue(ContactsContract.Data.MIMETYPE, linkConfig.videoCallMimetype)
.withValue(ContactsContract.Data.DATA1, systemContactInfo.displayPhone)
.withValue(ContactsContract.Data.DATA2, linkConfig.appName)
.withValue(ContactsContract.Data.DATA3, linkConfig.videoCallPrompt(systemContactInfo.displayPhone))
.withYieldAllowed(true)
.build(),
// Ensures that this RawContact entry is shown next to another RawContact entry we found for this contact
ContentProviderOperation.newUpdate(ContactsContract.AggregationExceptions.CONTENT_URI)
.withValue(ContactsContract.AggregationExceptions.RAW_CONTACT_ID1, systemContactInfo.siblingRawContactId)