Skip to content

Commit

Permalink
- strings resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
RazvanDanila committed Nov 15, 2023
1 parent 1e2458d commit f6bada9
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import org.mozilla.tiktokreporter.R
import org.mozilla.tiktokreporter.ui.components.LoadingScreen
import org.mozilla.tiktokreporter.ui.components.MozillaScaffold
import org.mozilla.tiktokreporter.ui.components.MozillaTopAppBar
Expand Down Expand Up @@ -51,6 +53,8 @@ fun AppPolicyScreen(
when (val action = state.action?.get()) {
AppPolicyScreenViewModel.UiAction.OnGoToStudies -> onGoToStudies()
AppPolicyScreenViewModel.UiAction.OnGoToStudyOnboarding -> onGoToStudyOnboarding()

// TODO: replace with general error screen
is AppPolicyScreenViewModel.UiAction.ShowMessage -> {
dialogState.value = DialogState.Message(
title = "Alert",
Expand All @@ -74,10 +78,10 @@ fun AppPolicyScreen(
onAgree = viewModel::acceptTerms,
onDisagree = if (isForOnboarding) {
{
dialogState.value = DialogState.Message(
title = "Review the terms & conditions",
message = "Please read these terms and conditions carefully before using TikTok Reporter",
negativeButtonText = "Got it",
dialogState.value = DialogState.MessageRes(
title = R.string.dialog_title_review_terms_and_conditions,
message = R.string.dialog_message_review_terms_and_conditions,
negativeButtonText = R.string.got_it,
onNegative = {
dialogState.value = DialogState.Nothing
},
Expand Down Expand Up @@ -180,15 +184,15 @@ private fun AppPolicyScreenContent(
agreeButton = {
PrimaryButton(
modifier = Modifier.fillMaxWidth(),
text = "I Agree",
text = stringResource(id = R.string.i_agree),
onClick = onAgree,
enabled = buttonsEnabled
)
},
disagreeButton = {
SecondaryButton(
modifier = Modifier.fillMaxWidth(),
text = "I Disagree",
text = stringResource(id = R.string.i_disagree),
onClick = onDisagree,
enabled = buttonsEnabled
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import androidx.compose.foundation.layout.height
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import org.mozilla.tiktokreporter.R
import org.mozilla.tiktokreporter.common.FormFieldError
import org.mozilla.tiktokreporter.common.FormFieldUiComponent
import org.mozilla.tiktokreporter.ui.components.MozillaTextField
Expand Down Expand Up @@ -48,8 +50,8 @@ fun FormTextField(
readOnly = field.readOnly,
errorText = field.error?.let {
when (it) {
FormFieldError.Empty -> "This field cannot be empty"
FormFieldError.EmptyCategory -> "Please suggest a category"
FormFieldError.Empty -> stringResource(id = R.string.error_message_empty_field)
FormFieldError.EmptyCategory -> stringResource(id = R.string.error_message_empty_category)
}
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.PermissionStatus
import com.google.accompanist.permissions.rememberPermissionState
import com.google.accompanist.permissions.shouldShowRationale
import org.mozilla.tiktokreporter.R
import org.mozilla.tiktokreporter.ScreenRecorderService
import org.mozilla.tiktokreporter.common.TabModelType
import org.mozilla.tiktokreporter.common.formcomponents.formComponentsItems
Expand Down Expand Up @@ -111,12 +113,12 @@ fun ReportFormScreen(
viewModel.uiAction.collectWithLifecycle { action ->
when (action) {
is ReportFormScreenViewModel.UiAction.ShowStudyNotActive -> {
dialogState.value = DialogState.Message(
title = "Select another study",
message = "The study you were participating into has ended. Please select another study to join.",
positiveButtonText = "Settings",
dialogState.value = DialogState.MessageRes(
title = R.string.dialog_title_inactive_study,
message = R.string.dialog_message_inactive_study,
positiveButtonText = R.string.settings,
onPositive = onGoToStudies,
negativeButtonText = "Not now",
negativeButtonText = R.string.not_now,
onNegative = onGoBack,
onDismissRequest = { dialogState.value = DialogState.Nothing }
)
Expand All @@ -136,15 +138,15 @@ fun ReportFormScreen(
onTabSelected = viewModel::onTabSelected,
onSubmitReport = viewModel::onSubmitReport,
onCancelReport = {
dialogState.value = DialogState.Message(
title = "Cancel report?",
message = "Are you sure you want to cancel the report? All the data entered will be deleted.",
positiveButtonText = "Delete",
dialogState.value = DialogState.MessageRes(
title = R.string.dialog_title_cancel_report,
message = R.string.dialog_message_cancel_report,
positiveButtonText = R.string.delete,
onPositive = {
viewModel.onCancelReport()
dialogState.value = DialogState.Nothing
},
negativeButtonText = "Keep",
negativeButtonText = R.string.keep,
onNegative = {
dialogState.value = DialogState.Nothing
},
Expand All @@ -166,10 +168,10 @@ fun ReportFormScreen(

else -> {
if (notificationsPermissionState.status.shouldShowRationale) {
dialogState.value = DialogState.Message(
title = "Notifications permission required",
message = "Notification permission required",
positiveButtonText = "Got it",
dialogState.value = DialogState.MessageRes(
title = R.string.dialog_title_notification_permission,
message = R.string.dialog_message_notification_permission,
positiveButtonText = R.string.settings,
onPositive = {
dialogState.value = DialogState.Nothing
val intent = Intent(
Expand All @@ -195,10 +197,10 @@ fun ReportFormScreen(

else -> {
if (notificationsPermissionState.status.shouldShowRationale) {
dialogState.value = DialogState.Message(
title = "Write external storage permission required",
message = "Write external storage permission required",
positiveButtonText = "Got it",
dialogState.value = DialogState.MessageRes(
title = R.string.dialog_title_write_external_storage_permission,
message = R.string.dialog_message_write_external_storage_permission,
positiveButtonText = R.string.got_it,
onPositive = {
dialogState.value = DialogState.Nothing
val intent = Intent(
Expand Down Expand Up @@ -279,8 +281,8 @@ private fun ReportFormScreenContent(
modifier = modifier,
tabs = state.tabs.map {
when (it) {
TabModelType.ReportLink -> "Report a Link"
TabModelType.RecordSession -> "Record a session"
TabModelType.ReportLink -> stringResource(id = R.string.report_link)
TabModelType.RecordSession -> stringResource(id = R.string.record_session)
}
},
onTabSelected = onTabSelected,
Expand Down Expand Up @@ -338,8 +340,8 @@ private fun LazyListScope.recordSessionItems(
Text(
modifier = Modifier.fillParentMaxWidth(),
text = when {
video == null -> "Start recording a TikTok session by pressing the button below and then go and browse TikTok. Once the recording is stopped you can submit this form."
else -> "You’ve recorded a TikTok session. Fill out some information then submit the form."
video == null -> stringResource(id = R.string.start_recording_session)
else -> stringResource(id = R.string.recording_session_available)
},
style = MozillaTypography.Body2
)
Expand All @@ -350,7 +352,7 @@ private fun LazyListScope.recordSessionItems(
item {
SecondaryButton(
modifier = Modifier.fillParentMaxWidth(),
text = "Record My TikTok Session",
text = stringResource(id = R.string.button_record_tiktok_session),
onClick = onStartRecording
)
}
Expand All @@ -360,7 +362,7 @@ private fun LazyListScope.recordSessionItems(
item {
SecondaryButton(
modifier = Modifier.fillParentMaxWidth(),
text = "Stop Recording",
text = stringResource(id = R.string.button_stop_recording),
onClick = onStopRecording
)
}
Expand All @@ -379,7 +381,7 @@ private fun LazyListScope.recordSessionItems(
if (showSubmitNoVideoError) {
item {
Text(
text = "Create a recording in order to submit the report",
text = stringResource(id = R.string.error_message_no_recording_available),
style = MozillaTypography.Body2,
color = MozillaColor.Error
)
Expand All @@ -391,7 +393,7 @@ private fun LazyListScope.recordSessionItems(
modifier = Modifier.fillParentMaxWidth(),
text = comments,
onTextChanged = onCommentsChanged,
label = "Comments (optional)",
label = stringResource(id = R.string.text_field_label_comments_optional),
maxLines = 5,
multiline = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.ExperimentalTextApi
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
Expand All @@ -26,6 +27,7 @@ import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.text.withAnnotation
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import org.mozilla.tiktokreporter.R
import org.mozilla.tiktokreporter.ui.components.MozillaScaffold
import org.mozilla.tiktokreporter.ui.components.MozillaTopAppBar
import org.mozilla.tiktokreporter.ui.components.SecondaryButton
Expand Down Expand Up @@ -82,16 +84,16 @@ fun ReportFormCompletedScreen(
tint = MozillaColor.Success
)
Text(
text = "Thank you!\nReport submitted.",
text = stringResource(id = R.string.report_submitted),
style = MozillaTypography.Success,
color = MozillaColor.Success,
textAlign = TextAlign.Center
)
}

SecondaryButton(
modifier = Modifier.fillMaxWidth(),
text = "I'm done",
text = stringResource(id = R.string.button_im_done),
onClick = onNavigateBack
)

Expand All @@ -103,15 +105,15 @@ fun ReportFormCompletedScreen(
color = MozillaColor.Inactive
)
) {
append("To receive a copy of your report on your email and to get follow up information about our study, go to ")
append(stringResource(id = R.string.report_copy_go_to))
}
withAnnotation("settings", "") {
withStyle(
SpanStyle(
color = MozillaColor.Red,
textDecoration = TextDecoration.Underline
)
) {
withStyle(
SpanStyle(
color = MozillaColor.Red,
textDecoration = TextDecoration.Underline
)
) {
withAnnotation("settings", "") {
append("Settings")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import org.mozilla.tiktokreporter.R
import org.mozilla.tiktokreporter.ui.components.MozillaScaffold
import org.mozilla.tiktokreporter.ui.components.MozillaTopAppBar
import org.mozilla.tiktokreporter.ui.theme.MozillaColor
Expand Down Expand Up @@ -113,42 +115,42 @@ private fun SettingsScreenContent(
SettingsScreenViewModel.SettingsEntry.About -> {
SettingEntry(
modifier = Modifier.fillParentMaxWidth(),
title = "ABOUT TIKTOK REPORTER",
title = stringResource(id = R.string.about_tik_tok_reporter).uppercase(),
onClick = onGoToAppPurpose
)
}
SettingsScreenViewModel.SettingsEntry.Studies -> {
SettingEntry(
modifier = Modifier.fillParentMaxWidth(),
title = "STUDIES",
title = stringResource(id = R.string.studies).uppercase(),
onClick = onGoToStudies
)
}
SettingsScreenViewModel.SettingsEntry.Email -> {
SettingEntry(
modifier = Modifier.fillParentMaxWidth(),
title = "EMAIL ADDRESS",
title = stringResource(id = R.string.email_address).uppercase(),
onClick = onGoToEmail
)
}
SettingsScreenViewModel.SettingsEntry.Terms -> {
SettingEntry(
modifier = Modifier.fillParentMaxWidth(),
title = "TERMS & CONDITIONS",
title = stringResource(id = R.string.terms_and_conditions).uppercase(),
onClick = onGoToTermsAndConditions
)
}
SettingsScreenViewModel.SettingsEntry.Privacy -> {
SettingEntry(
modifier = Modifier.fillParentMaxWidth(),
title = "PRIVACY POLICY",
title = stringResource(id = R.string.privacy_policy).uppercase(),
onClick = onGoToPrivacyPolicy
)
}
SettingsScreenViewModel.SettingsEntry.DataHandling -> {
SettingEntry(
modifier = Modifier.fillParentMaxWidth(),
title = "DATA HANDLING",
title = stringResource(id = R.string.data_handling).uppercase(),
onClick = onGoToDataHandling
)
}
Expand Down
Loading

0 comments on commit f6bada9

Please sign in to comment.