Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Android permissions from HomeActivity #46

Open
JoaquimLey opened this issue Apr 21, 2018 · 0 comments
Open

Extract Android permissions from HomeActivity #46

JoaquimLey opened this issue Apr 21, 2018 · 0 comments

Comments

@JoaquimLey
Copy link
Owner

HomeActivity is currently responsible for requesting the necessary Android permissions, this is wrong.

Context

The idea is the HomeActivity should only be responsible for navigation.

Tasks

  • Create a specific activity to request the permissions (since the app is unusable without), keeps the responsibilities simple.

Extract this code from HomeActivity

 /**
     * Runtime permission shenanigans
     */
    private fun hasReadSmsPermission(): Boolean {
        return ContextCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED &&
                ContextCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS) == PackageManager.PERMISSION_GRANTED &&
                ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_GRANTED
    }

    private fun requestReadAndSendSmsPermission() {
        ActivityCompat.requestPermissions(this,
                arrayOf(Manifest.permission.SEND_SMS, Manifest.permission.READ_SMS, Manifest.permission.RECEIVE_SMS), SMS_PERMISSION_CODE)
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant