Skip to content

Commit df36159

Browse files
committed
[optimize|doc] Optimize the Group edit page; modify the equals method of the GroupBean; update README
1 parent 0719b8b commit df36159

File tree

22 files changed

+402
-391
lines changed

22 files changed

+402
-391
lines changed

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,16 @@
4545
2. **Automatically update RSS** subscriptions
4646
3. **Download enclosures** (enclosure tags) of **torrent or magnet** links in RSS articles
4747
4. **Seeding** downloaded files
48-
5. **Play downloaded videos**
49-
6. Support variable playback **speed**, **long press** to speed up playback
50-
7. **Double-finger** gesture to **rotate and zoom** video
48+
5. **Play media enclosures or downloaded videos**
49+
6. Support variable playback **speed**, setup **audio track**, **subtitle track**, etc
50+
7. **Double-finger** gesture to **rotate and zoom** video, **long press** to speed up playback
5151
8. **Swipe** on the video to **control volume**, **brightness**, and **playback position**
5252
9. **Searching** existing **RSS subscription content**
5353
10. **Play other videos on the phone**
54-
11. Support **dark mode**
55-
12. ......
56-
57-
## 🚧 Todo
58-
59-
1. Automatically **download new videos**
60-
3. **Float** video playback **window**
61-
4. **Automatically** play the **next video**
54+
11. Support **custom MPV player**
55+
12. Support **import and export** subscriptions via **OPML**
56+
13. Support **dark mode**
57+
14. ......
6258

