Android Library that lights items for tutorials or walk-throughs etc...

Overview

Spotlight

alt text

Build Status Download License API

Gradle

dependencies {
    implementation 'com.github.takusemba:spotlight:x.x.x'
}

Usage

val spotlight = Spotlight.Builder(this)
    .setTargets(firstTarget, secondTarget, thirdTarget ...)
    .setBackgroundColor(R.color.spotlightBackground)
    .setDuration(1000L)
    .setAnimation(DecelerateInterpolator(2f))
    .setContainer(viewGroup)
    .setOnSpotlightListener(object : OnSpotlightListener {
      override fun onStarted() {
        Toast.makeText(this@MainActivity, "spotlight is started", Toast.LENGTH_SHORT).show()
      }
      override fun onEnded() {
        Toast.makeText(this@MainActivity, "spotlight is ended", Toast.LENGTH_SHORT).show()
      }
    })
    .build()         

If you want to show Spotlight immediately, you have to wait until views are laid out.

// with core-ktx method.
view.doOnPreDraw { Spotlight.Builder(this)...start() }


Target

Create a Target to add Spotlight.

Target is a spot to be casted by Spotlight. You can add multiple targets to Spotlight.

val target = Target.Builder()
    .setAnchor(100f, 100f)
    .setShape(Circle(100f))
    .setEffect(RippleEffect(100f, 200f, argb(30, 124, 255, 90)))
    .setOverlay(layout)
    .setOnTargetListener(object : OnTargetListener {
      override fun onStarted() {
        makeText(this@MainActivity, "first target is started", LENGTH_SHORT).show()
      }
      override fun onEnded() {
        makeText(this@MainActivity, "first target is ended", LENGTH_SHORT).show()
      }
    })
    .build()


Start/Finish Spotlight

val spotlight = Spotlight.Builder(this)...start()

spotlight.finish()

Next/Previous/Show Target

val spotlight = Spotlight.Builder(this)...start()

spotlight.next()

spotlight.previous()

spotlight.show(2)

Custom Shape

Shape defines how your target will look like. Circle and RoundedRectangle shapes are already implemented, but if you want your custom shape, it's arhivable by implementing Shape interface.

class CustomShape(
    override val duration: Long,
    override val interpolator: TimeInterpolator
) : Shape {

  override fun draw(canvas: Canvas, point: PointF, value: Float, paint: Paint) {
    // draw your shape here.
  }
}

Custom Effect

Effect allows you to decorates your target. RippleEffect and FlickerEffect shapes are already implemented, but if you want your custom effect, it's arhivable by implementing Effect interface.

class CustomEffect(
    override val duration: Long,
    override val interpolator: TimeInterpolator,
    override val repeatMode: Int
) : Effect {

  override fun draw(canvas: Canvas, point: PointF, value: Float, paint: Paint) {
    // draw your effect here.
  }
}

Sample

Clone this repo and check out the app module.

Author

Licence

