Unify crop borders settings
This commit is contained in:
parent
763da19c9d
commit
1920568057
8 changed files with 25 additions and 54 deletions
|
@ -51,8 +51,6 @@ 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 readWithTappingInverted = "reader_tapping_inverted"
|
const val readWithTappingInverted = "reader_tapping_inverted"
|
||||||
|
|
|
@ -115,8 +115,6 @@ class PreferencesHelper(val context: Context) {
|
||||||
|
|
||||||
fun cropBorders() = flowPrefs.getBoolean(Keys.cropBorders, false)
|
fun cropBorders() = flowPrefs.getBoolean(Keys.cropBorders, false)
|
||||||
|
|
||||||
fun cropBordersWebtoon() = flowPrefs.getBoolean(Keys.cropBordersWebtoon, false)
|
|
||||||
|
|
||||||
fun webtoonSidePadding() = flowPrefs.getInt(Keys.webtoonSidePadding, 0)
|
fun webtoonSidePadding() = flowPrefs.getInt(Keys.webtoonSidePadding, 0)
|
||||||
|
|
||||||
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
||||||
|
|
|
@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.always_show_chapter_transition
|
import kotlinx.android.synthetic.main.reader_settings_sheet.always_show_chapter_transition
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.background_color
|
import kotlinx.android.synthetic.main.reader_settings_sheet.background_color
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders
|
import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.crop_borders_webtoon
|
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.cutout_short
|
import kotlinx.android.synthetic.main.reader_settings_sheet.cutout_short
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.fullscreen
|
import kotlinx.android.synthetic.main.reader_settings_sheet.fullscreen
|
||||||
import kotlinx.android.synthetic.main.reader_settings_sheet.keepscreen
|
import kotlinx.android.synthetic.main.reader_settings_sheet.keepscreen
|
||||||
|
@ -92,6 +91,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||||
keepscreen.bindToPreference(preferences.keepScreenOn())
|
keepscreen.bindToPreference(preferences.keepScreenOn())
|
||||||
long_tap.bindToPreference(preferences.readWithLongTap())
|
long_tap.bindToPreference(preferences.readWithLongTap())
|
||||||
always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition())
|
always_show_chapter_transition.bindToPreference(preferences.alwaysShowChapterTransition())
|
||||||
|
crop_borders.bindToPreference(preferences.cropBorders())
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
true_color.visible()
|
true_color.visible()
|
||||||
|
@ -108,7 +108,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||||
|
|
||||||
scale_type.bindToPreference(preferences.imageScaleType(), 1)
|
scale_type.bindToPreference(preferences.imageScaleType(), 1)
|
||||||
zoom_start.bindToPreference(preferences.zoomStart(), 1)
|
zoom_start.bindToPreference(preferences.zoomStart(), 1)
|
||||||
crop_borders.bindToPreference(preferences.cropBorders())
|
|
||||||
page_transitions.bindToPreference(preferences.pageTransitions())
|
page_transitions.bindToPreference(preferences.pageTransitions())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +118,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||||
pager_prefs_group.invisible()
|
pager_prefs_group.invisible()
|
||||||
webtoon_prefs_group.visible()
|
webtoon_prefs_group.visible()
|
||||||
|
|
||||||
crop_borders_webtoon.bindToPreference(preferences.cropBordersWebtoon())
|
|
||||||
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
|
||||||
var volumeKeysEnabled = false
|
var volumeKeysEnabled = false
|
||||||
var volumeKeysInverted = false
|
var volumeKeysInverted = false
|
||||||
var trueColor = false
|
var trueColor = false
|
||||||
|
var imageCropBorders = false
|
||||||
var alwaysShowChapterTransition = true
|
var alwaysShowChapterTransition = true
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -50,6 +51,9 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
|
||||||
preferences.trueColor()
|
preferences.trueColor()
|
||||||
.register({ trueColor = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ trueColor = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
|
preferences.cropBorders()
|
||||||
|
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.alwaysShowChapterTransition()
|
preferences.alwaysShowChapterTransition()
|
||||||
.register({ alwaysShowChapterTransition = it })
|
.register({ alwaysShowChapterTransition = it })
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,6 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
||||||
var imageZoomType = ZoomType.Left
|
var imageZoomType = ZoomType.Left
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var imageCropBorders = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.pageTransitions()
|
preferences.pageTransitions()
|
||||||
.register({ usePageTransitions = it })
|
.register({ usePageTransitions = it })
|
||||||
|
@ -32,9 +29,6 @@ class PagerConfig(private val viewer: PagerViewer, preferences: PreferencesHelpe
|
||||||
|
|
||||||
preferences.zoomStart()
|
preferences.zoomStart()
|
||||||
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
.register({ zoomTypeFromPreference(it) }, { imagePropertyChangedListener?.invoke() })
|
||||||
|
|
||||||
preferences.cropBorders()
|
|
||||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun zoomTypeFromPreference(value: Int) {
|
private fun zoomTypeFromPreference(value: Int) {
|
||||||
|
|
|
@ -10,16 +10,10 @@ import uy.kohesive.injekt.api.get
|
||||||
*/
|
*/
|
||||||
class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig(preferences) {
|
class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig(preferences) {
|
||||||
|
|
||||||
var imageCropBorders = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
var sidePadding = 0
|
var sidePadding = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
preferences.cropBordersWebtoon()
|
|
||||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
|
||||||
|
|
||||||
preferences.webtoonSidePadding()
|
preferences.webtoonSidePadding()
|
||||||
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,6 +101,11 @@ class SettingsReaderController : SettingsController() {
|
||||||
defaultValue = false
|
defaultValue = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
switchPreference {
|
||||||
|
key = Keys.cropBorders
|
||||||
|
titleRes = R.string.pref_crop_borders
|
||||||
|
defaultValue = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
preferenceCategory {
|
preferenceCategory {
|
||||||
|
@ -154,22 +159,11 @@ class SettingsReaderController : SettingsController() {
|
||||||
titleRes = R.string.pref_page_transitions
|
titleRes = R.string.pref_page_transitions
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
}
|
}
|
||||||
switchPreference {
|
|
||||||
key = Keys.cropBorders
|
|
||||||
titleRes = R.string.pref_crop_borders
|
|
||||||
defaultValue = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preferenceCategory {
|
preferenceCategory {
|
||||||
titleRes = R.string.webtoon_viewer
|
titleRes = R.string.webtoon_viewer
|
||||||
|
|
||||||
switchPreference {
|
|
||||||
key = Keys.cropBordersWebtoon
|
|
||||||
titleRes = R.string.pref_crop_borders
|
|
||||||
defaultValue = false
|
|
||||||
}
|
|
||||||
|
|
||||||
intListPreference {
|
intListPreference {
|
||||||
key = Keys.webtoonSidePadding
|
key = Keys.webtoonSidePadding
|
||||||
titleRes = R.string.pref_webtoon_side_padding
|
titleRes = R.string.pref_webtoon_side_padding
|
||||||
|
|
|
@ -171,11 +171,19 @@
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintTop_toBottomOf="@id/true_color" />
|
app:layout_constraintTop_toBottomOf="@id/true_color" />
|
||||||
|
|
||||||
|
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
|
android:id="@+id/crop_borders"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/pref_crop_borders"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/always_show_chapter_transition" />
|
||||||
|
|
||||||
<android.widget.Space
|
<android.widget.Space
|
||||||
android:id="@+id/end_general_preferences"
|
android:id="@+id/end_general_preferences"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/always_show_chapter_transition" />
|
app:layout_constraintBottom_toBottomOf="@id/crop_borders" />
|
||||||
|
|
||||||
<!-- Pager preferences -->
|
<!-- Pager preferences -->
|
||||||
|
|
||||||
|
@ -228,22 +236,14 @@
|
||||||
app:layout_constraintStart_toEndOf="@id/verticalcenter"
|
app:layout_constraintStart_toEndOf="@id/verticalcenter"
|
||||||
app:layout_constraintTop_toBottomOf="@id/scale_type" />
|
app:layout_constraintTop_toBottomOf="@id/scale_type" />
|
||||||
|
|
||||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
|
||||||
android:id="@+id/crop_borders"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:text="@string/pref_crop_borders"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/zoom_start" />
|
|
||||||
|
|
||||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||||
android:id="@+id/page_transitions"
|
android:id="@+id/page_transitions"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/pref_page_transitions"
|
android:text="@string/pref_page_transitions"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
app:layout_constraintTop_toBottomOf="@id/crop_borders" />
|
app:layout_constraintTop_toBottomOf="@id/zoom_start" />
|
||||||
|
|
||||||
<android.widget.Space
|
<android.widget.Space
|
||||||
android:id="@+id/end_paged_preferences"
|
android:id="@+id/end_paged_preferences"
|
||||||
|
@ -295,22 +295,13 @@
|
||||||
android:id="@+id/webtoon_prefs"
|
android:id="@+id/webtoon_prefs"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="32dp"
|
||||||
android:text="@string/webtoon_viewer"
|
android:text="@string/webtoon_viewer"
|
||||||
android:textColor="?attr/colorAccent"
|
android:textColor="?attr/colorAccent"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/end_navigation_preferences" />
|
app:layout_constraintTop_toBottomOf="@id/end_navigation_preferences" />
|
||||||
|
|
||||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
|
||||||
android:id="@+id/crop_borders_webtoon"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:text="@string/pref_crop_borders"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/webtoon_side_padding_text"
|
android:id="@+id/webtoon_side_padding_text"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -328,7 +319,7 @@
|
||||||
android:entries="@array/webtoon_side_padding"
|
android:entries="@array/webtoon_side_padding"
|
||||||
app:layout_constraintLeft_toRightOf="@id/verticalcenter"
|
app:layout_constraintLeft_toRightOf="@id/verticalcenter"
|
||||||
app:layout_constraintRight_toRightOf="@id/spinner_end"
|
app:layout_constraintRight_toRightOf="@id/spinner_end"
|
||||||
app:layout_constraintTop_toBottomOf="@id/crop_borders_webtoon" />
|
app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" />
|
||||||
|
|
||||||
<!-- Groups of preferences -->
|
<!-- Groups of preferences -->
|
||||||
|
|
||||||
|
@ -337,7 +328,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:constraint_referenced_ids="pager_prefs,scale_type_text,scale_type,zoom_start_text,zoom_start,crop_borders,page_transitions"
|
app:constraint_referenced_ids="pager_prefs,scale_type_text,scale_type,zoom_start_text,zoom_start,page_transitions"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Group
|
<androidx.constraintlayout.widget.Group
|
||||||
|
@ -345,7 +336,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon,webtoon_side_padding_text,webtoon_side_padding" />
|
app:constraint_referenced_ids="webtoon_prefs,webtoon_side_padding_text,webtoon_side_padding" />
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.Guideline
|
<androidx.constraintlayout.widget.Guideline
|
||||||
android:id="@+id/verticalcenter"
|
android:id="@+id/verticalcenter"
|
||||||
|
|
Reference in a new issue