show a warning about deleting from all sources at the View screen
This commit is contained in:
parent
ec77ad3217
commit
33357e1413
1 changed files with 18 additions and 1 deletions
|
@ -9,6 +9,7 @@ import android.view.View
|
|||
import android.view.WindowManager
|
||||
import android.widget.RelativeLayout
|
||||
import com.bumptech.glide.Glide
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||
|
@ -82,7 +83,7 @@ class ViewContactActivity : ContactActivity() {
|
|||
R.id.edit -> launchEditContact(contact!!)
|
||||
R.id.share -> shareContact()
|
||||
R.id.open_with -> openWith()
|
||||
R.id.delete -> deleteContact()
|
||||
R.id.delete -> deleteContactFromAllSources()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
|
@ -508,6 +509,22 @@ class ViewContactActivity : ContactActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun deleteContactFromAllSources() {
|
||||
val addition = if (contact_sources_holder.childCount > 1) {
|
||||
"\n\n${getString(R.string.delete_from_all_sources)}"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
val message = "${getString(R.string.proceed_with_deletion)}$addition"
|
||||
ConfirmationDialog(this, message) {
|
||||
if (contact != null) {
|
||||
ContactsHelper(this).deleteContact(contact!!)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStarDrawable(on: Boolean) = resources.getDrawable(if (on) R.drawable.ic_star_on_vector else R.drawable.ic_star_off_vector)
|
||||
|
||||
private fun View.copyOnLongClick(value: String) {
|
||||
|
|
Loading…
Reference in a new issue