diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt index 8e05aa719f04..7eb7daa4905a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt @@ -32,6 +32,7 @@ import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.button.MaterialButton +import com.google.android.material.card.MaterialCardView import com.google.android.material.slider.Slider import com.google.android.material.textview.MaterialTextView import com.ichi2.anki.DispatchKeyEventListener @@ -40,6 +41,7 @@ import com.ichi2.anki.R import com.ichi2.anki.browser.PreviewerIdsFile import com.ichi2.anki.snackbar.BaseSnackbarBuilderProvider import com.ichi2.anki.snackbar.SnackbarBuilder +import com.ichi2.anki.utils.ext.sharedPrefs import com.ichi2.annotations.NeedsTest import com.ichi2.compat.CompatHelper.Companion.getSerializableCompat import com.ichi2.utils.performClickIfEnabled @@ -168,6 +170,10 @@ class PreviewerFragment : setOnMenuItemClickListener(this@PreviewerFragment) setNavigationOnClickListener { requireActivity().onBackPressedDispatcher.onBackPressed() } } + + if (sharedPrefs().getBoolean("safeDisplay", false)) { + view.findViewById(R.id.webview_container).elevation = 0F + } } override fun onMenuItemClick(item: MenuItem): Boolean { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/TemplatePreviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/TemplatePreviewerFragment.kt index 2fa8a3ed6b49..caff8ef19404 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/TemplatePreviewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/TemplatePreviewerFragment.kt @@ -26,11 +26,13 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.button.MaterialButton +import com.google.android.material.card.MaterialCardView import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout.OnTabSelectedListener import com.ichi2.anki.R import com.ichi2.anki.snackbar.BaseSnackbarBuilderProvider import com.ichi2.anki.snackbar.SnackbarBuilder +import com.ichi2.anki.utils.ext.sharedPrefs import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch @@ -91,6 +93,10 @@ class TemplatePreviewerFragment : } }) } + + if (sharedPrefs().getBoolean("safeDisplay", false)) { + view.findViewById(R.id.webview_container).elevation = 0F + } } companion object { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/utils/ext/Fragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/utils/ext/Fragment.kt new file mode 100644 index 000000000000..208463861e2c --- /dev/null +++ b/AnkiDroid/src/main/java/com/ichi2/anki/utils/ext/Fragment.kt @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Brayan Oliveira + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + */ +package com.ichi2.anki.utils.ext + +import android.content.SharedPreferences +import androidx.fragment.app.Fragment +import com.ichi2.anki.preferences.sharedPrefs + +fun Fragment.sharedPrefs(): SharedPreferences { + return requireContext().sharedPrefs() +}