Skip to content

Commit 7e0a2c2

Browse files
committed
[feature|optimize|fix] Support configure the tonal elevation of some components of Feed (#55), Article, and Search screens; optimize the layout of Article screen and search screen (#53); fix the wrong article deduplication issue (#54)
1 parent 6e59f4d commit 7e0a2c2

37 files changed

+1504
-317
lines changed

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ android {
2020
applicationId = "com.skyd.anivu"
2121
minSdk = 24
2222
targetSdk = 34
23-
versionCode = 17
24-
versionName = "1.1-beta45"
23+
versionCode = 18
24+
versionName = "1.1-beta46"
2525

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

app/proguard-rules.pro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,4 @@ public static final ** CREATOR;
113113
-dontwarn com.arthenica.smartexception.java.Exceptions
114114

115115
# MPV
116-
-keep,allowoptimization class is.xyz.mpv.MPVLib { public protected *; }
117-
118-
-dontwarn org.xmlpull.v1.**
119-
-keep class org.xmlpull.** { *; }
120-
-keepclassmembers class org.xmlpull.** { *; }
116+
-keep,allowoptimization class is.xyz.mpv.MPVLib { public protected *; }

app/src/main/java/com/skyd/anivu/ext/PaddingValuesExt.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.calculateEndPadding
55
import androidx.compose.foundation.layout.calculateStartPadding
66
import androidx.compose.runtime.Composable
77
import androidx.compose.ui.platform.LocalLayoutDirection
8+
import androidx.compose.ui.unit.Dp
89

910
@Composable
1011
operator fun PaddingValues.plus(other: PaddingValues): PaddingValues = PaddingValues(
@@ -15,3 +16,6 @@ operator fun PaddingValues.plus(other: PaddingValues): PaddingValues = PaddingVa
1516
end = calculateEndPadding(LocalLayoutDirection.current) +
1617
other.calculateEndPadding(LocalLayoutDirection.current)
1718
)
19+
20+
@Composable
21+
operator fun PaddingValues.plus(other: Dp): PaddingValues = this + PaddingValues(other)

app/src/main/java/com/skyd/anivu/ext/PreferenceExt.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ import com.skyd.anivu.model.preference.appearance.DateStylePreference
88
import com.skyd.anivu.model.preference.appearance.NavigationBarLabelPreference
99
import com.skyd.anivu.model.preference.appearance.TextFieldStylePreference
1010
import com.skyd.anivu.model.preference.appearance.ThemePreference
11+
import com.skyd.anivu.model.preference.appearance.article.ArticleItemTonalElevationPreference
12+
import com.skyd.anivu.model.preference.appearance.article.ArticleListTonalElevationPreference
13+
import com.skyd.anivu.model.preference.appearance.article.ArticleTopBarTonalElevationPreference
1114
import com.skyd.anivu.model.preference.appearance.feed.FeedGroupExpandPreference
15+
import com.skyd.anivu.model.preference.appearance.feed.FeedListTonalElevationPreference
16+
import com.skyd.anivu.model.preference.appearance.feed.FeedTopBarTonalElevationPreference
17+
import com.skyd.anivu.model.preference.appearance.search.SearchListTonalElevationPreference
18+
import com.skyd.anivu.model.preference.appearance.search.SearchTopBarTonalElevationPreference
1219
import com.skyd.anivu.model.preference.behavior.PickImageMethodPreference
1320
import com.skyd.anivu.model.preference.behavior.article.ArticleSwipeLeftActionPreference
1421
import com.skyd.anivu.model.preference.behavior.article.ArticleTapActionPreference
@@ -32,6 +39,13 @@ fun Preferences.toSettings(): Settings {
3239
textFieldStyle = TextFieldStylePreference.fromPreferences(this),
3340
dateStyle = DateStylePreference.fromPreferences(this),
3441
navigationBarLabel = NavigationBarLabelPreference.fromPreferences(this),
42+
feedListTonalElevation = FeedListTonalElevationPreference.fromPreferences(this),
43+
feedTopBarTonalElevation = FeedTopBarTonalElevationPreference.fromPreferences(this),
44+
articleListTonalElevation = ArticleListTonalElevationPreference.fromPreferences(this),
45+
articleTopBarTonalElevation = ArticleTopBarTonalElevationPreference.fromPreferences(this),
46+
articleItemTonalElevation = ArticleItemTonalElevationPreference.fromPreferences(this),
47+
searchListTonalElevation = SearchListTonalElevationPreference.fromPreferences(this),
48+
searchTopBarTonalElevation = SearchTopBarTonalElevationPreference.fromPreferences(this),
3549

3650
// Update
3751
ignoreUpdateVersion = IgnoreUpdateVersionPreference.fromPreferences(this),

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ data class ArticleBean(
4949
val image: String? = null,
5050
@ColumnInfo(name = LINK_COLUMN)
5151
var link: String? = null,
52+
@ColumnInfo(name = GUID_COLUMN)
53+
var guid: String? = null,
5254
@ColumnInfo(name = UPDATE_AT_COLUMN)
5355
var updateAt: Long? = null,
5456
@ColumnInfo(name = IS_READ_COLUMN)
@@ -66,6 +68,7 @@ data class ArticleBean(
6668
const val CONTENT_COLUMN = "content"
6769
const val IMAGE_COLUMN = "image"
6870
const val LINK_COLUMN = "link"
71+
const val GUID_COLUMN = "guid"
6972
const val UPDATE_AT_COLUMN = "updateAt"
7073
const val IS_READ_COLUMN = "isRead"
7174
const val IS_FAVORITE_COLUMN = "isFavorite"

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.skyd.anivu.model.db.migration.Migration2To3
2626
import com.skyd.anivu.model.db.migration.Migration3To4
2727
import com.skyd.anivu.model.db.migration.Migration4To5
2828
import com.skyd.anivu.model.db.migration.Migration5To6
29+
import com.skyd.anivu.model.db.migration.Migration6To7
2930

3031
const val APP_DATA_BASE_FILE_NAME = "app.db"
3132

@@ -41,7 +42,7 @@ const val APP_DATA_BASE_FILE_NAME = "app.db"
4142
GroupBean::class,
4243
],
4344
views = [FeedViewBean::class],
44-
version = 6,
45+
version = 7,
4546
)
4647
@TypeConverters(
4748
value = []
@@ -61,7 +62,7 @@ abstract class AppDatabase : RoomDatabase() {
6162

6263
private val migrations = arrayOf(
6364
Migration1To2(), Migration2To3(), Migration3To4(), Migration4To5(),
64-
Migration5To6()
65+
Migration5To6(), Migration6To7()
6566
)
6667

6768
fun getInstance(context: Context): AppDatabase {

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

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,25 @@ interface ArticleDao {
3131
val enclosureDao: EnclosureDao
3232
}
3333

34+
// null always compares false in '='
3435
@Query(
3536
"""
3637
SELECT * from $ARTICLE_TABLE_NAME
37-
WHERE ${ArticleBean.LINK_COLUMN} = :link
38-
AND ${ArticleBean.FEED_URL_COLUMN} = :feedUrl
38+
WHERE ${ArticleBean.GUID_COLUMN} = :guid AND
39+
${ArticleBean.FEED_URL_COLUMN} = :feedUrl
40+
"""
41+
)
42+
suspend fun queryArticleByGuid(
43+
guid: String?,
44+
feedUrl: String,
45+
): ArticleBean?
46+
47+
// null always compares false in '='
48+
@Query(
49+
"""
50+
SELECT * from $ARTICLE_TABLE_NAME
51+
WHERE ${ArticleBean.LINK_COLUMN} = :link AND
52+
${ArticleBean.FEED_URL_COLUMN} = :feedUrl
3953
"""
4054
)
4155
suspend fun queryArticleByLink(
@@ -56,16 +70,26 @@ interface ArticleDao {
5670
val hiltEntryPoint =
5771
EntryPointAccessors.fromApplication(appContext, ArticleDaoEntryPoint::class.java)
5872
articleWithEnclosureList.forEach {
59-
// 可能会出现link、feedUrl都一样,但是uuid不一样的情况
60-
var newArticle = queryArticleByLink(
61-
link = it.article.link,
62-
feedUrl = it.article.feedUrl,
63-
)
73+
// Duplicate article by guid or link
74+
val guid = it.article.guid
75+
val link = it.article.link
76+
var newArticle: ArticleBean? = null
77+
if (guid != null) {
78+
newArticle = queryArticleByGuid(
79+
guid = guid,
80+
feedUrl = it.article.feedUrl,
81+
)
82+
} else if (link != null) {
83+
newArticle = queryArticleByLink(
84+
link = link,
85+
feedUrl = it.article.feedUrl,
86+
)
87+
}
6488
if (newArticle == null) {
6589
innerUpdateArticle(it.article)
6690
newArticle = it.article
6791
} else {
68-
// 除了uuid,其他的字段都更新
92+
// Update all fields except articleId
6993
newArticle = it.article.copy(articleId = newArticle.articleId)
7094
innerUpdateArticle(newArticle)
7195
}
@@ -143,7 +167,7 @@ interface ArticleDao {
143167
@Query(
144168
"""
145169
UPDATE $ARTICLE_TABLE_NAME SET ${ArticleBean.IS_FAVORITE_COLUMN} = :favorite
146-
WHERE ${ArticleBean.ARTICLE_ID_COLUMN} LIKE :articleId
170+
WHERE ${ArticleBean.ARTICLE_ID_COLUMN} = :articleId
147171
"""
148172
)
149173
fun favoriteArticle(articleId: String, favorite: Boolean)
@@ -152,7 +176,7 @@ interface ArticleDao {
152176
@Query(
153177
"""
154178
UPDATE $ARTICLE_TABLE_NAME SET ${ArticleBean.IS_READ_COLUMN} = :read
155-
WHERE ${ArticleBean.ARTICLE_ID_COLUMN} LIKE :articleId
179+
WHERE ${ArticleBean.ARTICLE_ID_COLUMN} = :articleId
156180
"""
157181
)
158182
fun readArticle(articleId: String, read: Boolean)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.skyd.anivu.model.db.migration
2+
3+
import androidx.room.migration.Migration
4+
import androidx.sqlite.db.SupportSQLiteDatabase
5+
import com.skyd.anivu.model.bean.ARTICLE_TABLE_NAME
6+
import com.skyd.anivu.model.bean.ArticleBean
7+
8+
class Migration6To7 : Migration(6, 7) {
9+
override fun migrate(db: SupportSQLiteDatabase) {
10+
db.execSQL("ALTER TABLE $ARTICLE_TABLE_NAME ADD ${ArticleBean.GUID_COLUMN} TEXT")
11+
}
12+
}

app/src/main/java/com/skyd/anivu/model/preference/Settings.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ import com.skyd.anivu.model.preference.appearance.DateStylePreference
1313
import com.skyd.anivu.model.preference.appearance.NavigationBarLabelPreference
1414
import com.skyd.anivu.model.preference.appearance.TextFieldStylePreference
1515
import com.skyd.anivu.model.preference.appearance.ThemePreference
16+
import com.skyd.anivu.model.preference.appearance.article.ArticleItemTonalElevationPreference
17+
import com.skyd.anivu.model.preference.appearance.article.ArticleListTonalElevationPreference
18+
import com.skyd.anivu.model.preference.appearance.article.ArticleTopBarTonalElevationPreference
1619
import com.skyd.anivu.model.preference.appearance.feed.FeedGroupExpandPreference
20+
import com.skyd.anivu.model.preference.appearance.feed.FeedListTonalElevationPreference
21+
import com.skyd.anivu.model.preference.appearance.feed.FeedTopBarTonalElevationPreference
22+
import com.skyd.anivu.model.preference.appearance.search.SearchListTonalElevationPreference
23+
import com.skyd.anivu.model.preference.appearance.search.SearchTopBarTonalElevationPreference
1724
import com.skyd.anivu.model.preference.behavior.PickImageMethodPreference
1825
import com.skyd.anivu.model.preference.behavior.article.ArticleSwipeLeftActionPreference
1926
import com.skyd.anivu.model.preference.behavior.article.ArticleTapActionPreference
@@ -27,14 +34,19 @@ import com.skyd.anivu.model.preference.player.HardwareDecodePreference
2734
import com.skyd.anivu.model.preference.player.PlayerDoubleTapPreference
2835
import com.skyd.anivu.model.preference.player.PlayerShow85sButtonPreference
2936
import com.skyd.anivu.model.preference.player.PlayerShowScreenshotButtonPreference
37+
import com.skyd.anivu.ui.local.LocalArticleItemTonalElevation
38+
import com.skyd.anivu.ui.local.LocalArticleListTonalElevation
3039
import com.skyd.anivu.ui.local.LocalArticleSwipeLeftAction
3140
import com.skyd.anivu.ui.local.LocalArticleTapAction
41+
import com.skyd.anivu.ui.local.LocalArticleTopBarTonalElevation
3242
import com.skyd.anivu.ui.local.LocalAutoDeleteArticleBefore
3343
import com.skyd.anivu.ui.local.LocalAutoDeleteArticleFrequency
3444
import com.skyd.anivu.ui.local.LocalDarkMode
3545
import com.skyd.anivu.ui.local.LocalDateStyle
3646
import com.skyd.anivu.ui.local.LocalDeduplicateTitleInDesc
3747
import com.skyd.anivu.ui.local.LocalFeedGroupExpand
48+
import com.skyd.anivu.ui.local.LocalFeedListTonalElevation
49+
import com.skyd.anivu.ui.local.LocalFeedTopBarTonalElevation
3850
import com.skyd.anivu.ui.local.LocalHardwareDecode
3951
import com.skyd.anivu.ui.local.LocalHideEmptyDefault
4052
import com.skyd.anivu.ui.local.LocalIgnoreUpdateVersion
@@ -44,6 +56,8 @@ import com.skyd.anivu.ui.local.LocalPickImageMethod
4456
import com.skyd.anivu.ui.local.LocalPlayerDoubleTap
4557
import com.skyd.anivu.ui.local.LocalPlayerShow85sButton
4658
import com.skyd.anivu.ui.local.LocalPlayerShowScreenshotButton
59+
import com.skyd.anivu.ui.local.LocalSearchListTonalElevation
60+
import com.skyd.anivu.ui.local.LocalSearchTopBarTonalElevation
4761
import com.skyd.anivu.ui.local.LocalTextFieldStyle
4862
import com.skyd.anivu.ui.local.LocalTheme
4963
import com.skyd.anivu.ui.local.LocalUseAutoDelete
@@ -58,6 +72,13 @@ data class Settings(
5872
val textFieldStyle: String = TextFieldStylePreference.default,
5973
val dateStyle: String = DateStylePreference.default,
6074
val navigationBarLabel: String = NavigationBarLabelPreference.default,
75+
val feedListTonalElevation: Float = FeedListTonalElevationPreference.default,
76+
val feedTopBarTonalElevation: Float = FeedTopBarTonalElevationPreference.default,
77+
val articleListTonalElevation: Float = ArticleListTonalElevationPreference.default,
78+
val articleTopBarTonalElevation: Float = ArticleTopBarTonalElevationPreference.default,
79+
val articleItemTonalElevation: Float = ArticleItemTonalElevationPreference.default,
80+
val searchListTonalElevation: Float = SearchListTonalElevationPreference.default,
81+
val searchTopBarTonalElevation: Float = SearchTopBarTonalElevationPreference.default,
6182
// Update
6283
val ignoreUpdateVersion: Long = IgnoreUpdateVersionPreference.default,
6384
// Behavior
@@ -94,6 +115,13 @@ fun SettingsProvider(
94115
LocalTextFieldStyle provides settings.textFieldStyle,
95116
LocalDateStyle provides settings.dateStyle,
96117
LocalNavigationBarLabel provides settings.navigationBarLabel,
118+
LocalFeedListTonalElevation provides settings.feedListTonalElevation,
119+
LocalFeedTopBarTonalElevation provides settings.feedTopBarTonalElevation,
120+
LocalArticleListTonalElevation provides settings.articleListTonalElevation,
121+
LocalArticleTopBarTonalElevation provides settings.articleTopBarTonalElevation,
122+
LocalArticleItemTonalElevation provides settings.articleItemTonalElevation,
123+
LocalSearchListTonalElevation provides settings.searchListTonalElevation,
124+
LocalSearchTopBarTonalElevation provides settings.searchTopBarTonalElevation,
97125
// Update
98126
LocalIgnoreUpdateVersion provides settings.ignoreUpdateVersion,
99127
// Behavior
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.skyd.anivu.model.preference.appearance.article
2+
3+
import android.content.Context
4+
import androidx.datastore.preferences.core.Preferences
5+
import androidx.datastore.preferences.core.floatPreferencesKey
6+
import com.skyd.anivu.base.BasePreference
7+
import com.skyd.anivu.ext.dataStore
8+
import com.skyd.anivu.ext.put
9+
import kotlinx.coroutines.CoroutineScope
10+
import kotlinx.coroutines.Dispatchers
11+
import kotlinx.coroutines.launch
12+
13+
object ArticleItemTonalElevationPreference : BasePreference<Float> {
14+
private const val ARTICLE_ITEM_TONAL_ELEVATION = "articleItemTonalElevation"
15+
override val default = -2f
16+
17+
val key = floatPreferencesKey(ARTICLE_ITEM_TONAL_ELEVATION)
18+
19+
fun put(context: Context, scope: CoroutineScope, value: Float) {
20+
scope.launch(Dispatchers.IO) {
21+
context.dataStore.put(key, value)
22+
}
23+
}
24+
25+
override fun fromPreferences(preferences: Preferences): Float = preferences[key] ?: default
26+
}

0 commit comments

Comments
 (0)