Skip to content

Commit

Permalink
Post actionbar design rework and options for it. (#1155)
Browse files Browse the repository at this point in the history
* Changing comment appearance

* Changes

* Change badge color rework

* Add post actionbar mode setting

* Fix formatting

* Make righthandside comments align left

* Make righthandside comments align left

* Fix reply ordering

* Tweak lefthand

* Fix right order

---------

Co-authored-by: Zack <[email protected]>
  • Loading branch information
MV-GH and IzakJoubert authored Aug 8, 2023
1 parent a91e25e commit 51b6c0a
Show file tree
Hide file tree
Showing 28 changed files with 591 additions and 142 deletions.
239 changes: 239 additions & 0 deletions app/schemas/com.jerboa.db.AppDB/24.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"formatVersion": 1,
"database": {
"version": 24,
"identityHash": "f14512333b67d7575d8f9a47507b8e9b",
"entities": [
{
"tableName": "Account",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `current` INTEGER NOT NULL, `instance` TEXT NOT NULL, `name` TEXT NOT NULL, `jwt` TEXT NOT NULL, `default_listing_type` INTEGER NOT NULL DEFAULT 0, `default_sort_type` INTEGER NOT NULL DEFAULT 0, `verification_state` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "current",
"columnName": "current",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "instance",
"columnName": "instance",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "jwt",
"columnName": "jwt",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "defaultListingType",
"columnName": "default_listing_type",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "defaultSortType",
"columnName": "default_sort_type",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "verificationState",
"columnName": "verification_state",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
}
],
"primaryKey": {
"autoGenerate": false,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "AppSettings",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `font_size` INTEGER NOT NULL DEFAULT 16, `theme` INTEGER NOT NULL DEFAULT 0, `theme_color` INTEGER NOT NULL DEFAULT 0, `viewed_changelog` INTEGER NOT NULL DEFAULT 0, `post_view_mode` INTEGER NOT NULL DEFAULT 0, `show_bottom_nav` INTEGER NOT NULL DEFAULT 1, `show_collapsed_comment_content` INTEGER NOT NULL DEFAULT 0, `show_comment_action_bar_by_default` INTEGER NOT NULL DEFAULT 1, `show_voting_arrows_in_list_view` INTEGER NOT NULL DEFAULT 1, `show_parent_comment_navigation_buttons` INTEGER NOT NULL DEFAULT 0, `navigate_parent_comments_with_volume_buttons` INTEGER NOT NULL DEFAULT 0, `use_custom_tabs` INTEGER NOT NULL DEFAULT 1, `use_private_tabs` INTEGER NOT NULL DEFAULT 0, `secure_window` INTEGER NOT NULL DEFAULT 0, `blur_nsfw` INTEGER NOT NULL DEFAULT 1, `show_text_descriptions_in_navbar` INTEGER NOT NULL DEFAULT 1, `markAsReadOnScroll` INTEGER NOT NULL DEFAULT 0, `backConfirmationMode` INTEGER NOT NULL DEFAULT 1, `show_post_link_previews` INTEGER NOT NULL DEFAULT 1, `post_actionbar_mode` INTEGER NOT NULL DEFAULT 0)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "fontSize",
"columnName": "font_size",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "16"
},
{
"fieldPath": "theme",
"columnName": "theme",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "themeColor",
"columnName": "theme_color",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "viewedChangelog",
"columnName": "viewed_changelog",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "postViewMode",
"columnName": "post_view_mode",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "showBottomNav",
"columnName": "show_bottom_nav",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "showCollapsedCommentContent",
"columnName": "show_collapsed_comment_content",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "showCommentActionBarByDefault",
"columnName": "show_comment_action_bar_by_default",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "showVotingArrowsInListView",
"columnName": "show_voting_arrows_in_list_view",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "showParentCommentNavigationButtons",
"columnName": "show_parent_comment_navigation_buttons",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "navigateParentCommentsWithVolumeButtons",
"columnName": "navigate_parent_comments_with_volume_buttons",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "useCustomTabs",
"columnName": "use_custom_tabs",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "usePrivateTabs",
"columnName": "use_private_tabs",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "secureWindow",
"columnName": "secure_window",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "blurNSFW",
"columnName": "blur_nsfw",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "showTextDescriptionsInNavbar",
"columnName": "show_text_descriptions_in_navbar",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "markAsReadOnScroll",
"columnName": "markAsReadOnScroll",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "backConfirmationMode",
"columnName": "backConfirmationMode",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "showPostLinkPreviews",
"columnName": "show_post_link_previews",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "postActionbarMode",
"columnName": "post_actionbar_mode",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
}
],
"primaryKey": {
"autoGenerate": true,
"columnNames": [
"id"
]
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'f14512333b67d7575d8f9a47507b8e9b')"
]
}
}
16 changes: 11 additions & 5 deletions app/src/main/java/com/jerboa/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ import com.jerboa.api.ApiState
import com.jerboa.api.MINIMUM_API_VERSION
import com.jerboa.datatypes.types.Community
import com.jerboa.db.APP_SETTINGS_DEFAULT
import com.jerboa.feat.BackConfirmation.addConfirmationDialog
import com.jerboa.feat.BackConfirmation.addConfirmationToast
import com.jerboa.feat.BackConfirmation.disposeConfirmation
import com.jerboa.feat.BackConfirmationMode
import com.jerboa.feat.ShowConfirmationDialog
import com.jerboa.model.AccountSettingsViewModel
import com.jerboa.model.AccountSettingsViewModelFactory
import com.jerboa.model.AccountViewModel
Expand Down Expand Up @@ -75,11 +80,6 @@ import com.jerboa.ui.components.settings.account.AccountSettingsActivity
import com.jerboa.ui.components.settings.crashlogs.CrashLogsActivity
import com.jerboa.ui.components.settings.lookandfeel.LookAndFeelActivity
import com.jerboa.ui.theme.JerboaTheme
import com.jerboa.util.BackConfirmation.addConfirmationDialog
import com.jerboa.util.BackConfirmation.addConfirmationToast
import com.jerboa.util.BackConfirmation.disposeConfirmation
import com.jerboa.util.BackConfirmationMode
import com.jerboa.util.ShowConfirmationDialog

