Skip to content
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

[FEAT] StatusBar 유틸 클래스 구현 및 적용 #58

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.depromeet.presentation.seatReview.dialog.DatePickerDialog
import com.depromeet.presentation.seatReview.dialog.ImageUploadDialog
import com.depromeet.presentation.seatReview.dialog.ReviewMySeatDialog
import com.depromeet.presentation.seatReview.dialog.SelectSeatDialog
import com.depromeet.presentation.util.Utils
import dagger.hilt.android.AndroidEntryPoint
import java.io.FileNotFoundException
import java.io.InputStream
Expand All @@ -53,6 +54,10 @@ class ReviewActivity : BaseActivity<ActivityReviewBinding>({

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Utils(this).apply {
setStatusBarColor(window, com.depromeet.designsystem.R.color.color_background_tertiary)
}

viewModel.getStadiumName()
observeStadiumName()
observePreSignedUrl()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package com.depromeet.presentation.util

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build
import android.view.View
import android.view.Window
import android.view.WindowInsetsController
import android.view.WindowManager
import androidx.annotation.ColorRes
import androidx.core.view.WindowCompat

object Utils {
fun restartApp(context: Context, toastMsg: String?) {
class Utils(
private val context: Context
) {
fun restartApp(toastMsg: String?) {
val packageManager = context.packageManager
val packageName = context.packageName
val componentName = packageManager.getLaunchIntentForPackage(packageName)?.component
Expand All @@ -14,4 +24,39 @@ object Utils {
}
Runtime.getRuntime().exit(0)
}

fun setStatusBarColor(
window: Window,
@ColorRes color: Int
) {
window.statusBarColor = context.getColor(color)
}

fun isStatusBarBlackIconColor(
window: Window
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.setSystemBarsAppearance(
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
)
} else {
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
}

fun isStatusBarWhiteIconColor(
window: Window
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.setSystemBarsAppearance(
0,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS
)
} else {

window.decorView.systemUiVisibility = 0
}
}
}
Loading