refactor: switch to SplashScreen API

This commit is contained in:
2023-06-17 04:29:29 +03:00
parent c6b7df23ed
commit 759f584a67
8 changed files with 74 additions and 98 deletions
+9 -7
View File
@@ -10,20 +10,22 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/NPSTheme">
<activity android:name=".activities.SplashActivity" android:theme="@style/NPSTheme.Splash"
android:exported="true">
android:theme="@style/NPSTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".activities.MainActivity"
android:configChanges="screenSize|screenLayout|keyboardHidden|orientation"
android:exported="true"
android:theme="@style/NPSTheme.Splash"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".activities.MainActivity"
android:configChanges="screenSize|screenLayout|keyboardHidden|orientation">
</activity>
</application>
</manifest>
@@ -2,6 +2,7 @@ package com.illusionware.npsbrowser.activities
import android.os.Bundle
import android.view.MenuItem
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.fragment.app.FragmentManager
import com.illusionware.npsbrowser.R
import com.illusionware.npsbrowser.fragments.mainactivity.MainActivityFragment
@@ -9,6 +10,8 @@ import com.illusionware.npsbrowser.fragments.mainactivity.MainActivityFragment
class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
setTheme(R.style.NPSTheme)
setContentView(R.layout.activity_main)
@@ -1,35 +0,0 @@
package com.illusionware.npsbrowser.activities
import android.content.Intent
import android.os.Bundle
import android.view.View
class SplashActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startActivity(Intent(this, MainActivity::class.java))
finish()
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) hideSystemUI()
}
private fun hideSystemUI() {
// Enables regular immersive mode.
// For "lean back" mode, remove SYSTEM_UI_FLAG_IMMERSIVE.
// Or for "sticky immersive," replace it with SYSTEM_UI_FLAG_IMMERSIVE_STICKY
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE
// Set the content to appear under the system bars so that the
// content doesn't resize when the system bars hide and show.
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Hide the nav bar and status bar
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
}
@@ -13,7 +13,7 @@
android:fontFamily="sans-serif-light"
android:gravity="center"
android:textAlignment="center"
android:textColor="@color/colorAccent"
android:textColor="@color/colorError"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
+1 -1
View File
@@ -7,5 +7,5 @@
<color name="colorSecondaryDark">#515151</color>
<color name="colorOnSecondary">#DFFFFFFF</color>
<color name="colorAmoled">#000000</color>
<color name="colorAccent">#F93422</color>
<color name="colorError">#F93422</color>
</resources>
+2 -1
View File
@@ -7,5 +7,6 @@
<color name="colorSecondaryDark">#888888</color>
<color name="colorOnSecondary">#111111</color>
<color name="colorAmoled">#FFFFFF</color>
<color name="colorAccent">#F93422</color>
<color name="colorError">#F93422</color>
<color name="colorAccent">#545FBF</color>
</resources>
+30 -29
View File
@@ -1,34 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">NPS Browser</string>
<string name="title_activity_settings">Settings</string>
<string name="search">Search</string>
<string name="download">Download</string>
<string name="copy_zrif">Copy zRIF</string>
<string name="content_id">Content ID</string>
<string name="size">Size</string>
<string name="minfw">Minimum Firmware Version</string>
<string name="single_app_icon">Single app icon</string>
<string name="no_license">Warning: No license was provided for this content.</string>
<string name="cart_only">CART ONLY GAME</string>
<string name="no_download_link">Warning: No download link was provided for this content.</string>
<string name="downloading">Downloading...</string>
<string name="download_error">An error occurred while downloading. please try again</string>
<string name="pkg_url_copied">PKG URL Copied to Clipboard</string>
<string name="zrif_copied">zRIF Copied to Clipboard</string>
<string name="content_id_copied">Content ID Copied to Clipboard</string>
<string name="appearance">Appearance</string>
<string name="theme">Theme</string>
<string name="layout">Layout</string>
<string name="app_name">NPS Browser</string>
<string name="title_activity_settings">Settings</string>
<string name="search">Search</string>
<string name="download">Download</string>
<string name="copy_zrif">Copy zRIF</string>
<string name="content_id">Content ID</string>
<string name="size">Size</string>
<string name="minfw">Minimum Firmware Version</string>
<string name="single_app_icon">Single app icon</string>
<string name="no_license">Warning: No license was provided for this content.</string>
<string name="cart_only">CART ONLY GAME</string>
<string name="no_download_link">Warning: No download link was provided for this content.</string>
<string name="downloading">Downloading...</string>
<string name="download_error">An error occurred while downloading. please try again</string>
<string name="pkg_url_copied">PKG URL Copied to Clipboard</string>
<string name="zrif_copied">zRIF Copied to Clipboard</string>
<string name="content_id_copied">Content ID Copied to Clipboard</string>
<string name="appearance">Appearance</string>
<string name="theme">Theme</string>
<string name="layout">Layout</string>
<string-array name="app_theme">
<item>Light</item>
<item>Dark</item>
<item>Use System Default</item>
</string-array>
<string-array name="app_theme">
<item>Light</item>
<item>Dark</item>
<item>Use System Default</item>
</string-array>
<string-array name="layout_type">
<item>List</item>
<item>Grid</item>
</string-array>
<string-array name="layout_type">
<item>List</item>
<item>Grid</item>
</string-array>
<string name="title_activity_thing">thing</string>
</resources>
+7 -3
View File
@@ -30,9 +30,13 @@
<item name="windowNoTitle">true</item>
</style>
<style name="NPSTheme.Splash" parent="NPSTheme">
<item name="android:statusBarColor">#FF00A7FF</item>
<item name="android:windowBackground">@drawable/splash</item>
<style name="NPSTheme.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/colorAccent</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_nps_fg_no_shadow</item>
<item name="windowSplashScreenAnimationDuration">500</item>
<item name="postSplashScreenTheme">@style/NPSTheme</item>
</style>
<style name="NPSTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />