android: Use androidx splash screen

This commit is contained in:
Charles Lombardo 2023-03-15 16:37:14 -04:00 committed by bunnei
parent 3fcc6b1104
commit 55e4c2d87b
4 changed files with 12 additions and 2 deletions

View File

@ -136,6 +136,7 @@ dependencies {
implementation 'androidx.preference:preference:1.2.0' implementation 'androidx.preference:preference:1.2.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
implementation "io.coil-kt:coil:2.2.2" implementation "io.coil-kt:coil:2.2.2"
implementation 'androidx.core:core-splashscreen:1.0.0'
// Allows FRP-style asynchronous operations in Android. // Allows FRP-style asynchronous operations in Android.
implementation 'io.reactivex:rxandroid:1.2.1' implementation 'io.reactivex:rxandroid:1.2.1'

View File

@ -32,7 +32,7 @@
<activity <activity
android:name="org.yuzu.yuzu_emu.ui.main.MainActivity" android:name="org.yuzu.yuzu_emu.ui.main.MainActivity"
android:exported="true" android:exported="true"
android:theme="@style/Theme.Yuzu.Main" android:theme="@style/Theme.Yuzu.Splash.Main"
android:resizeableActivity="false"> android:resizeableActivity="false">
<!-- This intentfilter marks this Activity as the one that gets launched from Home screen. --> <!-- This intentfilter marks this Activity as the one that gets launched from Home screen. -->

View File

@ -14,12 +14,12 @@ import android.widget.FrameLayout
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.color.MaterialColors
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.yuzu.yuzu_emu.NativeLibrary import org.yuzu.yuzu_emu.NativeLibrary
import org.yuzu.yuzu_emu.R import org.yuzu.yuzu_emu.R
@ -35,6 +35,9 @@ class MainActivity : AppCompatActivity(), MainView {
private val presenter = MainPresenter(this) private val presenter = MainPresenter(this)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
val splashScreen = installSplashScreen()
splashScreen.setKeepOnScreenCondition { !DirectoryInitialization.areDirectoriesReady() }
ThemeHelper.setTheme(this) ThemeHelper.setTheme(this)
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)

View File

@ -1,6 +1,12 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="Theme.Yuzu.Splash.Main" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/yuzu_surface</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_yuzu</item>
<item name="postSplashScreenTheme">@style/Theme.Yuzu.Main</item>
</style>
<style name="Theme.Yuzu" parent="Theme.Material3.DayNight.NoActionBar"> <style name="Theme.Yuzu" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/yuzu_primary</item> <item name="colorPrimary">@color/yuzu_primary</item>
<item name="colorOnPrimary">@color/yuzu_onPrimary</item> <item name="colorOnPrimary">@color/yuzu_onPrimary</item>