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

Add voting arrows and score to posts in "List" view mode #472

Merged
merged 6 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class MainActivity : ComponentActivity() {
siteViewModel = siteViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
composable(
Expand Down Expand Up @@ -182,6 +183,7 @@ class MainActivity : ComponentActivity() {
postEditViewModel = postEditViewModel,
communityListViewModel = communityListViewModel,
appSettingsViewModel = appSettingsViewModel,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
// Only necessary for community deeplinks
Expand Down Expand Up @@ -225,6 +227,7 @@ class MainActivity : ComponentActivity() {
homeViewModel = homeViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
composable(
Expand Down Expand Up @@ -264,6 +267,7 @@ class MainActivity : ComponentActivity() {
commentReplyViewModel = commentReplyViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
// Necessary for deep links
Expand Down Expand Up @@ -304,6 +308,7 @@ class MainActivity : ComponentActivity() {
commentReplyViewModel = commentReplyViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
composable(
Expand Down Expand Up @@ -428,6 +433,7 @@ class MainActivity : ComponentActivity() {
navController = navController,
showCollapsedCommentContent = appSettings?.showCollapsedCommentContent ?: false,
showActionBarByDefault = appSettings?.showCommentActionBarByDefault ?: false,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
composable(
Expand Down Expand Up @@ -459,6 +465,7 @@ class MainActivity : ComponentActivity() {
navController = navController,
showCollapsedCommentContent = appSettings?.showCollapsedCommentContent ?: false,
showActionBarByDefault = appSettings?.showCommentActionBarByDefault ?: true,
showVotingArrowsInListView = appSettings?.showVotingArrowsInListView ?: true,
)
}
composable(
Expand Down
17 changes: 16 additions & 1 deletion app/src/main/java/com/jerboa/db/AppDB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ data class AppSettings(
defaultValue = "1",
)
val showCommentActionBarByDefault: Boolean,
@ColumnInfo(
name = "show_voting_arrows_in_list_view",
defaultValue = "1",
)
val showVotingArrowsInListView: Boolean,
)

@Dao
Expand Down Expand Up @@ -325,8 +330,17 @@ val MIGRATION_10_11 = object : Migration(10, 11) {
}
}

val MIGRATION_11_12 = object : Migration(11, 12) {
twizmwazin marked this conversation as resolved.
Show resolved Hide resolved
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(UPDATE_APP_CHANGELOG_UNVIEWED)
database.execSQL(
"ALTER TABLE AppSettings add column show_voting_arrows_in_list_view INTEGER NOT NULL default 1",
a1studmuffin marked this conversation as resolved.
Show resolved Hide resolved
)
}
}

@Database(
version = 11,
version = 12,
entities = [Account::class, AppSettings::class],
exportSchema = true,
)
Expand Down Expand Up @@ -361,6 +375,7 @@ abstract class AppDB : RoomDatabase() {
MIGRATION_8_9,
MIGRATION_9_10,
MIGRATION_10_11,
MIGRATION_11_12,
Copy link
Member

Choose a reason for hiding this comment

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

👍

)
// Necessary because it can't insert data on creation
.addCallback(object : Callback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fun CommunityActivity(
homeViewModel: HomeViewModel,
postEditViewModel: PostEditViewModel,
appSettingsViewModel: AppSettingsViewModel,
showVotingArrowsInListView: Boolean,
) {
Log.d("jerboa", "got to community activity")

Expand Down Expand Up @@ -224,6 +225,7 @@ fun CommunityActivity(
listState = postListState,
taglines = null,
postViewMode = getPostViewMode(appSettingsViewModel),
showVotingArrowsInListView = showVotingArrowsInListView,
)
},
floatingActionButtonPosition = FabPosition.End,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fun HomeActivity(
siteViewModel: SiteViewModel,
postEditViewModel: PostEditViewModel,
appSettingsViewModel: AppSettingsViewModel,
showVotingArrowsInListView: Boolean,
) {
Log.d("jerboa", "got to home activity")

Expand Down Expand Up @@ -113,6 +114,7 @@ fun HomeActivity(
ctx = ctx,
navController = navController,
postListState = postListState,
showVotingArrowsInListView = showVotingArrowsInListView,
)
},
floatingActionButtonPosition = FabPosition.End,
Expand Down Expand Up @@ -174,6 +176,7 @@ fun MainPostListingsContent(
padding: PaddingValues,
postListState: LazyListState,
appSettingsViewModel: AppSettingsViewModel,
showVotingArrowsInListView: Boolean,
) {
PostListings(
listState = postListState,
Expand Down Expand Up @@ -272,6 +275,7 @@ fun MainPostListingsContent(
}
},
account = account,
showVotingArrowsInListView = showVotingArrowsInListView,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fun PersonProfileActivity(
commentReplyViewModel: CommentReplyViewModel,
postEditViewModel: PostEditViewModel,
appSettingsViewModel: AppSettingsViewModel,
showVotingArrowsInListView: Boolean,
) {
Log.d("jerboa", "got to person activity")

Expand Down Expand Up @@ -141,6 +142,7 @@ fun PersonProfileActivity(
commentReplyViewModel = commentReplyViewModel,
postEditViewModel = postEditViewModel,
appSettingsViewModel = appSettingsViewModel,
showVotingArrowsInListView = showVotingArrowsInListView,
)
},
bottomBar = {
Expand Down Expand Up @@ -194,6 +196,7 @@ fun UserTabs(
postEditViewModel: PostEditViewModel,
padding: PaddingValues,
appSettingsViewModel: AppSettingsViewModel,
showVotingArrowsInListView: Boolean,
) {
val tabTitles = if (savedMode) {
listOf(UserTab.Posts.name, UserTab.Comments.name)
Expand Down Expand Up @@ -390,6 +393,7 @@ fun UserTabs(
listState = postListState,
taglines = null,
postViewMode = getPostViewMode(appSettingsViewModel),
showVotingArrowsInListView = showVotingArrowsInListView,
)
}
UserTab.Comments.ordinal -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fun PostActivity(
navController: NavController,
showCollapsedCommentContent: Boolean,
showActionBarByDefault: Boolean,
showVotingArrowsInListView: Boolean,
) {
Log.d("jerboa", "got to post activity")

Expand Down Expand Up @@ -205,6 +206,7 @@ fun PostActivity(
fullBody = true,
account = account,
postViewMode = PostViewMode.Card,
showVotingArrowsInListView = showVotingArrowsInListView,
)
}
item(key = "${postView.post.id}_is_comment_view") {
Expand Down
Loading