Skip to content

Commit 138307e

Browse files
authored
add OS version check for Input Screen overshoot alpha transitions (#6404)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1210786203196179?focus=true ### Description Only uses the overshoot interpolator on newer Android version to avoid an issue where alpha channel is zero (or generally cause a black screen for a split second) when the interpolation goes over the <0.0, 1.0> bounds. I'm also noticing that translation transition is not available at all on Android versions < 31, at least based on emulator testing, but leaving it in doesn't seem to cause any other issue. ### Steps to test this PR - [x] Try the Input Screen transitions on a device with API >= 34 - [x] Try the Input Screen transitions on a device with API < 34
1 parent 285732b commit 138307e

File tree

11 files changed

+195
-11
lines changed

11 files changed

+195
-11
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ import com.duckduckgo.browser.api.ui.BrowserScreens.PrivateSearchScreenNoParams
245245
import com.duckduckgo.browser.api.ui.BrowserScreens.WebViewActivityWithParams
246246
import com.duckduckgo.common.ui.DuckDuckGoActivity
247247
import com.duckduckgo.common.ui.DuckDuckGoFragment
248+
import com.duckduckgo.common.ui.anim.AnimationResourceProvider
248249
import com.duckduckgo.common.ui.experiments.visual.store.ExperimentalThemingDataStore
249250
import com.duckduckgo.common.ui.store.BrowserAppTheme
250251
import com.duckduckgo.common.ui.tabs.SwipingTabsFeatureProvider
@@ -1059,10 +1060,12 @@ class BrowserTabFragment :
10591060
requireContext(),
10601061
InputScreenActivityParams(query = query),
10611062
)
1063+
val enterTransition = AnimationResourceProvider.getSlideInFromTopFadeIn()
1064+
val exitTransition = AnimationResourceProvider.getSlideOutToBottomFadeOut()
10621065
val options = ActivityOptionsCompat.makeCustomAnimation(
10631066
requireActivity(),
1064-
CommonR.anim.slide_in_from_top_fade_in,
1065-
CommonR.anim.slide_out_to_bottom_fade_out,
1067+
enterTransition,
1068+
exitTransition,
10661069
)
10671070
searchInterstitialLauncher.launch(intent, options)
10681071
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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.common.ui.anim
18+
19+
import android.os.Build.VERSION
20+
import com.duckduckgo.mobile.android.R
21+
22+
object AnimationResourceProvider {
23+
24+
// The overshoot alpha transition can result in a black screen flash on older Android devices,
25+
// so we use the standard decelerate transition instead for these cases in the provider functions below.
26+
// The check is for version 34, as that's the range of devices on which we tested and confirmed that it works.
27+
28+
fun getSlideInFromBottomFadeIn(): Int {
29+
return if (VERSION.SDK_INT >= 34) {
30+
R.anim.slide_in_from_bottom_fade_in_overshoot
31+
} else {
32+
R.anim.slide_in_from_bottom_fade_in
33+
}
34+
}
35+
36+
fun getSlideOutToTopFadeOut(): Int {
37+
return if (VERSION.SDK_INT >= 34) {
38+
R.anim.slide_out_to_top_fade_out_overshoot
39+
} else {
40+
R.anim.slide_out_to_top_fade_out
41+
}
42+
}
43+
44+
fun getSlideInFromTopFadeIn(): Int {
45+
return if (VERSION.SDK_INT >= 34) {
46+
R.anim.slide_in_from_top_fade_in_overshoot
47+
} else {
48+
R.anim.slide_in_from_top_fade_in
49+
}
50+
}
51+
52+
fun getSlideOutToBottomFadeOut(): Int {
53+
return if (VERSION.SDK_INT >= 34) {
54+
R.anim.slide_out_to_bottom_fade_out_overshoot
55+
} else {
56+
R.anim.slide_out_to_bottom_fade_out
57+
}
58+
}
59+
}

common/common-ui/src/main/res/anim/slide_in_from_bottom_fade_in.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<set xmlns:android="http://schemas.android.com/apk/res/android"
1919
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
20+
android:interpolator="@android:anim/decelerate_interpolator">
2121

2222
<translate
2323
android:fromYDelta="56dp"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2025 DuckDuckGo
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:duration="300"
20+
android:interpolator="@anim/overshoot_interpolator_tension_1">
21+
22+
<translate
23+
android:fromYDelta="56dp"
24+
android:toYDelta="0dp" />
25+
26+
<alpha
27+
android:fromAlpha="0.0"
28+
android:toAlpha="1.0" />
29+
30+
</set>

common/common-ui/src/main/res/anim/slide_in_from_top_fade_in.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<set xmlns:android="http://schemas.android.com/apk/res/android"
1919
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
20+
android:interpolator="@android:anim/decelerate_interpolator">
2121

2222
<translate
2323
android:fromYDelta="-56dp"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2025 DuckDuckGo
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:duration="300"
20+
android:interpolator="@anim/overshoot_interpolator_tension_1">
21+
22+
<translate
23+
android:fromYDelta="-56dp"
24+
android:toYDelta="0dp" />
25+
26+
<alpha
27+
android:fromAlpha="0.0"
28+
android:toAlpha="1.0" />
29+
30+
</set>

common/common-ui/src/main/res/anim/slide_out_to_bottom_fade_out.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<set xmlns:android="http://schemas.android.com/apk/res/android"
1919
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
20+
android:interpolator="@android:anim/decelerate_interpolator">
2121

2222
<translate
2323
android:fromYDelta="0dp"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2025 DuckDuckGo
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:duration="300"
20+
android:interpolator="@anim/overshoot_interpolator_tension_1">
21+
22+
<translate
23+
android:fromYDelta="0dp"
24+
android:toYDelta="56dp" />
25+
26+
<alpha
27+
android:fromAlpha="1.0"
28+
android:toAlpha="0.0" />
29+
30+
</set>

common/common-ui/src/main/res/anim/slide_out_to_top_fade_out.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<set xmlns:android="http://schemas.android.com/apk/res/android"
1919
android:duration="300"
20-
android:interpolator="@anim/overshoot_interpolator_tension_1">
20+
android:interpolator="@android:anim/decelerate_interpolator">
2121

2222
<translate
2323
android:fromYDelta="0dp"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) 2025 DuckDuckGo
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<set xmlns:android="http://schemas.android.com/apk/res/android"
19+
android:duration="300"
20+
android:interpolator="@anim/overshoot_interpolator_tension_1">
21+
22+
<translate
23+
android:fromYDelta="0dp"
24+
android:toYDelta="-56dp" />
25+
26+
<alpha
27+
android:fromAlpha="1.0"
28+
android:toAlpha="0.0" />
29+
30+
</set>

0 commit comments

Comments
 (0)