mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 23:21:49 +01:00
Add option to reader sheet
This commit is contained in:
parent
c8a6a2653f
commit
2eaf083eee
@ -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].
|
||||
|
@ -188,7 +188,7 @@
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/end_general_preferences" />
|
||||
app:layout_constraintTop_toBottomOf="@id/end_navigation_preferences" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/scale_type_text"
|
||||
@ -245,6 +245,50 @@
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/crop_borders" />
|
||||
|
||||
<android.widget.Space
|
||||
android:id="@+id/end_paged_preferences"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/page_transitions"
|
||||
tools:layout_editor_absoluteX="24dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/navigation_prefs"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="24dp"
|
||||
android:text="Navigation"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/end_general_preferences" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tapping_inverted_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pref_read_with_tapping_inverted"
|
||||
app:layout_constraintBaseline_toBaselineOf="@id/tapping_inverted"
|
||||
app:layout_constraintEnd_toStartOf="@id/verticalcenter"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSpinner
|
||||
android:id="@+id/tapping_inverted"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:entries="@array/invert_tapping_mode"
|
||||
app:layout_constraintEnd_toEndOf="@id/spinner_end"
|
||||
app:layout_constraintStart_toEndOf="@id/verticalcenter"
|
||||
app:layout_constraintTop_toBottomOf="@+id/navigation_prefs" />
|
||||
|
||||
<android.widget.Space
|
||||
android:id="@+id/end_navigation_preferences"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tapping_inverted"
|
||||
tools:layout_editor_absoluteX="24dp" />
|
||||
|
||||
<!-- Webtoon preferences -->
|
||||
|
||||
<TextView
|
||||
@ -256,7 +300,7 @@
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/end_general_preferences" />
|
||||
app:layout_constraintTop_toBottomOf="@id/end_navigation_preferences" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/crop_borders_webtoon"
|
||||
|
@ -79,4 +79,11 @@
|
||||
<item>@string/filter_mode_multiply</item>
|
||||
<item>@string/filter_mode_screen</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="invert_tapping_mode">
|
||||
<item>@string/tapping_inverted_none</item>
|
||||
<item>@string/tapping_inverted_horizontal</item>
|
||||
<item>@string/tapping_inverted_vertical</item>
|
||||
<item>@string/tapping_inverted_both</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user