Crop borders for webtoon now have a separate setting. Close #972

This commit is contained in:
inorichi 2018-04-27 16:55:12 +02:00
parent 5c31271e91
commit 18883f1ba3
7 changed files with 48 additions and 6 deletions

View File

@ -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"

View File

@ -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)

View File

@ -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()
}
}
}

View File

@ -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)

View File

@ -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() {
}
}
}
}

View File

@ -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))
}
}

View File

@ -171,10 +171,16 @@
android:layout_height="wrap_content"
android:text="@string/pref_crop_borders"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/crop_borders_webtoon"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_crop_borders"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/fullscreen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_fullscreen"/>
</LinearLayout>
</LinearLayout>