From e47dd3d587eff58d57e4df62f149c94bc2753f4a Mon Sep 17 00:00:00 2001 From: Deumiankio <39210184+Deumiankio@users.noreply.github.com> Date: Sat, 30 Mar 2019 14:21:35 +0100 Subject: [PATCH] Add 32-bit color mode to reader settings (#1941) * add ARGB_8888 mode to reader settings * Only show option on Oreo or later. Only show option in settings screen. --- .../tachiyomi/data/preference/PreferenceKeys.kt | 2 ++ .../data/preference/PreferencesHelper.kt | 2 ++ .../kanade/tachiyomi/ui/reader/ReaderActivity.kt | 15 +++++++++++++++ .../ui/setting/SettingsReaderController.kt | 8 ++++++++ app/src/main/res/layout/reader_settings_sheet.xml | 13 ++++++++++++- app/src/main/res/values/strings.xml | 1 + 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 259e1fb8c..a3d5297f6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -15,6 +15,8 @@ object PreferenceKeys { const val showPageNumber = "pref_show_page_number_key" + const val trueColor = "pref_true_color_key" + const val fullscreen = "fullscreen" const val keepScreenOn = "pref_keep_screen_on_key" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index ee5b0b39e..c7b908f55 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -43,6 +43,8 @@ class PreferencesHelper(val context: Context) { fun showPageNumber() = rxPrefs.getBoolean(Keys.showPageNumber, true) + fun trueColor() = rxPrefs.getBoolean(Keys.trueColor, false) + fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true) fun keepScreenOn() = rxPrefs.getBoolean(Keys.keepScreenOn, 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 9861e288c..c3b8aefd8 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 @@ -6,6 +6,7 @@ import android.content.Context import android.content.Intent 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 @@ -13,6 +14,7 @@ import android.view.* import android.view.animation.Animation import android.view.animation.AnimationUtils import android.widget.SeekBar +import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga @@ -558,6 +560,9 @@ class ReaderActivity : BaseRxActivity() { subscriptions += preferences.showPageNumber().asObservable() .subscribe { setPageNumberVisibility(it) } + subscriptions += preferences.trueColor().asObservable() + .subscribe { setTrueColor(it) } + subscriptions += preferences.fullscreen().asObservable() .subscribe { setFullscreen(it) } @@ -614,6 +619,16 @@ class ReaderActivity : BaseRxActivity() { page_number.visibility = if (visible) View.VISIBLE else View.INVISIBLE } + /** + * Sets the 32-bit color mode according to [enabled]. + */ + private fun setTrueColor(enabled: Boolean) { + if (enabled) + SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.ARGB_8888) + else + SubsamplingScaleImageView.setPreferredBitmapConfig(Bitmap.Config.RGB_565) + } + /** * Sets the fullscreen reading mode (immersive) according to [enabled]. */ diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index 943995385..ac413f270 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.setting +import android.os.Build import android.support.v7.preference.PreferenceScreen import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys @@ -77,6 +78,13 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_show_page_number defaultValue = true } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + switchPreference { + key = Keys.trueColor + titleRes = R.string.pref_true_color + defaultValue = false + } + } preferenceCategory { titleRes = R.string.pager_viewer diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index f3b402baa..d28155d70 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -105,6 +105,17 @@ android:textColor="?android:attr/textColorSecondary" app:layout_constraintTop_toBottomOf="@id/background_color" /> + + + app:layout_constraintTop_toBottomOf="@id/true_color" /> Page transitions Double tap animation speed Show page number + 32-bit color Crop borders Use custom brightness Use custom color filter