Copyright 2017 Taku Semba.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • assign target to view..

    assign target to view..

    Hi,

    im trying to implement the library, but i cant put target as a view to method setPoint(textview1);

    the round is not fit to the view..

    any advice would help much.

    thanks

    opened by fadlifebriansyah 7
  • round rectangle spotlight

    round rectangle spotlight

    Thanks for awesome library, but I am little disappointed that there is no round rectangle option. anyone who forked and made changes for this feature?

    opened by mickychen0524 6
  • Spotlight starts at corner in every phone

    Spotlight starts at corner in every phone

     val firstRoot = LinearLayout(this)
            val first = layoutInflater.inflate(R.layout.spotlight_tour, firstRoot)
            val firstTarget = com.takusemba.spotlight.Target.Builder()
                .setAnchor(btnLoginWithEmail)
                .setEffect(RippleEffect(100f, 200f, argb(30, 124, 255, 90)))
                .setShape(RoundedRectangle(200f,400f,100f))
                .setOverlay(first)
                .build()
            val spotlight = Spotlight.Builder(this)
                .setTargets(firstTarget)
                .setBackgroundColor(R.color.spotlight_bg_color)
                .setDuration(1000L)
                .setAnimation(DecelerateInterpolator(2f))
                .build()
    
            btnLoginWithEmail.doOnPreDraw {
                spotlight.start()
            }
    // Even tried btnLoginWithEmail.post({}) but did not help
    

    By the way I am using Material design UI elements the button class is com.google.android.material.button.MaterialButton. Though I checked with regular Button class but it didn't work. In the corner again...

    opened by XiXiongMaoXiong 5
  • Show previous target

    Show previous target

    Hello,

    is there a method or some workaround to show the previous target? For moving to the next one we have spotlight.closeCurrentTarget(), anything similar for going back would be useful.

    In this way for example in a tutorial you can have all kind of buttons, skip, next but also back.

    opened by Elvereth 5
  • Manifest merger failed

    Manifest merger failed

    i had a issues. please help me.

    "Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91 is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:6:5-24:19 to override."

    opened by saviart 5
  • Spotlight position between phones

    Spotlight position between phones

    The spotlight position is different between two phone. A Pixel 2 XL emulator looks like this:

    https://i.imgur.com/G7Lcrmq.png

    but on a Pixel 3 XL phone (no emulator) it's here:

    https://i.imgur.com/7qddSSE.png

    I'm thinking the notch might be effecting the positioning.

    I'm also using 1.5.0 because 1.8.0 is throwing some manifest merge compiling error.

    bug 
    opened by krisdb 5
  • Spotlight is not started with CustomTarget

    Spotlight is not started with CustomTarget

    I created a customtarget.

    CustomTarget customtarget = new CustomTarget.Builder(activity)
                    .setPoint(viewToFocus)
                    .setRadius(50f)
                    .setView(R.layout.fab_filter_coachmark)
                    .build();
    

    Start spotlight:

    Spotlight.with(activity)
                        .setOverlayColor(ContextCompat.getColor(activity, R.color.transparent))
                        .setTargets(customtarget)
                        .setClosedOnTouchedOutside(true)
                        .start();
    

    layout : fab_filter_coachmark

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:background="@color/coachMarkBg"
        android:layout_height="match_parent">
        <TextView
            android:id="@+id/textViewDescription"
            android:layout_width="match_parent"
            android:text="Description"
            android:textColor="@color/white"
            android:layout_height="wrap_content" />
        <TextView
            android:layout_width="match_parent"
            android:text="got it"
            android:textColor="@color/blue_priceinsight"
            android:layout_height="wrap_content" />
    </LinearLayout>
    

    There are two issues

    1. Custom view is not inflated near to the target, It inflated on the top left of screen.
    2. Spotlight is not started on target.
    opened by HimanshuNarang 5
  • target.getView().getTag() return Null in OnTargetStateChangedListener

    target.getView().getTag() return Null in OnTargetStateChangedListener

    Hello, I got trouble when put data in tag view before put in setPoint method and get data in OnTargetStateChangedListener in method onStarted and onEnded, and always got null value.

    I think this is a bug.

    Sorry, my english is bad.

    Thank you

    opened by dhinx 5
  • Displaying spotLight over Dialog

    Displaying spotLight over Dialog

    Hi, the library was cool and working fine in activities and fragments. But whenever i want to display the overlay on top of dialog it was displaying below the dialog. Please suggest any possible solution..

    opened by NaveenKadiyala 4
  • Coachmark with Dialog

    Coachmark with Dialog

    Its an awesome library but I have a query how do I show the coachmark over the dialog. Its always coming behind the dialog. I am using the DialogFragment with animation in android.

    opened by mnnit-LaltuKumar 4
  • Make SpotlightView/Targetclickable

    Make SpotlightView/Targetclickable

    Can you make spotlightview or the target clickable? I know we can make a custom view and set clickable there but it would be great to make the target itself clickable to make the user tap on the target to move forward

    opened by nikhilpanju 4
  • Support for Jetpack Compose

    Support for Jetpack Compose

    Since most of the new UI development is moving toward Jetpack Compose, which is way better than XML, it would be great to have such a library for Compose.

    opened by divyanshdxn 0
  • Background blur

    Background blur

    Hello,

    Is there a way to set the background of the spotlight to a blur? Meaning that you cannot see the layout underneath the spotlight, due to the blur? I currently tried to but a view that matched parent on width and height but then it blocks the target being shown. Does anyone know a work around for this?

    Thanks!

    opened by DerSIlent 1
  • How to make spotlight persistence. If the current Configuration changes, from port to landscape, then spotlight index should persist.

    How to make spotlight persistence. If the current Configuration changes, from port to landscape, then spotlight index should persist.

    Consider a situation when there are some configuration changes. In the current spotlight, I don't think there is any way we can persist the targeted index. In my experience, if the screen is rotated, then the spotlight restart from the beginning.

    Also, consider if the user is using a different UI for different orientations, then in that case we will have to use a different layout for each target. But the thing is, the spotlight takes predefined layout targets. How can we conditionally or with some other method can change the target layout during runtime?

    opened by rishidyno 1
  • Feature: finish spotlight on touch outside of current target

    Feature: finish spotlight on touch outside of current target

    Problem

    I've seen issue https://github.com/TakuSemba/Spotlight/issues/123 (from @aryandii) and decided to help you make Spotlight more functional ✨

    Solution

    So I added a new flag to make it possible to finish spotlight on touch outside of current target. Let's see how it looks like:

    There is a listener to catch on touch outside of current target event. Finishing on touch outside is the only one usage of listener. If you want to add new Shape just create a child class and implement contains function. It can be quite complex if your shape is not primitive. So it can be not perfectly precise (and there is nothing horrible, IMHO). Round rectangle is an example of complex shape:

    @TakuSemba , thanks a lot for your work. I hope this feature will improve your project and engage new developers 🤝

    opened by valeryvpetrov-dev 1
