mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 13:51:48 +01:00
Theme fixes for reader
Smart by theme now changes its background color on day/night switch, white theme is now actually #FFFFFF on background Continous Vertical always uses black between pages, even if using light theme Fix animated gif backgrounds
This commit is contained in:
parent
4ce2172a0c
commit
52892da065
@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerPageHolder
|
||||
import eu.kanade.tachiyomi.util.lang.plusAssign
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import rx.Completable
|
||||
@ -38,14 +39,8 @@ class HttpPageLoader(
|
||||
*/
|
||||
private val queue = PriorityBlockingQueue<PriorityPage>()
|
||||
|
||||
/**
|
||||
* Current active subscriptions.
|
||||
*/
|
||||
private val subscriptions = CompositeSubscription()
|
||||
|
||||
/**
|
||||
* Preferences helper.
|
||||
*/
|
||||
private val preferences by injectLazy<PreferencesHelper>()
|
||||
private val preloadSize = 4
|
||||
|
||||
@ -233,7 +228,7 @@ class HttpPageLoader(
|
||||
page.bg = ImageUtil.autoSetBackground(
|
||||
image, readerTheme == 2, preferences.context
|
||||
)
|
||||
page.bgAlwaysWhite = readerTheme == 2
|
||||
page.bgType = PagerPageHolder.getBGType(readerTheme, preferences.context)
|
||||
stream.close()
|
||||
}
|
||||
page.stream = { chapterCache.getImageFile(imageUrl).inputStream() }
|
||||
|
@ -10,7 +10,7 @@ class ReaderPage(
|
||||
imageUrl: String? = null,
|
||||
var stream: (() -> InputStream)? = null,
|
||||
var bg: Drawable? = null,
|
||||
var bgAlwaysWhite: Boolean? = null
|
||||
var bgType: Int? = null
|
||||
) : Page(index, url, imageUrl, null) {
|
||||
|
||||
lateinit var chapter: ReaderChapter
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.viewer.pager
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.PointF
|
||||
@ -39,6 +40,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerConfig.ZoomType
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.ThemeUtil
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.isInNightMode
|
||||
import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
@ -255,8 +257,10 @@ class PagerPageHolder(
|
||||
if (!isAnimated) {
|
||||
if (viewer.config.readerTheme >= 2) {
|
||||
val imageView = initSubsamplingImageView()
|
||||
if (page.bg != null &&
|
||||
page.bgAlwaysWhite == (viewer.config.readerTheme == 2)) {
|
||||
if (page.bg != null && page.bgType == getBGType(
|
||||
viewer.config.readerTheme,
|
||||
context
|
||||
)) {
|
||||
imageView.setImage(ImageSource.inputStream(openStream!!))
|
||||
imageView.background = page.bg
|
||||
}
|
||||
@ -270,7 +274,7 @@ class PagerPageHolder(
|
||||
launchUI {
|
||||
imageView.background = setBG(bytesArray)
|
||||
page.bg = imageView.background
|
||||
page.bgAlwaysWhite = viewer.config.readerTheme == 2
|
||||
page.bgType = getBGType(viewer.config.readerTheme, context)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -281,8 +285,12 @@ class PagerPageHolder(
|
||||
} else {
|
||||
val imageView = initImageView()
|
||||
imageView.setImage(openStream!!)
|
||||
if (viewer.config.readerTheme >= 2 && page.bg != null)
|
||||
if (viewer.config.readerTheme >= 2 && page.bg != null) {
|
||||
imageView.background = page.bg
|
||||
} else if (viewer.config.readerTheme < 2) {
|
||||
imageView.background =
|
||||
ColorDrawable(ThemeUtil.readerBackgroundColor(viewer.config.readerTheme))
|
||||
}
|
||||
}
|
||||
}
|
||||
// Keep the Rx stream alive to close the input stream only when unsubscribed
|
||||
@ -512,4 +520,12 @@ class PagerPageHolder(
|
||||
})
|
||||
.into(this)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getBGType(readerTheme: Int, context: Context): Int {
|
||||
return if (readerTheme == 3) {
|
||||
if (context.isInNightMode()) 2 else 1
|
||||
} else 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.view.Gravity
|
||||
@ -33,6 +34,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.ReaderProgressBar
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
@ -113,6 +115,7 @@ class WebtoonPageHolder(
|
||||
|
||||
init {
|
||||
frame.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT)
|
||||
frame.setBackgroundColor(Color.BLACK)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,14 +129,13 @@ class WebtoonPageHolder(
|
||||
|
||||
private fun refreshLayoutParams() {
|
||||
frame.layoutParams = FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT).apply {
|
||||
if (!viewer.isContinuous) {
|
||||
bottomMargin = 15.dpToPx
|
||||
}
|
||||
|
||||
val margin = Resources.getSystem().displayMetrics.widthPixels * (viewer.config.sidePadding / 100f)
|
||||
marginEnd = margin.toInt()
|
||||
marginStart = margin.toInt()
|
||||
}
|
||||
if (!viewer.isContinuous) {
|
||||
frame.updatePaddingRelative(bottom = 15.dpToPx)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Uri
|
||||
@ -202,3 +203,8 @@ fun Context.openInBrowser(url: String) {
|
||||
toast(e.message)
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.isInNightMode(): Boolean {
|
||||
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||
return currentNightMode == Configuration.UI_MODE_NIGHT_YES
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import eu.kanade.tachiyomi.R
|
||||
import java.io.InputStream
|
||||
import java.net.URLConnection
|
||||
import kotlin.math.abs
|
||||
@ -56,9 +57,9 @@ object ImageUtil {
|
||||
return null
|
||||
}
|
||||
|
||||
fun autoSetBackground(image: Bitmap?, useWhiteAlways: Boolean, context: Context): Drawable {
|
||||
val backgroundColor = if (useWhiteAlways) Color.WHITE else
|
||||
context.getResourceColor(android.R.attr.colorBackground)
|
||||
fun autoSetBackground(image: Bitmap?, alwaysUseWhite: Boolean, context: Context): Drawable {
|
||||
val backgroundColor = if (alwaysUseWhite) Color.WHITE else
|
||||
context.getResourceColor(R.attr.readerBackground)
|
||||
if (image == null) return ColorDrawable(backgroundColor)
|
||||
if (image.width < 50 || image.height < 50)
|
||||
return ColorDrawable(backgroundColor)
|
||||
|
@ -15,13 +15,10 @@
|
||||
<item name="colorPrimaryVariant">@color/colorAmoledPrimary</item>
|
||||
<item name="colorOnPrimary">@color/colorAmoledPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorAmoledPrimary</item>
|
||||
<item name="android:colorBackground">@color/md_black_1000</item>
|
||||
<item name="android:colorBackground">@color/colorAmoledPrimary</item>
|
||||
<item name="readerBackground">@color/colorAmoledPrimary</item>
|
||||
|
||||
<!-- Material Dialog colors -->
|
||||
<item name="md_color_title">@color/textColorPrimary</item>
|
||||
<item name="md_color_content">@color/text_color_secondary</item>
|
||||
<item name="md_color_button_text">@color/colorAccent</item>
|
||||
<item name="md_background_color">@color/colorAmoledPrimary</item>
|
||||
<item name="md_corner_radius">16dp</item>
|
||||
</style>
|
||||
</resources>
|
@ -12,6 +12,7 @@
|
||||
</declare-styleable>
|
||||
|
||||
<attr name="actionBarTintColor" format="color"/>
|
||||
<attr name="readerBackground" format="color"/>
|
||||
<attr name="tabBarIconColor" format="reference|integer"/>
|
||||
<attr name="tabBarIconInactive" format="reference|integer"/>
|
||||
</resources>
|
||||
|
@ -22,6 +22,7 @@
|
||||
<item name="android:textColorSecondaryInverse">@color/text_color_inverse_secondary</item>
|
||||
<item name="android:textColorHintInverse">@color/text_color_inverse_hint</item>
|
||||
<item name="android:colorBackground">@color/background</item>
|
||||
<item name="readerBackground">@color/colorPrimary</item>
|
||||
<item name="android:listSelector">?colorAccent</item>
|
||||
<item name="android:divider">@color/divider</item>
|
||||
<item name="android:listDivider">@drawable/line_divider</item>
|
||||
|
Loading…
Reference in New Issue
Block a user