Skip to content

Commit

Permalink
[ui-androidx] show external storage permission dialog if it is required.
Browse files Browse the repository at this point in the history
The UI is the only place where we can ask users to grant the permission so far.

Right now only READ_EXTERNAL_STORAGE is the thing we need for sfizz.
  • Loading branch information
atsushieno committed Jul 30, 2020
1 parent 3e10bca commit af51816
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.androidaudioplugin.ui.androidx

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -63,5 +64,12 @@ class LocalPluginListActivity : AppCompatActivity() {
Toast.makeText(this, "Debugging mode enabled: now the service will block until debugger gets connected",
Toast.LENGTH_LONG).show()
}

// Show permissions dialog if any of them are required.
var readExtStorage = android.Manifest.permission.READ_EXTERNAL_STORAGE
if (packageManager.getPackageInfo(packageName, PackageManager.GET_PERMISSIONS)
.requestedPermissions.contains(readExtStorage) &&
checkSelfPermission(readExtStorage) == PackageManager.PERMISSION_DENIED)
requestPermissions(arrayOf(readExtStorage), 0)
}
}

0 comments on commit af51816

Please sign in to comment.