mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-09 02:28:55 +01:00
Add support for margins in Webtoon view
On larger tablets, matching the page width to the screen width in webtoon mode causes eye strain due to the image looking so magnified. Adding a page margin to the image can resolve this by effectively scaling the image down.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package eu.kanade.tachiyomi.widget.preference
|
||||
|
||||
import android.content.Context
|
||||
import android.support.v7.preference.ListPreference
|
||||
import android.util.AttributeSet
|
||||
|
||||
class FloatListPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
ListPreference(context, attrs) {
|
||||
|
||||
override fun persistString(value: String?): Boolean {
|
||||
return value != null && persistFloat(value.toFloat())
|
||||
}
|
||||
|
||||
override fun getPersistedString(defaultReturnValue: String?): String? {
|
||||
// When the underlying preference is using a PreferenceDataStore, there's no way (for now)
|
||||
// to check if a value is in the store, so we use a most likely unused value as workaround
|
||||
val defaultIntValue = Float.NEGATIVE_INFINITY
|
||||
|
||||
val value = getPersistedFloat(defaultIntValue)
|
||||
return if (value != defaultIntValue) {
|
||||
value.toString()
|
||||
} else {
|
||||
defaultReturnValue
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user