Skip to content

Commit 64b60f1

Browse files
Customize read/unread icons by account type
1 parent 055d8ab commit 64b60f1

File tree

10 files changed

+31
-15
lines changed

10 files changed

+31
-15
lines changed

app/src/main/java/com/readrops/app/item/ItemScreen.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class ItemScreen(
124124

125125
ItemScreenPage(
126126
itemWithFeed = itemWithFeed,
127+
accountType = screenModel.account.type!!,
127128
snackbarHostState = snackbarHostState,
128129
onOpenUrl = { url ->
129130
if (state.openInExternalBrowser) {

app/src/main/java/com/readrops/app/item/ItemScreenPage.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ import com.readrops.app.item.components.SimpleTitle
3434
import com.readrops.app.item.components.rememberBottomBarNestedScrollConnection
3535
import com.readrops.app.item.view.ItemNestedScrollView
3636
import com.readrops.app.item.view.ItemWebView
37+
import com.readrops.db.entities.account.AccountType
3738
import com.readrops.db.pojo.ItemWithFeed
3839

3940
@Composable
4041
fun ItemScreenPage(
4142
itemWithFeed: ItemWithFeed,
43+
accountType: AccountType,
4244
snackbarHostState: SnackbarHostState,
4345
onOpenUrl: (String) -> Unit,
4446
onShareItem: () -> Unit,
@@ -72,7 +74,8 @@ fun ItemScreenPage(
7274
ItemScreenBottomBar(
7375
state = BottomBarState(
7476
isRead = itemWithFeed.item.isRead,
75-
isStarred = itemWithFeed.item.isStarred
77+
isStarred = itemWithFeed.item.isStarred,
78+
accountType = accountType,
7679
),
7780
accentColor = accentColor,
7881
modifier = Modifier

app/src/main/java/com/readrops/app/item/components/ItemScreenBottomBar.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import com.readrops.app.util.DefaultPreview
2020
import com.readrops.app.util.FeedColors
2121
import com.readrops.app.util.theme.ReadropsTheme
2222
import com.readrops.app.util.theme.spacing
23+
import com.readrops.db.entities.account.AccountType
2324

2425
data class BottomBarState(
2526
val isRead: Boolean = false,
26-
val isStarred: Boolean = false
27+
val isStarred: Boolean = false,
28+
val accountType: AccountType,
2729
)
2830

2931
@Composable
@@ -54,9 +56,12 @@ fun ItemScreenBottomBar(
5456
) {
5557
Icon(
5658
painter = painterResource(
57-
id = if (state.isRead)
58-
R.drawable.ic_read
59-
else R.drawable.ic_unread
59+
id = if (state.isRead) {
60+
state.accountType.readIcon
61+
}
62+
else {
63+
state.accountType.unreadIcon
64+
}
6065
),
6166
tint = tint,
6267
contentDescription = null
@@ -107,7 +112,8 @@ private fun ItemScreenBottomBarPreview() {
107112
ItemScreenBottomBar(
108113
state = BottomBarState(
109114
isRead = false,
110-
isStarred = false
115+
isStarred = false,
116+
accountType = AccountType.GREADER
111117
),
112118
accentColor = MaterialTheme.colorScheme.primary,
113119
onShare = {},

app/src/main/java/com/readrops/app/timelime/TimelineScreenModel.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.readrops.app.timelime
22

33
import android.content.Context
4-
import android.content.Intent
54
import androidx.compose.runtime.Stable
65
import androidx.paging.Pager
76
import androidx.paging.PagingConfig
@@ -18,7 +17,6 @@ import com.readrops.app.util.PAGING_INITIAL_SIZE
1817
import com.readrops.app.util.PAGING_PAGE_SIZE
1918
import com.readrops.app.util.PAGING_PREFETCH_DISTANCE
2019
import com.readrops.app.util.Preferences
21-
import com.readrops.app.util.ShareIntentTextRenderer
2220
import com.readrops.app.util.Utils
2321
import com.readrops.app.util.extensions.clearSerializables
2422
import com.readrops.app.util.extensions.getSerializable
@@ -27,6 +25,8 @@ import com.readrops.db.entities.Feed
2725
import com.readrops.db.entities.Folder
2826
import com.readrops.db.entities.Item
2927
import com.readrops.db.entities.OpenIn
28+
import com.readrops.db.entities.account.AccountConfig
29+
import com.readrops.db.entities.account.AccountType
3030
import com.readrops.db.filters.MainFilter
3131
import com.readrops.db.filters.OrderField
3232
import com.readrops.db.filters.OrderType
@@ -61,7 +61,7 @@ class TimelineScreenModel(
6161
private val dispatcher: CoroutineDispatcher = Dispatchers.IO
6262
) : TabScreenModel(database, context) {
6363

64-
private val _timelineState = MutableStateFlow(TimelineState())
64+
private val _timelineState = MutableStateFlow(TimelineState(AccountType.LOCAL))
6565
val timelineState = _timelineState.asStateFlow()
6666

6767
// separate this from main Timeline state for performances
@@ -94,6 +94,7 @@ class TimelineScreenModel(
9494
}.collectLatest { (account, filters, timelinePreferences) ->
9595
_timelineState.update {
9696
it.copy(
97+
accountType = account.type!!,
9798
preferences = timelinePreferences,
9899
filters = filters.copy(
99100
showReadItems = timelinePreferences.showReadItems,
@@ -479,6 +480,7 @@ class TimelineScreenModel(
479480

480481
@Stable
481482
data class TimelineState(
483+
val accountType: AccountType,
482484
val isRefreshing: Boolean = false,
483485
val isDrawerOpen: Boolean = false,
484486
val currentFeed: String = "",
@@ -496,7 +498,7 @@ data class TimelineState(
496498
val dialog: DialogState? = null,
497499
val isAccountLocal: Boolean = false,
498500
val hideReadAllFAB: Boolean = false,
499-
val preferences: TimelinePreferences = TimelinePreferences()
501+
val preferences: TimelinePreferences = TimelinePreferences(),
500502
) {
501503

502504
val showSubtitle = filters.subFilter != SubFilter.ALL

app/src/main/java/com/readrops/app/timelime/TimelineTab.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ object TimelineTab : Tab {
318318
if (itemWithFeed != null) {
319319
TimelineItem(
320320
itemWithFeed = itemWithFeed,
321+
accoutType = state.accountType,
321322
onClick = {
322323
if (itemWithFeed.openInAsk && preferences.openInAsk) {
323324
screenModel.openDialog(

app/src/main/java/com/readrops/app/timelime/components/TimelineItem.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import androidx.compose.ui.draw.clip
2121
import androidx.compose.ui.graphics.Color
2222
import androidx.compose.ui.res.painterResource
2323
import androidx.compose.ui.unit.dp
24-
import com.readrops.app.R
2524
import com.readrops.app.util.DefaultPreview
2625
import com.readrops.app.util.theme.ReadropsTheme
2726
import com.readrops.app.util.theme.spacing
2827
import com.readrops.db.entities.Folder
2928
import com.readrops.db.entities.OpenIn
29+
import com.readrops.db.entities.account.AccountType
3030
import com.readrops.db.pojo.ItemWithFeed
3131
import java.time.LocalDateTime
3232

@@ -41,6 +41,7 @@ const val readAlpha = 0.6f
4141
@Composable
4242
fun TimelineItem(
4343
itemWithFeed: ItemWithFeed,
44+
accoutType: AccountType,
4445
onClick: () -> Unit,
4546
onFavorite: () -> Unit,
4647
onShare: () -> Unit,
@@ -102,9 +103,9 @@ fun TimelineItem(
102103
Icon(
103104
painter = painterResource(
104105
id = if (itemWithFeed.item.isRead) {
105-
R.drawable.ic_read
106+
accoutType.readIcon
106107
} else {
107-
R.drawable.ic_unread
108+
accoutType.unreadIcon
108109
}
109110
),
110111
contentDescription = null,

db/src/main/java/com/readrops/db/entities/account/AccountConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ data class AccountConfig(
1010
val canUpdateFeed: Boolean = true,
1111
val canDeleteFeed: Boolean = true,
1212
val canDeleteFolder: Boolean = true,
13-
val canMarkAllItemsAsRead: Boolean = true
13+
val canMarkAllItemsAsRead: Boolean = true,
1414
) {
1515

1616
companion object {

db/src/main/java/com/readrops/db/entities/account/AccountType.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import com.readrops.db.R
77
enum class AccountType(
88
@DrawableRes val iconRes: Int,
99
@StringRes val nameRes: Int,
10-
val config: AccountConfig
10+
val config: AccountConfig,
11+
@DrawableRes val readIcon: Int = R.drawable.ic_read,
12+
@DrawableRes val unreadIcon: Int = R.drawable.ic_unread,
1113
) {
1214
LOCAL(R.mipmap.ic_launcher, R.string.local_account, AccountConfig.LOCAL),
1315
NEXTCLOUD_NEWS(R.drawable.ic_nextcloud_news, R.string.nextcloud_news, AccountConfig.NEXTCLOUD_NEWS),

0 commit comments

Comments
 (0)