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

Commit 5f561f0b authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Fix back and cancel flows

This fixes all the back flows (finishing activities when they are not
needed). Also fix some transition animations.

Add a toast when "See other apps" is selected with changes done. This
will appear even if something is changed and reverted, as that kind of
thing is not tracked.

Test: manual, go over flows
Fixes: 154741024

Change-Id: I24611f4f32e41c7dd3774620518f2945db081727
parent 28354e54
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -674,8 +674,9 @@
                  android:label="@string/controls_providers_title"
                  android:theme="@style/Theme.ControlsManagement"
                  android:showForAllUsers="true"
                  android:clearTaskOnLaunch="true"
                  android:finishOnTaskLaunch="true"
                  android:excludeFromRecents="true"
                  android:launchMode="singleInstance"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
                  android:visibleToInstantApps="true">
        </activity>
@@ -683,6 +684,7 @@
        <activity android:name=".controls.management.ControlsEditingActivity"
                  android:theme="@style/Theme.ControlsManagement"
                  android:excludeFromRecents="true"
                  android:noHistory="true"
                  android:showForAllUsers="true"
                  android:finishOnTaskLaunch="true"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
@@ -694,6 +696,7 @@
                  android:excludeFromRecents="true"
                  android:showForAllUsers="true"
                  android:finishOnTaskLaunch="true"
                  android:launchMode="singleInstance"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
                  android:visibleToInstantApps="true">
        </activity>
+3 −0
Original line number Diff line number Diff line
@@ -2690,6 +2690,9 @@
    <!-- Controls management editing screen, text to indicate that all the favorites have been removed [CHAR LIMIT=NONE] -->
    <string name="controls_favorite_removed">All controls removed</string>

    <!-- Controls management favorites screen, See other apps with changes made [CHAR LIMIT=NONE] -->
    <string name="controls_favorite_toast_no_changes">Changes not saved</string>

    <!-- Controls management controls screen error on load message [CHAR LIMIT=60] -->
    <string name="controls_favorite_load_error">The list of all controls could not be loaded.</string>
    <!-- Controls management controls screen header for Other zone [CHAR LIMIT=60] -->
+7 −0
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ object ControlsAnimations {
                    allowEnterTransitionOverlap = true
                    enterTransition = enterWindowTransition(view.getId())
                    exitTransition = exitWindowTransition(view.getId())
                    reenterTransition = enterWindowTransition(view.getId())
                    returnTransition = exitWindowTransition(view.getId())
                }
            }

@@ -86,6 +88,11 @@ object ControlsAnimations {
                    showAnimation = false
                }
            }

            @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
            fun resetAnimation() {
                view.translationY = 0f
            }
        }
    }

+18 −28
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.controls.management

