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 33791194c3..c2b93868b1 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 @@ -57,7 +57,9 @@ object PreferenceKeys { const val readWithTapping = "reader_tap" - const val readWithTappingInverted = "reader_tapping_inverted" + const val pagerNavInverted = "reader_tapping_inverted" + + const val webtoonNavInverted = "reader_tapping_inverted_webtoon" const val readWithLongTap = "reader_long_tap" 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 ebad7166bd..946078b0e7 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 @@ -130,7 +130,9 @@ class PreferencesHelper(val context: Context) { fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true) - fun readWithTappingInverted() = flowPrefs.getEnum(Keys.readWithTappingInverted, Values.TappingInvertMode.NONE) + fun pagerNavInverted() = flowPrefs.getEnum(Keys.pagerNavInverted, Values.TappingInvertMode.NONE) + + fun webtoonNavInverted() = flowPrefs.getEnum(Keys.webtoonNavInverted, Values.TappingInvertMode.NONE) fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index 5585aa16ff..437381397d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -4,7 +4,7 @@ import android.os.Bundle import android.widget.CompoundButton import android.widget.Spinner import androidx.annotation.ArrayRes -import androidx.core.view.isInvisible +import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.core.widget.NestedScrollView import com.google.android.material.bottomsheet.BottomSheetDialog @@ -39,7 +39,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia super.onCreate(savedInstanceState) initGeneralPreferences() - initNavigationPreferences() when (activity.viewer) { is PagerViewer -> initPagerPreferences() @@ -83,36 +82,33 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia * Init the preferences for the pager reader. */ private fun initPagerPreferences() { - binding.webtoonPrefsGroup.isInvisible = true - binding.pagerPrefsGroup.isVisible = true + binding.webtoonPrefsGroup.root.isGone = true + binding.pagerPrefsGroup.root.isVisible = true - binding.pagerNav.bindToPreference(preferences.navigationModePager()) - binding.scaleType.bindToPreference(preferences.imageScaleType(), 1) - binding.zoomStart.bindToPreference(preferences.zoomStart(), 1) - binding.cropBorders.bindToPreference(preferences.cropBorders()) + binding.pagerPrefsGroup.tappingPrefsGroup.isVisible = preferences.readWithTapping().get() + + binding.pagerPrefsGroup.tappingInverted.bindToPreference(preferences.pagerNavInverted()) + + binding.pagerPrefsGroup.pagerNav.bindToPreference(preferences.navigationModePager()) + binding.pagerPrefsGroup.scaleType.bindToPreference(preferences.imageScaleType(), 1) + binding.pagerPrefsGroup.zoomStart.bindToPreference(preferences.zoomStart(), 1) + binding.pagerPrefsGroup.cropBorders.bindToPreference(preferences.cropBorders()) } /** * Init the preferences for the webtoon reader. */ private fun initWebtoonPreferences() { - binding.pagerPrefsGroup.isInvisible = true - binding.webtoonPrefsGroup.isVisible = true + binding.pagerPrefsGroup.root.isGone = true + binding.webtoonPrefsGroup.root.isVisible = true - binding.webtoonNav.bindToPreference(preferences.navigationModeWebtoon()) - binding.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon()) - binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values) - } + binding.webtoonPrefsGroup.tappingPrefsGroup.isVisible = preferences.readWithTapping().get() - /** - * Init the preferences for navigation. - */ - private fun initNavigationPreferences() { - if (!preferences.readWithTapping().get()) { - binding.navigationPrefsGroup.isVisible = false - } + binding.webtoonPrefsGroup.tappingInverted.bindToPreference(preferences.webtoonNavInverted()) - binding.tappingInverted.bindToPreference(preferences.readWithTappingInverted()) + binding.webtoonPrefsGroup.webtoonNav.bindToPreference(preferences.navigationModeWebtoon()) + binding.webtoonPrefsGroup.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon()) + binding.webtoonPrefsGroup.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt index 9cee493a20..35354a9dc7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/ViewerConfig.kt @@ -38,9 +38,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper) { preferences.readWithTapping() .register({ tappingEnabled = it }) - preferences.readWithTappingInverted() - .register({ tappingInverted = it }, { navigator.invertMode = it }) - preferences.readWithLongTap() .register({ longTapEnabled = it }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt index 0abf2cd2e9..c2e5f1470d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerConfig.kt @@ -36,6 +36,9 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe preferences.navigationModePager() .register({ navigationMode = it }, { updateNavigation(navigationMode) }) + + preferences.pagerNavInverted() + .register({ tappingInverted = it }, { navigator.invertMode = it }) } private fun zoomTypeFromPreference(value: Int) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt index 94ae03c36d..1a37b56685 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt @@ -29,6 +29,9 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi preferences.navigationModeWebtoon() .register({ navigationMode = it }, { updateNavigation(it) }) + + preferences.webtoonNavInverted() + .register({ tappingInverted = it }, { navigator.invertMode = it }) } override var navigator: ViewerNavigation = defaultNavigation() 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 f4162958e1..e49c57b516 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 @@ -137,6 +137,41 @@ class SettingsReaderController : SettingsController() { preferenceCategory { titleRes = R.string.pager_viewer + intListPreference { + key = Keys.navigationModePager + titleRes = R.string.pref_viewer_nav + entriesRes = arrayOf( + R.string.default_nav, + R.string.l_nav, + R.string.kindlish_nav, + R.string.edge_nav + ) + entryValues = arrayOf("0", "1", "2", "3") + defaultValue = "0" + summary = "%s" + + preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope) + } + listPreference { + key = Keys.pagerNavInverted + titleRes = R.string.pref_read_with_tapping_inverted + entriesRes = arrayOf( + R.string.tapping_inverted_none, + R.string.tapping_inverted_horizontal, + R.string.tapping_inverted_vertical, + R.string.tapping_inverted_both + ) + entryValues = arrayOf( + TappingInvertMode.NONE.name, + TappingInvertMode.HORIZONTAL.name, + TappingInvertMode.VERTICAL.name, + TappingInvertMode.BOTH.name + ) + defaultValue = TappingInvertMode.NONE.name + summary = "%s" + + preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope) + } intListPreference { key = Keys.imageScaleType titleRes = R.string.pref_image_scale_type @@ -175,6 +210,41 @@ class SettingsReaderController : SettingsController() { preferenceCategory { titleRes = R.string.webtoon_viewer + intListPreference { + key = Keys.navigationModeWebtoon + titleRes = R.string.pref_viewer_nav + entriesRes = arrayOf( + R.string.default_nav, + R.string.l_nav, + R.string.kindlish_nav, + R.string.edge_nav + ) + entryValues = arrayOf("0", "1", "2", "3") + defaultValue = "0" + summary = "%s" + + preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope) + } + listPreference { + key = Keys.webtoonNavInverted + titleRes = R.string.pref_read_with_tapping_inverted + entriesRes = arrayOf( + R.string.tapping_inverted_none, + R.string.tapping_inverted_horizontal, + R.string.tapping_inverted_vertical, + R.string.tapping_inverted_both + ) + entryValues = arrayOf( + TappingInvertMode.NONE.name, + TappingInvertMode.HORIZONTAL.name, + TappingInvertMode.VERTICAL.name, + TappingInvertMode.BOTH.name + ) + defaultValue = TappingInvertMode.NONE.name + summary = "%s" + + preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope) + } intListPreference { key = Keys.webtoonSidePadding titleRes = R.string.pref_webtoon_side_padding @@ -204,26 +274,6 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_read_with_tapping defaultValue = true } - listPreference { - key = Keys.readWithTappingInverted - titleRes = R.string.pref_read_with_tapping_inverted - entriesRes = arrayOf( - R.string.tapping_inverted_none, - R.string.tapping_inverted_horizontal, - R.string.tapping_inverted_vertical, - R.string.tapping_inverted_both - ) - entryValues = arrayOf( - TappingInvertMode.NONE.name, - TappingInvertMode.HORIZONTAL.name, - TappingInvertMode.VERTICAL.name, - TappingInvertMode.BOTH.name - ) - defaultValue = TappingInvertMode.NONE.name - summary = "%s" - - preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(scope) - } switchPreference { key = Keys.readWithLongTap titleRes = R.string.pref_read_with_long_tap diff --git a/app/src/main/res/layout/reader_pager_settings.xml b/app/src/main/res/layout/reader_pager_settings.xml new file mode 100644 index 0000000000..c3df83e81f --- /dev/null +++ b/app/src/main/res/layout/reader_pager_settings.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index 0ea618c608..890db6bd1d 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -18,10 +18,10 @@ android:alpha="0.5" android:scaleType="fitCenter" android:src="@drawable/ic_drag_pill_24dp" - android:tint="?attr/colorOnBackground" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + app:tint="?attr/colorOnBackground" /> - - - - - - - - - - - - - - - - - - - - - - - - - + app:layout_constraintTop_toBottomOf="@+id/always_show_chapter_transition" + tools:visibility="visible" /> - - - - - - - - - - - + app:layout_constraintTop_toBottomOf="@id/always_show_chapter_transition" /> - - - - - - diff --git a/app/src/main/res/layout/reader_webtoon_settings.xml b/app/src/main/res/layout/reader_webtoon_settings.xml new file mode 100644 index 0000000000..e870843028 --- /dev/null +++ b/app/src/main/res/layout/reader_webtoon_settings.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file