6359
## 🤩 Screenshots
6460

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ android {
2121
minSdk = 24
2222
targetSdk = 34
2323
versionCode = 17
24-
versionName = "1.1-beta43"
24+
versionName = "1.1-beta44"
2525

2626
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2727

app/src/main/java/com/skyd/anivu/model/bean/GroupBean.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,17 @@ open class GroupBean(
2525
override fun equals(other: Any?): Boolean {
2626
if (this === other) return true
2727
if (other !is GroupBean) return false
28-
return groupId == other.groupId
28+
29+
if (groupId != other.groupId) return false
30+
if (name != other.name) return false
31+
32+
return true
2933
}
3034

3135
override fun hashCode(): Int {
32-
return groupId.hashCode()
36+
var result = groupId.hashCode()
37+
result = 31 * result + name.hashCode()
38+
return result
3339
}
3440

3541
object DefaultGroup :

app/src/main/java/com/skyd/anivu/model/db/dao/FeedDao.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ interface FeedDao {
132132
)
133133
suspend fun getFeedsNotIn(groupIds: List<String>): List<FeedViewBean>
134134

135+
@Transaction
136+
@Query(
137+
"""
138+
SELECT * FROM $FEED_VIEW_NAME
139+
WHERE :groupId IS NULL AND ${FeedBean.GROUP_ID_COLUMN} IS NULL OR
140+
${FeedBean.GROUP_ID_COLUMN} = :groupId
141+
"""
142+
)
143+
suspend fun getFeedsByGroupId(groupId: String?): List<FeedViewBean>
144+
135145
@Transaction
136146
@RawQuery(observedEntities = [FeedBean::class, ArticleBean::class])
137147
fun getFeedPagingSource(sql: SupportSQLiteQuery): PagingSource<Int, FeedViewBean>

app/src/main/java/com/skyd/anivu/model/db/dao/GroupDao.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ interface GroupDao {
2929
@Insert(onConflict = OnConflictStrategy.REPLACE)
3030
suspend fun setGroup(groupBean: GroupBean)
3131

32+
@Transaction
33+
@Query("SELECT * FROM `$GROUP_TABLE_NAME` WHERE ${GroupBean.GROUP_ID_COLUMN} = :groupId")
34+
suspend fun getGroupById(groupId: String): GroupBean
35+
3236
@Transaction
3337
@Delete
3438
suspend fun removeGroup(groupBean: GroupBean): Int
@@ -37,6 +41,13 @@ interface GroupDao {
3741
@Query("DELETE FROM `$GROUP_TABLE_NAME` WHERE ${GroupBean.GROUP_ID_COLUMN} = :groupId")
3842
suspend fun removeGroup(groupId: String): Int
3943

44+
@Transaction
45+
@Query(
46+
"UPDATE `$GROUP_TABLE_NAME` SET ${GroupBean.NAME_COLUMN} = :name " +
47+
"WHERE ${GroupBean.GROUP_ID_COLUMN} = :groupId"
48+
)
49+
suspend fun renameGroup(groupId: String, name: String): Int
50+
4051
@Transaction
4152
suspend fun removeGroupWithFeed(groupId: String): Int {
4253
removeGroup(groupId)

app/src/main/java/com/skyd/anivu/model/repository/ArticleRepository.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ import androidx.paging.PagingConfig
55
import androidx.paging.PagingData
66
import com.skyd.anivu.base.BaseRepository
77
import com.skyd.anivu.model.bean.ArticleWithFeed
8+
import com.skyd.anivu.model.bean.GroupBean
89
import com.skyd.anivu.model.db.dao.ArticleDao
910
import com.skyd.anivu.model.db.dao.FeedDao
1011
import kotlinx.coroutines.Deferred
1112
import kotlinx.coroutines.Dispatchers
1213
import kotlinx.coroutines.async
1314
import kotlinx.coroutines.coroutineScope
1415
import kotlinx.coroutines.flow.Flow
16+
import kotlinx.coroutines.flow.flatMapConcat
1517
import kotlinx.coroutines.flow.flow
1618
import kotlinx.coroutines.flow.flowOn
1719
import javax.inject.Inject
@@ -28,6 +30,15 @@ class ArticleRepository @Inject constructor(
2830
}.flow.flowOn(Dispatchers.IO)
2931
}
3032

33+
fun refreshGroupArticles(groupId: String?): Flow<Unit> {
34+
return flow {
35+
val realGroupId = if (groupId == GroupBean.DEFAULT_GROUP_ID) null else groupId
36+
emit(feedDao.getFeedsByGroupId(realGroupId).map { it.feed.url })
37+
}.flatMapConcat {
38+
refreshArticleList(it)
39+
}.flowOn(Dispatchers.IO)
40+
}
41+
3142
fun refreshArticleList(feedUrls: List<String>): Flow<Unit> {
3243
return flow {
3344
emit(coroutineScope {

app/src/main/java/com/skyd/anivu/model/repository/FeedRepository.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ class FeedRepository @Inject constructor(
5050
else flowOf(groupDao.removeGroupWithFeed(groupId)).flowOn(Dispatchers.IO)
5151
}
5252

53+
suspend fun renameGroup(groupId: String, name: String): Flow<GroupBean> {
54+
return if (groupId == GroupBean.DEFAULT_GROUP_ID) flow {
55+
emit(GroupBean.DefaultGroup)
56+
} else flow {
57+
groupDao.renameGroup(groupId, name)
58+
emit(groupDao.getGroupById(groupId))
59+
}.flowOn(Dispatchers.IO)
60+
}
61+
5362
suspend fun moveGroupFeedsTo(fromGroupId: String, toGroupId: String): Flow<Int> {
5463
val realFromGroupId = if (fromGroupId == GroupBean.DEFAULT_GROUP_ID) null else fromGroupId
5564
val realToGroupId = if (toGroupId == GroupBean.DEFAULT_GROUP_ID) null else toGroupId
@@ -66,7 +75,7 @@ class FeedRepository @Inject constructor(
6675
url: String,
6776
groupId: String?,
6877
nickname: String?,
69-
): Flow<Unit> {
78+
): Flow<FeedBean> {
7079
return flow {
7180
val realNickname = if (nickname.isNullOrBlank()) null else nickname
7281
val realGroupId =
@@ -79,7 +88,8 @@ class FeedRepository @Inject constructor(
7988
)
8089
)
8190
}
82-
emit(feedDao.setFeedWithArticle(feedWithArticleBean))
91+
feedDao.setFeedWithArticle(feedWithArticleBean)
92+
emit(feedWithArticleBean.feed)
8393
}.flowOn(Dispatchers.IO)
8494
}
8595

app/src/main/java/com/skyd/anivu/ui/component/lazyverticalgrid/adapter/proxy/DefaultGroup1Proxy.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class DefaultGroup1Proxy(
1818
onExpandChange = group1Proxy.onExpandChange,
1919
isEmpty = group1Proxy.isEmpty,
2020
onShowAllArticles = group1Proxy.onShowAllArticles,
21-
onDelete = group1Proxy.onDelete,
22-
onFeedsMoveTo = group1Proxy.onMoveFeedsTo,
21+
onEdit = group1Proxy.onEdit,
2322
)
2423
}
2524
}

app/src/main/java/com/skyd/anivu/ui/component/lazyverticalgrid/adapter/proxy/Group1Proxy.kt

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,29 @@ import androidx.compose.foundation.layout.Row
88
import androidx.compose.foundation.layout.padding
99
import androidx.compose.foundation.shape.RoundedCornerShape
1010
import androidx.compose.material.icons.Icons
11-
import androidx.compose.material.icons.outlined.Delete
1211
import androidx.compose.material.icons.outlined.KeyboardArrowUp
13-
import androidx.compose.material.icons.outlined.MoveUp
14-
import androidx.compose.material3.DropdownMenu
15-
import androidx.compose.material3.DropdownMenuItem
16-
import androidx.compose.material3.Icon
1712
import androidx.compose.material3.MaterialTheme
1813
import androidx.compose.material3.Text
1914
import androidx.compose.runtime.Composable
2015
import androidx.compose.runtime.getValue
2116
import androidx.compose.runtime.mutableStateOf
2217
import androidx.compose.runtime.remember
23-
import androidx.compose.runtime.saveable.rememberSaveable
2418
import androidx.compose.runtime.setValue
2519
import androidx.compose.ui.Alignment
2620
import androidx.compose.ui.Modifier
2721
import androidx.compose.ui.draw.clip
28-
import androidx.compose.ui.res.stringResource
2922
import androidx.compose.ui.unit.Dp
3023
import androidx.compose.ui.unit.dp
31-
import com.skyd.anivu.R
3224
import com.skyd.anivu.model.bean.GroupBean
3325
import com.skyd.anivu.ui.component.AniVuIconButton
34-
import com.skyd.anivu.ui.component.dialog.DeleteWarningDialog
3526
import com.skyd.anivu.ui.component.lazyverticalgrid.adapter.LazyGridAdapter
3627

3728
open class Group1Proxy(
3829
val isExpand: (GroupBean) -> Boolean = { false },
3930
val onExpandChange: (GroupBean, Boolean) -> Unit = { _, _ -> },
4031
val isEmpty: (index: Int) -> Boolean,
4132
val onShowAllArticles: (GroupBean) -> Unit = { },
42-
val onDelete: ((GroupBean) -> Unit)? = null,
43-
val onMoveFeedsTo: ((from: GroupBean) -> Unit)? = null,
33+
val onEdit: ((GroupBean) -> Unit)? = null,
4434
) : LazyGridAdapter.Proxy<GroupBean>() {
4535
@Composable
4636
override fun Draw(index: Int, data: GroupBean) {
@@ -51,8 +41,7 @@ open class Group1Proxy(
5141
onExpandChange = onExpandChange,
5242
isEmpty = isEmpty,
5343
onShowAllArticles = onShowAllArticles,
54-
onDelete = onDelete,
55-
onFeedsMoveTo = onMoveFeedsTo,
44+
onEdit = onEdit,
5645
)
5746
}
5847
}
@@ -67,12 +56,9 @@ fun Group1Item(
6756
onExpandChange: (GroupBean, Boolean) -> Unit,
6857
isEmpty: (index: Int) -> Boolean,
6958
onShowAllArticles: (GroupBean) -> Unit,
70-
onDelete: ((GroupBean) -> Unit)? = null,
71-
onFeedsMoveTo: ((GroupBean) -> Unit)? = null,
59+
onEdit: ((GroupBean) -> Unit)? = null,
7260
) {
7361
var expand by remember(data) { mutableStateOf(initExpand(data)) }
74-
var expandMenu by rememberSaveable { mutableStateOf(false) }
75-
var openDeleteWarningDialog by rememberSaveable { mutableStateOf(false) }
7662

7763
val backgroundShapeCorner: Dp by animateDpAsState(
7864
targetValue = if (expand && !isEmpty(index)) 0.dp else SHAPE_CORNER_DP,
@@ -93,7 +79,9 @@ fun Group1Item(
9379
)
9480
.background(color = MaterialTheme.colorScheme.surfaceContainer)
9581
.combinedClickable(
96-
onLongClick = { expandMenu = true },
82+
onLongClick = if (onEdit == null) null else {
83+
{ onEdit(data) }
84+
},
9785
onClick = { onShowAllArticles(data) },
9886
)
9987
.padding(start = 20.dp, end = 8.dp)
@@ -120,43 +108,5 @@ fun Group1Item(
120108
contentDescription = null,
121109
rotate = expandIconRotate,
122110
)
123-
124-
DropdownMenu(
125-
expanded = expandMenu,
126-
onDismissRequest = { expandMenu = false },
127-
) {
128-
DropdownMenuItem(
129-
text = { Text(text = stringResource(id = R.string.delete)) },
130-
leadingIcon = {
131-
Icon(imageVector = Icons.Outlined.Delete, contentDescription = null)
132-
},
133-
enabled = onDelete != null && data.groupId != GroupBean.DEFAULT_GROUP_ID,
134-
onClick = {
135-
openDeleteWarningDialog = true
136-
expandMenu = false
137-
},
138-
)
139-
DropdownMenuItem(
140-
text = { Text(text = stringResource(id = R.string.feed_screen_group_feeds_move_to)) },
141-
leadingIcon = {
142-
Icon(imageVector = Icons.Outlined.MoveUp, contentDescription = null)
143-
},
144-
enabled = onFeedsMoveTo != null,
145-
onClick = {
146-
onFeedsMoveTo?.invoke(data)
147-
expandMenu = false
148-
},
149-
)
150-
}
151111
}
152-
153-
DeleteWarningDialog(
154-
visible = openDeleteWarningDialog,
155-
title = stringResource(id = R.string.feed_screen_delete_group_warning_title),
156-
text = stringResource(id = R.string.feed_screen_delete_group_warning, data.name),
157-
confirmText = stringResource(id = R.string.delete),
158-
onConfirm = { onDelete?.invoke(data) },
159-
onDismiss = { openDeleteWarningDialog = false },
160-
onDismissRequest = { openDeleteWarningDialog = false },
161-
)
162112
}

0 commit comments

Comments
 (0)