Skip to content

Commit

Permalink
[fix|build] Fix zero width characters in file size string; update dep…
Browse files Browse the repository at this point in the history
…endencies
  • Loading branch information
SkyD666 committed Dec 27, 2024
1 parent 02a7174 commit c9a73a1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
14 changes: 7 additions & 7 deletions app/src/androidTest/java/com/skyd/anivu/RssModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class RssModule {
groupId = null,
nickname = "Nvidia",
).first()
feedDao.getFeed("https://blogs.nvidia.cn/feed/").apply {
feedDao.getFeed("https://blogs.nvidia.cn/feed/").feed.apply {
assertTrue(groupId == null && nickname == "Nvidia")
}
}
Expand Down Expand Up @@ -185,7 +185,7 @@ class RssModule {
).first()

feedRepository.editFeedGroup(url1, groupId).first()
assertTrue(feedDao.getFeed(url1).groupId == groupId)
assertTrue(feedDao.getFeed(url1).feed.groupId == groupId)

feedRepository.moveGroupFeedsTo(GroupVo.DEFAULT_GROUP_ID, groupId).first()
assertTrue(feedDao.getFeedsByGroupId(null).isEmpty())
Expand Down Expand Up @@ -447,7 +447,7 @@ class RssModule {
val url1 = "https://blogs.nvidia.cn/feed/"
feedRepository.setFeed(url = url1, groupId = null, nickname = null).first()
feedRepository.editFeedCustomDescription(url1, "test13").first()
assertEquals(feedDao.getFeed(url1).customDescription, "test13")
assertEquals(feedDao.getFeed(url1).feed.customDescription, "test13")
}

/**
Expand All @@ -461,7 +461,7 @@ class RssModule {
val url1 = "https://blogs.nvidia.cn/feed/"
feedRepository.setFeed(url = url1, groupId = null, nickname = null).first()
feedRepository.editFeedNickname(url1, "nickname test13").first()
assertEquals(feedDao.getFeed(url1).nickname, "nickname test13")
assertEquals(feedDao.getFeed(url1).feed.nickname, "nickname test13")
}

/**
Expand All @@ -477,7 +477,7 @@ class RssModule {
val icon =
"https://www.gstatic.com/devrel-devsite/prod/v3239347c48d1e3c46204782fd038ba187a6753dfa7d7a0d08a574587ae2085f5/android/images/lockup.svg"
feedRepository.editFeedCustomIcon(url1, Uri.parse(icon)).first()
assertEquals(feedDao.getFeed(url1).customIcon, icon)
assertEquals(feedDao.getFeed(url1).feed.customIcon, icon)
}

/**
Expand All @@ -491,9 +491,9 @@ class RssModule {
val url1 = "https://blogs.nvidia.cn/feed/"
feedRepository.setFeed(url = url1, groupId = null, nickname = null).first()
feedRepository.editFeedSortXmlArticlesOnUpdate(url1, true).first()
assertTrue(feedDao.getFeed(url1).sortXmlArticlesOnUpdate)
assertTrue(feedDao.getFeed(url1).feed.sortXmlArticlesOnUpdate)
feedRepository.editFeedSortXmlArticlesOnUpdate(url1, false).first()
assertFalse(feedDao.getFeed(url1).sortXmlArticlesOnUpdate)
assertFalse(feedDao.getFeed(url1).feed.sortXmlArticlesOnUpdate)
}

/**
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/skyd/anivu/ext/NumberExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import android.util.TypedValue

fun Long.fileSize(context: Context): String =
Formatter.formatFileSize(context, this)
// On some systems, zero-width characters are inserted into the string
// for unknown reasons 🤔, and they need to be removed to avoid display issues.
.replace(Regex("[\\u200B\\u200C\\u200E\\u200F\\u202A-\\u202E\\u2060]"), "")

val Float.dp: Float
get() = TypedValue.applyDimension(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.skyd.anivu.ui.screen.media.list

import androidx.compose.foundation.background
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -11,7 +12,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.outlined.OpenInNew
Expand Down Expand Up @@ -144,7 +145,6 @@ fun Media1Item(
Spacer(modifier = Modifier.width(10.dp))
Column {
Text(
modifier = Modifier.wrapContentHeight(),
text = if (data.displayName.isNullOrBlank()) {
fileNameWithoutExtension
} else {
Expand All @@ -156,21 +156,28 @@ fun Media1Item(
Spacer(modifier = Modifier.height(8.dp))
Row(verticalAlignment = Alignment.CenterVertically) {
if (fileExtension.isNotBlank()) {
TagText(text = fileExtension.uppercase(Locale.getDefault()))
TagText(text = remember(fileExtension) { fileExtension.uppercase(Locale.getDefault()) })
Spacer(modifier = Modifier.width(12.dp))
} else if (data.isDir) {
TagText(text = stringResource(id = R.string.folder))
}
if (!data.isDir) {
Text(
text = data.size.fileSize(context),
modifier = Modifier
.basicMarquee()
.widthIn(min = 40.dp),
text = remember(data) { data.size.fileSize(context) },
style = MaterialTheme.typography.labelMedium,
)
}
Spacer(modifier = Modifier.weight(1f))
Text(
text = data.date.toDateTimeString(context = context),
modifier = Modifier
.basicMarquee()
.widthIn(min = 40.dp),
text = remember(data) { data.date.toDateTimeString(context = context) },
style = MaterialTheme.typography.labelMedium,
maxLines = 1,
)
}

Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
adaptive = "1.0.0"
coil = "3.0.4"
hilt = "2.53"
hilt = "2.54"
androidxTest = "1.2.1"
libtorrent4j = "2.1.0-35"
composeMaterial = "1.7.6"
composeMaterial3 = "1.4.0-alpha04"
coroutines = "1.9.0"
coroutines = "1.10.1"
okhttp3 = "4.12.0"
paging = "3.3.5"
rome = "2.1.0"
Expand Down Expand Up @@ -48,7 +48,7 @@ androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstall

material = { module = "com.google.android.material:material", version = "1.12.0" }
material-kolor = { module = "com.materialkolor:material-kolor", version = "2.0.0" }
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version = "0.36.0" }
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version = "0.37.0" }

hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
Expand All @@ -70,15 +70,15 @@ coil-gif = { module = "io.coil-kt.coil3:coil-gif", version.ref = "coil" }
coil-svg = { module = "io.coil-kt.coil3:coil-svg", version.ref = "coil" }
coil-video = { module = "io.coil-kt.coil3:coil-video", version.ref = "coil" }

lottie-compose = { module = "com.airbnb.android:lottie-compose", version = "6.6.1" }
lottie-compose = { module = "com.airbnb.android:lottie-compose", version = "6.6.2" }

rome = { module = "com.rometools:rome", version.ref = "rome" }
rome-modules = { module = "com.rometools:rome-modules", version.ref = "rome" }
ceau-opmlparser = { module = "be.ceau:opml-parser", version = "3.1.0" }

readability4j = { module = "net.dankito.readability4j:readability4j", version = "1.0.8" }

reorderable = { module = "sh.calvin.reorderable:reorderable", version = "2.4.0" }
reorderable = { module = "sh.calvin.reorderable:reorderable", version = "2.4.2" }

libtorrent4j-arm64 = { module = "org.libtorrent4j:libtorrent4j-android-arm64", version.ref = "libtorrent4j" }
libtorrent4j-arm = { module = "org.libtorrent4j:libtorrent4j-android-arm", version.ref = "libtorrent4j" }
Expand Down

0 comments on commit c9a73a1

Please sign in to comment.