Skip to content

Commit

Permalink
Merge pull request #58 from depromeet/feat/#57-status-bar
Browse files Browse the repository at this point in the history
[FEAT] StatusBar 유틸 클래스 구현 및 적용
  • Loading branch information
Jokwanhee authored Aug 3, 2024
2 parents b504dac + ea53bd9 commit 281bb74
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
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
}
}
}

0 comments on commit 281bb74

Please sign in to comment.