Skip to content

Commit

Permalink
Show getting started video
Browse files Browse the repository at this point in the history
  • Loading branch information
hueachilles committed Mar 12, 2024
1 parent 585f2ef commit 5b2c94e
Show file tree
Hide file tree
Showing 12 changed files with 244 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface AppSettingsProvider {

val termsOfServiceUrl: String
val privacyPolicyUrl: String
val gettingStartedVideoUrl: String

val debugEmail: String
val debugPassword: String
Expand All @@ -24,6 +25,7 @@ class SecretsAppSettingsProvider @Inject constructor() : AppSettingsProvider {

override val termsOfServiceUrl = "$baseUrl/terms?view=plain"
override val privacyPolicyUrl = "$baseUrl/privacy?view=plain"
override val gettingStartedVideoUrl = BuildConfig.GETTING_STARTED_VIDEO_URL

override val debugEmail: String
get() = BuildConfig.DEBUG_EMAIL_ADDRESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class AppPreferencesRepository @Inject constructor(
override suspend fun setShouldHideOnboarding(shouldHideOnboarding: Boolean) =
preferencesDataSource.setShouldHideOnboarding(shouldHideOnboarding)

override suspend fun setHideGettingStartedVideo(hide: Boolean) =
preferencesDataSource.setHideGettingStartedVideo(hide)

override suspend fun setSelectedIncident(id: Long) =
preferencesDataSource.setSelectedIncident(id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface LocalAppPreferencesRepository {
*/
suspend fun setShouldHideOnboarding(shouldHideOnboarding: Boolean)

suspend fun setHideGettingStartedVideo(hide: Boolean)

/**
* Caches ID of selected incident.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class LocalAppPreferencesDataSource @Inject constructor(
tableViewSortBy = worksiteSortByFromLiteral(it.tableViewSortBy),

allowAllAnalytics = it.allowAllAnalytics,

hideGettingStartedVideo = it.hideGettingStartedVideo,
)
}

Expand All @@ -61,6 +63,7 @@ class LocalAppPreferencesDataSource @Inject constructor(
languageKey = ""
tableViewSortBy = WorksiteSortBy.None.literal
allowAllAnalytics = false
hideGettingStartedVideo = false
}
}
}
Expand Down Expand Up @@ -139,4 +142,10 @@ class LocalAppPreferencesDataSource @Inject constructor(
it.copy { allowAllAnalytics = allowAll }
}
}

suspend fun setHideGettingStartedVideo(hide: Boolean) {
userPreferences.updateData {
it.copy { hideGettingStartedVideo = hide }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ message UserPreferences {
string table_view_sort_by = 8;

bool allow_all_analytics = 9;

bool hide_getting_started_video = 10;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ data class UserData(
val tableViewSortBy: WorksiteSortBy,

val allowAllAnalytics: Boolean,

val hideGettingStartedVideo: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ private val emptyUserData = UserData(
languageKey = "",
tableViewSortBy = WorksiteSortBy.None,
allowAllAnalytics = false,
hideGettingStartedVideo = false,
)

class TestLocalAppPreferencesRepository : LocalAppPreferencesRepository {
Expand All @@ -40,6 +41,12 @@ class TestLocalAppPreferencesRepository : LocalAppPreferencesRepository {
}
}

override suspend fun setHideGettingStartedVideo(hide: Boolean) {
currentUserData.let { current ->
userDataInternal.tryEmit(current.copy(hideGettingStartedVideo = hide))
}
}

override suspend fun setSelectedIncident(id: Long) {
currentUserData.let { current ->
userDataInternal.tryEmit(current.copy(selectedIncidentId = id))
Expand Down
Loading

0 comments on commit 5b2c94e

Please sign in to comment.