mirror of
https://github.com/videolan/vlc-android
synced 2024-12-04 23:34:38 +08:00
Refactor the storage fine permission request code
This commit is contained in:
parent
7d9760aab6
commit
dbab387fcf
@ -169,7 +169,7 @@ class MainActivity : ContentActivity(),
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == 1000) {
|
||||
if (requestCode == Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE) {
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
forceRefresh()
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class OnboardingActivity : AppCompatActivity(), OnboardingFragmentListener {
|
||||
grantResults: IntArray
|
||||
) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||
if (requestCode == 1000) {
|
||||
if (requestCode == Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE) {
|
||||
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
viewModel.permissionAlreadyAsked = true
|
||||
onNext()
|
||||
@ -124,7 +124,7 @@ class OnboardingActivity : AppCompatActivity(), OnboardingFragmentListener {
|
||||
Manifest.permission.READ_MEDIA_AUDIO,
|
||||
Manifest.permission.READ_MEDIA_IMAGES,
|
||||
Manifest.permission.READ_MEDIA_VIDEO
|
||||
), 1000
|
||||
), Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE
|
||||
)
|
||||
return@launch
|
||||
} else getStoragePermission(withDialog = false, onlyMedia = false)
|
||||
|
@ -51,6 +51,7 @@ import org.videolan.vlc.gui.SecondaryActivity
|
||||
import org.videolan.vlc.gui.helpers.getBitmapFromDrawable
|
||||
import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate.Companion.askStoragePermission
|
||||
import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate.Companion.getStoragePermission
|
||||
import org.videolan.vlc.util.Permissions
|
||||
|
||||
class EmptyLoadingStateView : FrameLayout {
|
||||
|
||||
@ -158,14 +159,14 @@ class EmptyLoadingStateView : FrameLayout {
|
||||
EmptyLoadingState.MISSING_AUDIO_PERMISSION -> ActivityCompat.requestPermissions(
|
||||
context as Activity, arrayOf(
|
||||
Manifest.permission.READ_MEDIA_AUDIO
|
||||
), 1000
|
||||
), Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE
|
||||
)
|
||||
|
||||
EmptyLoadingState.MISSING_VIDEO_PERMISSION -> ActivityCompat.requestPermissions(
|
||||
context as Activity, arrayOf(
|
||||
Manifest.permission.READ_MEDIA_VIDEO,
|
||||
Manifest.permission.READ_MEDIA_IMAGES
|
||||
), 1000
|
||||
), Permissions.FINE_STORAGE_PERMISSION_REQUEST_CODE
|
||||
)
|
||||
|
||||
else -> (context as? FragmentActivity)?.askStoragePermission(false, null)
|
||||
|
@ -64,6 +64,8 @@ object Permissions {
|
||||
const val PERMISSION_WRITE_STORAGE_TAG = 253
|
||||
const val MANAGE_EXTERNAL_STORAGE = 256
|
||||
|
||||
const val FINE_STORAGE_PERMISSION_REQUEST_CODE = 100001
|
||||
|
||||
|
||||
const val PERMISSION_SYSTEM_RINGTONE = 42
|
||||
private const val PERMISSION_SYSTEM_BRIGHTNESS = 43
|
||||
|
Loading…
Reference in New Issue
Block a user