Skip to content

Commit

Permalink
[Feat/#88] Custom Splash 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
yeoncheong committed Jul 20, 2023
1 parent b721d90 commit 13ab018
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 11 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,7 @@ dependencies {

// EncryptedSharedPreferences
implementation "androidx.security:security-crypto:1.0.0"

// Splash
implementation 'androidx.core:core-splashscreen:1.0.0'
}
18 changes: 10 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,16 @@
</intent-filter>
</activity>
<activity
android:name=".presentation.splash.OnboardingActivity"
android:exported="false"
android:screenOrientation="portrait" />
android:name=".presentation.splash.SplashActivity"
android:theme="@style/Theme.Umbbaandroid.Splash"
android:exported="true"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".presentation.onboarding.CommunicationActivity"
android:exported="false"
Expand Down Expand Up @@ -72,11 +79,6 @@
android:name=".presentation.MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
package com.sopt.umbba_android.presentation.splash

import android.content.Intent
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.lifecycleScope
import coil.ImageLoader
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder
import coil.load
import com.sopt.umbba_android.R
import com.sopt.umbba_android.databinding.ActivityOnboardingBinding
import com.sopt.umbba_android.databinding.ActivitySplashBinding
import com.sopt.umbba_android.presentation.login.LoginActivity
import com.sopt.umbba_android.util.binding.BindingActivity
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class OnboardingActivity : BindingActivity<ActivityOnboardingBinding>(R.layout.activity_onboarding) {
class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_splash) {
override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)

initLogoGif()
loadSplashScreen()
}

private fun initLogoGif() {
Expand All @@ -29,4 +37,16 @@ class OnboardingActivity : BindingActivity<ActivityOnboardingBinding>(R.layout.a

binding.ivLogoGif.load(R.raw.splash_logo, imageLoader = imageLoader)
}

private fun loadSplashScreen() {
lifecycleScope.launch {
delay(1500L)
goLoginActivity()
}
}

private fun goLoginActivity() {
startActivity(Intent(this, LoginActivity::class.java).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".presentation.splash.OnboardingActivity">
android:background="@color/umbba_white"
tools:context=".presentation.splash.SplashActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
<item name="colorPrimaryVariant">@color/primary_500</item>
<item name="colorOnPrimary">@color/primary_600</item>
</style>
<style name="Theme.Umbbaandroid.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@android:color/transparent</item>
<item name="windowSplashScreenAnimatedIcon">@android:color/transparent</item>
<item name="postSplashScreenTheme">@style/Base.Theme.Umbbaandroid</item>
</style>
<style name="Theme.Umbbaandroid" parent="Base.Theme.Umbbaandroid" />
</resources>

0 comments on commit 13ab018

Please sign in to comment.