From 233fb5a1c142484db14f803aee1fdd39a8c19a62 Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sat, 7 Nov 2020 12:41:04 +0200 Subject: [PATCH] Blur the content behind the toolbar --- app/build.gradle | 1 + .../pocketmode/ui/activities/MainActivity.kt | 8 ++ app/src/main/res/layout/activity_main.xml | 98 +++++++++++-------- 3 files changed, 65 insertions(+), 42 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c0716a4..7b0a439 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -121,6 +121,7 @@ dependencies { implementation 'com.afollestad.material-dialogs:core:3.1.0' implementation 'com.google.android.material:material:1.3.0-alpha03' implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" + implementation 'com.eightbitlab:blurview:1.6.5' implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.core:core-ktx:1.3.2' implementation 'androidx.browser:browser:1.2.0' diff --git a/app/src/main/java/com/artemchep/pocketmode/ui/activities/MainActivity.kt b/app/src/main/java/com/artemchep/pocketmode/ui/activities/MainActivity.kt index c05a336..a75ebd6 100644 --- a/app/src/main/java/com/artemchep/pocketmode/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/artemchep/pocketmode/ui/activities/MainActivity.kt @@ -27,6 +27,7 @@ import com.artemchep.pocketmode.models.Proximity import com.artemchep.pocketmode.ui.activities.base.BaseActivity import com.artemchep.pocketmode.util.ObserverConsumer import com.artemchep.pocketmode.viewmodels.MainViewModel +import eightbitlab.com.blurview.RenderScriptBlur /** * @author Artem Chepurnoy @@ -65,6 +66,13 @@ class MainActivity : BaseActivity(), super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + viewBinding.toolbarBlurView + .setupWith(viewBinding.root) + .setBlurAlgorithm(RenderScriptBlur(this)) + .setBlurRadius(5f) + .setBlurAutoUpdate(true) + .setHasFixedTransformationMatrix(true) + ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { _, insets -> viewBinding.statusBar.layoutParams.height = insets.systemWindowInsetTop viewBinding.scrollView.updatePadding( diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index db5dc92..5e3f163 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -80,51 +80,65 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - + android:layout_height="wrap_content"> - - - - - - - - - - - + android:layout_height="wrap_content" + android:orientation="vertical"> + + + + + + + + + + + + + + + + + + + +