Owner
TakuSemba
ex: CyberAgent.Inc, AbemaTv.Inc. currently, Invoice2go.Inc.
TakuSemba
🍭🚀💗 Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more

?????? Tutorials about animations with Animators, Animated Vector Drawables, Shared Transitions, and more

Smart Tool Factory 696 Dec 28, 2022
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022
An Android library which provides simple Item animations to RecyclerView items

RecyclerViewItemAnimators Library Travis master: This repo provides: Appearance animations Simple animators for the item views Quick start You can now

Gabriele Mariotti 3.1k Dec 16, 2022
Introduction your app to the user , Easy to use and set Items as you want

Introduction App This lib helps to introduce the App-by view page based on Kotlin. Features Easy Set up Items: Title, Describe, Background, Buttons Ap

S.M.Zendehbad 0 May 6, 2022
💳 A quick and easy flip view through which you can create views with two sides like credit cards, poker cards etc.

The article on how this library was created is now published. You can read it on this link here. →. ?? EasyFlipView Built with ❤︎ by Wajahat Karim and

Wajahat Karim 1.3k Dec 14, 2022
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

Enrique López Mañas 3.6k Dec 29, 2022
Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API

What is Postman? Postman is a reactive One-tap SMS verification library. This library allows the usage of RxJava with The SMS User Consent API Usage P

Cafer Mert Ceyhan 129 Dec 24, 2022
Android Country Picker is a Kotlin-first, flexible and powerful Android library that allows to integrate Country Picker with just a few lines.

1. Add dependency dependencies { implementation 'com.hbb20:android-country-picker:X.Y.Z' } For latest version, 2. Decide your use-case

Harsh B. Bhakta 65 Dec 6, 2022
Android library for swipable gestures

Swipper Android Library for custom views to control brightness , volume and seek through swipable gestures . These views could easily replace the conv

Mobile Development Group 105 Dec 30, 2022
Android Rubber Picker Library

RubberPicker RubberPicker library contains the RubberSeekBar and RubberRangePicker, inspired by Cuberto's rubber-range-picker. Getting started Setting

Chrisvin Jem 547 Jan 5, 2023
EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the Etsy app.

EtsyBlur EtsyBlur is an Android library that allows developers to easily add a glass-like blur effect implemented in the past Etsy app. Try out the sa

Manabu S. 755 Dec 29, 2022
[] Android library for using the Honeycomb animation API on all versions of the platform back to 1.0!

DEPRECATED NineOldAndroids is deprecated. No new development will be taking place. Existing versions will (of course) continue to function. New applic

Jake Wharton 4.5k Jan 9, 2023
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon

ChatKit for Android ChatKit is a library designed to simplify the development of UI for such a trivial task as chat. It has flexible possibilities for

Stfalcon LLC 3.6k Jan 5, 2023
Library containing common animations needed for transforming ViewPager scrolling for Android v13+.

ViewPagerTransforms Library containing common animations needed for transforming ViewPager scrolling on Android v13+. This library is a rewrite of the

Ian Thomas 2.5k Dec 29, 2022
Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

FabulousFilter Show some ❤️ and star the repo to support the project This library is the implementation of filter-concept posted on MaterialUp.com. It

Krupen Ghetiya 2.6k Jan 3, 2023
Android library to control Transition animates. A simple way to create a interactive animation.

TransitionPlayer Android library to control Transition animates. A simple way to create a interactive animation. Demo1 SimpleTransition Code: ....

林法鑫 1.2k Dec 17, 2022
Road Runner is a library for android which allow you to make your own loading animation using a SVG image

Road Runner Road Runner is a library for android which allow you to make your own loading animation using a SVG image Sample video View in Youtube Dem

Adrián Lomas 1.2k Nov 18, 2022
FPSAnimator is very easy animation library for Android TextureView and SurfaceView.

FPSAnimator A simple but powerful Tween / SpriteSheet / ParabolicMotion / animation library for Android TextureView and SurfaceView. Features The cont

Masayuki Suda 756 Dec 30, 2022
Android library for material scrolling techniques.

material-scrolling Android library for material scrolling techniques. Features Easily implement material scrolling techniques with RecyclerView. Custo

Satoru Fujiwara 601 Nov 29, 2022