UIPresenter library for android view-based UI presentation

Overview

UIPresenter

This android library is like a tour guide for your app's Views. It helps to explain to your user, the role of the Views in your Activity or Fragment. It supports minSdk 21 and up.

UIPresenter example 2 screenshot

How to get this library in your android app

Step 1. Add the jitpack repository to the repositories { } function, inside your project build.gradle or your settings.gradle like so:

repositories {
    google()
    mavenCentral()
    // Place the jitpack repository inside this, like so:
    maven { url 'https://jitpack.io' }
}

Step 2. Add the dependency in your module build.gradle file, like so:

dependencies {
    implementation 'com.github.germainkevinbusiness:UIPresenter:1.0.0-beta14'
}

That's it!

Example with a RecyclerView & a menu item

UIPresenter example 2 screenshot A Menu item being presented by the library

Usage

Basic usage is shown below, with more examples in the sample app.

UIPresenter(activity = this).set(
    viewToPresent = binding.recyclerView[2], // using view binding here
    descriptionText = "This is a row inside the RecyclerView with an animal image and name",
    presenterStateChangeListener = { _, _ -> }
)

Only the above three parameters inside the UIPresenter.set() method are required to display a Presenter on your Activity or Fragment's UI. The rest of the parameters in the UIPresenter.set() method are optional, but great for customization!

Here's the output of the above code in light and dark mode:

Light mode UIPresenter example Dark mode UIPresenter example

For more in-depth examples, check out the sample app.

Note

If you want to remove the Presenter on certain specific click events, here are the click events that the UIPresenter library can detect:

// When a click is done on the view you want to present
Presenter.STATE_VTP_PRESSED
// When a click is done on the presenter's PresenterShape which is the presenter's visible part
// with the description text, background & shadow layer
Presenter.STATE_FOCAL_PRESSED
// When a click is done outside the presenter's PresenterShape 
// and outside the view you want to present
Presenter.STATE_NON_FOCAL_PRESSED
// When a press on the back button is detected
Presenter.STATE_BACK_BUTTON_PRESSED

UIPresenter(fragment = this).set(
    // Now the library won't removes the presenter on any detected click event automatically
    // You now have to decide which click event will remove the presenter by yourself, like
    // show inside the presenterStateChangeListener below
    removePresenterOnAnyClickEvent = false,
    presenterStateChangeListener = { state, removePresenter ->
        // Removes the presenter when a click is done on the presenter's PresenterShape 
        // which is the presenter's visible part with the description text, 
        // background & shadow layer
        if (state == Presenter.STATE_FOCAL_PRESSED) {
            // Removes the presenter
            removePresenter()
        }
    }
)

To create your own animation when the presenter is being added to the decorView (called revealAnimation), or when the presenter is being removed from the decorView (called removeAnimation) , you need to implement the PresenterAnimation interface, like so:

class MyRevealAnimation : PresenterAnimation {

    override fun runAnimation(
        coroutineScope: CoroutineScope, // A scope to run your animation in, if you want
        presenter: Presenter, // The presenter the reveal animation will run on
        revealAnimationDuration: Long, // The duration of the animation
        afterAnim: () -> Unit // When called that means we can safely consider this animation to be done
    ) {
        // write your animation logic here
    }
}

class MyRemoveAnimation : RemoveAnimation {

    override fun runAnimation(
        coroutineScope: CoroutineScope, // A scope to run your animation in, if you want
        presenter: Presenter, // The presenter the remove animation will run on
        removeAnimationDuration: Long, // The duration of the removeAnimation
        afterAnim: () -> Unit // When called that means we can safely consider this animation to be done
    ) {
        // write your animation logic here
    }
}

You can apply your own animations to the UIPresenter like so:

UIPresenter(activity = this).set(
    revealAnimation = MyRevealAnimation(),
    removeAnimation = MyRemoveAnimation()
)

License

Licenced under the MIT Licence

Copyright (c) 2021 Kevin Germain

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...
Samples demonstrating the features and use of Koala Plot, a Compose Multiplatform based charting and plotting library written in Kotlin.

