Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19b127df authored by Peter Cai's avatar Peter Cai
Browse files

Revert "ui: Improve window inset calculation"

This reverts commit aca54159.
parent aca54159
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
        val origFabMarginRight = (fab.layoutParams as ViewGroup.MarginLayoutParams).rightMargin
        val origFabMarginBottom = (fab.layoutParams as ViewGroup.MarginLayoutParams).bottomMargin
        ViewCompat.setOnApplyWindowInsetsListener(fab) { v, insets ->
            val bars = insets.getInsetsIgnoringVisibility(WindowInsetsCompat.Type.systemBars())
            val bars = insets.getInsets(WindowInsetsCompat.Type.systemBars())

            v.updateLayoutParams<ViewGroup.MarginLayoutParams> {
                rightMargin = origFabMarginRight + bars.right
+5 −6
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import im.angry.openeuicc.util.OpenEuiccContextMarker
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import net.typeblog.lpac_jni.LocalProfileAssistant
import kotlin.math.max

class DownloadWizardActivity : BaseEuiccAccessActivity() {
    data class DownloadWizardState(
@@ -98,21 +97,21 @@ class DownloadWizardActivity : BaseEuiccAccessActivity() {
        val origHeight = navigation.layoutParams.height

        ViewCompat.setOnApplyWindowInsetsListener(navigation) { v, insets ->
            val bars = insets.getInsetsIgnoringVisibility(
            val bars = insets.getInsets(
                WindowInsetsCompat.Type.systemBars()
                    or WindowInsetsCompat.Type.displayCutout()
                    or WindowInsetsCompat.Type.ime()
            )
            val ime = insets.getInsets(WindowInsetsCompat.Type.ime())
            v.updatePadding(bars.left, 0, bars.right, max(bars.bottom, ime.bottom))
            v.updatePadding(bars.left, 0, bars.right, bars.bottom)
            val newParams = navigation.layoutParams
            newParams.height = origHeight + max(bars.bottom, ime.bottom)
            newParams.height = origHeight + bars.bottom
            navigation.layoutParams = newParams
            WindowInsetsCompat.CONSUMED
        }

        val fragmentRoot = requireViewById<View>(R.id.step_fragment_container)
        ViewCompat.setOnApplyWindowInsetsListener(fragmentRoot) { v, insets ->
            val bars = insets.getInsetsIgnoringVisibility(
            val bars = insets.getInsets(
                WindowInsetsCompat.Type.systemBars()
                    or WindowInsetsCompat.Type.displayCutout()
            )
+9 −1
Original line number Diff line number Diff line
@@ -34,10 +34,18 @@ fun DialogFragment.setWidthPercent(percentage: Int) {
    dialog?.window?.setLayout(percentWidth.toInt(), ViewGroup.LayoutParams.WRAP_CONTENT)
}

/**
 * Call this method (in onActivityCreated or later)
 * to make the dialog near-full screen.
 */
fun DialogFragment.setFullScreen() {
    dialog?.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
}

fun AppCompatActivity.setupToolbarInsets() {
    val spacer = requireViewById<View>(R.id.toolbar_spacer)
    ViewCompat.setOnApplyWindowInsetsListener(requireViewById(R.id.toolbar)) { v, insets ->
        val bars = insets.getInsetsIgnoringVisibility(
        val bars = insets.getInsets(
            WindowInsetsCompat.Type.systemBars()
                or WindowInsetsCompat.Type.displayCutout()
        )
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ class LuiActivity : AppCompatActivity() {
        setContentView(R.layout.activity_lui)

        ViewCompat.setOnApplyWindowInsetsListener(requireViewById(R.id.lui_container)) { v, insets ->
            val bars = insets.getInsetsIgnoringVisibility(
            val bars = insets.getInsets(
                WindowInsetsCompat.Type.systemBars()
                    or WindowInsetsCompat.Type.displayCutout()
            )