Skip to content

Commit

Permalink
Merge pull request #106 from CrisisCleanup/update-menu-screen
Browse files Browse the repository at this point in the history
Update menu screen
  • Loading branch information
hueachilles committed Mar 12, 2024
2 parents 7153ab9 + 63a3a68 commit 001f530
Show file tree
Hide file tree
Showing 26 changed files with 357 additions and 189 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {

android {
defaultConfig {
val buildVersion = 189
val buildVersion = 190
applicationId = "com.crisiscleanup"
versionCode = buildVersion
versionName = "0.9.${buildVersion - 168}"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/crisiscleanup/MainActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class MainActivityViewModel @Inject constructor(
var isAccountExpired by mutableStateOf(false)
private set

val termsOfServiceUrl = "${appSettingsProvider.baseUrl}/terms?view=plain"
val privacyPolicyUrl = "${appSettingsProvider.baseUrl}/privacy?view=plain"
val termsOfServiceUrl = appSettingsProvider.termsOfServiceUrl
val privacyPolicyUrl = appSettingsProvider.privacyPolicyUrl
var hasAcceptedTerms by mutableStateOf(false)
private set
var isAcceptingTerms by mutableStateOf(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ interface AppSettingsProvider {
val baseUrl: String
val mapsApiKey: String

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

val debugEmail: String
val debugPassword: String
}
Expand All @@ -19,6 +23,10 @@ class SecretsAppSettingsProvider @Inject constructor() : AppSettingsProvider {
override val mapsApiKey: String
get() = BuildConfig.MAPS_API_KEY

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
override val debugPassword: String
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 @@ -22,6 +22,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.crisiscleanup.core.designsystem.theme.LocalFontStyles
Expand All @@ -35,6 +36,7 @@ fun CrisisCleanupAlertDialog(
// TODO Common dimensions
shape: Shape = RoundedCornerShape(8.dp),
onDismissRequest: () -> Unit = {},
dialogTestTag: String = "ccuAlertDialog",
title: String = "",
titleContent: @Composable () -> Unit = {},
confirmButton: @Composable () -> Unit = { },
Expand All @@ -48,6 +50,7 @@ fun CrisisCleanupAlertDialog(
@Composable {
Text(
title,
Modifier.testTag("alertDialogTitle"),
style = LocalFontStyles.current.header3,
)
}
Expand All @@ -59,12 +62,16 @@ fun CrisisCleanupAlertDialog(
if (text.isBlank()) {
textContent()
} else {
Text(text)
Text(
text,
Modifier.testTag("alertDialogText"),
)
}
}
}

AlertDialog(
modifier = Modifier.testTag(dialogTestTag),
tonalElevation = tonalElevation,
textContentColor = textContentColor,
shape = shape,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun OpenSettingsDialog(
CrisisCleanupTextButton(
text = dismissText,
onClick = closeDialog,
modifier = Modifier.testTag("ccuAlertDialogDismissBtn"),
modifier = Modifier.testTag("openSettingsDialogDismissAction"),
)
},
confirmButton = {
Expand All @@ -40,9 +40,10 @@ fun OpenSettingsDialog(
ContextCompat.startActivity(context, intent, null)
closeDialog()
},
modifier = Modifier.testTag("ccuAlertDialogConfirmBtn"),
modifier = Modifier.testTag("openSettingsDialogPositiveAction"),
)
},
dialogTestTag = "openSettingsDialog",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
Expand Down Expand Up @@ -36,16 +38,16 @@ fun RegisterSuccessView(
tint = statusClosedColor,
)

androidx.compose.material3.Text(
Text(
title,
listItemModifier,
listItemModifier.testTag("registerSuccessTitle"),
style = LocalFontStyles.current.header1,
textAlign = TextAlign.Center,
)

androidx.compose.material3.Text(
Text(
text,
listItemModifier,
listItemModifier.testTag("registerSuccessText"),
textAlign = TextAlign.Center,
)

Expand Down
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,20 +18,17 @@ import kotlinx.datetime.Instant
import retrofit2.Retrofit
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.PATCH
import retrofit2.http.POST
import retrofit2.http.Path
import javax.inject.Inject

private interface AccountApi {
@Headers("Cookie: ")
@POST("magic_link")
suspend fun initiateMagicLink(
@Body emailPayload: NetworkEmailPayload,
): NetworkMagicLinkResult

@Headers("Cookie: ")
@ThrowClientErrorHeader
@POST("otp")
suspend fun initiatePhoneLogin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.crisiscleanup.core.network.model.NetworkRefreshToken
import kotlinx.coroutines.sync.Mutex
import retrofit2.Retrofit
import retrofit2.http.Body
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import javax.inject.Inject
Expand All @@ -29,22 +28,18 @@ private interface AuthApi {
suspend fun oauthLogin(@Body body: NetworkOauthPayload): NetworkOauthResult

@ThrowClientErrorHeader
@Headers("Cookie: ")
@POST("magic_link/{code}/login")
suspend fun magicLinkCodeAuth(@Path("code") token: String): NetworkCodeAuthResult

@ThrowClientErrorHeader
@Headers("Cookie: ")
@POST("otp/verify")
suspend fun verifyPhoneCode(@Body body: NetworkPhoneCodePayload): NetworkPhoneOneTimePasswordResult

@ThrowClientErrorHeader
@Headers("Cookie: ")
@POST("otp/generate_token")
suspend fun oneTimePasswordAuth(@Body body: NetworkOneTimePasswordPayload): NetworkCodeAuthResult

@ThrowClientErrorHeader
@Headers("Cookie: ")
@POST("api-mobile-refresh-token")
suspend fun refreshAccountTokens(@Body body: NetworkRefreshToken): NetworkOauthResult
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,24 @@ import kotlinx.datetime.Instant
import retrofit2.Retrofit
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Headers
import retrofit2.http.Path
import retrofit2.http.Query
import retrofit2.http.QueryMap
import retrofit2.http.Tag
import javax.inject.Inject

private interface DataSourceApi {
@TokenAuthenticationHeader
@GET("users/me")
suspend fun getProfile(): NetworkAccountProfileResult
suspend fun getProfile(
@Tag endpointId: EndpointRequestId = EndpointRequestId.MyProfile,
): NetworkAccountProfileResult

@Headers("Cookie: ")
@GET("users/me")
suspend fun getProfile(
@Header("Authorization")
accessToken: String,
@Tag endpointId: EndpointRequestId = EndpointRequestId.MyProfileNoAuth,
): NetworkUserProfile

@TokenAuthenticationHeader
Expand Down Expand Up @@ -190,14 +192,14 @@ private interface DataSourceApi {
): NetworkWorkTypeRequestResult

@TokenAuthenticationHeader
@GET("/organizations")
@GET("organizations")
suspend fun getNearbyClaimingOrganizations(
@Query("nearby_claimed")
nearbyClaimed: String,
): NetworkOrganizationsResult

@TokenAuthenticationHeader
@GET("/users")
@GET("users")
suspend fun searchUsers(
@Query("search")
q: String,
Expand All @@ -216,20 +218,20 @@ private interface DataSourceApi {
): NetworkCaseHistoryResult

@TokenAuthenticationHeader
@GET("/users")
@GET("users")
suspend fun getUsers(
@Query("id__in")
ids: String,
): NetworkUsersResult

@TokenAuthenticationHeader
@GET("/organizations")
@GET("organizations")
suspend fun searchOrganizations(
@Query("search") q: String,
): NetworkOrganizationsSearchResult

@TokenAuthenticationHeader
@GET("/incident_requests")
@GET("incident_requests")
suspend fun getRedeployRequests(): NetworkRedeployRequestsResult
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import com.crisiscleanup.core.network.model.profilePictureUrl
import retrofit2.Retrofit
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.POST
import retrofit2.http.Path
import java.net.URL
Expand All @@ -60,13 +59,11 @@ private interface RegisterApi {
@Path("code") inviteCode: String,
): NetworkPersistentInvitationResult

@Headers("Cookie: ")
@GET("users/{user}")
suspend fun noAuthUser(
@Path("user") userId: Long,
): NetworkUser

@Headers("Cookie: ")
@GET("organizations/{organization}")
suspend fun noAuthOrganization(
@Path("organization") organizationId: Long,
Expand Down
Loading

0 comments on commit 001f530

Please sign in to comment.