properly handle upgrading from old version to 4.x
This commit is contained in:
parent
2884d2fad6
commit
dccba111bd
|
@ -1,11 +1,15 @@
|
|||
package com.simplemobiletools.contacts.activities
|
||||
|
||||
import android.Manifest
|
||||
import android.app.SearchManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.support.v4.app.ActivityCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.support.v4.view.MenuItemCompat
|
||||
import android.support.v4.view.ViewPager
|
||||
import android.support.v7.widget.SearchView
|
||||
|
@ -63,6 +67,12 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
werePermissionsHandled = true
|
||||
if (it) {
|
||||
handlePermission(PERMISSION_WRITE_CONTACTS) {
|
||||
// workaround for upgrading from version 3.x to 4.x as we added a new permission from an already granted permissions group
|
||||
val hasGetAccountsPermission = ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) == PackageManager.PERMISSION_GRANTED
|
||||
if (!hasGetAccountsPermission) {
|
||||
ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.GET_ACCOUNTS), 34)
|
||||
}
|
||||
|
||||
storeLocalAccountData()
|
||||
initFragments()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue