blur background for ExploreWokaActivity according to android version
Ui for ExploreWokaActivity activity transitions
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
package com.woka.home
|
||||
|
||||
import android.graphics.RenderEffect
|
||||
import android.graphics.Shader
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.View.OnAttachStateChangeListener
|
||||
import android.view.WindowManager
|
||||
import android.transition.Fade
|
||||
import android.view.Window
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
@@ -16,8 +12,7 @@ import com.woka.R
|
||||
import com.woka.databinding.ActivityExploreWokaBinding
|
||||
import com.woka.utils.WokaBaseActivity
|
||||
import com.woka.utils.lightStatusBar
|
||||
import java.util.function.Consumer
|
||||
|
||||
import com.woka.utils.toast
|
||||
|
||||
class ExploreWokaActivity : WokaBaseActivity() {
|
||||
|
||||
@@ -25,6 +20,12 @@ class ExploreWokaActivity : WokaBaseActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
with(window){
|
||||
lightStatusBar()
|
||||
|
||||
requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
||||
enterTransition = Fade().apply { duration = 200 }
|
||||
}
|
||||
enableEdgeToEdge()
|
||||
binding = ActivityExploreWokaBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
@@ -34,9 +35,26 @@ class ExploreWokaActivity : WokaBaseActivity() {
|
||||
insets
|
||||
}
|
||||
|
||||
window.lightStatusBar()
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S){
|
||||
binding.root.setBackgroundColor(ContextCompat.getColor(this, R.color.black_50))
|
||||
}
|
||||
|
||||
binding.root.setRenderEffect(RenderEffect.createBlurEffect(50f, 50f, Shader.TileMode.MIRROR))
|
||||
clickEvents()
|
||||
}
|
||||
|
||||
private fun clickEvents() {
|
||||
binding.apply {
|
||||
closeBtn.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
root.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
wokaFm.setOnClickListener {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.woka.home
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.graphics.RenderEffect
|
||||
import android.graphics.Shader
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.Animation
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GravityCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
@@ -124,6 +130,16 @@ class HomeActivity : WokaBaseActivity(),
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (viewModel.isHomeBackgroundBlurred){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
|
||||
viewModel.isHomeBackgroundBlurred = false
|
||||
binding.root.setRenderEffect(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (binding.bottomNav.getSelectedTab() != HOME){
|
||||
binding.bottomNav.selectTab(HOME)
|
||||
@@ -186,6 +202,10 @@ class HomeActivity : WokaBaseActivity(),
|
||||
selectTheme(userPrefs?.appTheme?: Theme.THEME_ONE, true)
|
||||
|
||||
selectLanguage(userPrefs?.appLanguage?: LOCALE_ENGLISH, true)
|
||||
|
||||
if (viewModel.isHomeBackgroundBlurred){
|
||||
blurBackground()
|
||||
}
|
||||
}
|
||||
|
||||
private fun clickEvents() {
|
||||
@@ -305,19 +325,34 @@ class HomeActivity : WokaBaseActivity(),
|
||||
.replace(R.id.fc_home, Home1Fragment.newInstance())
|
||||
.commit()
|
||||
}
|
||||
|
||||
updateBackground()
|
||||
viewModel.selectedBottomTab = tab
|
||||
}
|
||||
EXPLORE_WOKA -> {
|
||||
startActivity(Intent(this, ExploreWokaActivity::class.java))
|
||||
|
||||
blurBackground()
|
||||
|
||||
startActivity(Intent(this, ExploreWokaActivity::class.java)
|
||||
, ActivityOptions.makeSceneTransitionAnimation(this).toBundle())
|
||||
}
|
||||
MY_LIST -> {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.fc_home, MyListFragment.newInstance())
|
||||
.commit()
|
||||
|
||||
updateBackground()
|
||||
viewModel.selectedBottomTab = tab
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateBackground()
|
||||
viewModel.selectedBottomTab = tab
|
||||
// blurring root view
|
||||
private fun blurBackground(){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !viewModel.isHomeBackgroundBlurred){
|
||||
binding.root.setRenderEffect(RenderEffect.createBlurEffect(60f, 60f, Shader.TileMode.REPEAT))
|
||||
viewModel.isHomeBackgroundBlurred = true
|
||||
}
|
||||
}
|
||||
|
||||
// updating background
|
||||
|
||||
@@ -16,6 +16,7 @@ class HomeViewModel: ViewModel(){
|
||||
private val userRepository = UserRepository(RetrofitHelper.getRetrofit().create(UserApiService::class.java))
|
||||
|
||||
var selectedBottomTab: Int = HOME
|
||||
var isHomeBackgroundBlurred: Boolean = false
|
||||
|
||||
private val _localeChangeLiveData = MutableLiveData<String>()
|
||||
val localeChangeLiveData: LiveData<String>
|
||||
|
||||
Reference in New Issue
Block a user