mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 19:03:16 -05:00
Crop borders for webtoon now have a separate setting. Close #972
This commit is contained in:
parent
5c31271e91
commit
18883f1ba3
7 changed files with 48 additions and 6 deletions
|
@ -39,6 +39,8 @@ object PreferenceKeys {
|
||||||
|
|
||||||
const val cropBorders = "crop_borders"
|
const val cropBorders = "crop_borders"
|
||||||
|
|
||||||
|
const val cropBordersWebtoon = "crop_borders_webtoon"
|
||||||
|
|
||||||
const val readWithTapping = "reader_tap"
|
const val readWithTapping = "reader_tap"
|
||||||
|
|
||||||
const val readWithVolumeKeys = "reader_volume_keys"
|
const val readWithVolumeKeys = "reader_volume_keys"
|
||||||
|
|
|
@ -67,6 +67,8 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun cropBorders() = rxPrefs.getBoolean(Keys.cropBorders, false)
|
fun cropBorders() = rxPrefs.getBoolean(Keys.cropBorders, false)
|
||||||
|
|
||||||
|
fun cropBordersWebtoon() = rxPrefs.getBoolean(Keys.cropBordersWebtoon, false)
|
||||||
|
|
||||||
fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true)
|
fun readWithTapping() = rxPrefs.getBoolean(Keys.readWithTapping, true)
|
||||||
|
|
||||||
fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false)
|
fun readWithVolumeKeys() = rxPrefs.getBoolean(Keys.readWithVolumeKeys, false)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.util.plusAssign
|
import eu.kanade.tachiyomi.util.plusAssign
|
||||||
|
import eu.kanade.tachiyomi.util.visibleIf
|
||||||
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||||
import kotlinx.android.synthetic.main.reader_settings_dialog.view.*
|
import kotlinx.android.synthetic.main.reader_settings_dialog.view.*
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
|
@ -91,6 +92,23 @@ class ReaderSettingsDialog : DialogFragment() {
|
||||||
crop_borders.setOnCheckedChangeListener { _, isChecked ->
|
crop_borders.setOnCheckedChangeListener { _, isChecked ->
|
||||||
preferences.cropBorders().set(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() {
|
override fun onDestroyView() {
|
||||||
|
@ -98,4 +116,4 @@ class ReaderSettingsDialog : DialogFragment() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,12 @@ import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.util.DisplayMetrics
|
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.MATCH_PARENT
|
||||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
@ -123,7 +128,7 @@ class WebtoonReader : BaseReader() {
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.subscribe { refreshAdapter() })
|
.subscribe { refreshAdapter() })
|
||||||
|
|
||||||
subscriptions.add(readerActivity.preferences.cropBorders()
|
subscriptions.add(readerActivity.preferences.cropBordersWebtoon()
|
||||||
.asObservable()
|
.asObservable()
|
||||||
.doOnNext { cropBorders = it }
|
.doOnNext { cropBorders = it }
|
||||||
.skip(1)
|
.skip(1)
|
||||||
|
|
|
@ -90,6 +90,11 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pref_crop_borders
|
titleRes = R.string.pref_crop_borders
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.cropBordersWebtoon
|
||||||
|
titleRes = R.string.pref_crop_borders_webtoon
|
||||||
|
defaultValue = false
|
||||||
|
}
|
||||||
switchPreference {
|
switchPreference {
|
||||||
key = Keys.keepScreenOn
|
key = Keys.keepScreenOn
|
||||||
titleRes = R.string.pref_keep_screen_on
|
titleRes = R.string.pref_keep_screen_on
|
||||||
|
@ -116,4 +121,4 @@ class SettingsReaderController : SettingsController() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,10 @@ inline fun View.gone() {
|
||||||
visibility = 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
|
* Returns a TextDrawable determined by input
|
||||||
*
|
*
|
||||||
|
@ -63,4 +67,4 @@ fun View.getRound(text: String, random : Boolean = true): TextDrawable {
|
||||||
.useFont(Typeface.DEFAULT)
|
.useFont(Typeface.DEFAULT)
|
||||||
.endConfig()
|
.endConfig()
|
||||||
.buildRound(text, if (random) ColorGenerator.MATERIAL.randomColor else ColorGenerator.MATERIAL.getColor(text))
|
.buildRound(text, if (random) ColorGenerator.MATERIAL.randomColor else ColorGenerator.MATERIAL.getColor(text))
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,10 +171,16 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/pref_crop_borders"/>
|
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.support.v7.widget.SwitchCompat
|
||||||
android:id="@+id/fullscreen"
|
android:id="@+id/fullscreen"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/pref_fullscreen"/>
|
android:text="@string/pref_fullscreen"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Loading…
Reference in a new issue