class MainActivity : AppCompatActivity() {
val siteViewModel by viewModels<SiteViewModel>()
Expand Down Expand Up @@ -256,6 +256,7 @@ class MainActivity : AppCompatActivity() {
blurNSFW = appSettings.blurNSFW,
showPostLinkPreviews = appSettings.showPostLinkPreviews,
markAsReadOnScroll = appSettings.markAsReadOnScroll,
postActionbarMode = appSettings.postActionbarMode,
)
}

Expand Down Expand Up @@ -297,6 +298,7 @@ class MainActivity : AppCompatActivity() {
blurNSFW = appSettings.blurNSFW,
showPostLinkPreviews = appSettings.showPostLinkPreviews,
markAsReadOnScroll = appSettings.markAsReadOnScroll,
postActionbarMode = appSettings.postActionbarMode,
)
}

Expand Down Expand Up @@ -369,6 +371,7 @@ class MainActivity : AppCompatActivity() {
drawerState = drawerState,
onBack = appState::popBackStack,
markAsReadOnScroll = appSettings.markAsReadOnScroll,
postActionbarMode = appSettings.postActionbarMode,
)
}

Expand Down Expand Up @@ -403,6 +406,7 @@ class MainActivity : AppCompatActivity() {
showPostLinkPreviews = appSettings.showPostLinkPreviews,
drawerState = drawerState,
markAsReadOnScroll = appSettings.markAsReadOnScroll,
postActionbarMode = appSettings.postActionbarMode,
)
}

Expand Down Expand Up @@ -508,6 +512,7 @@ class MainActivity : AppCompatActivity() {
usePrivateTabs = appSettings.usePrivateTabs,
blurNSFW = appSettings.blurNSFW,
showPostLinkPreview = appSettings.showPostLinkPreviews,
postActionbarMode = appSettings.postActionbarMode,
)
}
}
Expand Down Expand Up @@ -538,6 +543,7 @@ class MainActivity : AppCompatActivity() {
siteViewModel = siteViewModel,
blurNSFW = appSettings.blurNSFW,
showPostLinkPreview = appSettings.showPostLinkPreviews,
postActionbarMode = appSettings.postActionbarMode,
)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/datatypes/SampleData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ val samplePostView = PostView(
read = false,
creator_blocked = false,
my_vote = null,
unread_comments = 0,
unread_comments = 2,
)

val sampleLinkPostView = PostView(
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/jerboa/db/AppDB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ val APP_SETTINGS_DEFAULT = AppSettings(
backConfirmationMode = 1,
markAsReadOnScroll = false,
showPostLinkPreviews = true,
postActionbarMode = 0,
)

@Database(
version = 23,
version = 24,
entities = [Account::class, AppSettings::class],
exportSchema = true,
)
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/java/com/jerboa/db/AppDBMigrations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,31 @@ val MIGRATION_22_23 = object : Migration(22, 23) {
}
}

val MIGRATION_23_22 = object : Migration(23, 22) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"ALTER TABLE AppSettings DROP COLUMN markAsReadOnScroll",
)
}
}

val MIGRATION_23_24 = object : Migration(23, 24) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(UPDATE_APP_CHANGELOG_UNVIEWED)
database.execSQL(
"ALTER TABLE AppSettings ADD COLUMN post_actionbar_mode INTEGER NOT NULL DEFAULT 0",
)
}
}

val MIGRATION_24_23 = object : Migration(24, 23) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"ALTER TABLE AppSettings DROP COLUMN post_actionbar_mode",
)
}
}

// Don't forget to test your migration with `./gradlew app:connectAndroidTest`
val MIGRATIONS_LIST = arrayOf(
MIGRATION_1_2,
Expand All @@ -321,4 +346,7 @@ val MIGRATIONS_LIST = arrayOf(
MIGRATION_21_22,
MIGRATION_22_21,
MIGRATION_22_23,
MIGRATION_23_22,
MIGRATION_23_24,
MIGRATION_24_23,
)
2 changes: 1 addition & 1 deletion app/src/main/java/com/jerboa/db/entity/Account.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.jerboa.db.entity
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.jerboa.util.AccountVerificationState
import com.jerboa.feat.AccountVerificationState

@Entity
data class Account(
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/jerboa/db/entity/AppSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,9 @@ data class AppSettings(
defaultValue = "1",
)
val showPostLinkPreviews: Boolean,
@ColumnInfo(
name = "post_actionbar_mode",
defaultValue = "0",
)
val postActionbarMode: Int,
)
Loading

0 comments on commit 51b6c0a

Please sign in to comment.