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

#22 [fix] 투명 상태바 적용 #24

Merged
merged 7 commits into from
Jan 10, 2024
41 changes: 41 additions & 0 deletions app/src/main/java/com/sopetit/softie/SoftieApplication.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.sopetit.softie

import android.app.Activity
import android.app.Application
import android.os.Bundle
import android.view.Window
import android.view.WindowManager
import androidx.appcompat.app.AppCompatDelegate
import dagger.hilt.android.HiltAndroidApp
import timber.log.Timber
Expand All @@ -12,5 +16,42 @@ class SoftieApplication : Application() {
if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())

AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
setStatusBarTransparent()
}

private fun setStatusBarTransparent() {
registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
applyWindowFlags(activity.window)
}

override fun onActivityStarted(activity: Activity) { // TODO("Not yet implemented")
}

override fun onActivityResumed(activity: Activity) { // TODO("Not yet implemented")
}

override fun onActivityPaused(activity: Activity) { // TODO("Not yet implemented")
}

override fun onActivityStopped(activity: Activity) { // TODO("Not yet implemented")
}

override fun onActivitySaveInstanceState(
activity: Activity,
outState: Bundle
) { // TODO("Not yet implemented")
}

override fun onActivityDestroyed(activity: Activity) { // TODO("Not yet implemented")
}
})
}

private fun applyWindowFlags(window: Window) {
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.sopetit.softie.ui.onboarding

import android.os.Bundle
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.sopetit.softie.R
import com.sopetit.softie.databinding.ActivityOnboardingBinding
Expand All @@ -20,15 +19,10 @@ class OnboardingActivity :
super.onCreate(savedInstanceState)
binding.viewModel = viewModel

initStatusBarColor()
initMakeFragment()
initChangeFragment()
}

private fun initStatusBarColor() {
window.statusBarColor = ContextCompat.getColor(this, R.color.background)
}

private fun initMakeFragment() {
val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_onboarding_fragment)
if (currentFragment == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.sopetit.softie.ui.storytelling

import android.os.Bundle
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.sopetit.softie.R
import com.sopetit.softie.databinding.ActivityStoryTellingBinding
Expand All @@ -13,7 +12,6 @@ class StoryTellingActivity :
super.onCreate(savedInstanceState)

initFragment()
initStatusBarColor()
}

private fun initFragment() {
Expand All @@ -26,10 +24,6 @@ class StoryTellingActivity :
}
}

private fun initStatusBarColor() {
window.statusBarColor = ContextCompat.getColor(this, R.color.story_telling_background)
}

fun replaceFragment(fragment: Fragment) {
val fragmentManager = supportFragmentManager
val fragmentTransaction = fragmentManager.beginTransaction()
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_happy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_happy"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_main.xml
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=".ui.main.MainActivity">
tools:context=".ui.main.MainActivity"
android:fitsSystemWindows="true">

<TextView
android:layout_width="wrap_content"
Expand All @@ -22,4 +23,4 @@
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</layout>
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_onboarding.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_onboarding_top_bar"
Expand All @@ -29,7 +30,7 @@
android:id="@+id/iv_onboarding_top_bar_first"
android:layout_width="0dp"
android:layout_height="6dp"
android:layout_marginTop="28dp"
android:layout_marginTop="52dp"
android:layout_marginEnd="5dp"
android:src="@{viewModel.bearChoiceView ? @drawable/shape_main1_fill_99_rect : @drawable/shape_gray100_fill_99_rect}"
app:layout_constraintEnd_toStartOf="@id/iv_onboarding_top_bar_second"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_story_telling.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fcv_story_telling_fragment"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_happy_empty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="16dp"
android:layout_marginTop="40dp"
android:text="@string/happy_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_story_telling_intro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="194dp"
android:layout_marginTop="218dp"
android:src="@drawable/ic_girl1"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_story_telling_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="194dp"
android:layout_marginTop="218dp"
android:src="@drawable/ic_girl2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<!-- Customize your light theme here. -->
<item name="android:includeFontPadding">false</item>
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
</style>

<style name="Theme.Softie" parent="Base.Theme.Softie" />
Expand Down