import android.app.ActivityOptions
import android.content.ComponentName
import android.content.Intent
import android.os.Bundle
@@ -70,10 +69,6 @@ class ControlsEditingActivity @Inject constructor(
        }
    }

    override fun onBackPressed() {
        finish()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

@@ -102,6 +97,23 @@ class ControlsEditingActivity @Inject constructor(
        currentUserTracker.stopTracking()
    }

    override fun onBackPressed() {
        globalActionsComponent.handleShowGlobalActionsMenu()
        animateExitAndFinish()
    }

    private fun animateExitAndFinish() {
        val rootView = requireViewById<ViewGroup>(R.id.controls_management_root)
        ControlsAnimations.exitAnimation(
                rootView,
                object : Runnable {
                    override fun run() {
                        finish()
                    }
                }
        ).start()
    }

    private fun bindViews() {
        setContentView(R.layout.controls_management)

@@ -124,35 +136,13 @@ class ControlsEditingActivity @Inject constructor(
    }

    private fun bindButtons() {
        requireViewById<Button>(R.id.other_apps).apply {
            visibility = View.VISIBLE
            setText(R.string.controls_menu_add)
            setOnClickListener {
                saveFavorites()
                val intent = Intent(this@ControlsEditingActivity,
                        ControlsFavoritingActivity::class.java).apply {
                    putExtras(this@ControlsEditingActivity.intent)
                    putExtra(ControlsFavoritingActivity.EXTRA_SINGLE_STRUCTURE, true)
                }
                startActivity(intent, ActivityOptions
                    .makeSceneTransitionAnimation(this@ControlsEditingActivity).toBundle())
            }
        }

        val rootView = requireViewById<ViewGroup>(R.id.controls_management_root)
        saveButton = requireViewById<Button>(R.id.done).apply {
            isEnabled = false
            setText(R.string.save)
            setOnClickListener {
                saveFavorites()
                ControlsAnimations.exitAnimation(
                    rootView,
                    object : Runnable {
                        override fun run() {
                            finish()
                        }
                    }
                ).start()
                animateExitAndFinish()
                globalActionsComponent.handleShowGlobalActionsMenu()
            }
        }
+33 −14
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.ViewStub
import android.widget.Button
import android.widget.FrameLayout
import android.widget.TextView
import android.widget.Toast
import androidx.viewpager2.widget.ViewPager2
import com.android.systemui.Prefs
import com.android.systemui.R
@@ -63,6 +64,7 @@ class ControlsFavoritingActivity @Inject constructor(
        // If provided, show this structure page first
        const val EXTRA_STRUCTURE = "extra_structure"
        const val EXTRA_SINGLE_STRUCTURE = "extra_single_structure"
        internal const val EXTRA_FROM_PROVIDER_SELECTOR = "extra_from_provider_selector"
        private const val TOOLTIP_PREFS_KEY = Prefs.Key.CONTROLS_STRUCTURE_SWIPE_TOOLTIP_COUNT
        private const val TOOLTIP_MAX_SHOWN = 2
    }
@@ -70,6 +72,7 @@ class ControlsFavoritingActivity @Inject constructor(
    private var component: ComponentName? = null
    private var appName: CharSequence? = null
    private var structureExtra: CharSequence? = null
    private var fromProviderSelector = false

    private lateinit var structurePager: ViewPager2
    private lateinit var statusText: TextView
@@ -105,7 +108,10 @@ class ControlsFavoritingActivity @Inject constructor(
    }

    override fun onBackPressed() {
        finish()
        if (!fromProviderSelector) {
            globalActionsComponent.handleShowGlobalActionsMenu()
        }
        animateExitAndFinish()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
@@ -116,6 +122,7 @@ class ControlsFavoritingActivity @Inject constructor(
        appName = intent.getCharSequenceExtra(EXTRA_APP)
        structureExtra = intent.getCharSequenceExtra(EXTRA_STRUCTURE) ?: ""
        component = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME)
        fromProviderSelector = intent.getBooleanExtra(EXTRA_FROM_PROVIDER_SELECTOR, false)

        bindViews()
    }
@@ -271,18 +278,38 @@ class ControlsFavoritingActivity @Inject constructor(
        bindButtons()
    }

    private fun animateExitAndFinish() {
        val rootView = requireViewById<ViewGroup>(R.id.controls_management_root)
        ControlsAnimations.exitAnimation(
                rootView,
                object : Runnable {
                    override fun run() {
                        finish()
                    }
                }
        ).start()
    }

    private fun bindButtons() {
        otherAppsButton = requireViewById<Button>(R.id.other_apps).apply {
            setOnClickListener {
                val i = Intent()
                i.setComponent(
                    ComponentName(context, ControlsProviderSelectorActivity::class.java))
                val i = Intent().apply {
                    component = ComponentName(context, ControlsProviderSelectorActivity::class.java)
                }
                if (doneButton.isEnabled) {
                    // The user has made changes
                    Toast.makeText(
                            applicationContext,
                            R.string.controls_favorite_toast_no_changes,
                            Toast.LENGTH_SHORT
                            ).show()
                }
                startActivity(i, ActivityOptions
                    .makeSceneTransitionAnimation(this@ControlsFavoritingActivity).toBundle())
                animateExitAndFinish()
            }
        }

        val rootView = requireViewById<ViewGroup>(R.id.controls_management_root)
        doneButton = requireViewById<Button>(R.id.done).apply {
            isEnabled = false
            setOnClickListener {
@@ -293,15 +320,7 @@ class ControlsFavoritingActivity @Inject constructor(
                        StructureInfo(component!!, it.structureName, favoritesForStorage)
                    )
                }

                ControlsAnimations.exitAnimation(
                    rootView,
                    object : Runnable {
                        override fun run() {
                            finish()
                        }
                    }
                ).start()
                animateExitAndFinish()
                globalActionsComponent.handleShowGlobalActionsMenu()
            }
        }
Loading