From e2510c144ad3568caf81660d6ab1b4023202aad4 Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 18 Jul 2022 18:32:25 -0400 Subject: [PATCH] Misc cleanup - Migrate sources filter screen to full compose - Use standard "OK"/"Cancel" actions for delete category dialog - Abstract some AppBar logic - Remove some dead code - Group related strings --- .../browse/SourcesFilterScreen.kt | 44 ++++--- .../category/components/CategoryDialogs.kt | 12 +- .../kanade/presentation/components/AppBar.kt | 96 +++++++++++++--- .../kanade/presentation/manga/MangaScreen.kt | 6 +- .../{MangaSmallAppBar.kt => MangaAppBar.kt} | 6 +- .../presentation/updates/UpdatesScreen.kt | 107 +++++------------- .../browse/source/SourcesFilterController.kt | 12 +- .../ui/manga/chapter/ChapterDownloadView.kt | 41 ------- .../manga/chapter/base/BaseChapterHolder.kt | 21 ---- .../ui/manga/chapter/base/BaseChapterItem.kt | 47 -------- .../manga/chapter/base/BaseChaptersAdapter.kt | 24 ---- app/src/main/res/layout/track_search_item.xml | 1 - app/src/main/res/values/strings.xml | 17 +-- 13 files changed, 160 insertions(+), 274 deletions(-) rename app/src/main/java/eu/kanade/presentation/manga/components/{MangaSmallAppBar.kt => MangaAppBar.kt} (98%) delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterHolder.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterItem.kt delete mode 100644 app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChaptersAdapter.kt diff --git a/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt index c0bcfd97a..37700094b 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/SourcesFilterScreen.kt @@ -1,24 +1,27 @@ package eu.kanade.presentation.browse +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.asPaddingValues import androidx.compose.foundation.layout.navigationBars +import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.lazy.items import androidx.compose.material3.Checkbox import androidx.compose.material3.Switch import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier -import androidx.compose.ui.input.nestedscroll.NestedScrollConnection -import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import eu.kanade.domain.source.model.Source import eu.kanade.presentation.browse.components.BaseSourceItem +import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.components.PreferenceRow +import eu.kanade.presentation.components.Scaffold import eu.kanade.presentation.components.ScrollbarLazyColumn +import eu.kanade.presentation.util.plus import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.browse.source.FilterUiModel import eu.kanade.tachiyomi.ui.browse.source.SourcesFilterPresenter @@ -28,22 +31,32 @@ import kotlinx.coroutines.flow.collectLatest @Composable fun SourcesFilterScreen( - nestedScrollInterop: NestedScrollConnection, + navigateUp: () -> Unit, presenter: SourcesFilterPresenter, onClickLang: (String) -> Unit, onClickSource: (Source) -> Unit, ) { val context = LocalContext.current - when { - presenter.isLoading -> LoadingScreen() - presenter.isEmpty -> EmptyScreen(textResource = R.string.source_filter_empty_screen) - else -> { - SourcesFilterContent( - nestedScrollInterop = nestedScrollInterop, - state = presenter, - onClickLang = onClickLang, - onClickSource = onClickSource, + Scaffold( + modifier = Modifier.statusBarsPadding(), + topBar = { + AppBar( + title = stringResource(R.string.label_sources), + navigateUp = navigateUp, ) + }, + ) { paddingValues -> + when { + presenter.isLoading -> LoadingScreen() + presenter.isEmpty -> EmptyScreen(textResource = R.string.source_filter_empty_screen) + else -> { + SourcesFilterContent( + paddingValues = paddingValues, + state = presenter, + onClickLang = onClickLang, + onClickSource = onClickSource, + ) + } } } LaunchedEffect(Unit) { @@ -59,14 +72,13 @@ fun SourcesFilterScreen( @Composable fun SourcesFilterContent( - nestedScrollInterop: NestedScrollConnection, + paddingValues: PaddingValues, state: SourcesFilterState, onClickLang: (String) -> Unit, onClickSource: (Source) -> Unit, ) { ScrollbarLazyColumn( - modifier = Modifier.nestedScroll(nestedScrollInterop), - contentPadding = WindowInsets.navigationBars.asPaddingValues(), + contentPadding = paddingValues + WindowInsets.navigationBars.asPaddingValues(), ) { items( items = state.items, diff --git a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt index 1c4f30829..be451b9d3 100644 --- a/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/category/components/CategoryDialogs.kt @@ -118,16 +118,16 @@ fun CategoryDeleteDialog( AlertDialog( onDismissRequest = onDismissRequest, confirmButton = { - TextButton(onClick = onDismissRequest) { - Text(text = stringResource(R.string.no)) - } - }, - dismissButton = { TextButton(onClick = { onDelete() onDismissRequest() },) { - Text(text = stringResource(R.string.yes)) + Text(text = stringResource(android.R.string.ok)) + } + }, + dismissButton = { + TextButton(onClick = onDismissRequest) { + Text(text = stringResource(android.R.string.cancel)) } }, title = { diff --git a/app/src/main/java/eu/kanade/presentation/components/AppBar.kt b/app/src/main/java/eu/kanade/presentation/components/AppBar.kt index cfc24c77c..255860e31 100644 --- a/app/src/main/java/eu/kanade/presentation/components/AppBar.kt +++ b/app/src/main/java/eu/kanade/presentation/components/AppBar.kt @@ -2,8 +2,14 @@ package eu.kanade.presentation.components import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.RowScope +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.WindowInsetsSides +import androidx.compose.foundation.layout.only +import androidx.compose.foundation.layout.systemBars +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.Icon @@ -11,11 +17,16 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.SmallTopAppBar import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.drawBehind +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight @@ -24,29 +35,82 @@ import eu.kanade.tachiyomi.R @Composable fun AppBar( + modifier: Modifier = Modifier, + // Text title: String?, subtitle: String? = null, + // Up button navigateUp: (() -> Unit)? = null, navigationIcon: ImageVector = Icons.Default.ArrowBack, + // Menu actions: @Composable RowScope.() -> Unit = {}, + // Action mode + actionModeCounter: Int = 0, + onCancelActionMode: () -> Unit = {}, + actionModeActions: @Composable RowScope.() -> Unit = {}, + // Banners + downloadedOnlyMode: Boolean = false, + incognitoMode: Boolean = false, ) { - SmallTopAppBar( - navigationIcon = { - navigateUp?.let { - IconButton(onClick = it) { - Icon( - imageVector = navigationIcon, - contentDescription = stringResource(R.string.abc_action_bar_up_description), - ) + val isActionMode by derivedStateOf { actionModeCounter > 0 } + val backgroundColor = if (isActionMode) { + TopAppBarDefaults.smallTopAppBarColors().containerColor(1f).value + } else { + MaterialTheme.colorScheme.surface + } + + Column( + modifier = modifier.drawBehind { drawRect(backgroundColor) }, + ) { + SmallTopAppBar( + modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Top)), + navigationIcon = { + if (isActionMode) { + IconButton(onClick = onCancelActionMode) { + Icon( + imageVector = Icons.Default.Close, + contentDescription = stringResource(id = R.string.action_cancel), + ) + } + } else { + navigateUp?.let { + IconButton(onClick = it) { + Icon( + imageVector = navigationIcon, + contentDescription = stringResource(R.string.abc_action_bar_up_description), + ) + } + } } - } - }, - title = { - AppBarTitle(title, subtitle) - // TODO: incognito/downloaded only banners - }, - actions = actions, - ) + }, + title = { + if (isActionMode) { + AppBarTitle(actionModeCounter.toString()) + } else { + AppBarTitle(title, subtitle) + } + }, + actions = { + if (isActionMode) { + actionModeActions() + } else { + actions() + } + }, + // Background handled by parent + colors = TopAppBarDefaults.smallTopAppBarColors( + containerColor = Color.Transparent, + scrolledContainerColor = Color.Transparent, + ), + ) + + if (downloadedOnlyMode) { + DownloadedOnlyModeBanner() + } + if (incognitoMode) { + IncognitoModeBanner() + } + } } @Composable diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 476a387b5..5dbb2b23f 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -60,9 +60,9 @@ import eu.kanade.presentation.components.VerticalFastScroller import eu.kanade.presentation.manga.components.ChapterHeader import eu.kanade.presentation.manga.components.ExpandableMangaDescription import eu.kanade.presentation.manga.components.MangaActionRow +import eu.kanade.presentation.manga.components.MangaAppBar import eu.kanade.presentation.manga.components.MangaChapterListItem import eu.kanade.presentation.manga.components.MangaInfoBox -import eu.kanade.presentation.manga.components.MangaSmallAppBar import eu.kanade.presentation.util.isScrolledToEnd import eu.kanade.presentation.util.isScrollingUp import eu.kanade.presentation.util.plus @@ -237,7 +237,7 @@ private fun MangaScreenSmallImpl( val animatedBgAlpha by animateFloatAsState( if (firstVisibleItemIndex > 0 || firstVisibleItemScrollOffset > 0) 1f else 0f, ) - MangaSmallAppBar( + MangaAppBar( title = state.manga.title, titleAlphaProvider = { animatedTitleAlpha }, backgroundAlphaProvider = { animatedBgAlpha }, @@ -458,7 +458,7 @@ fun MangaScreenLargeImpl( Scaffold( modifier = Modifier.padding(insetPadding), topBar = { - MangaSmallAppBar( + MangaAppBar( modifier = Modifier.onSizeChanged { onTopBarHeightChanged(it.height) }, title = state.manga.title, titleAlphaProvider = { if (chapters.any { it.selected }) 1f else 0f }, diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaSmallAppBar.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaAppBar.kt similarity index 98% rename from app/src/main/java/eu/kanade/presentation/manga/components/MangaSmallAppBar.kt rename to app/src/main/java/eu/kanade/presentation/manga/components/MangaAppBar.kt index 825dc8b31..35603ba84 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaSmallAppBar.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaAppBar.kt @@ -38,7 +38,7 @@ import eu.kanade.presentation.manga.DownloadAction import eu.kanade.tachiyomi.R @Composable -fun MangaSmallAppBar( +fun MangaAppBar( modifier: Modifier = Modifier, title: String, titleAlphaProvider: () -> Float, @@ -57,7 +57,7 @@ fun MangaSmallAppBar( ) { val isActionMode = actionModeCounter > 0 val backgroundAlpha = if (isActionMode) 1f else backgroundAlphaProvider() - val backgroundColor by TopAppBarDefaults.centerAlignedTopAppBarColors().containerColor(1f) + val backgroundColor by TopAppBarDefaults.smallTopAppBarColors().containerColor(1f) Column( modifier = modifier.drawBehind { drawRect(backgroundColor.copy(alpha = backgroundAlpha)) @@ -199,7 +199,7 @@ fun MangaSmallAppBar( } }, // Background handled by parent - colors = TopAppBarDefaults.centerAlignedTopAppBarColors( + colors = TopAppBarDefaults.smallTopAppBarColors( containerColor = Color.Transparent, scrolledContainerColor = Color.Transparent, ), diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt index fa0a6004c..1b8cb2e16 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesScreen.kt @@ -1,7 +1,6 @@ package eu.kanade.presentation.updates import androidx.activity.compose.BackHandler -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsetsSides import androidx.compose.foundation.layout.asPaddingValues @@ -12,35 +11,25 @@ import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.Close import androidx.compose.material.icons.filled.FlipToBack import androidx.compose.material.icons.filled.Refresh import androidx.compose.material.icons.filled.SelectAll import androidx.compose.material3.Icon import androidx.compose.material3.IconButton -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.SmallTopAppBar -import androidx.compose.material3.Text -import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.runtime.toMutableStateList import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.drawBehind -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.style.TextOverflow import com.google.accompanist.swiperefresh.SwipeRefresh import com.google.accompanist.swiperefresh.rememberSwipeRefreshState +import eu.kanade.presentation.components.AppBar import eu.kanade.presentation.components.ChapterDownloadAction -import eu.kanade.presentation.components.DownloadedOnlyModeBanner import eu.kanade.presentation.components.EmptyScreen -import eu.kanade.presentation.components.IncognitoModeBanner import eu.kanade.presentation.components.MangaBottomActionMenu import eu.kanade.presentation.components.Scaffold import eu.kanade.presentation.components.SwipeRefreshIndicator @@ -201,72 +190,36 @@ fun UpdatesAppBar( onSelectAll: () -> Unit, onInvertSelection: () -> Unit, ) { - val isActionMode = actionModeCounter > 0 - val backgroundColor = if (isActionMode) { - TopAppBarDefaults.centerAlignedTopAppBarColors().containerColor(1f).value - } else { - MaterialTheme.colorScheme.surface - } - - Column( - modifier = modifier.drawBehind { drawRect(backgroundColor) }, - ) { - SmallTopAppBar( - modifier = Modifier.windowInsetsPadding(WindowInsets.systemBars.only(WindowInsetsSides.Top)), - navigationIcon = { - if (isActionMode) { - IconButton(onClick = { selected.clear() }) { - Icon( - imageVector = Icons.Default.Close, - contentDescription = stringResource(id = R.string.action_cancel), - ) - } - } - }, - title = { - Text( - text = if (isActionMode) actionModeCounter.toString() else stringResource(R.string.label_recent_updates), - maxLines = 1, - overflow = TextOverflow.Ellipsis, + AppBar( + modifier = modifier, + title = stringResource(R.string.label_recent_updates), + actions = { + IconButton(onClick = onUpdateLibrary) { + Icon( + imageVector = Icons.Default.Refresh, + contentDescription = stringResource(R.string.action_update_library), ) - }, - actions = { - if (isActionMode) { - IconButton(onClick = onSelectAll) { - Icon( - imageVector = Icons.Default.SelectAll, - contentDescription = stringResource(R.string.action_select_all), - ) - } - IconButton(onClick = onInvertSelection) { - Icon( - imageVector = Icons.Default.FlipToBack, - contentDescription = stringResource(R.string.action_select_inverse), - ) - } - } else { - IconButton(onClick = onUpdateLibrary) { - Icon( - imageVector = Icons.Default.Refresh, - contentDescription = stringResource(R.string.action_update_library), - ) - } - } - }, - // Background handled by parent - colors = TopAppBarDefaults.centerAlignedTopAppBarColors( - containerColor = Color.Transparent, - scrolledContainerColor = Color.Transparent, - ), - ) - - if (downloadedOnlyMode) { - DownloadedOnlyModeBanner() - } - if (incognitoMode) { - IncognitoModeBanner() - } - } + } + }, + actionModeCounter = actionModeCounter, + onCancelActionMode = { selected.clear() }, + actionModeActions = { + IconButton(onClick = onSelectAll) { + Icon( + imageVector = Icons.Default.SelectAll, + contentDescription = stringResource(R.string.action_select_all), + ) + } + IconButton(onClick = onInvertSelection) { + Icon( + imageVector = Icons.Default.FlipToBack, + contentDescription = stringResource(R.string.action_select_inverse), + ) + } + }, + downloadedOnlyMode = downloadedOnlyMode, + incognitoMode = incognitoMode, + ) } @Composable diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterController.kt index c46880af5..ed7bda0f3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/SourcesFilterController.kt @@ -1,22 +1,18 @@ package eu.kanade.tachiyomi.ui.browse.source import androidx.compose.runtime.Composable -import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import eu.kanade.domain.source.model.Source import eu.kanade.presentation.browse.SourcesFilterScreen -import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.ui.base.controller.ComposeController +import eu.kanade.tachiyomi.ui.base.controller.FullComposeController -class SourceFilterController : ComposeController() { - - override fun getTitle() = resources?.getString(R.string.label_sources) +class SourceFilterController : FullComposeController() { override fun createPresenter(): SourcesFilterPresenter = SourcesFilterPresenter() @Composable - override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) { + override fun ComposeContent() { SourcesFilterScreen( - nestedScrollInterop = nestedScrollInterop, + navigateUp = router::popCurrentController, presenter = presenter, onClickLang = { language -> presenter.toggleLanguage(language) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt deleted file mode 100644 index 591536e07..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/ChapterDownloadView.kt +++ /dev/null @@ -1,41 +0,0 @@ -package eu.kanade.tachiyomi.ui.manga.chapter - -import android.content.Context -import android.util.AttributeSet -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.setValue -import androidx.compose.ui.platform.AbstractComposeView -import eu.kanade.presentation.components.ChapterDownloadAction -import eu.kanade.presentation.components.ChapterDownloadIndicator -import eu.kanade.presentation.theme.TachiyomiTheme -import eu.kanade.tachiyomi.data.download.model.Download - -class ChapterDownloadView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyle: Int = 0, -) : AbstractComposeView(context, attrs, defStyle) { - - private var state by mutableStateOf(Download.State.NOT_DOWNLOADED) - private var progress by mutableStateOf(0) - - var listener: (ChapterDownloadAction) -> Unit = {} - - @Composable - override fun Content() { - TachiyomiTheme { - ChapterDownloadIndicator( - downloadStateProvider = { state }, - downloadProgressProvider = { progress }, - onClick = listener, - ) - } - } - - fun setState(state: Download.State, progress: Int = 0) { - this.state = state - this.progress = progress - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterHolder.kt deleted file mode 100644 index d90d61451..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterHolder.kt +++ /dev/null @@ -1,21 +0,0 @@ -package eu.kanade.tachiyomi.ui.manga.chapter.base - -import android.view.View -import eu.davidea.viewholders.FlexibleViewHolder -import eu.kanade.presentation.components.ChapterDownloadAction - -open class BaseChapterHolder( - view: View, - private val adapter: BaseChaptersAdapter<*>, -) : FlexibleViewHolder(view, adapter) { - - val downloadActionListener: (ChapterDownloadAction) -> Unit = { action -> - when (action) { - ChapterDownloadAction.START -> adapter.clickListener.downloadChapter(bindingAdapterPosition) - ChapterDownloadAction.START_NOW -> adapter.clickListener.startDownloadNow(bindingAdapterPosition) - ChapterDownloadAction.CANCEL, ChapterDownloadAction.DELETE -> { - adapter.clickListener.deleteChapter(bindingAdapterPosition) - } - } - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterItem.kt deleted file mode 100644 index 53917f4e6..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChapterItem.kt +++ /dev/null @@ -1,47 +0,0 @@ -package eu.kanade.tachiyomi.ui.manga.chapter.base - -import eu.davidea.flexibleadapter.items.AbstractHeaderItem -import eu.davidea.flexibleadapter.items.AbstractSectionableItem -import eu.kanade.domain.chapter.model.Chapter -import eu.kanade.tachiyomi.data.download.model.Download -import eu.kanade.tachiyomi.source.model.Page - -abstract class BaseChapterItem>( - val chapter: Chapter, - header: H? = null, -) : AbstractSectionableItem(header) { - - private var _status: Download.State = Download.State.NOT_DOWNLOADED - - var status: Download.State - get() = download?.status ?: _status - set(value) { - _status = value - } - - val progress: Int - get() { - val pages = download?.pages ?: return 0 - return pages.map(Page::progress).average().toInt() - } - - @Transient - var download: Download? = null - - val isDownloaded: Boolean - get() = status == Download.State.DOWNLOADED - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other is BaseChapterItem<*, *>) { - return chapter.id == other.chapter.id && chapter.read == other.chapter.read - } - return false - } - - override fun hashCode(): Int { - var result = chapter.id.hashCode() - result = 31 * result + chapter.read.hashCode() - return result - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChaptersAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChaptersAdapter.kt deleted file mode 100644 index 826ab2a05..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/chapter/base/BaseChaptersAdapter.kt +++ /dev/null @@ -1,24 +0,0 @@ -package eu.kanade.tachiyomi.ui.manga.chapter.base - -import eu.davidea.flexibleadapter.FlexibleAdapter -import eu.davidea.flexibleadapter.items.IFlexible - -abstract class BaseChaptersAdapter>( - controller: OnChapterClickListener, - items: List? = null, -) : FlexibleAdapter(items, controller, true) { - - /** - * Listener for browse item clicks. - */ - val clickListener: OnChapterClickListener = controller - - /** - * Listener which should be called when user clicks the download icons. - */ - interface OnChapterClickListener { - fun downloadChapter(position: Int) - fun deleteChapter(position: Int) - fun startDownloadNow(position: Int) - } -} diff --git a/app/src/main/res/layout/track_search_item.xml b/app/src/main/res/layout/track_search_item.xml index f79c5cf1a..c308c418c 100644 --- a/app/src/main/res/layout/track_search_item.xml +++ b/app/src/main/res/layout/track_search_item.xml @@ -24,7 +24,6 @@ android:layout_height="95dp" android:layout_marginStart="12dp" android:layout_marginTop="12dp" - android:contentDescription="@string/description_cover" android:scaleType="centerCrop" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d58f437f2..c9765543f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -72,6 +72,8 @@ Edit categories Rename category Set categories + Do you wish to delete the category \"%s\"? + Delete category Edit cover View chapters Stop @@ -135,6 +137,7 @@ Loading… + InternalError: Check crash logs for further information App not available @@ -357,6 +360,8 @@ Fit height Original size Smart fit + Navigate to pan + Zoom landscape image Zoom start position Automatic Left @@ -722,6 +727,7 @@ Updating library + Unable to open last read chapter Ch. %1$s - %2$s @@ -804,9 +810,6 @@ %d extension updates available - - Cover of manga - No downloads No recent updates @@ -848,12 +851,4 @@ Previous page Next page - Navigate to pan - Zoom landscape image - Unable to open last read chapter - Do you wish to delete the category %s - Delete category - Yes - No - InternalError: Check crash logs for further information