Эх сурвалжийг харах

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.
Deumiankio 6 жил өмнө
parent
commit
e47dd3d587

+ 2 - 0
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"

+ 2 - 0
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)

+ 15 - 0
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<ReaderPresenter>() {
             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<ReaderPresenter>() {
             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].
          */

+ 8 - 0
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
 

+ 12 - 1
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" />
 
+    <android.support.v7.widget.SwitchCompat
+        android:id="@+id/true_color"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="16dp"
+        android:text="@string/pref_true_color"
+        android:textColor="?android:attr/textColorSecondary"
+        android:visibility="gone"
+        tools:visibility="visible"
+        app:layout_constraintTop_toBottomOf="@id/show_page_number" />
+
     <android.support.v7.widget.SwitchCompat
         android:id="@+id/fullscreen"
         android:layout_width="match_parent"
@@ -112,7 +123,7 @@
         android:layout_marginTop="16dp"
         android:text="@string/pref_fullscreen"
         android:textColor="?android:attr/textColorSecondary"
-        app:layout_constraintTop_toBottomOf="@id/show_page_number" />
+        app:layout_constraintTop_toBottomOf="@id/true_color" />
 
     <android.support.v7.widget.SwitchCompat
         android:id="@+id/keepscreen"

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -173,6 +173,7 @@
     <string name="pref_page_transitions">Page transitions</string>
     <string name="pref_double_tap_anim_speed">Double tap animation speed</string>
     <string name="pref_show_page_number">Show page number</string>
+    <string name="pref_true_color">32-bit color</string>
     <string name="pref_crop_borders">Crop borders</string>
     <string name="pref_custom_brightness">Use custom brightness</string>
     <string name="pref_custom_color_filter">Use custom color filter</string>