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 66e9d4181..6caa902f5 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 @@ -39,6 +39,8 @@ object PreferenceKeys { const val cropBorders = "crop_borders" + const val cropBordersWebtoon = "crop_borders_webtoon" + const val readWithTapping = "reader_tap" const val readWithVolumeKeys = "reader_volume_keys" 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 ed10fa7d3..cf594838e 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 @@ -67,6 +67,8 @@ class PreferencesHelper(val context: Context) { fun cropBorders() = rxPrefs.getBoolean(Keys.cropBorders, false) + fun cropBordersWebtoon() = rxPrefs.getBoolean(Keys.cropBordersWebtoon, false) + fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true) fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt index 8927ad4fe..f40f47e2c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt @@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.util.plusAssign +import eu.kanade.tachiyomi.util.visibleIf import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener import kotlinx.android.synthetic.main.reader_settings_dialog.view.* import rx.Observable @@ -91,6 +92,23 @@ class ReaderSettingsDialog : DialogFragment() { crop_borders.setOnCheckedChangeListener { _, isChecked -> preferences.cropBorders().set(isChecked) } + + crop_borders_webtoon.isChecked = preferences.cropBordersWebtoon().getOrDefault() + crop_borders_webtoon.setOnCheckedChangeListener { _, isChecked -> + preferences.cropBordersWebtoon().set(isChecked) + } + + val readerActivity = activity as? ReaderActivity + val isWebtoonViewer = if (readerActivity != null) { + val mangaViewer = readerActivity.presenter.manga.viewer + val viewer = if (mangaViewer == 0) preferences.defaultViewer() else mangaViewer + viewer == ReaderActivity.WEBTOON + } else { + false + } + + crop_borders.visibleIf { !isWebtoonViewer } + crop_borders_webtoon.visibleIf { isWebtoonViewer } } override fun onDestroyView() { @@ -98,4 +116,4 @@ class ReaderSettingsDialog : DialogFragment() { super.onDestroyView() } -} \ No newline at end of file +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt index d2164f9e7..3ac0c5085 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonReader.kt @@ -4,7 +4,12 @@ import android.os.Build import android.os.Bundle import android.support.v7.widget.RecyclerView import android.util.DisplayMetrics -import android.view.* +import android.view.Display +import android.view.GestureDetector +import android.view.LayoutInflater +import android.view.MotionEvent +import android.view.View +import android.view.ViewGroup import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import eu.kanade.tachiyomi.source.model.Page @@ -123,7 +128,7 @@ class WebtoonReader : BaseReader() { .distinctUntilChanged() .subscribe { refreshAdapter() }) - subscriptions.add(readerActivity.preferences.cropBorders() + subscriptions.add(readerActivity.preferences.cropBordersWebtoon() .asObservable() .doOnNext { cropBorders = it } .skip(1) 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 aa3188f03..7b0cb48bd 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 @@ -90,6 +90,11 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_crop_borders defaultValue = false } + switchPreference { + key = Keys.cropBordersWebtoon + titleRes = R.string.pref_crop_borders_webtoon + defaultValue = false + } switchPreference { key = Keys.keepScreenOn titleRes = R.string.pref_keep_screen_on @@ -116,4 +121,4 @@ class SettingsReaderController : SettingsController() { } } -} \ No newline at end of file +} diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt index e3f6bbb01..af9b041e2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ViewExtensions.kt @@ -47,6 +47,10 @@ inline fun View.gone() { visibility = View.GONE } +inline fun View.visibleIf(block: () -> Boolean) { + visibility = if (block()) View.VISIBLE else View.GONE +} + /** * Returns a TextDrawable determined by input * @@ -63,4 +67,4 @@ fun View.getRound(text: String, random : Boolean = true): TextDrawable { .useFont(Typeface.DEFAULT) .endConfig() .buildRound(text, if (random) ColorGenerator.MATERIAL.randomColor else ColorGenerator.MATERIAL.getColor(text)) -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/reader_settings_dialog.xml b/app/src/main/res/layout/reader_settings_dialog.xml index 2ac02900b..ea9793236 100644 --- a/app/src/main/res/layout/reader_settings_dialog.xml +++ b/app/src/main/res/layout/reader_settings_dialog.xml @@ -171,10 +171,16 @@ android:layout_height="wrap_content" android:text="@string/pref_crop_borders"/> + + - \ No newline at end of file +