Skip to content

Commit

Permalink
disable fragment animation in safe display mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MorenoTropical committed Dec 10, 2024
1 parent 34d42da commit 7b9d9a7
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import com.google.android.material.appbar.CollapsingToolbarLayout
import com.google.android.material.appbar.MaterialToolbar
import com.ichi2.anki.R
import com.ichi2.anki.SingleFragmentActivity
import com.ichi2.anki.utils.ext.sharedPrefs
import com.ichi2.anki.utils.isWindowCompact
import com.ichi2.utils.FragmentFactoryUtils
import timber.log.Timber
Expand Down Expand Up @@ -113,7 +114,7 @@ class PreferencesFragment :
fragment.arguments = pref.extras
childFragmentManager.commit {
replace(R.id.settings_container, fragment, fragment::class.jvmName)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
setOpenTransition(this)
addToBackStack(null)
}
return true
Expand All @@ -125,7 +126,7 @@ class PreferencesFragment :
parentFragmentManager.popBackStack() // clear the search fragment from the backstack
childFragmentManager.commit {
replace(R.id.settings_container, fragment, fragment.javaClass.name)
setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
setOpenTransition(this)
addToBackStack(fragment.javaClass.name)
}

Expand All @@ -140,6 +141,12 @@ class PreferencesFragment :
view?.findViewById<MaterialToolbar>(R.id.toolbar)?.title = title
}

private fun setOpenTransition(fragmentTransaction: FragmentTransaction) {
if (!sharedPrefs().getBoolean("safeDisplay", false)) {
fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
}
}

/**
* Starts the first settings fragment, which by default is [HeaderFragment].
* The initial fragment may be overridden by putting the java class name
Expand Down

0 comments on commit 7b9d9a7

Please sign in to comment.