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.
This commit is contained in:
		
							parent
							
								
									af0e3a278f
								
							
						
					
					
						commit
						e47dd3d587
					
				| @ -15,6 +15,8 @@ object PreferenceKeys { | |||||||
| 
 | 
 | ||||||
|     const val showPageNumber = "pref_show_page_number_key" |     const val showPageNumber = "pref_show_page_number_key" | ||||||
| 
 | 
 | ||||||
|  |     const val trueColor = "pref_true_color_key" | ||||||
|  | 
 | ||||||
|     const val fullscreen = "fullscreen" |     const val fullscreen = "fullscreen" | ||||||
| 
 | 
 | ||||||
|     const val keepScreenOn = "pref_keep_screen_on_key" |     const val keepScreenOn = "pref_keep_screen_on_key" | ||||||
|  | |||||||
| @ -43,6 +43,8 @@ class PreferencesHelper(val context: Context) { | |||||||
| 
 | 
 | ||||||
|     fun showPageNumber() = rxPrefs.getBoolean(Keys.showPageNumber, true) |     fun showPageNumber() = rxPrefs.getBoolean(Keys.showPageNumber, true) | ||||||
| 
 | 
 | ||||||
|  |     fun trueColor() = rxPrefs.getBoolean(Keys.trueColor, false) | ||||||
|  | 
 | ||||||
|     fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true) |     fun fullscreen() = rxPrefs.getBoolean(Keys.fullscreen, true) | ||||||
| 
 | 
 | ||||||
|     fun keepScreenOn() = rxPrefs.getBoolean(Keys.keepScreenOn, true) |     fun keepScreenOn() = rxPrefs.getBoolean(Keys.keepScreenOn, true) | ||||||
|  | |||||||
| @ -6,6 +6,7 @@ import android.content.Context | |||||||
| import android.content.Intent | import android.content.Intent | ||||||
| import android.content.pm.ActivityInfo | import android.content.pm.ActivityInfo | ||||||
| import android.content.res.Configuration | import android.content.res.Configuration | ||||||
|  | import android.graphics.Bitmap | ||||||
| import android.graphics.Color | import android.graphics.Color | ||||||
| import android.os.Build | import android.os.Build | ||||||
| import android.os.Bundle | import android.os.Bundle | ||||||
| @ -13,6 +14,7 @@ import android.view.* | |||||||
| import android.view.animation.Animation | import android.view.animation.Animation | ||||||
| import android.view.animation.AnimationUtils | import android.view.animation.AnimationUtils | ||||||
| import android.widget.SeekBar | import android.widget.SeekBar | ||||||
|  | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView | ||||||
| import eu.kanade.tachiyomi.R | import eu.kanade.tachiyomi.R | ||||||
| import eu.kanade.tachiyomi.data.database.models.Chapter | import eu.kanade.tachiyomi.data.database.models.Chapter | ||||||
| import eu.kanade.tachiyomi.data.database.models.Manga | import eu.kanade.tachiyomi.data.database.models.Manga | ||||||
| @ -558,6 +560,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() { | |||||||
|             subscriptions += preferences.showPageNumber().asObservable() |             subscriptions += preferences.showPageNumber().asObservable() | ||||||
|                 .subscribe { setPageNumberVisibility(it) } |                 .subscribe { setPageNumberVisibility(it) } | ||||||
| 
 | 
 | ||||||
|  |             subscriptions += preferences.trueColor().asObservable() | ||||||
|  |                 .subscribe { setTrueColor(it) } | ||||||
|  | 
 | ||||||
|             subscriptions += preferences.fullscreen().asObservable() |             subscriptions += preferences.fullscreen().asObservable() | ||||||
|                 .subscribe { setFullscreen(it) } |                 .subscribe { setFullscreen(it) } | ||||||
| 
 | 
 | ||||||
| @ -614,6 +619,16 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() { | |||||||
|             page_number.visibility = if (visible) View.VISIBLE else View.INVISIBLE |             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]. |          * Sets the fullscreen reading mode (immersive) according to [enabled]. | ||||||
|          */ |          */ | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| package eu.kanade.tachiyomi.ui.setting | package eu.kanade.tachiyomi.ui.setting | ||||||
| 
 | 
 | ||||||
|  | import android.os.Build | ||||||
| import android.support.v7.preference.PreferenceScreen | import android.support.v7.preference.PreferenceScreen | ||||||
| import eu.kanade.tachiyomi.R | import eu.kanade.tachiyomi.R | ||||||
| import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys | import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys | ||||||
| @ -77,6 +78,13 @@ class SettingsReaderController : SettingsController() { | |||||||
|             titleRes = R.string.pref_show_page_number |             titleRes = R.string.pref_show_page_number | ||||||
|             defaultValue = true |             defaultValue = true | ||||||
|         } |         } | ||||||
|  |         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||||||
|  |             switchPreference { | ||||||
|  |                 key = Keys.trueColor | ||||||
|  |                 titleRes = R.string.pref_true_color | ||||||
|  |                 defaultValue = false | ||||||
|  |             } | ||||||
|  |         } | ||||||
|         preferenceCategory { |         preferenceCategory { | ||||||
|             titleRes = R.string.pager_viewer |             titleRes = R.string.pager_viewer | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -105,6 +105,17 @@ | |||||||
|         android:textColor="?android:attr/textColorSecondary" |         android:textColor="?android:attr/textColorSecondary" | ||||||
|         app:layout_constraintTop_toBottomOf="@id/background_color" /> |         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.support.v7.widget.SwitchCompat | ||||||
|         android:id="@+id/fullscreen" |         android:id="@+id/fullscreen" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="match_parent" | ||||||
| @ -112,7 +123,7 @@ | |||||||
|         android:layout_marginTop="16dp" |         android:layout_marginTop="16dp" | ||||||
|         android:text="@string/pref_fullscreen" |         android:text="@string/pref_fullscreen" | ||||||
|         android:textColor="?android:attr/textColorSecondary" |         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.support.v7.widget.SwitchCompat | ||||||
|         android:id="@+id/keepscreen" |         android:id="@+id/keepscreen" | ||||||
|  | |||||||
| @ -173,6 +173,7 @@ | |||||||
|     <string name="pref_page_transitions">Page transitions</string> |     <string name="pref_page_transitions">Page transitions</string> | ||||||
|     <string name="pref_double_tap_anim_speed">Double tap animation speed</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_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_crop_borders">Crop borders</string> | ||||||
|     <string name="pref_custom_brightness">Use custom brightness</string> |     <string name="pref_custom_brightness">Use custom brightness</string> | ||||||
|     <string name="pref_custom_color_filter">Use custom color filter</string> |     <string name="pref_custom_color_filter">Use custom color filter</string> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Deumiankio
						Deumiankio