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.RequestOptions
|
||||||
import com.bumptech.glide.request.target.Target
|
import com.bumptech.glide.request.target.Target
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
|
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||||
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
||||||
import com.simplemobiletools.contacts.R
|
import com.simplemobiletools.contacts.R
|
||||||
import com.simplemobiletools.contacts.extensions.config
|
import com.simplemobiletools.contacts.extensions.config
|
||||||
|
@ -35,6 +36,8 @@ class ContactActivity : SimpleActivity() {
|
||||||
setContentView(R.layout.activity_contact)
|
setContentView(R.layout.activity_contact)
|
||||||
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
|
supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_cross)
|
||||||
|
|
||||||
|
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||||
|
if (it) {
|
||||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
initContact()
|
initContact()
|
||||||
|
@ -43,6 +46,11 @@ class ContactActivity : SimpleActivity() {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
toast(R.string.no_contacts_permission)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initContact() {
|
private fun initContact() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.simplemobiletools.commons.extensions.toast
|
||||||
import com.simplemobiletools.commons.extensions.updateTextColors
|
import com.simplemobiletools.commons.extensions.updateTextColors
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
|
||||||
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
|
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.helpers.PERMISSION_WRITE_CONTACTS
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.contacts.BuildConfig
|
import com.simplemobiletools.contacts.BuildConfig
|
||||||
|
@ -36,6 +37,8 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
appLaunched()
|
appLaunched()
|
||||||
contacts_fab.setOnClickListener { addNewContact() }
|
contacts_fab.setOnClickListener { addNewContact() }
|
||||||
|
|
||||||
|
handlePermission(PERMISSION_READ_CONTACTS) {
|
||||||
|
if (it) {
|
||||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||||
if (it) {
|
if (it) {
|
||||||
initContacts()
|
initContacts()
|
||||||
|
@ -44,6 +47,11 @@ class MainActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
toast(R.string.no_contacts_permission)
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue