Skip to content

Commit

Permalink
ui: disable previewers' elevation with safeDisplay
Browse files Browse the repository at this point in the history
after some feedback in discord
  • Loading branch information
BrayanDSO committed Mar 14, 2024
1 parent bf218de commit c2c991a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -168,6 +170,10 @@ class PreviewerFragment :
setOnMenuItemClickListener(this@PreviewerFragment)
setNavigationOnClickListener { requireActivity().onBackPressedDispatcher.onBackPressed() }
}

if (sharedPrefs().getBoolean("safeDisplay", false)) {
view.findViewById<MaterialCardView>(R.id.webview_container).elevation = 0F
}
}

override fun onMenuItemClick(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -91,6 +93,10 @@ class TemplatePreviewerFragment :
}
})
}

if (sharedPrefs().getBoolean("safeDisplay", false)) {
view.findViewById<MaterialCardView>(R.id.webview_container).elevation = 0F
}
}

companion object {
Expand Down
24 changes: 24 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/anki/utils/ext/Fragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2024 Brayan Oliveira <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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()
}

0 comments on commit c2c991a

Please sign in to comment.