forked from hardcoresushi/DroidFS
Fix storage permission requests
This commit is contained in:
parent
1e75e9a32f
commit
a726f7a7d0
@ -80,16 +80,6 @@ class SelectPathFragment: Fragment() {
|
|||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun requestManageAllFiles(): Boolean {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
||||||
if (!Environment.isExternalStorageManager()) {
|
|
||||||
startActivity(Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:"+requireContext().packageName)))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
originalRememberVolume = sharedPrefs.getBoolean(ConstValues.REMEMBER_VOLUME_KEY, true)
|
originalRememberVolume = sharedPrefs.getBoolean(ConstValues.REMEMBER_VOLUME_KEY, true)
|
||||||
@ -111,8 +101,13 @@ class SelectPathFragment: Fragment() {
|
|||||||
refreshStatus(binding.editVolumeName.text)
|
refreshStatus(binding.editVolumeName.text)
|
||||||
}
|
}
|
||||||
binding.buttonPickDirectory.setOnClickListener {
|
binding.buttonPickDirectory.setOnClickListener {
|
||||||
if (!requestManageAllFiles()) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Environment.isExternalStorageManager()) {
|
||||||
|
launchPickDirectory()
|
||||||
|
} else {
|
||||||
|
startActivity(Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, Uri.parse("package:"+requireContext().packageName)))
|
||||||
|
}
|
||||||
|
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (
|
if (
|
||||||
ContextCompat.checkSelfPermission(
|
ContextCompat.checkSelfPermission(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
@ -135,7 +130,6 @@ class SelectPathFragment: Fragment() {
|
|||||||
launchPickDirectory()
|
launchPickDirectory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
binding.editVolumeName.addTextChangedListener(object: TextWatcher {
|
binding.editVolumeName.addTextChangedListener(object: TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable?) {}
|
override fun afterTextChanged(s: Editable?) {}
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user