• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Kotlin
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library for creating blur effects under Android UI elements

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.

More Repositories

1

SlidingTutorial-Android

Android Library for making animated tutorials inside your app
Java
2,486
star
2

FanLayoutManager

Using Fan Layout Manager you can implement the horizontal list, the items of which move like fan blades
Java
2,056
star
3

AdaptiveTableLayout

Library that makes it possible to read, edit and write CSV files
Java
1,902
star
4

WaveInApp

Live Audio Equalizer with wave effect
Java
1,785
star
5

MusicBobber

Awesome Audio Widget for any Android Music App
Java
881
star
6

LoopBar

Tap Bar with infinite scrolling. Make the navigation menu right at fingerprints, in a tab bar.
Java
741
star
7

CRNetworkButton

Send Button for iOS
Swift
654
star
8

FireworkyPullToRefresh

Let's try to refresh your data with our library!
Java
641
star
9

BubbleAnimationLayout

You don’t want your apps look and feel boring, do you? Add some bubbles!
Java
577
star
10

CycleMenu

Custom LayoutManager for the inner RecyclerView
Java
575
star
11

CRPageViewController

While a standard page view allows you to navigate between pages by using simple gestures, our component goes further
Objective-C
394
star
12

PlayWidget

Break the monotony and make your music player unique!
Java
366
star
13

Bitutorial

Crumbling tutorial for Android Apps
Java
357
star
14

CRParticleEffect

A CocoaPod that simplifies creation of the particle effects.
Objective-C
348
star
15

Android-Marshmallow-Boot-Animation

Java
244
star
16

DroidArt

Android library that allows perform manipulations with text and easily combine it with images.
Kotlin
209
star
17

flutter_sliding_tutorial

User onboarding library with smooth animation of objects and background colors
Dart
127
star
18

CRRulerControl

Customizable component, created by Cleveroad iOS developers, is aimed at turning a simple ruler into a handy and smart instrument
Objective-C
112
star
19

ARFaceDetection

AR-based library for Android which is capable of detecting faces and overlaying images above the user’s head
Kotlin
52
star
20

slidingtutorial-ios

iOS Library for making animated tutorials inside your app
Objective-C
49
star
21

Bootstrap

This set of libraries is designed to help developers accomplish various tasks easier and faster
Kotlin
40
star
22

cr_calendar

Highly customizable, feature-packed calendar widget for Flutter.
Dart
31
star
23

CRRollingLabel

Objective-C
30
star
24

CRCellCollectionView

With this component, pictures in your apps collection view will look like honeycomb instead of the boring standard variant
Objective-C
28
star
25

ColorDetection

ColorDetection is an app built with OpenCV and using computer vision at its core. It’s able to detect and change colors of objects using a camera of iOS devices.
Objective-C++
22
star
26

cr_logger

Dart
15
star
27

cr_file_saver

Kotlin
3
star
28

CRRefreshControl

2
star
29

cr_json_widget

Dart
2
star
30

CRPlotView

1
star
31

CRPinCodeControl

1
star
32

cr_mentions

Dart
1
star