Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

started localization for the app and added first german local #447

Merged
merged 17 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/src/main/java/com/jerboa/db/AppDB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,15 @@ val MIGRATION_9_10 = object : Migration(9, 10) {
}
}

val MIGRATION_10_11 = object : Migration(10, 11) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here? You should probably merge from main.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had the issue that after an update the app crashed and told me i need a migration to work. Tried it that way. Maybe its not correct. Sorry i am new to this 😓
Will try to revert this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha no problem. Just merge from main and you should be good.

override fun migrate(database: SupportSQLiteDatabase) {
// Add show_bottom_nav column
database.execSQL(UPDATE_APP_CHANGELOG_UNVIEWED)
}
}

@Database(
version = 10,
version = 11,
entities = [Account::class, AppSettings::class],
exportSchema = true,
)
Expand Down Expand Up @@ -337,6 +344,7 @@ abstract class AppDB : RoomDatabase() {
MIGRATION_7_8,
MIGRATION_8_9,
MIGRATION_9_10,
MIGRATION_10_11,
)
// Necessary because it can't insert data on creation
.addCallback(object : Callback() {
Expand Down
26 changes: 14 additions & 12 deletions app/src/main/java/com/jerboa/ui/components/comment/CommentNode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.Border
import com.jerboa.CommentNodeData
import com.jerboa.InstantScores
import com.jerboa.R
import com.jerboa.VoteType
import com.jerboa.border
import com.jerboa.buildCommentsTree
Expand Down Expand Up @@ -126,9 +128,9 @@ fun CommentBody(
onClick: () -> Unit,
) {
val content = if (comment.removed) {
"*Removed*"
stringResource(R.string.comment_body_removed)
} else if (comment.deleted) {
"*Deleted*"
stringResource(R.string.comment_body_deleted)
} else {
comment.content
}
Expand Down Expand Up @@ -574,17 +576,17 @@ fun CommentOptionsDialog(
text = {
Column {
IconAndTextDrawerItem(
text = "Goto Comment",
text = stringResource(R.string.comment_node_goto_comment),
icon = Icons.Outlined.Link,
onClick = onCommentLinkClick,
)
IconAndTextDrawerItem(
text = "View Source",
text = stringResource(R.string.comment_node_view_source),
icon = Icons.Outlined.Description,
onClick = onViewSourceClick,
)
IconAndTextDrawerItem(
text = "Copy Permalink",
text = stringResource(R.string.comment_node_copy_permalink),
icon = Icons.Outlined.ContentCopy,
onClick = {
val permalink = commentView.comment.ap_id
Expand All @@ -595,7 +597,7 @@ fun CommentOptionsDialog(
)
if (!isCreator) {
IconAndTextDrawerItem(
text = "Report Comment",
text = stringResource(R.string.comment_node_report_comment),
icon = Icons.Outlined.Flag,
onClick = onReportClick,
)
Expand All @@ -607,20 +609,20 @@ fun CommentOptionsDialog(
}
if (isCreator) {
IconAndTextDrawerItem(
text = "Edit",
text = stringResource(R.string.comment_node_edit),
icon = Icons.Outlined.Edit,
onClick = onEditCommentClick,
)
val deleted = commentView.comment.deleted
if (deleted) {
IconAndTextDrawerItem(
text = "Restore",
text = stringResource(R.string.comment_node_restore),
icon = Icons.Outlined.Restore,
onClick = onDeleteCommentClick,
)
} else {
IconAndTextDrawerItem(
text = "Delete",
text = stringResource(R.string.comment_node_delete),
icon = Icons.Outlined.Delete,
onClick = onDeleteCommentClick,
)
Expand Down Expand Up @@ -655,7 +657,7 @@ fun ShowMoreChildren(
) {
TextButton(
content = {
Text("${commentView.counts.child_count} more replies")
Text(stringResource(R.string.comment_node_more_replies, commentView.counts.child_count))
},
onClick = { onFetchChildrenClick(commentView) },
)
Expand Down Expand Up @@ -692,14 +694,14 @@ fun ShowCommentContextButtons(
) {
OutlinedButton(
content = {
Text("View Post")
Text(stringResource(R.string.comment_node_view_post))
},
onClick = { onPostClick(postId) },
)
if (showContextButton && commentParentId != null) {
OutlinedButton(
content = {
Text("View Context")
Text(stringResource(R.string.comment_node_view_context))
},
onClick = { onCommentClick(commentParentId) },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.TextFieldValue
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.jerboa.R
import com.jerboa.db.Account
import com.jerboa.ui.components.common.MarkdownTextField

Expand All @@ -29,7 +31,7 @@ fun CommentEditHeader(
TopAppBar(
title = {
Text(
text = "Edit",
text = stringResource(R.string.comment_edit_edit),
)
},
actions = {
Expand Down Expand Up @@ -57,7 +59,7 @@ fun CommentEditHeader(
) {
Icon(
Icons.Outlined.Close,
contentDescription = "Back",
contentDescription = stringResource(R.string.comment_edit_back),
)
}
},
Expand All @@ -84,7 +86,7 @@ fun CommentEdit(
onTextChange = onContentChange,
account = account,
modifier = Modifier.fillMaxWidth(),
placeholder = "Type your comment",
placeholder = stringResource(R.string.comment_edit_type_your_comment),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.R
import com.jerboa.VoteType
import com.jerboa.datatypes.CommunitySafe
import com.jerboa.datatypes.PersonMentionView
Expand Down Expand Up @@ -215,28 +217,31 @@ fun CommentReplyNodeOptionsDialog(
text = {
Column {
IconAndTextDrawerItem(
text = "View Source",
text = stringResource(R.string.comment_mention_node_view_source),
icon = Icons.Outlined.Description,
onClick = onViewSourceClick,
)
IconAndTextDrawerItem(
text = "Copy Permalink",
text = stringResource(R.string.comment_mention_node_copy_permalink),
icon = Icons.Outlined.Link,
onClick = {
val permalink = personMentionView.comment.ap_id
localClipboardManager.setText(AnnotatedString(permalink))
Toast.makeText(ctx, "Permalink Copied", Toast.LENGTH_SHORT).show()
Toast.makeText(ctx, "Permalink Copied", Toast.LENGTH_SHORT).show() //TODO localization
onDismissRequest()
},
)
if (!isCreator) {
IconAndTextDrawerItem(
text = "Report Comment",
text = stringResource(R.string.comment_mention_node_report_comment),
icon = Icons.Outlined.Flag,
onClick = onReportClick,
)
IconAndTextDrawerItem(
text = "Block ${personMentionView.creator.name}",
text = stringResource(
R.string.comment_mention_node_block,
personMentionView.creator.name
),
icon = Icons.Outlined.Block,
onClick = onBlockCreatorClick,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.jerboa.R
import com.jerboa.datatypes.CommentReplyView
import com.jerboa.datatypes.CommentView
import com.jerboa.datatypes.PersonMentionView
Expand All @@ -40,7 +42,7 @@ fun CommentReplyHeader(
TopAppBar(
title = {
Text(
text = "Reply",
text = stringResource(R.string.comment_reply_reply),
)
},
actions = {
Expand Down Expand Up @@ -68,7 +70,7 @@ fun CommentReplyHeader(
) {
Icon(
Icons.Outlined.Close,
contentDescription = "Back",
contentDescription = stringResource(R.string.comment_reply_back),
)
}
},
Expand Down Expand Up @@ -277,7 +279,7 @@ fun PostReply(
onTextChange = onReplyChange,
account = account,
modifier = Modifier.fillMaxWidth(),
placeholder = "Type your comment",
placeholder = stringResource(R.string.comment_reply_type_your_comment),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.tooling.preview.Preview
import com.jerboa.R
import com.jerboa.VoteType
import com.jerboa.datatypes.CommentReplyView
import com.jerboa.datatypes.CommunitySafe
Expand Down Expand Up @@ -215,7 +217,7 @@ fun CommentReplyNodeOptionsDialog(
text = {
Column {
IconAndTextDrawerItem(
text = "View Source",
text = stringResource(R.string.comment_reply_node_view_source),
icon = Icons.Outlined.Description,
onClick = onViewSourceClick,
)
Expand All @@ -231,12 +233,15 @@ fun CommentReplyNodeOptionsDialog(
)
if (!isCreator) {
IconAndTextDrawerItem(
text = "Report Comment",
text = stringResource(R.string.comment_reply_node_report_comment),
icon = Icons.Outlined.Flag,
onClick = onReportClick,
)
IconAndTextDrawerItem(
text = "Block ${commentReplyView.creator.name}",
text = stringResource(
R.string.comment_reply_node_block,
commentReplyView.creator.name
),
icon = Icons.Outlined.Block,
onClick = onBlockCreatorClick,
)
Expand Down
19 changes: 11 additions & 8 deletions app/src/main/java/com/jerboa/ui/components/common/AppBars.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
Expand All @@ -41,6 +42,7 @@ import androidx.navigation.compose.rememberNavController
import com.google.accompanist.flowlayout.FlowCrossAxisAlignment
import com.google.accompanist.flowlayout.FlowMainAxisAlignment
import com.google.accompanist.flowlayout.FlowRow
import com.jerboa.R
import com.jerboa.datatypes.PersonSafe
import com.jerboa.datatypes.api.GetUnreadCountResponse
import com.jerboa.datatypes.samplePersonSafe
Expand Down Expand Up @@ -417,7 +419,8 @@ fun Sidebar(

LazyColumn(
state = listState,
modifier = Modifier.padding(padding)
modifier = Modifier
.padding(padding)
.simpleVerticalScrollbar(listState),
verticalArrangement = Arrangement.spacedBy(MEDIUM_PADDING),
) {
Expand Down Expand Up @@ -451,7 +454,7 @@ fun Sidebar(
)
}
TimeAgo(
precedingString = "Created",
precedingString = stringResource(R.string.AppBars_created),
includeAgo = true,
published = published,
)
Expand Down Expand Up @@ -495,32 +498,32 @@ fun CommentsAndPosts(
) {
FlowRow {
Text(
text = "${siFormat(usersActiveDay)} users / day",
text = stringResource(R.string.AppBars_users_day, siFormat(usersActiveDay)),
color = MaterialTheme.colorScheme.onBackground.muted,
)
DotSpacer(style = MaterialTheme.typography.bodyMedium)
Text(
text = "${siFormat(usersActiveWeek)} users / week",
text = stringResource(R.string.AppBars_users_week, siFormat(usersActiveWeek)),
color = MaterialTheme.colorScheme.onBackground.muted,
)
DotSpacer(style = MaterialTheme.typography.bodyMedium)
Text(
text = "${siFormat(usersActiveMonth)} users / month",
text = stringResource(R.string.AppBars_users_month, siFormat(usersActiveMonth)),
color = MaterialTheme.colorScheme.onBackground.muted,
)
DotSpacer(style = MaterialTheme.typography.bodyMedium)
Text(
text = "${siFormat(usersActiveHalfYear)} users / 6 months",
text = stringResource(R.string.AppBars_users_6_months, siFormat(usersActiveHalfYear)),
color = MaterialTheme.colorScheme.onBackground.muted,
)
DotSpacer(style = MaterialTheme.typography.bodyMedium)
Text(
text = "${siFormat(postCount)} posts",
text = stringResource(R.string.AppBars_posts, siFormat(postCount)),
color = MaterialTheme.colorScheme.onBackground.muted,
)
DotSpacer(style = MaterialTheme.typography.bodyMedium)
Text(
text = "${siFormat(commentCount)} comments",
text = stringResource(R.string.AppBars_comments, siFormat(commentCount)),
color = MaterialTheme.colorScheme.onBackground.muted,
)
}
Expand Down
Loading