Skip to content

Commit fbc10e0

Browse files
authored
use colored backdrop for Input Screen alpha transitions on API 33+ (#6421)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1210820490944337?focus=true ### Description Uses the `backdrop` API for window transitions to supply a backdrop color which is drawn below and beyond bounds of the activity to prevent the activity window fading to black during alpha transitions. I remove the translation transition from API < 31 because it didn't run on tested devices anyway. Additionally, I cleaned up the transition files and moved them to `duckchat` module, which is more appropriate as they are targeted specifically at the Input Screen transition behavior. ### Steps to test this PR - [x] Verify the slide + fade transitions look right in light and dark mode on API >= 33 - [x] Verify the fade transition looks right in light and dark mode on API < 33 (unchaged behavior) ### UI changes (for API 33+) | Before | After | | ------ | ----- | ![before](https://github.com/user-attachments/assets/92a492eb-f578-4217-b0c5-8e856e69d082)|![after](https://github.com/user-attachments/assets/a17161cb-e655-4ffc-b72e-0679a274db3c)|
1 parent 9ae2a9b commit fbc10e0

File tree

14 files changed

+177
-109
lines changed

14 files changed

+177
-109
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ import com.duckduckgo.browser.api.ui.BrowserScreens.PrivateSearchScreenNoParams
246246
import com.duckduckgo.browser.api.ui.BrowserScreens.WebViewActivityWithParams
247247
import com.duckduckgo.common.ui.DuckDuckGoActivity
248248
import com.duckduckgo.common.ui.DuckDuckGoFragment
249-
import com.duckduckgo.common.ui.anim.AnimationResourceProvider
250249
import com.duckduckgo.common.ui.experiments.visual.store.ExperimentalThemingDataStore
251250
import com.duckduckgo.common.ui.store.BrowserAppTheme
252251
import com.duckduckgo.common.ui.tabs.SwipingTabsFeatureProvider
@@ -288,6 +287,7 @@ import com.duckduckgo.downloads.api.DownloadsFileActions
288287
import com.duckduckgo.downloads.api.FileDownloader
289288
import com.duckduckgo.downloads.api.FileDownloader.PendingFileDownload
290289
import com.duckduckgo.duckchat.api.DuckChat
290+
import com.duckduckgo.duckchat.api.inputscreen.BrowserAndInputScreenTransitionProvider
291291
import com.duckduckgo.duckchat.impl.inputscreen.ui.InputScreenActivity.Companion.QUERY
292292
import com.duckduckgo.duckchat.impl.inputscreen.ui.InputScreenActivity.Companion.TAB_ID
293293
import com.duckduckgo.duckchat.impl.inputscreen.ui.InputScreenActivityParams
@@ -574,6 +574,9 @@ class BrowserTabFragment :
574574
@Inject
575575
lateinit var omnibarTypeResolver: OmnibarTypeResolver
576576

577+
@Inject
578+
lateinit var browserAndInputScreenTransitionProvider: BrowserAndInputScreenTransitionProvider
579+
577580
/**
578581
* We use this to monitor whether the user was seeing the in-context Email Protection signup prompt
579582
* This is needed because the activity stack will be cleared if an external link is opened in our browser
@@ -1075,8 +1078,8 @@ class BrowserTabFragment :
10751078
requireContext(),
10761079
InputScreenActivityParams(query = query),
10771080
)
1078-
val enterTransition = AnimationResourceProvider.getSlideInFromTopFadeIn()
1079-
val exitTransition = AnimationResourceProvider.getSlideOutToBottomFadeOut()
1081+
val enterTransition = browserAndInputScreenTransitionProvider.getInputScreenEnterAnimation()
1082+
val exitTransition = browserAndInputScreenTransitionProvider.getBrowserExitAnimation()
10801083
val options = ActivityOptionsCompat.makeCustomAnimation(
10811084
requireActivity(),
10821085
enterTransition,

common/common-ui/src/main/java/com/duckduckgo/common/ui/anim/AnimationResourceProvider.kt

Lines changed: 0 additions & 59 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2025 DuckDuckGo
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.duckduckgo.duckchat.api.inputscreen
18+
19+
/**
20+
* Provides animation resources for activity transitions between browser and input screen.
21+
*/
22+
interface BrowserAndInputScreenTransitionProvider {
23+
24+
fun getBrowserEnterAnimation(): Int
25+
26+
fun getBrowserExitAnimation(): Int
27+
28+
fun getInputScreenEnterAnimation(): Int
29+
30+
fun getInputScreenExitAnimation(): Int
31+
}

common/common-ui/src/main/res/anim/slide_in_from_bottom_fade_in_overshoot.xml renamed to duckchat/duckchat-api/src/main/res/anim-v33/slide_in_from_bottom_fade_in_dark.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,18 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
18+
android:backdropColor="@color/background_background_dark"
19+
android:duration="@integer/slide_animation_duration_ms"
20+
android:showBackdrop="true">
2121

2222
<translate
2323
android:fromYDelta="56dp"
24+
android:interpolator="@anim/overshoot_interpolator_tension_1"
2425
android:toYDelta="0dp" />
2526

2627
<alpha
2728
android:fromAlpha="0.0"
29+
android:interpolator="@android:anim/decelerate_interpolator"
2830
android:toAlpha="1.0" />
2931

3032
</set>

common/common-ui/src/main/res/anim/slide_in_from_top_fade_in_overshoot.xml renamed to duckchat/duckchat-api/src/main/res/anim-v33/slide_in_from_bottom_fade_in_light.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,18 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
18+
android:backdropColor="@color/background_background_light"
19+
android:duration="@integer/slide_animation_duration_ms"
20+
android:showBackdrop="true">
2121

2222
<translate
23-
android:fromYDelta="-56dp"
23+
android:fromYDelta="56dp"
24+
android:interpolator="@anim/overshoot_interpolator_tension_1"
2425
android:toYDelta="0dp" />
2526

2627
<alpha
2728
android:fromAlpha="0.0"
29+
android:interpolator="@android:anim/decelerate_interpolator"
2830
android:toAlpha="1.0" />
2931

3032
</set>

common/common-ui/src/main/res/anim/slide_in_from_top_fade_in.xml renamed to duckchat/duckchat-api/src/main/res/anim-v33/slide_in_from_top_fade_in.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,16 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@android:anim/decelerate_interpolator">
18+
android:duration="@integer/slide_animation_duration_ms">
2119

2220
<translate
2321
android:fromYDelta="-56dp"
22+
android:interpolator="@anim/overshoot_interpolator_tension_1"
2423
android:toYDelta="0dp" />
2524

2625
<alpha
2726
android:fromAlpha="0.0"
27+
android:interpolator="@android:anim/decelerate_interpolator"
2828
android:toAlpha="1.0" />
2929

3030
</set>

common/common-ui/src/main/res/anim/slide_out_to_bottom_fade_out_overshoot.xml renamed to duckchat/duckchat-api/src/main/res/anim-v33/slide_out_to_bottom_fade_out_dark.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,18 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
18+
android:backdropColor="@color/background_background_dark"
19+
android:duration="@integer/slide_animation_duration_ms"
20+
android:showBackdrop="true">
2121

2222
<translate
2323
android:fromYDelta="0dp"
24+
android:interpolator="@anim/overshoot_interpolator_tension_1"
2425
android:toYDelta="56dp" />
2526

2627
<alpha
2728
android:fromAlpha="1.0"
29+
android:interpolator="@android:anim/decelerate_interpolator"
2830
android:toAlpha="0.0" />
2931

3032
</set>

common/common-ui/src/main/res/anim/slide_out_to_top_fade_out_overshoot.xml renamed to duckchat/duckchat-api/src/main/res/anim-v33/slide_out_to_bottom_fade_out_light.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,18 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
18+
android:backdropColor="@color/background_background_light"
19+
android:duration="@integer/slide_animation_duration_ms"
20+
android:showBackdrop="true">
2121

2222
<translate
2323
android:fromYDelta="0dp"
24-
android:toYDelta="-56dp" />
24+
android:interpolator="@anim/overshoot_interpolator_tension_1"
25+
android:toYDelta="56dp" />
2526

2627
<alpha
2728
android:fromAlpha="1.0"
29+
android:interpolator="@android:anim/decelerate_interpolator"
2830
android:toAlpha="0.0" />
2931

3032
</set>

common/common-ui/src/main/res/anim/slide_out_to_top_fade_out.xml renamed to duckchat/duckchat-api/src/main/res/anim-v33/slide_out_to_top_fade_out.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,16 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@android:anim/decelerate_interpolator">
18+
android:duration="@integer/slide_animation_duration_ms">
2119

2220
<translate
2321
android:fromYDelta="0dp"
22+
android:interpolator="@anim/overshoot_interpolator_tension_1"
2423
android:toYDelta="-56dp" />
2524

2625
<alpha
2726
android:fromAlpha="1.0"
27+
android:interpolator="@android:anim/decelerate_interpolator"
2828
android:toAlpha="0.0" />
2929

3030
</set>

common/common-ui/src/main/res/anim/slide_in_from_bottom_fade_in.xml renamed to duckchat/duckchat-api/src/main/res/anim/fade_in.xml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
1+
<?xml version="1.0" encoding="utf-8"?><!--
32
~ Copyright (c) 2025 DuckDuckGo
43
~
54
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +15,11 @@
1615
-->
1716

1817
<set xmlns:android="http://schemas.android.com/apk/res/android"
19-
android:duration="300"
20-
android:interpolator="@android:anim/decelerate_interpolator">
21-
22-
<translate
23-
android:fromYDelta="56dp"
24-
android:toYDelta="0dp" />
18+
android:duration="@integer/slide_animation_duration_ms">
2519

2620
<alpha
2721
android:fromAlpha="0.0"
22+
android:interpolator="@android:anim/decelerate_interpolator"
2823
android:toAlpha="1.0" />
2924

3025
</set>

0 commit comments

Comments
 (0)