Merge remote-tracking branch 'upstream/master'

This commit is contained in:
jmir1 2021-07-03 23:19:02 +02:00
commit 23e78d8a8b
29 changed files with 89 additions and 57 deletions

View file

@ -248,11 +248,10 @@ dependencies {
implementation("com.afollestad.material-dialogs:datetime:$materialDialogsVersion")
// Conductor
implementation("com.bluelinelabs:conductor:2.1.5")
implementation("com.bluelinelabs:conductor-support:2.1.5") {
exclude(group = "com.android.support")
}
implementation("com.github.tachiyomiorg:conductor-support-preference:2.0.1")
val conductorVersion = "3.0.0"
implementation("com.bluelinelabs:conductor:$conductorVersion")
implementation("com.bluelinelabs:conductor-viewpager:$conductorVersion")
implementation("com.github.tachiyomiorg:conductor-support-preference:$conductorVersion")
// FlowBinding
val flowbindingVersion = "1.0.0"

View file

@ -631,7 +631,7 @@ class AnimeController :
return
}
when (val previousController = router.backstack[router.backstackSize - 2].controller()) {
when (val previousController = router.backstack[router.backstackSize - 2].controller) {
is AnimelibController -> {
router.handleBack()
previousController.search(query)

View file

@ -3,10 +3,11 @@ package eu.kanade.tachiyomi.ui.anime.track
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import coil.clear
import coil.load
import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.kanade.tachiyomi.data.track.model.AnimeTrackSearch
import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding
import eu.kanade.tachiyomi.util.view.setMaxLinesAndEllipsize
import eu.kanade.tachiyomi.util.system.dpToPx
import java.util.Locale
class TrackSearchHolder(
@ -23,7 +24,9 @@ class TrackSearchHolder(
binding.trackSearchTitle.text = track.title
binding.trackSearchCover.clear()
if (track.cover_url.isNotEmpty()) {
binding.trackSearchCover.load(track.cover_url)
binding.trackSearchCover.loadAny(track.cover_url) {
transformations(RoundedCornersTransformation(6.dpToPx.toFloat()))
}
}
val hasStatus = track.publishing_status.isNotBlank()
@ -51,8 +54,11 @@ class TrackSearchHolder(
binding.trackSearchStartResult.text = track.start_date
}
binding.trackSearchSummary.setMaxLinesAndEllipsize()
binding.trackSearchSummary.text = track.summary
val hasSummary = track.summary.isNotBlank()
binding.trackSearchSummary.isVisible = hasSummary
if (hasSummary) {
binding.trackSearchSummary.text = track.summary
}
}
fun setUnchecked() {

View file

@ -600,7 +600,7 @@ class AnimelibController(
override fun onSearchViewQueryTextChange(newText: String?) {
// Ignore events if this controller isn't at the top to avoid query being reset
if (router.backstack.lastOrNull()?.controller() == this) {
if (router.backstack.lastOrNull()?.controller == this) {
presenter.query = newText ?: ""
performSearch()
}

View file

@ -10,14 +10,12 @@ import androidx.viewbinding.ViewBinding
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.RestoreViewOnCreateController
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
import timber.log.Timber
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
RestoreViewOnCreateController(bundle) {
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) : Controller(bundle) {
protected lateinit var binding: VB
private set

View file

@ -5,7 +5,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.bluelinelabs.conductor.RestoreViewOnCreateController
import com.bluelinelabs.conductor.Controller
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
@ -16,7 +16,7 @@ import com.bluelinelabs.conductor.changehandler.SimpleSwapChangeHandler
*
* Implementations should override this class and implement [.onCreateDialog] to create a custom dialog, such as an [android.app.AlertDialog]
*/
abstract class DialogController : RestoreViewOnCreateController {
abstract class DialogController : Controller {
protected var dialog: Dialog? = null
private set

View file

@ -9,7 +9,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.support.RouterPagerAdapter
import com.bluelinelabs.conductor.viewpager.RouterPagerAdapter
import com.google.android.material.badge.BadgeDrawable
import com.google.android.material.tabs.TabLayout
import com.jakewharton.rxrelay.PublishRelay

View file

@ -136,7 +136,7 @@ open class AnimeExtensionController :
}
searchView.queryTextChanges()
.filter { router.backstack.lastOrNull()?.controller() == this }
.filter { router.backstack.lastOrNull()?.controller == this }
.onEach {
query = it.toString()
drawExtensions()

View file

@ -60,9 +60,9 @@ open class AnimeExtensionPresenter(
val items = mutableListOf<AnimeExtensionItem>()
val updatesSorted = installed.filter { it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedBy { it.pkgName }
val installedSorted = installed.filter { !it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedWith(compareBy({ !it.isObsolete }, { it.pkgName }))
val untrustedSorted = untrusted.sortedBy { it.pkgName }
val updatesSorted = installed.filter { it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedBy { it.name }
val installedSorted = installed.filter { !it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedWith(compareBy({ !it.isObsolete }, { it.name }))
val untrustedSorted = untrusted.sortedBy { it.name }
val availableSorted = available
// Filter out already installed extensions and disabled languages
.filter { avail ->
@ -81,9 +81,11 @@ open class AnimeExtensionPresenter(
}
if (installedSorted.isNotEmpty() || untrustedSorted.isNotEmpty()) {
val header = AnimeExtensionGroupItem(context.getString(R.string.ext_installed), installedSorted.size + untrustedSorted.size)
items += installedSorted.map { extension ->
AnimeExtensionItem(extension, header, currentDownloads[extension.pkgName])
}
items += untrustedSorted.map { extension ->
AnimeExtensionItem(extension, header)
}

View file

@ -261,7 +261,7 @@ open class BrowseAnimeSourceController(bundle: Bundle) :
searchItem.fixExpand(
onExpand = { invalidateMenuOnExpand() },
onCollapse = {
if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller() is GlobalAnimeSearchController) {
if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller is GlobalAnimeSearchController) {
router.popController(this)
} else {
nonSubmittedQuery = ""

View file

@ -136,7 +136,7 @@ open class ExtensionController :
}
searchView.queryTextChanges()
.filter { router.backstack.lastOrNull()?.controller() == this }
.filter { router.backstack.lastOrNull()?.controller == this }
.onEach {
query = it.toString()
drawExtensions()

View file

@ -61,9 +61,9 @@ open class ExtensionPresenter(
val items = mutableListOf<ExtensionItem>()
val updatesSorted = installed.filter { it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedBy { it.pkgName }
val installedSorted = installed.filter { !it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedWith(compareBy({ !it.isObsolete }, { it.pkgName }))
val untrustedSorted = untrusted.sortedBy { it.pkgName }
val updatesSorted = installed.filter { it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedBy { it.name }
val installedSorted = installed.filter { !it.hasUpdate && (showNsfwExtensions || !it.isNsfw) }.sortedWith(compareBy({ !it.isObsolete }, { it.name }))
val untrustedSorted = untrusted.sortedBy { it.name }
val availableSorted = available
// Filter out already installed extensions and disabled languages
.filter { avail ->
@ -82,9 +82,11 @@ open class ExtensionPresenter(
}
if (installedSorted.isNotEmpty() || untrustedSorted.isNotEmpty()) {
val header = ExtensionGroupItem(context.getString(R.string.ext_installed), installedSorted.size + untrustedSorted.size)
items += installedSorted.map { extension ->
ExtensionItem(extension, header, currentDownloads[extension.pkgName])
}
items += untrustedSorted.map { extension ->
ExtensionItem(extension, header)
}

View file

@ -26,7 +26,7 @@ class AnimeSourceSearchController(
override fun onItemClick(view: View, position: Int): Boolean {
val item = adapter?.getItem(position) as? AnimeSourceItem ?: return false
newAnime = item.anime
val searchController = router.backstack.findLast { it.controller().javaClass == AnimeSearchController::class.java }?.controller() as AnimeSearchController?
val searchController = router.backstack.findLast { it.controller.javaClass == AnimeSearchController::class.java }?.controller as AnimeSearchController?
val dialog =
AnimeSearchController.MigrationDialog(oldAnime, newAnime, this)
dialog.targetController = searchController

View file

@ -26,7 +26,7 @@ class SourceSearchController(
override fun onItemClick(view: View, position: Int): Boolean {
val item = adapter?.getItem(position) as? SourceItem ?: return false
newManga = item.manga
val searchController = router.backstack.findLast { it.controller().javaClass == SearchController::class.java }?.controller() as SearchController?
val searchController = router.backstack.findLast { it.controller.javaClass == SearchController::class.java }?.controller as SearchController?
val dialog =
SearchController.MigrationDialog(oldManga, newManga, this)
dialog.targetController = searchController

View file

@ -261,7 +261,7 @@ open class BrowseSourceController(bundle: Bundle) :
searchItem.fixExpand(
onExpand = { invalidateMenuOnExpand() },
onCollapse = {
if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller() is GlobalSearchController) {
if (router.backstackSize >= 2 && router.backstack[router.backstackSize - 2].controller is GlobalSearchController) {
router.popController(this)
} else {
nonSubmittedQuery = ""

View file

@ -7,7 +7,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.support.RouterPagerAdapter
import com.bluelinelabs.conductor.viewpager.RouterPagerAdapter
import com.google.android.material.tabs.TabLayout
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.PagerControllerBinding

View file

@ -600,7 +600,7 @@ class LibraryController(
override fun onSearchViewQueryTextChange(newText: String?) {
// Ignore events if this controller isn't at the top to avoid query being reset
if (router.backstack.lastOrNull()?.controller() == this) {
if (router.backstack.lastOrNull()?.controller == this) {
presenter.query = newText ?: ""
performSearch()
}

View file

@ -229,7 +229,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
}
)
syncActivityViewWithController(router.backstack.lastOrNull()?.controller())
syncActivityViewWithController(router.backstack.lastOrNull()?.controller)
if (savedInstanceState == null) {
// Reset Incognito Mode on relaunch
@ -261,11 +261,11 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
// Close BrowseSourceController and its MangaController child when incognito mode is disabled
if (!it) {
val fg = router.backstack.last().controller()
val fg = router.backstack.last().controller
if (fg is BrowseSourceController || fg is MangaController && fg.fromSource) {
router.popToRoot()
}
val fga = router.backstack.last().controller()
val fga = router.backstack.last().controller
if (fga is BrowseAnimeSourceController || fga is AnimeController && fga.fromSource) {
router.popToRoot()
}

View file

@ -614,7 +614,7 @@ class MangaController :
return
}
when (val previousController = router.backstack[router.backstackSize - 2].controller()) {
when (val previousController = router.backstack[router.backstackSize - 2].controller) {
is LibraryController -> {
router.handleBack()
previousController.search(query)

View file

@ -3,10 +3,11 @@ package eu.kanade.tachiyomi.ui.manga.track
import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView
import coil.clear
import coil.load
import coil.loadAny
import coil.transform.RoundedCornersTransformation
import eu.kanade.tachiyomi.data.track.model.TrackSearch
import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding
import eu.kanade.tachiyomi.util.view.setMaxLinesAndEllipsize
import eu.kanade.tachiyomi.util.system.dpToPx
import java.util.Locale
class TrackSearchHolder(
@ -23,7 +24,9 @@ class TrackSearchHolder(
binding.trackSearchTitle.text = track.title
binding.trackSearchCover.clear()
if (track.cover_url.isNotEmpty()) {
binding.trackSearchCover.load(track.cover_url)
binding.trackSearchCover.loadAny(track.cover_url) {
transformations(RoundedCornersTransformation(6.dpToPx.toFloat()))
}
}
val hasStatus = track.publishing_status.isNotBlank()
@ -51,8 +54,11 @@ class TrackSearchHolder(
binding.trackSearchStartResult.text = track.start_date
}
binding.trackSearchSummary.setMaxLinesAndEllipsize()
binding.trackSearchSummary.text = track.summary
val hasSummary = track.summary.isNotBlank()
binding.trackSearchSummary.isVisible = hasSummary
if (hasSummary) {
binding.trackSearchSummary.text = track.summary
}
}
fun setUnchecked() {

View file

@ -7,7 +7,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.support.RouterPagerAdapter
import com.bluelinelabs.conductor.viewpager.RouterPagerAdapter
import com.google.android.material.tabs.TabLayout
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.PagerControllerBinding

View file

@ -7,7 +7,7 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.support.RouterPagerAdapter
import com.bluelinelabs.conductor.viewpager.RouterPagerAdapter
import com.google.android.material.tabs.TabLayout
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.PagerControllerBinding

View file

@ -192,7 +192,7 @@ class AnimeHistoryController :
searchView.clearFocus()
}
searchView.queryTextChanges()
.filter { router.backstack.lastOrNull()?.controller() == this }
.filter { router.backstack.lastOrNull()?.controller == this }
.onEach {
query = it.toString()
presenter.updateList(query)

View file

@ -194,7 +194,7 @@ class HistoryController :
searchView.clearFocus()
}
searchView.queryTextChanges()
.filter { router.backstack.lastOrNull()?.controller() == this }
.filter { router.backstack.lastOrNull()?.controller == this }
.onEach {
query = it.toString()
presenter.updateList(query)

View file

@ -2,5 +2,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:alpha="0.08" android:color="?attr/colorPrimary" app:state_dragged="true" />
<item android:alpha="0.08" android:color="?attr/colorPrimary" android:state_activated="true" />
<item android:color="@android:color/transparent" />
</selector>

View file

@ -78,7 +78,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:clickable="true"
app:layout_insetEdge="bottom"
app:menu="@menu/main_nav" />
app:menu="@menu/main_nav"
tools:ignore="KeyboardInaccessibleWidget" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -97,8 +97,10 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/reader_seekbar_background"
android:clickable="true"
android:paddingStart="8dp"
android:paddingEnd="8dp">
android:paddingEnd="8dp"
tools:ignore="KeyboardInaccessibleWidget">
<TextView
android:id="@+id/left_page_text"
@ -150,7 +152,9 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
android:background="?attr/colorToolbar">
android:background="?attr/colorToolbar"
android:clickable="true"
tools:ignore="KeyboardInaccessibleWidget">
<ImageButton
android:id="@+id/action_reading_mode"

View file

@ -36,7 +36,8 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="12dp"
android:layout_marginTop="8dp"
android:hint="@string/title">
android:hint="@string/title"
app:endIconMode="clear_text">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/title_input_edit_text"

View file

@ -15,15 +15,17 @@
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/track_search_cover"
android:layout_width="130dp"
android:layout_height="180dp"
android:layout_width="68dp"
android:layout_height="95dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:contentDescription="@string/description_cover"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@mipmap/ic_launcher" />
@ -32,7 +34,7 @@
android:id="@+id/track_search_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginStart="12dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="36dp"
android:ellipsize="end"
@ -122,18 +124,27 @@
<TextView
android:id="@+id/track_search_summary"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="12dp"
android:layout_marginBottom="8dp"
android:ellipsize="end"
android:maxLines="4"
android:textAppearance="?attr/textAppearanceCaption"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/track_search_status"
app:layout_constraintTop_toBottomOf="@+id/track_search_status"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier"
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas condimentum et turpis ut sollicitudin. Donec tellus dolor, rhoncus a mattis eget, tempor quis augue. Fusce eleifend dignissim turpis a molestie. Praesent tincidunt, risus sed egestas fringilla, urna orci ultrices libero, id iaculis sem lorem placerat lacus." />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="track_search_start_result,track_search_title,track_search_type_result,track_search_status,track_search_cover,track_search_status_result,track_search_type,track_search_start" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>