⭐ TLDR; Updates the permission screen request flow to be scalable for multiple permission. This PR includes a new optional permission to record audio 🎤 (PR #194 implements audio in video recording)
New permissions can be optional or mandatory (revoked mandatory perms prevent PreviewScreen from loading)
Granting camera permission, minimizing the app and setting it to "ask every time" OR revoking the permission will cause it to be prompted when the app is reopened.
Granting audio/optional permission, minimizing the app, and setting it to "ask every time" will cause it to be prompted when the app is reopened
The permissions screen will only display if:
permissions are set to "ask every time"
camera permission is not granted
Interesting changes:
permissions module -- excised all permissions components from JcaApp and slapped them into their own ✨ new ✨ module. (I think they like it there 😄 )
❗❗ AppTestUtil.kt -- added RECORD_AUDIO to list of required permissions. Make sure tests grant or revoke newly added permissions or they will FAIL (preview screen will be unable to load)
JcaApp.kt -- moved permission screen into the navhost. permissions screen will automatically navigate to preview once complete. Preview will automatically navigate to permissions screen if the permission has been revoked while the app was minimized. pops back stack so you can't navigate back after entering and leaving permissions screen
PermissionsEnums.kt -- closely mirrors QuickSettingsEnums.kt in purpose and implementation. It stores UI information relevant for a permission's screen (i.e. Icon, description, accessibility text)
PermissionsUi.kt -- No major visual changes. Refactored to support PermissionEnum. Completely removed CameraPermission component. PermissionTemplate now used for all permissions in PermissionsScreens.kt
PermissionsViewModel.kt -- viewmodel for... you guessed it: PermissionsScreen. The most important thing it does is hold onto the queue of PermissionEnums to be displayed on the permission screen and pops them off as you respond to permission requests.
PermissionsScreen.kt -- Takes in a PermissionsViewModel and displays the first value from the queue. The function to request a required permission changes its behavior if it has been revoked by the user. The user will be taken to the app settings screen to manually grant the permission. (Since this is rather abrupt, a future PR will prompt a dialog to politely suggest the user to the app settings to grant the permission.)
⭐ TLDR; Updates the permission screen request flow to be scalable for multiple permission. This PR includes a new optional permission to record audio 🎤 (PR #194 implements audio in video recording)
The permissions screen will only display if:
Interesting changes:
permissions
module -- excised all permissions components fromJcaApp
and slapped them into their own ✨ new ✨ module. (I think they like it there 😄 )AppTestUtil.kt
-- addedRECORD_AUDIO
to list of required permissions. Make sure tests grant or revoke newly added permissions or they will FAIL (preview screen will be unable to load)JcaApp.kt
-- moved permission screen into the navhost. permissions screen will automatically navigate to preview once complete. Preview will automatically navigate to permissions screen if the permission has been revoked while the app was minimized. pops back stack so you can't navigate back after entering and leaving permissions screenPermissionsEnums.kt
-- closely mirrorsQuickSettingsEnums.kt
in purpose and implementation. It stores UI information relevant for a permission's screen (i.e. Icon, description, accessibility text)PermissionsUi.kt
-- No major visual changes. Refactored to supportPermissionEnum
. Completely removedCameraPermission
component.PermissionTemplate
now used for all permissions inPermissionsScreens.kt
PermissionsViewModel.kt
-- viewmodel for... you guessed it:PermissionsScreen
. The most important thing it does is hold onto the queue ofPermissionEnums
to be displayed on the permission screen and pops them off as you respond to permission requests.PermissionsScreen.kt
-- Takes in a PermissionsViewModel and displays the first value from the queue. The function to request a required permission changes its behavior if it has been revoked by the user. The user will be taken to the app settings screen to manually grant the permission. (Since this is rather abrupt, a future PR will prompt a dialog to politely suggest the user to the app settings to grant the permission.)Demo of the multiple permissions screen
https://github.com/google/jetpack-camera-app/assets/20013168/ba2fbe8c-dcd9-46a3-9496-15139dd9ca35