feat: Add splashscreen
This commit is contained in:
parent
61ca940b52
commit
d2f8b75267
|
@ -45,4 +45,6 @@ dependencies {
|
|||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
||||
implementation("androidx.core:core-splashscreen:1.0.1")
|
||||
}
|
|
@ -14,10 +14,10 @@
|
|||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.NeatCalendar.Splash">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
|
|
@ -3,14 +3,29 @@ package com.p_vacho.neat_calendar
|
|||
import android.os.Bundle
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// Attach the splash screen to the activity before initialization begins
|
||||
// (before super.onCreate) to make it show up during the activity init.
|
||||
val splashScreen = installSplashScreen()
|
||||
|
||||
// Keep the splash screen visible until initialization is complete
|
||||
splashScreen.setKeepOnScreenCondition {
|
||||
// TODO: Once implemented, make sure keep the splashscreen on until
|
||||
// all of the necessary data are obtained from the API, for now,
|
||||
// no initialization delay is needed.
|
||||
false
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
enableEdgeToEdge()
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
// Handle window insets for proper layout adjustment
|
||||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
|
||||
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
|
||||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
|
||||
|
|
16
app/src/main/res/drawable/ic_splash_icon.xml
Normal file
16
app/src/main/res/drawable/ic_splash_icon.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960">
|
||||
|
||||
<group
|
||||
android:pivotX="512"
|
||||
android:pivotY="512"
|
||||
android:scaleX="0.50"
|
||||
android:scaleY="0.50">
|
||||
<path
|
||||
android:pathData="M200,880q-33,0 -56.5,-23.5T120,800v-560q0,-33 23.5,-56.5T200,160h40v-80h80v80h320v-80h80v80h40q33,0 56.5,23.5T840,240v560q0,33 -23.5,56.5T760,880L200,880ZM200,800h560v-400L200,400v400ZM200,320h560v-80L200,240v80ZM200,320v-80,80ZM480,560q-17,0 -28.5,-11.5T440,520q0,-17 11.5,-28.5T480,480q17,0 28.5,11.5T520,520q0,17 -11.5,28.5T480,560ZM320,560q-17,0 -28.5,-11.5T280,520q0,-17 11.5,-28.5T320,480q17,0 28.5,11.5T360,520q0,17 -11.5,28.5T320,560ZM640,560q-17,0 -28.5,-11.5T600,520q0,-17 11.5,-28.5T640,480q17,0 28.5,11.5T680,520q0,17 -11.5,28.5T640,560ZM480,720q-17,0 -28.5,-11.5T440,680q0,-17 11.5,-28.5T480,640q17,0 28.5,11.5T520,680q0,17 -11.5,28.5T480,720ZM320,720q-17,0 -28.5,-11.5T280,680q0,-17 11.5,-28.5T320,640q17,0 28.5,11.5T360,680q0,17 -11.5,28.5T320,720ZM640,720q-17,0 -28.5,-11.5T600,680q0,-17 11.5,-28.5T640,640q17,0 28.5,11.5T680,680q0,17 -11.5,28.5T640,720Z"
|
||||
android:fillColor="#e8eaed"/>
|
||||
</group>
|
||||
</vector>
|
|
@ -2,6 +2,12 @@
|
|||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.NeatCalendar" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your dark theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
|
||||
</style>
|
||||
|
||||
<!-- Splash Screen Theme -->
|
||||
<style name="Theme.NeatCalendar.Splash" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenBackground">@color/splash_dark_background</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash_icon</item>
|
||||
<item name="postSplashScreenTheme">@style/Theme.NeatCalendar</item>
|
||||
</style>
|
||||
</resources>
|
|
@ -2,4 +2,7 @@
|
|||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
|
||||
<color name="splash_light_background">#F5F5F5</color> <!-- Light gray -->
|
||||
<color name="splash_dark_background">#121212</color> <!-- Dark gray -->
|
||||
</resources>
|
|
@ -2,8 +2,14 @@
|
|||
<!-- Base application theme. -->
|
||||
<style name="Base.Theme.NeatCalendar" parent="Theme.Material3.DayNight.NoActionBar">
|
||||
<!-- Customize your light theme here. -->
|
||||
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
|
||||
</style>
|
||||
|
||||
<style name="Theme.NeatCalendar" parent="Base.Theme.NeatCalendar" />
|
||||
</resources>
|
||||
|
||||
<!-- Splash Screen Theme -->
|
||||
<style name="Theme.NeatCalendar.Splash" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenBackground">@color/splash_light_background</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_splash_icon</item>
|
||||
<item name="postSplashScreenTheme">@style/Theme.NeatCalendar</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue