mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Add option to reader sheet
This commit is contained in:
		| @@ -28,6 +28,7 @@ import kotlinx.android.synthetic.main.reader_settings_sheet.pager_prefs_group | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.rotation_mode | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.scale_type | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.show_page_number | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.tapping_inverted | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.true_color | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.viewer | ||||
| import kotlinx.android.synthetic.main.reader_settings_sheet.webtoon_prefs_group | ||||
| @@ -57,6 +58,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia | ||||
|         super.onCreate(savedInstanceState) | ||||
|  | ||||
|         initGeneralPreferences() | ||||
|         initNavigationPreferences() | ||||
|  | ||||
|         when (activity.viewer) { | ||||
|             is PagerViewer -> initPagerPreferences() | ||||
| @@ -119,6 +121,13 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia | ||||
|         webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values) | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Init the preferences for navigation. | ||||
|      */ | ||||
|     private fun initNavigationPreferences() { | ||||
|         tapping_inverted.bindToPreference(preferences.readWithTappingInverted()) | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Binds a checkbox or switch view with a boolean preference. | ||||
|      */ | ||||
| @@ -137,6 +146,19 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia | ||||
|         setSelection(pref.get() - offset, false) | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Binds a spinner to an enum preference. | ||||
|      */ | ||||
|     private inline fun <reified T : Enum<T>> Spinner.bindToPreference(pref: Preference<T>) { | ||||
|         val enumConstants = T::class.java.enumConstants | ||||
|  | ||||
|         onItemSelectedListener = IgnoreFirstSpinnerListener { position -> | ||||
|             enumConstants?.get(position)?.let { pref.set(it) } | ||||
|         } | ||||
|  | ||||
|         enumConstants?.indexOf(pref.get())?.let { setSelection(it, false) } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Binds a spinner to an int preference. The position of the spinner item must | ||||
|      * correlate with the [intValues] resource item (in arrays.xml), which is a <string-array> | ||||
|   | ||||
| @@ -15,10 +15,10 @@ import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters | ||||
| import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer | ||||
| import eu.kanade.tachiyomi.util.view.gone | ||||
| import eu.kanade.tachiyomi.util.view.visible | ||||
| import rx.subscriptions.CompositeSubscription | ||||
| import timber.log.Timber | ||||
| import kotlin.math.max | ||||
| import kotlin.math.min | ||||
| import rx.subscriptions.CompositeSubscription | ||||
| import timber.log.Timber | ||||
|  | ||||
| /** | ||||
|  * Implementation of a [BaseViewer] to display pages with a [RecyclerView]. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user