mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Hide cutout toggle button if fullscreen is off (#6150)
This commit is contained in:
		| @@ -5,11 +5,14 @@ import android.util.AttributeSet | ||||
| import android.view.LayoutInflater | ||||
| import androidx.core.view.isVisible | ||||
| import androidx.core.widget.NestedScrollView | ||||
| import androidx.lifecycle.lifecycleScope | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.data.preference.asImmediateFlow | ||||
| import eu.kanade.tachiyomi.databinding.ReaderGeneralSettingsBinding | ||||
| import eu.kanade.tachiyomi.ui.reader.ReaderActivity | ||||
| import eu.kanade.tachiyomi.util.preference.bindToPreference | ||||
| import kotlinx.coroutines.flow.launchIn | ||||
| 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.showPageNumber.bindToPreference(preferences.showPageNumber()) | ||||
|         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.longTap.bindToPreference(preferences.readWithLongTap()) | ||||
|         binding.alwaysShowChapterTransition.bindToPreference(preferences.alwaysShowChapterTransition()) | ||||
|         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 | ||||
|                     titleRes = R.string.pref_cutout_short | ||||
|                     defaultValue = true | ||||
|                     preferences.fullscreen().asImmediateFlow { isVisible = it }.launchIn(viewScope) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user