Skip to content
This repository was archived by the owner on Aug 10, 2020. It is now read-only.
Open
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
8 changes: 8 additions & 0 deletions app/src/main/java/app/getfeeling/feeling/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.core.view.ViewCompat
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.NavController
Expand All @@ -12,6 +13,7 @@ import androidx.navigation.ui.setupWithNavController
import app.getfeeling.feeling.databinding.MainActivityBinding
import app.getfeeling.feeling.ui.me.MeViewModel
import app.getfeeling.feeling.ui.signin.SignInViewModel
import app.getfeeling.feeling.util.makeStatusBarTransparent
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.floatingactionbutton.FloatingActionButton
import dagger.android.support.DaggerAppCompatActivity
Expand Down Expand Up @@ -42,6 +44,12 @@ class MainActivity : DaggerAppCompatActivity() {
binding.fab.setOnClickListener {
meViewModel.addFeeling()
}
this.makeStatusBarTransparent()


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.nav_host_fragment)) { _, insets ->
insets.consumeSystemWindowInsets()
}
}

override fun onNewIntent(intent: Intent) {
Expand Down
30 changes: 30 additions & 0 deletions app/src/main/java/app/getfeeling/feeling/util/ViewExtension.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package app.getfeeling.feeling.util

import android.app.Activity
import android.graphics.Color
import android.os.Build
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager

fun Activity.makeStatusBarTransparent() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no compat way of doing this? I really dislike the look of this. Also why can't this just be a private function in the activity?

window.apply {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
window.apply {
with(window) {

It should be this unless window is what you're returning

clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} else {
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
}
statusBarColor = Color.TRANSPARENT
}
}
}

fun View.setMarginTop(marginTop: Int) {
val menuLayoutParams = this.layoutParams as ViewGroup.MarginLayoutParams
menuLayoutParams.setMargins(0, marginTop, 0, 0)
this.layoutParams = menuLayoutParams
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}