Koala Plot Samples This repository houses samples demonstrating the use and features of Koala Plot libraries. How to run Build koalaplot-core with the

Android App Development using Android Studio Project for The Swastika. It is edit profile view.

Edit_Profile_View Android App Development using Android Studio Project for The Swastika. It is edit profile view. To start with this project first is

SceneView Android - 3D/AR Android View with ARCore and Google Filament
SceneView Android - 3D/AR Android View with ARCore and Google Filament

SceneView is a 3D/AR Android View with ARCore and Google Filament. This is the newest way to make your Android 3D/AR app.

A 2020s compatible React Native keyboard avoiding view for Android and iOS that just works.

react-native-keyboard-shift Example Snack coming soon Until then: Clone this repo: git clone https://github.com/FullStackCraft/react-native-keyboard-s

 ⚡️ A supercharged native Web View for iOS and Android ⚡️
⚡️ A supercharged native Web View for iOS and Android ⚡️

⚡️ A supercharged native Web View for iOS and Android ⚡️ Ionic Portals is a supercharged native Web View component for iOS and Android that lets you a

Simple custom view that draws an n-point star for Android
Simple custom view that draws an n-point star for Android

StarView 🌟 Simple custom view that draws an n-point star for Android. Features

An Android app that pulls the credit score information from a given endpoint and displays the records as a donut view

ClearScoreTest This is an Android app that pulls the credit score information fr

A package to include a standard Unlock premium view in iOS and Android apps

A package to include a standard Unlock premium view in iOS and Android apps

Android application for GitHub user search and view user details
Android application for GitHub user search and view user details

GitHubApp Android application for GitHub user search and view user details Architecture UI observing the live data for the main list as received from

Releases(1.0.6)
Owner
Germain Kevin
Android Software engineer | Android Library developer | Jetpack compose & XML | Programmer
Germain Kevin
Simple Android web-view-based application. The primary purpose is to show the website in Kiosk mode.

Kiosk mode app Simple Android web-view-based application. The primary purpose is to show the website in Kiosk mode. By default, the app works in Scree

Mykola Kichatov 1 Oct 25, 2022
weiV(pronounced the same as wave), a new declarative UI development framework based on the Android View system.

weiV(pronounced the same as wave) 简体中文 if ("weiV" == "View".reversed()) { Log.d( "weiV", "It means Inversion of Control, you shoul

fangbing chen 69 Nov 22, 2022
Patter Lock using Hilt, Coroutines, Flow and Custom View Components based on MVVM architecture.

Pattern Lock App Sample project for created Pattern Lock View using custom view. Preview Usage Step 1 Add the PatterLockView in your XML layout file.

Furkan Özcan 5 Aug 22, 2021
An App based on MVVM architecture to track & store a user's runs using Google Maps, with options to view & sort the runs as per the user's choice along the with option to run the app in background.

An App based on MVVM architecture to track & store a user's runs using Google Maps, with options to view & sort the runs as per the user's choice along the with option to run the app in background.

Harshit Maheshwari 1 Jun 9, 2022
FDPClient-EDITED - A free mixin-based injection hacked-client for Minecraft using Minecraft Forge based on LiquidBounce

FDPClient A free mixin-based injection hacked-client for Minecraft using Minecra

SuperSkidder 7 Aug 29, 2022
Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs

Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs. -> you can click on headline and it will open an article of that news in the app(no need to go to chrome or any browser)

SUMIT KUMAR 5 Nov 28, 2022
📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.

Material NavigationView for Android ?? ?? Android Library to implement Rich, Beautiful Material Navigation View for your project with Material Design

Shreyas Patil 198 Dec 17, 2022
Android library for Tesla Authentication based on Tesla JSON API (Unofficial)

TeslaAndroidAuth Lightweight Android library for Tesla SSO Authentication based

Octopus Energy 3 Jan 10, 2022
A Kotlin/JVM based library for BitShares blockchain.

A Kotlin/JVM based library for BitShares blockchain. It implements most functions of BitShares Core including objects (de)serialization, transactions sign/broadcast, wallet create/restore, and more.

Husk 1 Apr 9, 2022