mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-16 14:09:17 +01:00
Hide cutout toggle button if fullscreen is off (#6150)
This commit is contained in:
parent
f0a5557e60
commit
33a02b47d5
@ -5,11 +5,14 @@ import android.util.AttributeSet
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
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.data.preference.asImmediateFlow
|
||||||
import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding
|
import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding
|
||||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||||
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
import eu.kanade.tachiyomi.util.preference.bindToPreference
|
||||||
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,15 +38,17 @@ class ReaderGeneralSettings @JvmOverloads constructor(context: Context, attrs: A
|
|||||||
binding.backgroundColor.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
|
binding.backgroundColor.bindToIntPreference(preferences.readerTheme(), R.array.reader_themes_values)
|
||||||
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
binding.showPageNumber.bindToPreference(preferences.showPageNumber())
|
||||||
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
binding.fullscreen.bindToPreference(preferences.fullscreen())
|
||||||
|
preferences.fullscreen()
|
||||||
|
.asImmediateFlow {
|
||||||
|
// If the preference is explicitly disabled, that means the setting was configured since there is a cutout
|
||||||
|
binding.cutoutShort.isVisible = it && ((context as ReaderActivity).hasCutout || !preferences.cutoutShort().get())
|
||||||
|
binding.cutoutShort.bindToPreference(preferences.cutoutShort())
|
||||||
|
}
|
||||||
|
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||||
|
|
||||||
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.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 ((context as ReaderActivity).hasCutout || !preferences.cutoutShort().get()) {
|
|
||||||
binding.cutoutShort.isVisible = true
|
|
||||||
binding.cutoutShort.bindToPreference(preferences.cutoutShort())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ class SettingsReaderController : SettingsController() {
|
|||||||
key = Keys.cutoutShort
|
key = Keys.cutoutShort
|
||||||
titleRes = R.string.pref_cutout_short
|
titleRes = R.string.pref_cutout_short
|
||||||
defaultValue = true
|
defaultValue = true
|
||||||
|
preferences.fullscreen().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user