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 65b02c323..be65ddfdf 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 @@ -36,6 +36,10 @@ operator fun Preference>.minusAssign(item: T) { set(get() - item) } +fun Preference.toggle() { + set(!get()) +} + class PreferencesHelper(val context: Context) { private val prefs = PreferenceManager.getDefaultSharedPreferences(context) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 79d9c3a0e..b1517f91e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -34,6 +34,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationReceiver import eu.kanade.tachiyomi.data.notification.Notifications import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.asImmediateFlow +import eu.kanade.tachiyomi.data.preference.toggle import eu.kanade.tachiyomi.databinding.ReaderActivityBinding import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity import eu.kanade.tachiyomi.ui.main.MainActivity @@ -375,6 +376,19 @@ class ReaderActivity : BaseRxActivity() } .launchIn(lifecycleScope) + with(binding.actionCropBorders) { + setTooltip(R.string.pref_crop_borders) + + setOnClickListener { + val isPagerType = ReadingModeType.isPagerType(presenter.getMangaViewer()) + if (isPagerType) { + preferences.cropBorders().toggle() + } else { + preferences.cropBordersWebtoon().toggle() + } + } + } + with(binding.actionSettings) { setTooltip(R.string.action_settings) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt index 7e54c74c7..4f0c1a3f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/ReadingModeType.kt @@ -21,5 +21,10 @@ enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @D val current = fromPreference(preference) return current.next() } + + fun isPagerType(preference: Int): Boolean { + val mode = fromPreference(preference) + return mode == LEFT_TO_RIGHT || mode == RIGHT_TO_LEFT || mode == VERTICAL + } } } diff --git a/app/src/main/res/drawable/ic_crop_free_24dp.xml b/app/src/main/res/drawable/ic_crop_free_24dp.xml new file mode 100644 index 000000000..0b681872e --- /dev/null +++ b/app/src/main/res/drawable/ic_crop_free_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/reader_activity.xml b/app/src/main/res/layout/reader_activity.xml index a134f2a71..d2d968a20 100644 --- a/app/src/main/res/layout/reader_activity.xml +++ b/app/src/main/res/layout/reader_activity.xml @@ -171,12 +171,25 @@ android:background="?selectableItemBackgroundBorderless" android:contentDescription="@string/pref_rotation_type" android:padding="@dimen/material_layout_keylines_screen_edge_margin" - app:layout_constraintEnd_toStartOf="@id/action_settings" + app:layout_constraintEnd_toStartOf="@id/action_crop_borders" app:layout_constraintStart_toEndOf="@+id/action_reader_mode" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@drawable/ic_screen_rotation_24dp" app:tint="?attr/colorOnPrimary" /> + +