Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #353 from KelvnPere/EMA-352-Unable_to_access_content
Browse files Browse the repository at this point in the history
Additions of New Tags Permission to Android
  • Loading branch information
KelvnPere authored Jul 10, 2023
2 parents 4dcb00f + 8c934bb commit 370a74b
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ captures/
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json
app/google-services.json

# Freeline
freeline.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,17 @@ class LoginRepository @Inject constructor(
* Get stored permissions
*/
fun getPermissionsFromPrefs(): List<String> = 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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ interface PermissionsAction {
*/
fun isBeginnerVideoPlaybackAllowed(): Boolean

/**
* @return true if personal videos can be played, else false
*/
fun isPersonalVideosPlaybackAllowed():Boolean

/**
* @return true if teams videos can be played, else false
*/
fun isSteamTeamsVideoPlaybackAllowed():Boolean

/**
* LiveData for permission action
*/
Expand Down Expand Up @@ -77,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
Expand Down Expand Up @@ -120,4 +130,10 @@ class PermissionActionDelegate @Inject constructor(

override fun isBeginnerVideoPlaybackAllowed(): Boolean =
loginRepository.isBeginnerVideoPlaybackAllowed()

override fun isPersonalVideosPlaybackAllowed(): Boolean =
loginRepository.isPersonalVideosPlayback()

override fun isSteamTeamsVideoPlaybackAllowed(): Boolean =
loginRepository.isStreamTeamsVideosPlayback()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions model/src/main/java/com/razeware/emitron/model/Attributes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
8 changes: 8 additions & 0 deletions model/src/main/java/com/razeware/emitron/model/Data.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
16 changes: 15 additions & 1 deletion model/src/main/java/com/razeware/emitron/model/PermissionTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down

0 comments on commit 370a74b

Please sign in to comment.