From 4cc6fef1bcff4e52b51ff68a306cd82332946ed8 Mon Sep 17 00:00:00 2001 From: KelvnPere Date: Wed, 7 Jun 2023 23:38:37 +0100 Subject: [PATCH 1/3] Commit for the Change made --- .gitignore | 2 +- .../emitron/data/login/LoginRepository.kt | 13 +++++++++++++ .../emitron/ui/login/PermissionActionDelegate.kt | 16 ++++++++++++++++ .../emitron/data/login/LoginRepositoryTest.kt | 14 ++++++++++++++ .../com/razeware/emitron/model/Attributes.kt | 10 ++++++++++ .../main/java/com/razeware/emitron/model/Data.kt | 8 ++++++++ .../com/razeware/emitron/model/PermissionTag.kt | 16 +++++++++++++++- 7 files changed, 77 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 17d4c7f3..c1ebe52b 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,7 @@ captures/ .externalNativeBuild # Google Services (e.g. APIs or Firebase) -google-services.json +app/google-services.json # Freeline freeline.py diff --git a/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt b/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt index 8ae8b7b6..d05c7be7 100644 --- a/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt +++ b/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt @@ -106,4 +106,17 @@ class LoginRepository @Inject constructor( * Get stored permissions */ fun getPermissionsFromPrefs(): List = loginPrefs.getPermissions() + + /** + * Check if user has permission to stream personal videos + */ + fun isPersonalVideosPlayback(): Boolean = + loginPrefs.getPermissions().contains(PermissionTag.StreamPersonal.param) + + /** + * Check if user has Team Videos permission + */ + + fun isStreamTeamsVideosPlayback():Boolean = + loginPrefs.getPermissions().contains(PermissionTag.StreamTeams.param) } diff --git a/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt b/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt index 91697acb..1c33ada9 100644 --- a/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt +++ b/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt @@ -33,6 +33,16 @@ interface PermissionsAction { */ fun isBeginnerVideoPlaybackAllowed(): Boolean + /** + * @return true if personal videos can be played, else false + */ + fun isPersonalVideos():Boolean + + /** + * @return true if teams videos can be played, else false + */ + fun isSteamTeamsVideo():Boolean + /** * LiveData for permission action */ @@ -120,4 +130,10 @@ class PermissionActionDelegate @Inject constructor( override fun isBeginnerVideoPlaybackAllowed(): Boolean = loginRepository.isBeginnerVideoPlaybackAllowed() + + override fun isPersonalVideos(): Boolean = + loginRepository.isPersonalVideosPlayback() + + override fun isSteamTeamsVideo(): Boolean = + loginRepository.isStreamTeamsVideosPlayback() } diff --git a/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt b/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt index 2e767975..3d73dce2 100644 --- a/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt +++ b/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt @@ -115,6 +115,20 @@ class LoginRepositoryTest { repository.isProfessionalVideoPlaybackAllowed() isEqualTo true } + @Test + fun hasPersonalPermission(){ + whenever(loginPrefs.getPermissions()).doReturn(listOf("stream-personal-videos")) + + repository.isPersonalVideosPlayback() isEqualTo true + } + + @Test + fun hasTeamsPermission(){ + whenever(loginPrefs.getPermissions()).doReturn(listOf("stream-team-videos")) + + repository.isStreamTeamsVideosPlayback() isEqualTo true + } + @Test fun hasStreamProPermission_NoPermission() { // Given diff --git a/model/src/main/java/com/razeware/emitron/model/Attributes.kt b/model/src/main/java/com/razeware/emitron/model/Attributes.kt index 1ca1cf2d..c5b7289b 100644 --- a/model/src/main/java/com/razeware/emitron/model/Attributes.kt +++ b/model/src/main/java/com/razeware/emitron/model/Attributes.kt @@ -73,6 +73,16 @@ data class Attributes( */ val professional: Boolean? = null, + /** + * Is content free? + */ + val teams:Boolean? = null, + + /** + * Is content free? + */ + val personal:Boolean?= null, + /** * Content popularity */ diff --git a/model/src/main/java/com/razeware/emitron/model/Data.kt b/model/src/main/java/com/razeware/emitron/model/Data.kt index 728de063..9ffb591b 100644 --- a/model/src/main/java/com/razeware/emitron/model/Data.kt +++ b/model/src/main/java/com/razeware/emitron/model/Data.kt @@ -105,6 +105,14 @@ data class Data( */ fun isProfessional(): Boolean = attributes?.professional == true + /** + * @return true if content requires a personal subscription, else false + */ + fun isPersonal(): Boolean = attributes?.personal == true + + + fun isTeams(): Boolean = attributes?.teams == true + /** * If data represents a progression object * diff --git a/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt b/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt index f0444ad0..a6db1e53 100644 --- a/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt +++ b/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt @@ -15,7 +15,21 @@ enum class PermissionTag(val param: String) { /** * Download allowed */ - Download("download-videos"); + Download("download-videos"), + + /** + * For Teams + */ + + StreamTeams("stream-team-videos"), + + /** + * Personal Videos + */ + + StreamPersonal("stream-personal-videos"); + + companion object { /** From bd9850b1caf99dfc34c105f426a56e726f4b8c4c Mon Sep 17 00:00:00 2001 From: KelvnPere Date: Wed, 7 Jun 2023 23:38:37 +0100 Subject: [PATCH 2/3] Removed Google_JSON file --- .gitignore | 2 +- .../emitron/data/login/LoginRepository.kt | 13 +++++++++++++ .../emitron/ui/login/PermissionActionDelegate.kt | 16 ++++++++++++++++ .../emitron/data/login/LoginRepositoryTest.kt | 15 ++++++++++++++- .../com/razeware/emitron/model/Attributes.kt | 10 ++++++++++ .../main/java/com/razeware/emitron/model/Data.kt | 8 ++++++++ .../com/razeware/emitron/model/PermissionTag.kt | 16 +++++++++++++++- 7 files changed, 77 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 17d4c7f3..c1ebe52b 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,7 @@ captures/ .externalNativeBuild # Google Services (e.g. APIs or Firebase) -google-services.json +app/google-services.json # Freeline freeline.py diff --git a/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt b/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt index 8ae8b7b6..d05c7be7 100644 --- a/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt +++ b/app/src/main/java/com/razeware/emitron/data/login/LoginRepository.kt @@ -106,4 +106,17 @@ class LoginRepository @Inject constructor( * Get stored permissions */ fun getPermissionsFromPrefs(): List = loginPrefs.getPermissions() + + /** + * Check if user has permission to stream personal videos + */ + fun isPersonalVideosPlayback(): Boolean = + loginPrefs.getPermissions().contains(PermissionTag.StreamPersonal.param) + + /** + * Check if user has Team Videos permission + */ + + fun isStreamTeamsVideosPlayback():Boolean = + loginPrefs.getPermissions().contains(PermissionTag.StreamTeams.param) } diff --git a/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt b/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt index 91697acb..1c33ada9 100644 --- a/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt +++ b/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt @@ -33,6 +33,16 @@ interface PermissionsAction { */ fun isBeginnerVideoPlaybackAllowed(): Boolean + /** + * @return true if personal videos can be played, else false + */ + fun isPersonalVideos():Boolean + + /** + * @return true if teams videos can be played, else false + */ + fun isSteamTeamsVideo():Boolean + /** * LiveData for permission action */ @@ -120,4 +130,10 @@ class PermissionActionDelegate @Inject constructor( override fun isBeginnerVideoPlaybackAllowed(): Boolean = loginRepository.isBeginnerVideoPlaybackAllowed() + + override fun isPersonalVideos(): Boolean = + loginRepository.isPersonalVideosPlayback() + + override fun isSteamTeamsVideo(): Boolean = + loginRepository.isStreamTeamsVideosPlayback() } diff --git a/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt b/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt index 2e767975..e32f1a5f 100644 --- a/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt +++ b/app/src/test/java/com/razeware/emitron/data/login/LoginRepositoryTest.kt @@ -110,11 +110,24 @@ class LoginRepositoryTest { fun hasStreamProPermission() { // Given whenever(loginPrefs.getPermissions()).doReturn(listOf("stream-professional-videos")) - // Then repository.isProfessionalVideoPlaybackAllowed() isEqualTo true } + @Test + fun hasPersonalPermission(){ + whenever(loginPrefs.getPermissions()).doReturn(listOf("stream-personal-videos")) + + repository.isPersonalVideosPlayback() isEqualTo true + } + + @Test + fun hasTeamsPermission(){ + whenever(loginPrefs.getPermissions()).doReturn(listOf("stream-team-videos")) + + repository.isStreamTeamsVideosPlayback() isEqualTo true + } + @Test fun hasStreamProPermission_NoPermission() { // Given diff --git a/model/src/main/java/com/razeware/emitron/model/Attributes.kt b/model/src/main/java/com/razeware/emitron/model/Attributes.kt index 1ca1cf2d..c5b7289b 100644 --- a/model/src/main/java/com/razeware/emitron/model/Attributes.kt +++ b/model/src/main/java/com/razeware/emitron/model/Attributes.kt @@ -73,6 +73,16 @@ data class Attributes( */ val professional: Boolean? = null, + /** + * Is content free? + */ + val teams:Boolean? = null, + + /** + * Is content free? + */ + val personal:Boolean?= null, + /** * Content popularity */ diff --git a/model/src/main/java/com/razeware/emitron/model/Data.kt b/model/src/main/java/com/razeware/emitron/model/Data.kt index 728de063..9ffb591b 100644 --- a/model/src/main/java/com/razeware/emitron/model/Data.kt +++ b/model/src/main/java/com/razeware/emitron/model/Data.kt @@ -105,6 +105,14 @@ data class Data( */ fun isProfessional(): Boolean = attributes?.professional == true + /** + * @return true if content requires a personal subscription, else false + */ + fun isPersonal(): Boolean = attributes?.personal == true + + + fun isTeams(): Boolean = attributes?.teams == true + /** * If data represents a progression object * diff --git a/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt b/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt index f0444ad0..a6db1e53 100644 --- a/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt +++ b/model/src/main/java/com/razeware/emitron/model/PermissionTag.kt @@ -15,7 +15,21 @@ enum class PermissionTag(val param: String) { /** * Download allowed */ - Download("download-videos"); + Download("download-videos"), + + /** + * For Teams + */ + + StreamTeams("stream-team-videos"), + + /** + * Personal Videos + */ + + StreamPersonal("stream-personal-videos"); + + companion object { /** From 8c934bb874587ae3d0dc3eb4e041d0d586eea5ae Mon Sep 17 00:00:00 2001 From: KelvnPere Date: Mon, 3 Jul 2023 16:01:13 +0100 Subject: [PATCH 3/3] Added the - stream-teams permission and personal to the collection page. --- .../ui/collection/CollectionViewModel.kt | 17 +++++++++++++++++ .../ui/login/PermissionActionDelegate.kt | 10 +++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/razeware/emitron/ui/collection/CollectionViewModel.kt b/app/src/main/java/com/razeware/emitron/ui/collection/CollectionViewModel.kt index 9d02db0b..4973d305 100644 --- a/app/src/main/java/com/razeware/emitron/ui/collection/CollectionViewModel.kt +++ b/app/src/main/java/com/razeware/emitron/ui/collection/CollectionViewModel.kt @@ -311,6 +311,8 @@ class CollectionViewModel @Inject constructor( val collection = _collection.value val isCollectionFree = collection?.attributes?.free ?: false val isProfessionalContent = collection?.isProfessional() + val isPersonalContent = collection?.isPersonal() + val isTeamsContent = collection?.isTeams() val isDownloaded = collection?.isDownloaded() return when { @@ -321,6 +323,21 @@ class CollectionViewModel @Inject constructor( permissionActionDelegate.isProfessionalVideoPlaybackAllowed() } } + + isConnected && isPersonalContent == true ->{ + if (checkDownloadPermission && isDownloaded()){ + permissionActionDelegate.isDownloadAllowed() + }else{ + permissionActionDelegate.isPersonalVideosPlaybackAllowed() + } + } + isConnected && isTeamsContent == true ->{ + if (checkDownloadPermission && isDownloaded()){ + permissionActionDelegate.isDownloadAllowed() + }else{ + permissionActionDelegate.isSteamTeamsVideoPlaybackAllowed() + } + } !isConnected -> permissionActionDelegate.isDownloadAllowed() else -> { if (checkDownloadPermission && isDownloaded == true) { diff --git a/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt b/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt index 1c33ada9..0d61894d 100644 --- a/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt +++ b/app/src/main/java/com/razeware/emitron/ui/login/PermissionActionDelegate.kt @@ -36,12 +36,12 @@ interface PermissionsAction { /** * @return true if personal videos can be played, else false */ - fun isPersonalVideos():Boolean + fun isPersonalVideosPlaybackAllowed():Boolean /** * @return true if teams videos can be played, else false */ - fun isSteamTeamsVideo():Boolean + fun isSteamTeamsVideoPlaybackAllowed():Boolean /** * LiveData for permission action @@ -87,7 +87,7 @@ class PermissionActionDelegate @Inject constructor( get() = _permissionActionResult /** - * We check if the user is in [BuildConfig.DEBUG] mode to allow contributors + * We check if the user is in [Build`Config.DEBUG] mode to allow contributors * to use the app (we give them fake permissions). * * Get permissions for the current logged in user @@ -131,9 +131,9 @@ class PermissionActionDelegate @Inject constructor( override fun isBeginnerVideoPlaybackAllowed(): Boolean = loginRepository.isBeginnerVideoPlaybackAllowed() - override fun isPersonalVideos(): Boolean = + override fun isPersonalVideosPlaybackAllowed(): Boolean = loginRepository.isPersonalVideosPlayback() - override fun isSteamTeamsVideo(): Boolean = + override fun isSteamTeamsVideoPlaybackAllowed(): Boolean = loginRepository.isStreamTeamsVideosPlayback() }