Bug 1839522 – added splash screen compat implementation, tied extra duration to the experiment

fenix/116.0
mike a 11 months ago committed by mergify[bot]
parent 437b188fe8
commit 9deabdfa42

@ -607,6 +607,7 @@ dependencies {
implementation ComponentsDependencies.androidx_lifecycle_viewmodel
implementation ComponentsDependencies.androidx_core
implementation ComponentsDependencies.androidx_core_ktx
implementation FenixDependencies.androidx_core_splashscreen
implementation FenixDependencies.androidx_transition
implementation ComponentsDependencies.androidx_work_runtime
implementation FenixDependencies.androidx_datastore

@ -99,6 +99,7 @@
<activity
android:name=".HomeActivity"
android:theme="@style/SplashScreen"
android:exported="true"
android:configChanges="keyboard|keyboardHidden|mcc|mnc|orientation|screenSize|layoutDirection|smallestScreenSize|screenLayout"
android:launchMode="singleTask"

@ -33,6 +33,7 @@ import androidx.annotation.VisibleForTesting.Companion.PROTECTED
import androidx.appcompat.app.ActionBar
import androidx.appcompat.widget.Toolbar
import androidx.core.app.NotificationManagerCompat
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavDestination
import androidx.navigation.NavDirections
@ -43,6 +44,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.Job
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import mozilla.appservices.places.BookmarkRoot
@ -229,6 +231,8 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
components.strictMode.attachListenerToDisablePenaltyDeath(supportFragmentManager)
MarkersFragmentLifecycleCallbacks.register(supportFragmentManager, components.core.engine)
maybeShowSplashScreen()
// There is disk read violations on some devices such as samsung and pixel for android 9/10
components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
// Theme setup should always be called before super.onCreate
@ -411,6 +415,29 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
}
}
private fun maybeShowSplashScreen() {
if (components.settings.isFirstSplashScreenShown) {
return
} else {
components.settings.isFirstSplashScreenShown = true
// Splash screen compat fails to draw icons on earlier versions.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
return
}
}
if (FxNimbus.features.splashScreen.value().enabled) {
val splashScreen = installSplashScreen()
var keepSplashOnScreen = true
val delay = FxNimbus.features.splashScreen.value().maximumDurationMs.toLong()
splashScreen.setKeepOnScreenCondition { keepSplashOnScreen }
MainScope().launch {
delay(timeMillis = delay)
keepSplashOnScreen = false
}
}
}
private fun checkAndExitPiP() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && isInPictureInPictureMode && intent != null) {
// Exit PiP mode

@ -435,6 +435,11 @@ class Settings(private val appContext: Context) : PreferencesHolder {
default = true,
)
var isFirstSplashScreenShown: Boolean by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_is_first_splash_screen_shown),
default = false,
)
var nimbusLastFetchTime: Long by longPreference(
appContext.getPreferenceKey(R.string.pref_key_nimbus_last_fetch),
default = 0L,

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@mipmap/ic_launcher_round"
android:width="160dp"
android:height="160dp"
android:gravity="center" />
</layer-list>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_launcher_foreground" />
</layer-list>

@ -3,6 +3,12 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources>
<style name="SplashScreen" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/fx_mobile_layer_color_1</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<item name="postSplashScreenTheme">@style/NormalTheme</item>
</style>
<style name="DialogStyleNormal" parent="DialogStyleDark"/>
<style name="NormalTheme" parent="NormalThemeBase" >

@ -71,6 +71,7 @@
<string name="pref_key_re_engagement_notification_shown" translatable="false">pref_key_re_engagement_notification_shown</string>
<string name="pref_key_re_engagement_notification_enabled" translatable="false">pref_key_re_engagement_notification_enabled</string>
<string name="pref_key_is_first_run" translatable="false">pref_key_is_first_run</string>
<string name="pref_key_is_first_splash_screen_shown" translatable="false">pref_key_is_first_splash_screen_shown</string>
<string name="pref_key_nimbus_last_fetch" translatable="false">pref_key_nimbus_last_fetch</string>
<string name="pref_key_home_blocklist">pref_key_home_blocklist</string>

@ -4,6 +4,13 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="SplashScreen" parent="Theme.SplashScreen.IconBackground">
<item name="windowSplashScreenBackground">@color/fx_mobile_layer_color_1</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_screen</item>
<item name="windowSplashScreenIconBackgroundColor">@color/ic_launcher_background</item>
<item name="postSplashScreenTheme">@style/NormalTheme</item>
</style>
<style name="NormalThemeBase" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
<!-- Android system styling -->
<item name="searchViewStyle">@style/SearchViewStyle</item>

@ -24,6 +24,7 @@ object FenixVersions {
const val androidx_legacy = "1.0.0"
const val androidx_lifecycle = "2.6.1"
const val androidx_navigation = "2.5.3"
const val androidx_splash_screen = "1.0.1"
const val androidx_paging = "3.1.1"
const val androidx_transition = "1.4.1"
const val androidx_datastore = "1.0.0"
@ -54,6 +55,7 @@ object FenixDependencies {
const val androidx_benchmark_junit4 = "androidx.benchmark:benchmark-junit4:${FenixVersions.androidx_benchmark}"
const val androidx_benchmark_macro_junit4 = "androidx.benchmark:benchmark-macro-junit4:${FenixVersions.androidx_benchmark}"
const val androidx_core_splashscreen = "androidx.core:core-splashscreen:${FenixVersions.androidx_splash_screen}"
const val androidx_profileinstaller = "androidx.profileinstaller:profileinstaller:${FenixVersions.androidx_profileinstaller}"
const val androidx_activity_ktx = "androidx.activity:activity-ktx:${FenixVersions.androidx_activity}"
const val androidx_legacy = "androidx.legacy:legacy-support-v4:${FenixVersions.androidx_legacy}"

Loading…
Cancel
Save