Better Tablet support

This commit is contained in:
Jay 2019-11-22 19:40:26 -08:00
parent eb5d9015a2
commit 10c6d4f8f2
6 changed files with 27 additions and 2 deletions

View File

@ -251,6 +251,7 @@ buildscript {
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}
}

View File

@ -1,5 +1,7 @@
package eu.kanade.tachiyomi.data.database.models
import eu.kanade.tachiyomi.source.model.SManga
open class MangaImpl : Manga {
override var id: Long? = null
@ -34,6 +36,12 @@ open class MangaImpl : Manga {
override var hide_title: Boolean = false
override fun copyFrom(other: SManga) {
if (other is MangaImpl && (other as MangaImpl)::title.isInitialized && other.title != title)
title = other.title
super.copyFrom(other)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || javaClass != other.javaClass) return false

View File

@ -23,8 +23,6 @@ interface SManga : Serializable {
var initialized: Boolean
fun copyFrom(other: SManga) {
if (other.title != title)
title = other.title
if (other.author != null)
author = other.author

View File

@ -151,11 +151,15 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
container = (view as ViewGroup).findViewById(R.id.manga_info_layout) as? View
val bottomM = manga_genres_tags.marginBottom
val fabBaseMarginBottom = fab_favorite.marginBottom
val manga_coverMarginBottom = fab_favorite.marginBottom
container?.doOnApplyWindowInsets { v, insets, padding ->
if (resources?.configuration?.orientation == Configuration.ORIENTATION_LANDSCAPE) {
fab_favorite?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
}
manga_cover?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
bottomMargin = manga_coverMarginBottom + insets.systemWindowInsetBottom
}
}
else {
manga_genres_tags?.updateLayoutParams<ViewGroup.MarginLayoutParams> {

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.widget
import android.content.Context
import android.content.res.Configuration
import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
@ -55,11 +56,17 @@ class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: Attribut
}
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
if (isTablet(child.context)) return true
val translationY = getFabTranslationYForSnackbar(parent, child)
child.translationY = translationY
return true
}
private fun isTablet(context: Context): Boolean {
return (context.resources.configuration.screenLayout and Configuration
.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
}
private fun getFabTranslationYForSnackbar(parent: CoordinatorLayout, fab:
FloatingActionButton): Float {
var minOffset = 0f

View File

@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.widget
import android.content.Context
import android.content.res.Configuration
import android.util.AttributeSet
import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
@ -15,11 +16,17 @@ class FABMoveBehaviour(context: Context, attrs: AttributeSet) :
return dependency is Snackbar.SnackbarLayout
}
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
if (isTablet(child.context)) return true
val translationY = getFabTranslationYForSnackbar(parent, child)
child.translationY = translationY
return true
}
private fun isTablet(context: Context): Boolean {
return (context.resources.configuration.screenLayout and Configuration
.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
}
private fun getFabTranslationYForSnackbar(parent: CoordinatorLayout, fab: FloatingActionButton): Float {
var minOffset = 0f
val dependencies = parent.getDependencies(fab)