add Contacts permission

This commit is contained in:
tibbi 2017-12-10 11:19:55 +01:00
parent 6015afdb9f
commit b655590776
3 changed files with 19 additions and 1 deletions

View File

@ -32,5 +32,5 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.2.3'
implementation 'com.simplemobiletools:commons:3.2.4'
}

View File

@ -4,6 +4,9 @@
package="com.simplemobiletools.contacts"
android:installLocation="auto">
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<application
android:name=".App"
android:allowBackup="true"

View File

@ -6,8 +6,10 @@ import android.view.Menu
import android.view.MenuItem
import com.simplemobiletools.commons.extensions.appLaunched
import com.simplemobiletools.commons.extensions.restartActivity
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
import com.simplemobiletools.commons.helpers.LICENSE_MULTISELECT
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
import com.simplemobiletools.contacts.BuildConfig
import com.simplemobiletools.contacts.R
import com.simplemobiletools.contacts.extensions.config
@ -19,6 +21,15 @@ class MainActivity : SimpleActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
appLaunched()
handlePermission(PERMISSION_WRITE_CONTACTS) {
if (it) {
initContacts()
} else {
toast(R.string.no_contacts_permission)
finish()
}
}
}
override fun onResume() {
@ -55,4 +66,8 @@ class MainActivity : SimpleActivity() {
private fun launchAbout() {
startAboutActivity(R.string.app_name, LICENSE_KOTLIN or LICENSE_MULTISELECT, BuildConfig.VERSION_NAME)
}
private fun initContacts() {
}
}