Library for creating blur effects under Android UI elements

Overview

BlurTutorial Awesome

Header image

Meet BlurTutorial, an Android-based library made by Cleveroad

Hurry to check our newest library that helps to blur the background in Android apps. BlurTutorial highlights the needed UI elements and brings users' attention to the app's parts you're introducing. You can easily apply a blurred view behind the dialog window and context menu, singling out the important elements.

Demo image

Want to play around with BlurTutorial animation? Check Appetize!

We’ve created the library to help users enhance their app's usability and appearance. BlurTutorial handles both the tasks.

Awesome

Awesome

Setup

To use BlurTutorial add dependency to your project:

    implementation 'com.cleveroad.blur_tutorial:blur_tutorial:1.0.1'

Usage

BlurTutorial

The main component of library is the BlurTutorial interface.

    /*
     Add list of states to tutorial.
    */
    fun addAllStates(states: List<TutorialState>)

    /*
     Add one state to tutorial.
    */
    fun addState(state: TutorialState)

    /*
     Add one state by position.
    */
    fun setState(state: TutorialState, index: Int)

    /*
     Remove state from tutorial.
    */
    fun removeState(state: TutorialState)

    /*
     Clear all states of tutorial. 
     Cancel tutorial process.
    */
    fun clearStates()

    /*
     Get current state of tutorial.
    */
    fun getCurrentState(): TutorialState?

    /*
     Start tutorial process.
     
     Should be called in [Activity.onResume] or [Fragment.onResume] or later.
     If you also highlight action bar menu items,
     call it in [Activity.onPrepareOptionsMenu] or [Fragment.onPrepareOptionsMenu] or later.
    */
    fun start()

    /*
     Go to next state of tutorial.
     Finish the current state.
    */
    fun next()

    /*
     Interrupt tutorial process.
     It can be renewed by calling next() or start()
    */
    fun interrupt()
    
    /* 
     Change configuration of
     current [BlurTutorial] instance.
    */
    fun configure(): TutorialBuilder

    /* 
     Save state of tutorial. 
     You must call it in onSaveInstanceState()
     of your Fragment or Activity.
    */
    fun onSaveInstanceState(outState: Bundle)

    /* 
     Restore state of tutorial. 
     You must call it in onRestoreInstanceState() of 
     your Fragment or Activity.
    */
    fun onRestoreInstanceState(savedState: Bundle?)

    /*
     Release resources. 
     You must call it in onDestroy() of 
     your Fragment or Activity.
    */
    fun onDestroy()

TutorialState

TutorialState is an interface, that describes UI item to explain. There are a few data classes, that implement this interface:

  • ViewState - describes the View to highlight.
  • MenuState - describes the menu item to highlight.
  • RecyclerItemState - describes the RecyclerView item to highlight.
  • PathState - describes the geometric figure to highlight. By using this state you can highlight a part of view or a part of visible screen area.

TutorialBuilder

To create an instance of BlurTutorial you have to use TutorialBuilder.

Builder method name parameter description is required
withParent Root of your layout. Will be blurred or dimmed. yes
withPopupLayout Layout of popup window. yes
withPopupAppearAnimation Popup appear animation resource no
withPopupDisappearAnimation Popup disappear animation resource no
withPopupAppearAnimator Popup appear animator resource no
withPopupDisappearAnimator Popup disappear animator resource no
withPopupXOffset X offset of popup window no
withPopupYOffset Y offset of popup window no
withPopupCornerRadius Radius of popup corners no
withBlurRadius Radius of blur. Must be in a range (0.0; 25.0]. By default, it's 10.0 no
withOverlayColor Color of overlay, that will be displayed above blurred or dimmed background. no
withHighlightType Type of highlight: Blur or Dim. By default, it's Blur. no
withListener Listener of tutorial process yes

TutorialListener

Also you have to set listener of tutorial process:

interface TutorialListener {

    /*
     Called before state is entered.
     Use it to prepare UI for view highlighting.
     E.g. smoothly scroll to this view.
    */
    override fun onStateEnter(state: TutorialState)

    // Called after state exit.
    override fun onStateExit(state: TutorialState)

    // Called on state error. E.g. highlighted view is not visible, etc.
    override fun onStateError(state: TutorialState, error: StateException)

