From 7c8e8317a8c24261b62645c477028fdd3717e4e8 Mon Sep 17 00:00:00 2001 From: arkon Date: Thu, 21 Apr 2022 22:47:51 -0400 Subject: [PATCH] Simplify history item description building --- .../presentation/history/HistoryScreen.kt | 25 ++++++++----------- .../database/ClearDatabaseController.kt | 3 --- app/src/main/res/values/strings.xml | 1 - 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index adbc67298c..4c130588c7 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -39,7 +39,6 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import androidx.core.text.buildSpannedString import androidx.paging.compose.LazyPagingItems import androidx.paging.compose.collectAsLazyPagingItems import androidx.paging.compose.items @@ -60,7 +59,7 @@ import uy.kohesive.injekt.api.get import java.text.DateFormat import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import java.util.* +import java.util.Date val chapterFormatter = DecimalFormat( "#.###", @@ -223,18 +222,16 @@ fun HistoryItem( ) Row { Text( - text = buildSpannedString { - if (history.chapterNumber > -1) { - append( - stringResource( - R.string.history_prefix, - chapterFormatter.format(history.chapterNumber) - ) - ) - } - append(history.readAt?.toTimestampString()) - }.toString(), - modifier = Modifier.padding(top = 2.dp), + text = if (history.chapterNumber > -1) { + stringResource( + R.string.recent_manga_time, + chapterFormatter.format(history.chapterNumber), + history.readAt?.toTimestampString() ?: "", + ) + } else { + history.readAt?.toTimestampString() ?: "" + }, + modifier = Modifier.padding(top = 4.dp), style = textStyle ) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt index a47075667a..9002efc416 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/database/ClearDatabaseController.kt @@ -9,7 +9,6 @@ import android.view.MenuInflater import android.view.MenuItem import android.view.View import androidx.core.view.forEach -import androidx.core.view.get import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -37,7 +36,6 @@ class ClearDatabaseController : private var menu: Menu? = null private var actionFab: ExtendedFloatingActionButton? = null - private var actionFabScrollListener: RecyclerView.OnScrollListener? = null init { setHasOptionsMenu(true) @@ -143,7 +141,6 @@ class ClearDatabaseController : override fun cleanupFab(fab: ExtendedFloatingActionButton) { actionFab?.setOnClickListener(null) - actionFabScrollListener?.let { recycler?.removeOnScrollListener(it) } actionFab = null } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 96c5c276fc..8346aee7a8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -703,7 +703,6 @@ Updating library - Ch. %1$s - Ch. %1$s - %2$s Clear history History deleted