[Android] Properly manage permissions settings visibility
Nicolas Pomepuy
git at videolan.org
Mon Nov 25 11:07:02 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Nov 14 15:09:48 2024 +0100| [d60182959ed0aba8f617943c6f4ea48f0d0d70a3] | committer: Duncan McNamara
Properly manage permissions settings visibility
> https://code.videolan.org/videolan/vlc-android/commit/d60182959ed0aba8f617943c6f4ea48f0d0d70a3
---
.../org/videolan/television/ui/preferences/PreferencesFragment.kt | 6 ++++++
application/vlc-android/res/xml/preferences.xml | 3 ++-
.../src/org/videolan/vlc/gui/dialogs/PermissionListDialog.kt | 5 +++--
.../src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt | 1 +
4 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesFragment.kt b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesFragment.kt
index 7c8b02a848..5af34b529d 100644
--- a/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesFragment.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/preferences/PreferencesFragment.kt
@@ -43,6 +43,7 @@ import org.videolan.vlc.gui.PinCodeActivity
import org.videolan.vlc.gui.PinCodeReason
import org.videolan.vlc.gui.SecondaryActivity
import org.videolan.vlc.gui.dialogs.ConfirmAudioPlayQueueDialog
+import org.videolan.vlc.gui.dialogs.PermissionListDialog
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
class PreferencesFragment : BasePreferenceFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
@@ -57,6 +58,7 @@ class PreferencesFragment : BasePreferenceFragment(), SharedPreferences.OnShared
findPreference<Preference>("casting_category")?.isVisible = false
findPreference<Preference>(KEY_VIDEO_APP_SWITCH)?.isVisible = AndroidDevices.hasPiP
findPreference<Preference>("remote_access_category")?.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
+ findPreference<Preference>("permissions_title")?.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
}
override fun onStart() {
@@ -138,6 +140,10 @@ class PreferencesFragment : BasePreferenceFragment(), SharedPreferences.OnShared
activity?.setResult(RESULT_RESTART)
return true
}
+ "permissions" -> {
+ PermissionListDialog.newInstance().show((activity as FragmentActivity).supportFragmentManager, "PermissionListDialog")
+ return true
+ }
else -> super.onPreferenceTreeClick(preference)
}
}
diff --git a/application/vlc-android/res/xml/preferences.xml b/application/vlc-android/res/xml/preferences.xml
index 4610820de1..77c3655772 100644
--- a/application/vlc-android/res/xml/preferences.xml
+++ b/application/vlc-android/res/xml/preferences.xml
@@ -50,7 +50,8 @@
android:summary="%s"
android:title="@string/metered_connection"/>
</PreferenceCategory>
- <PreferenceCategory android:title="@string/permissions">
+ <PreferenceCategory android:title="@string/permissions"
+ android:key="permissions_title">
<PreferenceScreen
android:key="permissions"
android:summary="@string/permissions_summary"
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PermissionListDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PermissionListDialog.kt
index cbe41861b1..7404cd8faf 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PermissionListDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PermissionListDialog.kt
@@ -38,6 +38,7 @@ import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED
import kotlinx.coroutines.launch
+import org.videolan.resources.AndroidDevices
import org.videolan.resources.SCHEME_PACKAGE
import org.videolan.tools.dp
import org.videolan.tools.setGone
@@ -196,7 +197,7 @@ class PermissionListDialog : VLCBottomSheetDialogFragment() {
binding.manageMediaPermsCheck.background = ContextCompat.getDrawable(requireActivity(), R.drawable.rounded_corners_permissions_warning)
showWarning()
} else
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.R) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
if (!Permissions.hasAllAccess(requireActivity())) {
Permissions.checkReadStoragePermission(
requireActivity(),
@@ -256,7 +257,7 @@ class PermissionListDialog : VLCBottomSheetDialogFragment() {
}
//Manage view visibility for older versions
- if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.R) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R || AndroidDevices.isTv) {
binding.manageMediaPermsCheck.setGone()
binding.manageMediaVideo.setGone()
binding.manageMediaAudio.setGone()
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt
index e3c5b6a79d..ebf5e5c453 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/preferences/PreferencesFragment.kt
@@ -89,6 +89,7 @@ class PreferencesFragment : BasePreferenceFragment(), SharedPreferences.OnShared
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
findPreference<Preference>("remote_access_category")?.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
+ findPreference<Preference>("permissions_title")?.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
More information about the Android
mailing list