allow sending batch SMS or emails
This commit is contained in:
parent
e572ecb678
commit
a095dc1983
|
@ -1,6 +1,8 @@
|
|||
package com.simplemobiletools.contacts.adapters
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -15,6 +17,7 @@ import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
|||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||
import com.simplemobiletools.commons.extensions.getColoredDrawableWithColor
|
||||
import com.simplemobiletools.commons.extensions.isActivityDestroyed
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.models.RadioItem
|
||||
import com.simplemobiletools.commons.views.FastScroller
|
||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||
|
@ -62,6 +65,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
findItem(R.id.cab_remove).isVisible = location == LOCATION_FAVORITES_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
findItem(R.id.cab_add_to_favorites).isVisible = location == LOCATION_CONTACTS_TAB
|
||||
findItem(R.id.cab_add_to_group).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB
|
||||
findItem(R.id.cab_send_sms_to_contacts).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB
|
||||
findItem(R.id.cab_send_email_to_contacts).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_FAVORITES_TAB
|
||||
findItem(R.id.cab_delete).isVisible = location == LOCATION_CONTACTS_TAB || location == LOCATION_GROUP_CONTACTS
|
||||
|
||||
if (location == LOCATION_GROUP_CONTACTS) {
|
||||
|
@ -87,6 +92,8 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
R.id.cab_add_to_favorites -> addToFavorites()
|
||||
R.id.cab_add_to_group -> addToGroup()
|
||||
R.id.cab_share -> shareContacts()
|
||||
R.id.cab_send_sms_to_contacts -> sendSMSToContacts()
|
||||
R.id.cab_send_email_to_contacts -> sendEmailToContacts()
|
||||
R.id.cab_remove -> removeContacts()
|
||||
R.id.cab_delete -> askConfirmDelete()
|
||||
}
|
||||
|
@ -225,6 +232,49 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
activity.shareContacts(filtered)
|
||||
}
|
||||
|
||||
private fun sendSMSToContacts() {
|
||||
val numbers = StringBuilder()
|
||||
selectedPositions.forEach {
|
||||
val contact = contactItems[it]
|
||||
contact.phoneNumbers.forEach {
|
||||
if (it.value.isNotEmpty()) {
|
||||
numbers.append("${it.value};")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val uriString = "smsto:${numbers.toString().trimEnd(';')}"
|
||||
Intent(Intent.ACTION_SENDTO, Uri.parse(uriString)).apply {
|
||||
if (resolveActivity(activity.packageManager) != null) {
|
||||
activity.startActivity(this)
|
||||
} else {
|
||||
activity.toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendEmailToContacts() {
|
||||
val emails = ArrayList<String>()
|
||||
selectedPositions.forEach {
|
||||
val contact = contactItems[it]
|
||||
contact.emails.forEach {
|
||||
if (it.value.isNotEmpty()) {
|
||||
emails.add(it.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Intent(Intent.ACTION_SEND_MULTIPLE).apply {
|
||||
type = "message/rfc822"
|
||||
putExtra(Intent.EXTRA_EMAIL, emails.toTypedArray())
|
||||
if (resolveActivity(activity.packageManager) != null) {
|
||||
activity.startActivity(this)
|
||||
} else {
|
||||
activity.toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewRecycled(holder: ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
if (!activity.isActivityDestroyed()) {
|
||||
|
|
|
@ -26,6 +26,14 @@
|
|||
android:icon="@drawable/ic_share"
|
||||
android:title="@string/share"
|
||||
app:showAsAction="ifRoom"/>
|
||||
<item
|
||||
android:id="@+id/cab_send_sms_to_contacts"
|
||||
android:title="@string/send_sms_to_contacts"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/cab_send_email_to_contacts"
|
||||
android:title="@string/send_email_to_contacts"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/cab_delete"
|
||||
android:icon="@drawable/ic_delete"
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Company</string>
|
||||
<string name="job_position">Job position</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Neuer Kontakt</string>
|
||||
<string name="edit_contact">Kontakt bearbeiten</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Company</string>
|
||||
<string name="job_position">Job position</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Νέα επαφή</string>
|
||||
<string name="edit_contact">Επεξεργασία επαφής</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Société</string>
|
||||
<string name="job_position">Poste</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Nouveau contact</string>
|
||||
<string name="edit_contact">Modifier contact</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Tvrtka</string>
|
||||
<string name="job_position">Radno mjesto</string>
|
||||
<string name="website">Web stranica</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Novi kontakt</string>
|
||||
<string name="edit_contact">Uredi kontakt</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Company</string>
|
||||
<string name="job_position">Job position</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">새로운 연락처</string>
|
||||
<string name="edit_contact">연락처 수정</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Company</string>
|
||||
<string name="job_position">Job position</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Naujas kontaktas</string>
|
||||
<string name="edit_contact">Redaguoti kontaktą</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Organização</string>
|
||||
<string name="job_position">Cargo</string>
|
||||
<string name="website">Site</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Novo contacto</string>
|
||||
<string name="edit_contact">Editar contacto</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Организация</string>
|
||||
<string name="job_position">Должность</string>
|
||||
<string name="website">Сайт</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Новый контакт</string>
|
||||
<string name="edit_contact">Редактировать контакт</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Firma</string>
|
||||
<string name="job_position">Pracovná pozícia</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Poslať kontaktom SMS</string>
|
||||
<string name="send_email_to_contacts">Poslať kontaktom email</string>
|
||||
<string name="send_sms_to_group">Poslať skupine SMS</string>
|
||||
<string name="send_email_to_group">Poslať skupine email</string>
|
||||
|
||||
<string name="new_contact">Nový kontakt</string>
|
||||
<string name="edit_contact">Upraviť kontakt</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Företag</string>
|
||||
<string name="job_position">Befattning</string>
|
||||
<string name="website">Webbplats</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">Ny kontakt</string>
|
||||
<string name="edit_contact">Redigera kontakt</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">公司</string>
|
||||
<string name="job_position">職位</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">新聯絡人</string>
|
||||
<string name="edit_contact">編輯聯絡人</string>
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
<string name="company">Company</string>
|
||||
<string name="job_position">Job position</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="send_sms_to_contacts">Send SMS to contacts</string>
|
||||
<string name="send_email_to_contacts">Send email to contacts</string>
|
||||
<string name="send_sms_to_group">Send SMS to group</string>
|
||||
<string name="send_email_to_group">Send email to group</string>
|
||||
|
||||
<string name="new_contact">New contact</string>
|
||||
<string name="edit_contact">Edit contact</string>
|
||||
|
|
Loading…
Reference in New Issue