mirror of
https://github.com/etesync/android
synced 2025-03-24 19:35:42 +00:00
Show a snack if missing permissions.
A lot of people don't grant etesync the appropriate permissions and then complain it doesn't work. Hopefully this will fix this point of failure.
This commit is contained in:
parent
3d439ba26f
commit
c2df2f8d44
@ -12,6 +12,7 @@ import android.content.ContentResolver
|
||||
import android.content.ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS
|
||||
import android.content.Intent
|
||||
import android.content.SyncStatusObserver
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.MenuItem
|
||||
@ -132,6 +133,26 @@ class AccountsActivity : BaseActivity(), NavigationView.OnNavigationItemSelected
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
val denied = HashMap<String, Boolean>()
|
||||
for (permission in permissions.withIndex()) {
|
||||
val status = grantResults[permission.index]
|
||||
if (status != PackageManager.PERMISSION_GRANTED) {
|
||||
val key = permission.value.substringAfterLast('_')
|
||||
if (key != "TASKS") {
|
||||
// We don't want to show it for tasks
|
||||
denied[key] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (denied.size > 0) {
|
||||
val deniedString = denied.keys.joinToString(", ")
|
||||
Snackbar.make(findViewById(R.id.coordinator), getString(R.string.accounts_missing_permissions, deniedString), Snackbar.LENGTH_INDEFINITE).show()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val HINT_ACCOUNT_ADD = "AddAccount"
|
||||
}
|
||||
|
@ -81,6 +81,7 @@
|
||||
<string name="accounts_global_sync_disabled">System-wide automatic synchronization is disabled</string>
|
||||
<string name="accounts_global_sync_enable">Enable</string>
|
||||
<string name="accounts_showcase_add">You need to add an account in order to use EteSync. Click here to add one...</string>
|
||||
<string name="accounts_missing_permissions">Missing permissions: %s</string>
|
||||
|
||||
<!-- AccountUpdateService -->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user