-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
로띠 스플래시 액티비티 추가 #231
로띠 스플래시 액티비티 추가 #231
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,19 +11,14 @@ import android.widget.Toast | |
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import androidx.activity.viewModels | ||
import androidx.compose.runtime.collectAsState | ||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen | ||
import com.mashup.dorabangs.core.designsystem.theme.DorabangsTheme | ||
import com.mashup.dorabangs.navigation.DoraApp | ||
import com.mashup.dorabangs.splash.FirstEntryScreen | ||
import com.mashup.dorabangs.splash.SplashViewModel | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class MainActivity : ComponentActivity() { | ||
|
||
private val splashViewModel: SplashViewModel by viewModels() | ||
private val overlayPermissionLauncher = | ||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { | ||
if (!Settings.canDrawOverlays(this)) { | ||
|
@@ -36,32 +31,24 @@ class MainActivity : ComponentActivity() { | |
super.onCreate(savedInstanceState) | ||
checkPermission() | ||
|
||
val userId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID) | ||
splashViewModel.checkUserToken(userId) | ||
|
||
val firstEntryScreen = intent.getStringExtra("firstEntry") | ||
val url = intent.data?.path?.substring(1).orEmpty() | ||
|
||
installSplashScreen().apply { | ||
setKeepOnScreenCondition { | ||
(splashViewModel.isSplashShow.value || splashViewModel.firstEntryScreen.value == FirstEntryScreen.Splash) && | ||
url.isBlank() | ||
} | ||
} | ||
|
||
setContent { | ||
val firstEntryScreen = splashViewModel.firstEntryScreen.collectAsState() | ||
if (firstEntryScreen.value != FirstEntryScreen.Splash) { | ||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager | ||
firstEntryScreen?.let { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 firstEntryScreen null인 케이스가 있음? 있다면 빈 화면만 나올 것 같은뎅 |
||
if (firstEntryScreen != FirstEntryScreen.Splash.name) { | ||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager | ||
|
||
DorabangsTheme { | ||
DoraApp( | ||
isFirstEntry = firstEntryScreen.value == FirstEntryScreen.Onboarding, | ||
hideKeyboardAction = { | ||
currentFocus?.let { | ||
imm?.hideSoftInputFromWindow(it.windowToken, 0) | ||
} | ||
}, | ||
) | ||
DorabangsTheme { | ||
DoraApp( | ||
isFirstEntry = firstEntryScreen == FirstEntryScreen.Onboarding.name, | ||
hideKeyboardAction = { | ||
currentFocus?.let { | ||
imm?.hideSoftInputFromWindow(it.windowToken, 0) | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.mashup.dorabangs.splash | ||
|
||
import android.annotation.SuppressLint | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.provider.Settings | ||
import androidx.activity.ComponentActivity | ||
import androidx.activity.compose.setContent | ||
import androidx.activity.viewModels | ||
import androidx.compose.runtime.collectAsState | ||
import com.mashup.dorabangs.MainActivity | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@SuppressLint("CustomSplashScreen") | ||
@AndroidEntryPoint | ||
class SplashActivity : ComponentActivity() { | ||
private val splashViewModel: SplashViewModel by viewModels() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
val userId = Settings.Secure.getString(contentResolver, Settings.Secure.ANDROID_ID) | ||
splashViewModel.checkUserToken(userId) | ||
|
||
val url = intent.data?.path?.substring(1).orEmpty() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 쓰는데가 없는뎅 ?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 웅 그래서 지우려고햇는데,, 기존에 main에 있떤 코드여서 위에서 물어본건데 아무도 모르면 |
||
|
||
setContent { | ||
SplashScreen() | ||
|
||
val firstEntryScreen = splashViewModel.firstEntryScreen.collectAsState() | ||
if (firstEntryScreen.value != FirstEntryScreen.Splash) { | ||
val intent = Intent(this, MainActivity::class.java) | ||
intent.putExtra("firstEntry", firstEntryScreen.value.name) | ||
startActivity(intent) | ||
finish() | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.mashup.dorabangs.splash | ||
|
||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.unit.dp | ||
import com.mashup.dorabangs.core.designsystem.component.util.LottieLoader | ||
import com.mashup.dorabangs.core.designsystem.R as coreR | ||
|
||
@Composable | ||
fun SplashScreen() { | ||
Box(modifier = Modifier.fillMaxSize()) { | ||
LottieLoader( | ||
lottieRes = coreR.raw.splash, | ||
modifier = Modifier.align(Alignment.Center).size(126.dp), | ||
) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,11 @@ import com.mashup.dorabangs.domain.usecase.user.GetUserAccessTokenUseCase | |
import com.mashup.dorabangs.domain.usecase.user.RegisterUserUseCase | ||
import com.mashup.dorabangs.domain.usecase.user.SetUserAccessTokenUseCase | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.coroutines.flow.asStateFlow | ||
import kotlinx.coroutines.flow.firstOrNull | ||
import kotlinx.coroutines.withTimeout | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
|
@@ -40,19 +40,18 @@ class SplashViewModel @Inject constructor( | |
token | ||
}.orEmpty() | ||
|
||
withTimeout(SPLASH_SCREEN_TIME) { | ||
if (userAccessToken.isNotEmpty()) { | ||
splashShowFlow.value = false | ||
_firstEntryScreen.value = if (getIsFirstEntryUseCase().firstOrNull() != false) FirstEntryScreen.Onboarding else FirstEntryScreen.Home | ||
} else { | ||
// Todo :: 유저 토큰 가져오기 실패에 대한 처리 해줘야함 (Like 토스트 메시지) | ||
} | ||
if (userAccessToken.isNotEmpty()) { | ||
delay(SPLASH_SCREEN_TIME) | ||
splashShowFlow.value = false | ||
_firstEntryScreen.value = if (getIsFirstEntryUseCase().firstOrNull() != false) FirstEntryScreen.Onboarding else FirstEntryScreen.Home | ||
} else { | ||
// Todo :: 유저 토큰 가져오기 실패에 대한 처리 해줘야함 (Like 토스트 메시지) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거도 같이할 생각 없나~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅋㅋ이건 호현오빠한테 토스~ |
||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private const val SPLASH_SCREEN_TIME = 1000L | ||
private const val SPLASH_SCREEN_TIME = 3000L | ||
} | ||
} | ||
|
||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import com.mashup.dorabangs.domain.model.Folder | |
import com.mashup.dorabangs.domain.utils.isValidUrl | ||
|
||
data class HomeState( | ||
val isLoading: Boolean = false, | ||
val isLoading: Boolean = true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why??? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. false로 했더니 액티비티 전환 시 컴포저블 보이고 로딩 도는 이슈가 있어서 바꿨므당 |
||
val isScrollLoading: Boolean = false, | ||
val clipBoardState: ClipBoardState = ClipBoardState(), | ||
val tapElements: List<FeedUiModel.DoraChipUiModel> = emptyList(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 기존에 url받아와서 그냥 비어있는지만 체크하던데,,무슨 기능인지 아는사람?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
나는 몰라!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스플래시 만든 사람이 모르면 우리도 몰라 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ddyeon @Ahn-seokjoo
억울하오 억울하오