mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Added SMS invite menu & feature
This commit is contained in:
parent
f13dceaa34
commit
838f9f592c
3 changed files with 48 additions and 5 deletions
|
|
@ -111,12 +111,15 @@ class ContactFragment : GenericFragment() {
|
|||
|
||||
viewModel.showLongPressMenuForNumberOrAddressEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { model ->
|
||||
val modalBottomSheet = ContactNumberOrAddressMenuDialogFragment({
|
||||
val modalBottomSheet = ContactNumberOrAddressMenuDialogFragment(model.isSip, {
|
||||
// onDismiss
|
||||
model.selected.value = false
|
||||
}, {
|
||||
// onCopyNumberOrAddressToClipboard
|
||||
copyNumberOrAddressToClipboard(model.displayedValue, model.isSip)
|
||||
}, {
|
||||
// onInviteNumberOrAddress
|
||||
inviteContactBySms(model.displayedValue)
|
||||
})
|
||||
|
||||
modalBottomSheet.show(
|
||||
|
|
@ -190,11 +193,22 @@ class ContactFragment : GenericFragment() {
|
|||
val sendIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_STREAM, publicUri)
|
||||
putExtra(Intent.EXTRA_SUBJECT, "John Doe")
|
||||
putExtra(Intent.EXTRA_SUBJECT, viewModel.contact.value?.friend?.name)
|
||||
type = ContactsContract.Contacts.CONTENT_VCARD_TYPE
|
||||
}
|
||||
|
||||
val shareIntent = Intent.createChooser(sendIntent, null)
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
|
||||
private fun inviteContactBySms(number: String) {
|
||||
Log.i("$TAG Sending SMS to [$number]")
|
||||
val smsIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SENDTO
|
||||
data = Uri.parse("smsto:$number")
|
||||
putExtra("address", number)
|
||||
putExtra("sms_body", "Coucou <3") // TODO FIXME
|
||||
}
|
||||
startActivity(smsIntent)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,10 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
|||
import org.linphone.databinding.ContactNumberOrAddressLongPressMenuBinding
|
||||
|
||||
class ContactNumberOrAddressMenuDialogFragment(
|
||||
private val isSip: Boolean,
|
||||
private val onDismiss: (() -> Unit)? = null,
|
||||
private val onCopyNumberOrAddressToClipboard: (() -> Unit)? = null
|
||||
private val onCopyNumberOrAddressToClipboard: (() -> Unit)? = null,
|
||||
private val onInviteNumberOrAddress: (() -> Unit)? = null
|
||||
) : BottomSheetDialogFragment() {
|
||||
companion object {
|
||||
const val TAG = "ContactNumberOrAddressMenuDialogFragment"
|
||||
|
|
@ -51,12 +53,18 @@ class ContactNumberOrAddressMenuDialogFragment(
|
|||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val view = ContactNumberOrAddressLongPressMenuBinding.inflate(layoutInflater)
|
||||
view.isSip = isSip
|
||||
|
||||
view.setCopyNumberOrAddressClickListener {
|
||||
onCopyNumberOrAddressToClipboard?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
view.setInviteNumberOrAddressClickListener {
|
||||
onInviteNumberOrAddress?.invoke()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
return view.root
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@
|
|||
<variable
|
||||
name="copyNumberOrAddressClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="inviteNumberOrAddressClickListener"
|
||||
type="View.OnClickListener" />
|
||||
<variable
|
||||
name="isSip"
|
||||
type="Boolean" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
|
@ -15,15 +21,30 @@
|
|||
android:background="@color/separator">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/copy"
|
||||
android:onClick="@{copyNumberOrAddressClickListener}"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:id="@+id/copy"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Copier le numéro"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/copy"
|
||||
app:layout_constraintBottom_toTopOf="@id/invite"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{inviteNumberOrAddressClickListener}"
|
||||
style="@style/context_menu_action_label_style"
|
||||
android:visibility="@{isSip ? View.GONE : View.VISIBLE}"
|
||||
android:id="@+id/invite"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Inviter"
|
||||
android:background="@color/gray_2"
|
||||
android:layout_marginBottom="1dp"
|
||||
android:drawableStart="@drawable/invite"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue