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

Commit 0b229eae authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Animate the internet dialog launch.

This CL animates the launch of the internet dialog from the touch
surface that started the dialog.

Note that changes of the content of the dialog itself are not animated
yet, this will be done in a follow-up CL.

See b/201046726 for before/after videos.

Bug: 201046726
Test: Manual
Change-Id: Iaf45371eec5d8cf1f5c6a13ebf20474a0b565abc
parent bb6c39d3
Loading
Loading
Loading
Loading
+35 −4
Original line number Diff line number Diff line
@@ -25,7 +25,11 @@ import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.WindowInsets
import android.view.WindowManager
import android.view.WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR
import android.view.WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
import android.view.WindowManagerPolicyConstants
import android.widget.FrameLayout

private const val TAG = "DialogLaunchAnimator"
@@ -252,6 +256,17 @@ private class DialogLaunchAnimation(
            WindowManager.LayoutParams.MATCH_PARENT
        )

        // If we are using gesture navigation, then we can overlay the navigation/task bars with
        // the host dialog.
        val navigationMode = context.resources.getInteger(
            com.android.internal.R.integer.config_navBarInteractionMode)
        if (navigationMode == WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL) {
            window.attributes.fitInsetsTypes = window.attributes.fitInsetsTypes and
                WindowInsets.Type.navigationBars().inv()
            window.addFlags(FLAG_LAYOUT_IN_SCREEN or FLAG_LAYOUT_INSET_DECOR)
            window.setDecorFitsSystemWindows(false)
        }

        // Prevent the host dialog from drawing until the animation starts.
        hostDialogRoot.viewTreeObserver.addOnPreDrawListener(
            object : ViewTreeObserver.OnPreDrawListener {
@@ -356,15 +371,21 @@ private class DialogLaunchAnimation(
                dialogView.removeOnLayoutChangeListener(this)
                startAnimation(
                    isLaunching = true,
                    onLaunchAnimationStart = { drawHostDialog = true },
                    onLaunchAnimationStart = {
                        drawHostDialog = true

                        // The ghost of the touch surface was just created, so the touch surface is
                        // currently invisible. We need to make sure that it stays invisible as long
                        // as the dialog is shown or animating.
                        if (touchSurface is LaunchableView) {
                            touchSurface.setShouldBlockVisibilityChanges(true)
                        }
                    },
                    onLaunchAnimationEnd = {
                        touchSurface.setTag(R.id.launch_animation_running, null)

                        // We hide the touch surface when the dialog is showing. We will make this
                        // view visible again when dismissing the dialog.
                        // TODO(b/193634619): Provide an easy way for views to check if they should
                        // be hidden because of a dialog launch so that they don't override this
                        // visibility when updating/refreshing itself.
                        touchSurface.visibility = View.INVISIBLE

                        isLaunching = false
@@ -417,6 +438,11 @@ private class DialogLaunchAnimation(
        if (!shouldAnimateDialogIntoView()) {
            Log.i(TAG, "Skipping animation of dialog into the touch surface")

            // Make sure we allow the touch surface to change its visibility again.
            if (touchSurface is LaunchableView) {
                touchSurface.setShouldBlockVisibilityChanges(false)
            }

            // If the view is invisible it's probably because of us, so we make it visible again.
            if (touchSurface.visibility == View.INVISIBLE) {
                touchSurface.visibility = View.VISIBLE
@@ -434,6 +460,11 @@ private class DialogLaunchAnimation(
                hostDialog.window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
            },
            onLaunchAnimationEnd = {
                // Make sure we allow the touch surface to change its visibility again.
                if (touchSurface is LaunchableView) {
                    touchSurface.setShouldBlockVisibilityChanges(false)
                }

                touchSurface.visibility = View.VISIBLE
                originalDialogView!!.visibility = View.INVISIBLE
                dismissDialogs(true /* instantDismiss */)
+30 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.animation

/** A view that can expand/launch into an app or a dialog. */
interface LaunchableView {
    /**
     * Set whether this view should block/prevent all visibility changes. This ensures that this
     * view remains invisible during the launch animation given that it is ghosted and already drawn
     * somewhere else.
     *
     * Note that when this is set to true, both the [normal][android.view.View.setVisibility] and
     * [transition][android.view.View.setTransitionVisibility] visibility changes must be blocked.
     */
    fun setShouldBlockVisibilityChanges(block: Boolean)
}
 No newline at end of file
+0 −23
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<inset xmlns:android="http://schemas.android.com/apk/res/android">
    <shape android:shape="rectangle">
        <corners android:radius="8dp" />
        <solid android:color="?android:attr/colorBackground" />
    </shape>
</inset>
+0 −22
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
          http://www.apache.org/licenses/LICENSE-2.0
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android">
    <shape android:shape="rectangle">
        <corners
            android:topLeftRadius="@dimen/internet_dialog_corner_radius"
            android:topRightRadius="@dimen/internet_dialog_corner_radius"
            android:bottomLeftRadius="@dimen/internet_dialog_corner_radius"
            android:bottomRightRadius="@dimen/internet_dialog_corner_radius"/>
        <solid android:color="?android:attr/colorBackground" />
    </shape>
</inset>
+1 −2
Original line number Diff line number Diff line
@@ -20,8 +20,7 @@
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:id="@+id/internet_connectivity_dialog"
    android:layout_width="@dimen/large_dialog_width"
    android:layout_height="@dimen/internet_dialog_list_max_height"
    android:background="@drawable/internet_dialog_rounded_top_corner_background"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <LinearLayout
Loading