From 5f2eb19ea37ba191d414eee4e8f45f20f1a73e89 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 9 Jan 2020 19:31:09 -0800 Subject: [PATCH] Fixes for merging from upstream --- .../tachiyomi/ui/category/CategoryController.kt | 7 +++++-- .../kanade/tachiyomi/ui/library/LibraryController.kt | 3 ++- .../tachiyomi/ui/manga/info/MangaInfoController.kt | 12 ++++++------ .../migration/manga/design/PreMigrationController.kt | 8 +++++--- .../eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 1 + .../tachiyomi/ui/reader/ReaderColorFilterSheet.kt | 8 ++++---- .../tachiyomi/ui/reader/loader/DownloadPageLoader.kt | 4 ++-- .../java/eu/kanade/tachiyomi/util/ViewExtensions.kt | 12 +++++++----- .../eu/kanade/tachiyomi/widget/FABMoveBehaviour.kt | 2 +- app/src/main/res/drawable/splash_background.xml | 5 +++-- app/src/main/res/layout/categories_controller.xml | 2 +- app/src/main/res/values/themes.xml | 3 --- 12 files changed, 37 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt index aa124d0599..318d6aebd6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt @@ -81,7 +81,7 @@ class CategoryController : NucleusController(), super.onViewCreated(view) adapter = CategoryAdapter(this@CategoryController) - recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(view.context) + recycler.layoutManager = LinearLayoutManager(view.context) recycler.setHasFixedSize(true) recycler.adapter = adapter adapter?.isHandleDragEnabled = true @@ -93,10 +93,13 @@ class CategoryController : NucleusController(), val fabBaseMarginBottom = fab?.marginBottom ?: 0 recycler.doOnApplyWindowInsets { v, insets, padding -> - v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom) + fab?.updateLayoutParams { bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom } + // offset the recycler by the fab's inset + some inset on top + v.updatePaddingRelative(bottom = padding.bottom + (fab?.marginBottom ?: 0) + + fabBaseMarginBottom + (fab?.height ?: 0)) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 7a59c04629..a39fe9a205 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -18,6 +18,7 @@ import androidx.appcompat.view.ActionMode import androidx.appcompat.widget.SearchView import androidx.core.graphics.drawable.DrawableCompat import androidx.core.view.GravityCompat +import androidx.drawerlayout.widget.DrawerLayout import com.bluelinelabs.conductor.ControllerChangeHandler import com.bluelinelabs.conductor.ControllerChangeType import com.f2prateek.rx.preferences.Preference @@ -215,7 +216,7 @@ class LibraryController( super.onDetach(view) } - override fun createSecondaryDrawer(drawer: androidx.drawerlayout.widget.DrawerLayout): ViewGroup { + override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup { val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView navView = view drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt index 1e69d75489..a2b009ab33 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoController.kt @@ -25,6 +25,7 @@ import com.bumptech.glide.load.DataSource import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.resource.bitmap.RoundedCorners +import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.target.CustomTarget import com.bumptech.glide.request.transition.Transition import com.google.android.material.snackbar.BaseTransientBottomBar @@ -578,18 +579,17 @@ class MangaInfoController : NucleusController(), 3 -> centerCrop().transform(MaskTransformation(R.drawable.mask_star)) } } - .listener(object : RequestListener { - override fun onResourceReady(resource: Bitmap, model: Any, target: Target, dataSource: DataSource, isFirstResource: Boolean): Boolean { + .into(object : CustomTarget(96, 96) { + override fun onResourceReady(resource: Bitmap, transition: Transition?) { createShortcut(resource) - return true } - override fun onLoadFailed(e: GlideException?, model: Any?, target: Target?, isFirstResource: Boolean): Boolean { + override fun onLoadCleared(placeholder: Drawable?) { } + + override fun onLoadFailed(errorDrawable: Drawable?) { activity?.toast(R.string.icon_creation_fail) - return true } }) - .submit() } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/PreMigrationController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/PreMigrationController.kt index aa05d4d437..9aa27c474e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/PreMigrationController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/PreMigrationController.kt @@ -77,9 +77,11 @@ class PreMigrationController(bundle: Bundle? = null) : BaseController(bundle), F val bottomSheet = dialog?.findViewById( com.google.android.material.R.id.design_bottom_sheet ) - val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet) - behavior.state = BottomSheetBehavior.STATE_EXPANDED - behavior.skipCollapsed = true + if (bottomSheet != null) { + val behavior: BottomSheetBehavior<*> = BottomSheetBehavior.from(bottomSheet) + behavior.state = BottomSheetBehavior.STATE_EXPANDED + behavior.skipCollapsed = true + } } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 332b8075e2..744d00f4be 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -9,6 +9,7 @@ import android.content.pm.ActivityInfo import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.Color +import android.os.Build import android.os.Bundle import android.view.KeyEvent import android.view.Menu diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt index a69c91e181..a11f7e9d13 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderColorFilterSheet.kt @@ -30,7 +30,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog(activ private val preferences by injectLazy() - private var behavior: BottomSheetBehavior<*>? = null + private var sheetBehavior: BottomSheetBehavior<*>? = null /** * Subscriptions used for this dialog @@ -51,7 +51,7 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog(activ val view = activity.layoutInflater.inflate(R.layout.reader_color_filter_sheet, null) setContentView(view) - behavior = BottomSheetBehavior.from(view.parent as ViewGroup) + sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) // Initialize subscriptions. subscriptions += preferences.colorFilter().asObservable() @@ -138,8 +138,8 @@ class ReaderColorFilterSheet(activity: ReaderActivity) : BottomSheetDialog(activ override fun onStart() { super.onStart() - behavior?.skipCollapsed = true - behavior?.state = BottomSheetBehavior.STATE_EXPANDED + sheetBehavior?.skipCollapsed = true + sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED } override fun onDetachedFromWindow() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt index d3d7953be9..a21993a787 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/loader/DownloadPageLoader.kt @@ -33,9 +33,9 @@ class DownloadPageLoader( return downloadManager.buildPageList(source, manga, chapter.chapter) .map { pages -> pages.map { page -> - ReaderPage(page.index, page.url, page.imageUrl) { + ReaderPage(page.index, page.url, page.imageUrl, { context.contentResolver.openInputStream(page.uri ?: Uri.EMPTY)!! - }.apply { + }).apply { status = Page.READY } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt index 2b69ea225e..83db35c3fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt @@ -21,6 +21,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout import com.amulyakhare.textdrawable.TextDrawable import com.amulyakhare.textdrawable.util.ColorGenerator import eu.kanade.tachiyomi.R +import kotlin.math.min /** * Returns coordinates of view. @@ -42,7 +43,7 @@ Unit)? = null): Snackbar { val snack = Snackbar.make(this, message, length) val textView: TextView = snack.view.findViewById(com.google.android.material.R.id.snackbar_text) textView.setTextColor(context.getResourceColor(R.attr.snackbar_text)) - when { + /* when { Build.VERSION.SDK_INT >= 23 -> { val leftM = if (this is CoordinatorLayout) 0 else rootWindowInsets.systemWindowInsetLeft val rightM = if (this is CoordinatorLayout) 0 @@ -51,21 +52,22 @@ Unit)? = null): Snackbar { .systemWindowInsetBottom, rightM, leftM) } else -> snack.config(context) - } + }*/ + snack.config(context) if (f != null) { snack.f() } - if (Build.VERSION.SDK_INT < 23) { + // if (Build.VERSION.SDK_INT < 23) { val view = if (this !is CoordinatorLayout) this else snack.view view.doOnApplyWindowInsets { _, insets, _ -> snack.view.updateLayoutParams { bottomMargin = 12 + insets.systemWindowInsetBottom } } - } + /*} else { snack.view.doOnApplyWindowInsets { _,_,_ -> } - } + }*/ snack.show() return snack } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/FABMoveBehaviour.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/FABMoveBehaviour.kt index 0417d3ac45..6cee334986 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/FABMoveBehaviour.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/FABMoveBehaviour.kt @@ -32,7 +32,7 @@ class FABMoveBehaviour(context: Context, attrs: AttributeSet) : val dependencies = parent.getDependencies(fab) for (i in 0 until dependencies.size) { val view = dependencies[i] - if (view is Snackbar.SnackbarLayout) { + if (view is Snackbar.SnackbarLayout && view.isShown) { minOffset = min(minOffset, view.translationY - view.height) } } diff --git a/app/src/main/res/drawable/splash_background.xml b/app/src/main/res/drawable/splash_background.xml index 7541671832..ff5ff95ead 100644 --- a/app/src/main/res/drawable/splash_background.xml +++ b/app/src/main/res/drawable/splash_background.xml @@ -1,12 +1,13 @@ - + + android:src="@drawable/splash_icon" + android:tint="@color/snackbarBackground"/> diff --git a/app/src/main/res/layout/categories_controller.xml b/app/src/main/res/layout/categories_controller.xml index 7268434b4c..ad6c6f1f8e 100644 --- a/app/src/main/res/layout/categories_controller.xml +++ b/app/src/main/res/layout/categories_controller.xml @@ -20,7 +20,7 @@ android:id="@+id/fab" app:layout_anchor="@id/recycler" app:srcCompat="@drawable/ic_add_white_24dp" - style="@style/Theme.Widget.FAB"/> + style="@style/Theme.Widget.FABFixed"/> @color/dialogDark @color/iconColorDark - true - ?colorPrimaryDark - ?colorPrimaryDark