handle both write and read contact permissions
This commit is contained in:
parent
efc70f1e18
commit
7b849cb090
|
@ -15,6 +15,7 @@ import com.bumptech.glide.request.RequestListener
|
|||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
||||
import com.simplemobiletools.contacts.R
|
||||
import com.simplemobiletools.contacts.extensions.config
|
||||
|
@ -35,9 +36,16 @@ class ContactActivity : SimpleActivity() {
|
|||
setContentView(R.layout.activity_contact)
|
||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
|
||||
|
||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
if (it) {
|
||||
initContact()
|
||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||
if (it) {
|
||||
initContact()
|
||||
} else {
|
||||
toast(R.string.no_contacts_permission)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
toast(R.string.no_contacts_permission)
|
||||
finish()
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simplemobiletools.commons.extensions.toast
|
|||
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||
import com.simplemobiletools.contacts.BuildConfig
|
||||
|
@ -36,9 +37,16 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||
appLaunched()
|
||||
contacts_fab.setOnClickListener { addNewContact() }
|
||||
|
||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||
if (it) {
|
||||
initContacts()
|
||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||
if (it) {
|
||||
initContacts()
|
||||
} else {
|
||||
toast(R.string.no_contacts_permission)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
toast(R.string.no_contacts_permission)
|
||||
finish()
|
||||
|
|
Loading…
Reference in New Issue