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

Commit c438854e authored by Danny Burakov's avatar Danny Burakov Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Removes legacy visibility toggle." into main

parents c2ef1a13 9b5695a0
Loading
Loading
Loading
Loading
+1 −29
Original line number Diff line number Diff line
@@ -16,11 +16,9 @@

package com.android.systemui.scene.ui.view

import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import android.widget.FrameLayout
import androidx.activity.OnBackPressedDispatcher
import androidx.activity.OnBackPressedDispatcherOwner
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
@@ -39,7 +37,6 @@ import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
import com.android.systemui.statusbar.notification.stack.shared.flexiNotifsEnabled
import com.android.systemui.statusbar.notification.stack.ui.view.SharedNotificationContainer
import java.time.Instant
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch

@@ -98,7 +95,7 @@ object SceneWindowRootViewBinder {
                    )

                    val legacyView = view.requireViewById<View>(R.id.legacy_window_root)
                    view.addView(createVisibilityToggleView(legacyView))
                    legacyView.isVisible = false

                    // This moves the SharedNotificationContainer to the WindowRootView just after
                    //  the SceneContainerView. This SharedNotificationContainer should contain NSSL
@@ -123,29 +120,4 @@ object SceneWindowRootViewBinder {
            }
        }
    }

    private var clickCount = 0
    private var lastClick = Instant.now()

    /**
     * A temporary UI to toggle on/off the visibility of the given [otherView]. It is toggled by
     * tapping 5 times in quick succession on the device camera (top center).
     */
    // TODO(b/291321285): Remove this when the Flexiglass UI is mature enough to turn off legacy
    //  SysUI altogether.
    private fun createVisibilityToggleView(otherView: View): View {
        val toggleView = View(otherView.context)
        otherView.isVisible = false
        toggleView.layoutParams = FrameLayout.LayoutParams(200, 200, Gravity.CENTER_HORIZONTAL)
        toggleView.setOnClickListener {
            val now = Instant.now()
            clickCount = if (now.minusSeconds(2) > lastClick) 1 else clickCount + 1
            if (clickCount == 5) {
                otherView.isVisible = !otherView.isVisible
                clickCount = 0
            }
            lastClick = now
        }
        return toggleView
    }
}