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:allowBackup="true"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:usesCleartextTraffic="true"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/NPSTheme"> android:theme="@style/NPSTheme"
<activity android:name=".activities.SplashActivity" android:theme="@style/NPSTheme.Splash" android:usesCleartextTraffic="true">
android:exported="true"> <activity
android:name=".activities.MainActivity"
android:configChanges="screenSize|screenLayout|keyboardHidden|orientation"
android:exported="true"
android:theme="@style/NPSTheme.Splash"
>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".activities.MainActivity"
android:configChanges="screenSize|screenLayout|keyboardHidden|orientation">
</activity>
</application> </application>
</manifest> </manifest>
@@ -2,6 +2,7 @@ package com.illusionware.npsbrowser.activities
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import com.illusionware.npsbrowser.R import com.illusionware.npsbrowser.R
import com.illusionware.npsbrowser.fragments.mainactivity.MainActivityFragment import com.illusionware.npsbrowser.fragments.mainactivity.MainActivityFragment
@@ -9,6 +10,8 @@ import com.illusionware.npsbrowser.fragments.mainactivity.MainActivityFragment
class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener { class MainActivity : BaseActivity(), FragmentManager.OnBackStackChangedListener {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setTheme(R.style.NPSTheme) setTheme(R.style.NPSTheme)
setContentView(R.layout.activity_main) 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:fontFamily="sans-serif-light"
android:gravity="center" android:gravity="center"
android:textAlignment="center" android:textAlignment="center"
android:textColor="@color/colorAccent" android:textColor="@color/colorError"
android:textSize="24sp" android:textSize="24sp"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
+1 -1
View File
@@ -7,5 +7,5 @@
<color name="colorSecondaryDark">#515151</color> <color name="colorSecondaryDark">#515151</color>
<color name="colorOnSecondary">#DFFFFFFF</color> <color name="colorOnSecondary">#DFFFFFFF</color>
<color name="colorAmoled">#000000</color> <color name="colorAmoled">#000000</color>
<color name="colorAccent">#F93422</color> <color name="colorError">#F93422</color>
</resources> </resources>
+2 -1
View File
@@ -7,5 +7,6 @@
<color name="colorSecondaryDark">#888888</color> <color name="colorSecondaryDark">#888888</color>
<color name="colorOnSecondary">#111111</color> <color name="colorOnSecondary">#111111</color>
<color name="colorAmoled">#FFFFFF</color> <color name="colorAmoled">#FFFFFF</color>
<color name="colorAccent">#F93422</color> <color name="colorError">#F93422</color>
<color name="colorAccent">#545FBF</color>
</resources> </resources>
+1
View File
@@ -31,4 +31,5 @@
<item>List</item> <item>List</item>
<item>Grid</item> <item>Grid</item>
</string-array> </string-array>
<string name="title_activity_thing">thing</string>
</resources> </resources>
+7 -3
View File
@@ -30,9 +30,13 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="NPSTheme.Splash" parent="NPSTheme"> <style name="NPSTheme.Splash" parent="Theme.SplashScreen">
<item name="android:statusBarColor">#FF00A7FF</item> <item name="windowSplashScreenBackground">@color/colorAccent</item>
<item name="android:windowBackground">@drawable/splash</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_nps_fg_no_shadow</item>
<item name="windowSplashScreenAnimationDuration">500</item>
<item name="postSplashScreenTheme">@style/NPSTheme</item>
</style> </style>
<style name="NPSTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="NPSTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />