Temporarily unrevert crop borders unification (closes #3487)

Reverts 1920568057
This commit is contained in:
arkon 2020-07-31 14:59:34 -04:00
parent ccc0a61158
commit 6a5af438dd
8 changed files with 50 additions and 22 deletions

View File

@ -51,6 +51,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 readWithTappingInverted = "reader_tapping_inverted" const val readWithTappingInverted = "reader_tapping_inverted"

View File

@ -119,6 +119,8 @@ 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)

View File

@ -71,7 +71,6 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
binding.keepscreen.bindToPreference(preferences.keepScreenOn()) binding.keepscreen.bindToPreference(preferences.keepScreenOn())
binding.longTap.bindToPreference(preferences.readWithLongTap()) binding.longTap.bindToPreference(preferences.readWithLongTap())
binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition()) binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition())
binding.cropBorders.bindToPreference(preferences.cropBorders())
binding.pageTransitions.bindToPreference(preferences.pageTransitions()) binding.pageTransitions.bindToPreference(preferences.pageTransitions())
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout // If the preference is explicitly disabled, that means the setting was configured since there is a cutout
@ -90,6 +89,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
binding.scaleType.bindToPreference(preferences.imageScaleType(), 1) binding.scaleType.bindToPreference(preferences.imageScaleType(), 1)
binding.zoomStart.bindToPreference(preferences.zoomStart(), 1) binding.zoomStart.bindToPreference(preferences.zoomStart(), 1)
binding.cropBorders.bindToPreference(preferences.cropBorders())
} }
/** /**
@ -99,6 +99,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
binding.pagerPrefsGroup.isInvisible = true binding.pagerPrefsGroup.isInvisible = true
binding.webtoonPrefsGroup.isVisible = true binding.webtoonPrefsGroup.isVisible = true
binding.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon())
binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values) binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
} }

View File

@ -27,7 +27,6 @@ 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 {
@ -55,9 +54,6 @@ 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 })
} }

View File

@ -17,12 +17,18 @@ 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.imageScaleType() preferences.imageScaleType()
.register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() }) .register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() })
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) {

View File

@ -10,10 +10,16 @@ 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() })
} }

View File

@ -55,11 +55,6 @@ class SettingsReaderController : SettingsController() {
defaultValue = false defaultValue = false
} }
} }
switchPreference {
key = Keys.cropBorders
titleRes = R.string.pref_crop_borders
defaultValue = false
}
switchPreference { switchPreference {
key = Keys.enableTransitions key = Keys.enableTransitions
titleRes = R.string.pref_page_transitions titleRes = R.string.pref_page_transitions
@ -160,6 +155,11 @@ class SettingsReaderController : SettingsController() {
defaultValue = "1" defaultValue = "1"
summary = "%s" summary = "%s"
} }
switchPreference {
key = Keys.cropBorders
titleRes = R.string.pref_crop_borders
defaultValue = false
}
} }
preferenceCategory { preferenceCategory {
@ -179,6 +179,11 @@ class SettingsReaderController : SettingsController() {
defaultValue = "0" defaultValue = "0"
summary = "%s" summary = "%s"
} }
switchPreference {
key = Keys.cropBordersWebtoon
titleRes = R.string.pref_crop_borders
defaultValue = false
}
} }
preferenceCategory { preferenceCategory {

View File

@ -73,21 +73,13 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/viewer" /> app:layout_constraintTop_toBottomOf="@+id/viewer" />
<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/general_prefs" />
<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: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/general_prefs" />
<!-- General reading mode preferences --> <!-- General reading mode preferences -->
@ -249,11 +241,20 @@
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" />
<android.widget.Space <android.widget.Space
android:id="@+id/end_paged_preferences" android:id="@+id/end_paged_preferences"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@+id/zoom_start" app:layout_constraintBottom_toBottomOf="@+id/crop_borders"
tools:layout_editor_absoluteX="24dp" /> tools:layout_editor_absoluteX="24dp" />
<TextView <TextView
@ -325,6 +326,15 @@
app:layout_constraintRight_toRightOf="@id/spinner_end" app:layout_constraintRight_toRightOf="@id/spinner_end"
app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" /> app:layout_constraintTop_toBottomOf="@id/webtoon_prefs" />
<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="10dp"
android:text="@string/pref_crop_borders"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/webtoon_side_padding" />
<!-- Groups of preferences --> <!-- Groups of preferences -->
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
@ -332,7 +342,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" app:constraint_referenced_ids="pager_prefs,scale_type_text,scale_type,zoom_start_text,zoom_start,crop_borders"
tools:visibility="visible" /> tools:visibility="visible" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
@ -340,7 +350,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,webtoon_side_padding_text,webtoon_side_padding" /> app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon,webtoon_side_padding_text,webtoon_side_padding" />
<androidx.constraintlayout.widget.Guideline <androidx.constraintlayout.widget.Guideline
android:id="@+id/verticalcenter" android:id="@+id/verticalcenter"