Re Added read Permission check as i probably shouldn't have removed it

This commit is contained in:
Jnewbon 2022-07-11 00:43:36 +01:00
parent f998deb725
commit 7fe3849705
No known key found for this signature in database
GPG key ID: D93597B99F8F7E91

View file

@ -5,9 +5,11 @@ import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.ServiceConnection import android.content.ServiceConnection
import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import android.os.IBinder import android.os.IBinder
import android.util.Log import android.util.Log
import androidx.core.app.ActivityCompat
import com.anggrayudi.storage.SimpleStorage import com.anggrayudi.storage.SimpleStorage
import com.anggrayudi.storage.SimpleStorageHelper import com.anggrayudi.storage.SimpleStorageHelper
import com.audiobookshelf.app.data.AbsDatabase import com.audiobookshelf.app.data.AbsDatabase
@ -31,6 +33,11 @@ class MainActivity : BridgeActivity() {
val storageHelper = SimpleStorageHelper(this) val storageHelper = SimpleStorageHelper(this)
val storage = SimpleStorage(this) val storage = SimpleStorage(this)
val REQUEST_PERMISSIONS = 1
var PERMISSIONS_ALL = arrayOf(
Manifest.permission.READ_EXTERNAL_STORAGE
)
public override fun onCreate(savedInstanceState: Bundle?) { public override fun onCreate(savedInstanceState: Bundle?) {
// TODO: Optimize using strict mode logs // TODO: Optimize using strict mode logs
// StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder() // StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
@ -50,6 +57,12 @@ class MainActivity : BridgeActivity() {
DbManager.initialize(applicationContext) DbManager.initialize(applicationContext)
val permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
PERMISSIONS_ALL,
REQUEST_PERMISSIONS)
}
registerPlugin(AbsAudioPlayer::class.java) registerPlugin(AbsAudioPlayer::class.java)
registerPlugin(AbsDownloader::class.java) registerPlugin(AbsDownloader::class.java)