    /* 
     Called when popup view is inflated.
     Use this method to populate your popup view.
    */
    override fun onPopupViewInflated(state: TutorialState, popupView: View)

    // Called when tutorial process is finished.
    override fun onFinish()
}

Fragment/Activity usage

companion object {
    private const val VIEW_ID = 0
    private const val MENU_ITEM_ID = 1
    private const val RECYCLER_ITEM_ID = 2
    private const val PATH_ID = 3
    
    private const val RECYCLER_ITEM_INDEX = 10
    ...
}
...

private val path = Path().apply {
        addCircle(500F, 500F, 300F, Path.Direction.CCW) 
}

private val states by lazy {
        listOf(ViewState(VIEW_ID, tvHighlight),
               MenuState(MENU_ITEM_ID, tbMenuOwner, R.id.menu_item),
               RecyclerItemState(RECYCLER_ITEM_ID, rvOwner, RECYCLER_ITEM_INDEX),
               PathState(PATH_ID, path)
}

private var tutorial: BlurTutorial? = null

private val tutorialListener = object : SimpleTutorialListener() {

        override fun onPopupViewInflated(state: TutorialState, popupView: View) {
            popupView.run {
                val tvTitle = findViewById<TextView>(R.id.tvTitle)
                
                tvTitle.textResource = when (state.id) {
                    VIEW_ID -> R.string.view_title
                    MENU_ITEM_ID -> R.string.menu_title
                    RECYCLER_ITEM_ID -> R.string.recycler_title
                    PATH_ID -> R.string.path_state
                }
                setOnClickListener { tutorial?.next() }
            }
        }
    }
    
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        initTutorial()
    }
    
    override fun onResume() {
        super.onResume()
        tutorial?.start()
    }
    
    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        tutorial?.onSaveInstanceState(outState)
    }

    override fun onViewStateRestored(savedInstanceState: Bundle?) {
        super.onViewStateRestored(savedInstanceState)
        tutorial?.onRestoreInstanceState(savedInstanceState)
    }

    override fun onDestroy() {
        tutorial?.onDestroy()
        super.onDestroy()
    }
    
    private fun initTutorial() {
        tutorial = TutorialBuilder()
                .withParent(clParent)
                .withListener(tutorialListener)
                .withPopupLayout(R.layout.popup_window)
                .withPopupCornerRadius(POPUP_RADIUS)
                .withBlurRadius(BLUR_RADIUS)
                .build().apply { addAllStates(states) }
    }

Proguard

Also depending on your Proguard config, you have to setup your proguard-rules.pro file:

-keepclassmembers class androidx.appcompat.widget.Toolbar { *; }

-keep class com.google.android.material.bottomnavigation.BottomNavigationView
-keepclassmembers class com.google.android.material.bottomnavigation.BottomNavigationView { *; }

-keep class com.google.android.material.bottomnavigation.BottomNavigationItemView
-keepclassmembers class com.google.android.material.bottomnavigation.BottomNavigationItemView { *; }

-keep class androidx.appcompat.view.menu.MenuItemImpl
-keepclassmembers class androidx.appcompat.view.menu.MenuItemImpl { *; }

-keep class com.google.android.material.navigation.NavigationView
-keepclassmembers class com.google.android.material.navigation.NavigationView { *; }

-keep class com.google.android.material.internal.NavigationMenuPresenter** { *; }
-keepclassmembers class com.google.android.material.internal.NavigationMenuPresenter { *; }

-keep class com.google.android.material.bottomappbar.BottomAppBar
-keepclassmembers class com.google.android.material.bottomappbar.BottomAppBar { *; }

License


The MIT License (MIT)

Copyright (c) 2016 Cleveroad Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...
Android library for creating an expandable to full screen view inside a viewgroup composition.
Android library for creating an expandable to full screen view inside a viewgroup composition.

Expandable Panel Android Library Check ExpandablePanel Demo application on GooglePlay: Details This Android library implements the expand by sliding l

Android Material Json Form Wizard is a library for creating beautiful form based wizards within your app just by defining json in a particular format.
Android Material Json Form Wizard is a library for creating beautiful form based wizards within your app just by defining json in a particular format.

Android Json Wizard Android Json Wizard is a library for creating beautiful form based wizards within your app just by defining json in a particular f

