Remove color filter preview image

This commit is contained in:
arkon 2020-07-11 19:09:13 -04:00
parent d7a89b0f8c
commit 8536ecb611
5 changed files with 7 additions and 94 deletions

View File

@ -232,7 +232,12 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
invalidateOptionsMenu() invalidateOptionsMenu()
} }
R.id.action_settings -> ReaderSettingsSheet(this).show() R.id.action_settings -> ReaderSettingsSheet(this).show()
R.id.action_custom_filter -> ReaderColorFilterSheet(this).show() R.id.action_custom_filter -> {
ReaderColorFilterSheet(this)
// Remove dimmed backdrop so changes can be previewd
.apply { window?.setDimAmount(0f) }
.show()
}
} }
return super.onOptionsItemSelected(item) return super.onOptionsItemSelected(item)
} }

View File

@ -1,6 +1,5 @@
package eu.kanade.tachiyomi.ui.reader package eu.kanade.tachiyomi.ui.reader
import android.graphics.Color
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.SeekBar import android.widget.SeekBar
@ -9,11 +8,8 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener import eu.kanade.tachiyomi.widget.IgnoreFirstSpinnerListener
import eu.kanade.tachiyomi.widget.SimpleSeekBarListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener
import kotlin.math.abs
import kotlinx.android.synthetic.main.reader_color_filter.brightness_seekbar import kotlinx.android.synthetic.main.reader_color_filter.brightness_seekbar
import kotlinx.android.synthetic.main.reader_color_filter.color_filter_mode import kotlinx.android.synthetic.main.reader_color_filter.color_filter_mode
import kotlinx.android.synthetic.main.reader_color_filter.custom_brightness import kotlinx.android.synthetic.main.reader_color_filter.custom_brightness
@ -27,8 +23,6 @@ import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_alpha
import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_blue_value import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_blue_value
import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_green_value import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_green_value
import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_red_value import kotlinx.android.synthetic.main.reader_color_filter.txt_color_filter_red_value
import kotlinx.android.synthetic.main.reader_color_filter_sheet.brightness_overlay
import kotlinx.android.synthetic.main.reader_color_filter_sheet.color_overlay
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.sample
@ -39,7 +33,7 @@ import uy.kohesive.injekt.injectLazy
*/ */
class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheetDialog(activity) { class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheetDialog(activity) {
private val preferences by injectLazy<PreferencesHelper>() private val preferences: PreferencesHelper by injectLazy()
private var sheetBehavior: BottomSheetBehavior<*>? = null private var sheetBehavior: BottomSheetBehavior<*>? = null
@ -205,15 +199,6 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
* 0 sets system brightness and hides the overlay. * 0 sets system brightness and hides the overlay.
*/ */
private fun setCustomBrightnessValue(value: Int, view: View, isDisabled: Boolean = false) = with(view) { private fun setCustomBrightnessValue(value: Int, view: View, isDisabled: Boolean = false) = with(view) {
// Set black overlay visibility.
if (value < 0) {
brightness_overlay.visible()
val alpha = (abs(value) * 2.56).toInt()
brightness_overlay.setBackgroundColor(Color.argb(alpha, 0, 0, 0))
} else {
brightness_overlay.gone()
}
if (!isDisabled) { if (!isDisabled) {
txt_brightness_seekbar_value.text = value.toString() txt_brightness_seekbar_value.text = value.toString()
} }
@ -230,8 +215,6 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
.sample(100) .sample(100)
.onEach { setColorFilterValue(it, view) } .onEach { setColorFilterValue(it, view) }
.launchIn(activity.scope) .launchIn(activity.scope)
} else {
color_overlay.gone()
} }
setColorFilterSeekBar(enabled, view) setColorFilterSeekBar(enabled, view)
} }
@ -242,8 +225,6 @@ class ReaderColorFilterSheet(private val activity: ReaderActivity) : BottomSheet
* @param view view of the dialog * @param view view of the dialog
*/ */
private fun setColorFilterValue(@ColorInt color: Int, view: View) = with(view) { private fun setColorFilterValue(@ColorInt color: Int, view: View) = with(view) {
color_overlay.visible()
color_overlay.setFilterColor(color, preferences.colorFilterMode().get())
setValues(color, view) setValues(color, view)
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/frame"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="@id/scroll"
app:layout_constraintEnd_toStartOf="@id/scroll"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/scroll">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/filter_mock" />
<View
android:id="@+id/brightness_overlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<eu.kanade.tachiyomi.ui.reader.ReaderColorFilterView
android:id="@+id/color_overlay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
</FrameLayout>
<androidx.core.widget.NestedScrollView
android:id="@+id/scroll"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/frame">
<include layout="@layout/reader_color_filter" />
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -4,30 +4,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="200dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/filter_mock" />
<View
android:id="@+id/brightness_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<eu.kanade.tachiyomi.ui.reader.ReaderColorFilterView
android:id="@+id/color_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
</FrameLayout>
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">