From 5f561f0b01b52ed5095b128ad2aec1df61e241e9 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Mon, 27 Apr 2020 13:38:55 -0400 Subject: [PATCH] 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 --- packages/SystemUI/AndroidManifest.xml | 5 +- packages/SystemUI/res/values/strings.xml | 3 ++ .../controls/management/ControlsAnimations.kt | 7 +++ .../management/ControlsEditingActivity.kt | 46 +++++++----------- .../management/ControlsFavoritingActivity.kt | 47 +++++++++++++------ .../ControlsProviderSelectorActivity.kt | 23 ++++++++- 6 files changed, 86 insertions(+), 45 deletions(-) diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 37900fb134960..1306657ae403f 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -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"> @@ -683,6 +684,7 @@ diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index d639ed074240a..c60bc46fe6d9e 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -2690,6 +2690,9 @@ All controls removed + + Changes not saved + The list of all controls could not be loaded. diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsAnimations.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsAnimations.kt index 4ca47d1d41ba8..cad166d7cd9e0 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsAnimations.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsAnimations.kt @@ -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 + } } } diff --git a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt index 640c90d2ba597..4e9c550297c53 100644 --- a/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/controls/management/ControlsEditingActivity.kt @@ -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(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