A new canvas drawing library for Android. Aims to be the Fabric.js for Android. Supports text, images, and hand/stylus drawing input. The library has a website and API docs, check it out

FabricView - A new canvas drawing library for Android. The library was born as part of a project in SD Hacks (www.sdhacks.io) on October 3rd. It is cu

Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.
Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. The library is based on the code of Mario Klingemann.

Android StackBlur Android StackBlur is a library that can perform a blurry effect on a Bitmap based on a gradient or radius, and return the result. Th

Android library providing bread crumbs to the support library fragments.

Hansel And Gretel Android library providing bread crumbs for compatibility fragments. Usage For a working implementation of this project see the sampl

Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.
Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your development.

Bubbles for Android Bubbles for Android is an Android library to provide chat heads capabilities on your apps. With a fast way to integrate with your

Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)
Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (https://github.com/romannurik/android-wizardpager)

Wizard Pager Wizard Pager is a library that provides an example implementation of a Wizard UI on Android, it's based of Roman Nurik's wizard pager (ht

Comments
  • View is not focused

    View is not focused

    So the situation is: CoordinatorLayout > AppBarLayout > Toolbar(1 child) + ConstraintLayout(2 child) is OK, works as intended CoordinatorLayout > AppBarLayout > Toolbar(1 child) + ConstraintLayout(2 child) > any child of ConstraintLayout is BAD, blurs and not highlighted

    opened by Monabr 0
  • Why is the height of the button specified to 25dp in sample project?

    Why is the height of the button specified to 25dp in sample project?

    Tested Device: Pixel XL Android 23 (Emulator)

    Issue : Why is the height of the button hardcoded to 25dp?

    Expectation: Screen Shot 2020-06-10 at 16 50 35

    Reality : Screen Shot 2020-06-10 at 16 53 54

    Issue in the popup_window.xml

           <Button
            android:id="@+id/bGotIt"
            android:layout_width="wrap_content"
            android:layout_height="25dp"
            .../>```
    
    
    opened by sanjogshrestha 0
Owner
Cleveroad
Professional web and mobile development company. Full-cycle IT development!
Cleveroad
Provides 9-patch based drop shadow for view elements. Works on API level 9 or later.

Material Shadow 9-Patch This library provides 9-patch based drop shadow for view elements. Works on API level 14 or later. Target platforms API level

Haruki Hasegawa 481 Dec 19, 2022
Dali is an image blur library for Android. It contains several modules for static blurring, live blurring and animations.

Dali Dali is an image blur library for Android. It is easy to use, fast and extensible. Dali contains several modules for either static blurring, live

Patrick Favre-Bulle 1k Dec 1, 2022
JetCompose - Blur Effect in Android 12 with motion layout carousel

JetCompose Blur Effect in Android 12 with motion layout carousel

Vikas Singh 4 Jul 27, 2022
Parallax everywhere is a library with alternative android widgets with parallax effects.

Parallax Everywhere# Parallax everywhere (PEW) is a library with alternative android views using parallax effects. Demo You can try the demo app on go

fmSirvent 712 Nov 14, 2022
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

David Schreiber-Ranner 1.1k Nov 10, 2022
effects for android notifications

#NiftyNotification effects for android notifications.base on (Crouton) ScreenShot Usage NiftyNotificationView.build(this,msg, effect,R.id.mLyout)

李涛 1.1k Nov 10, 2022
Sliding cards with pretty gallery effects.

SlidingCard Sliding cards with pretty gallery effects. Download Include the following dependency in your build.gradle file. Gradle: repositories {

mxn 681 Sep 7, 2022
Draggable views with rotation and skew/scale effects

DraggableView Draggable views with rotation and skew/scale effects. Usage Implement DragController.IDragViewGroup Create instance of DragController Ov

Eugene Levenetc 562 Nov 11, 2022
This is a library to help creating expanding views with animation in Android

About the Library inspiration This library is strongly inspired in this concept from Hila Peleg in dribble. See it below Working example For more deta

Diego Bezerra 944 Dec 27, 2022
A powerful library for creating notifications in android platform.

Download Download the latest AAR or grab via Maven: <dependency> <groupId>com.github.halysongoncalves</groupId> <artifactId>pugnotification</artif

Halyson Lima Gonçalves 867 Nov 19, 2022