• Stars
    star
    1,737
  • Rank 26,819 (Top 0.6 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 4 months ago

Reviews

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

Repository Details

A simple material design app intro with cool animations and a fluent API.

Icon

material-intro

Build Status JitPack Downloads License GitHub issues

A simple material design app intro with cool animations and a fluent API.

Very inspired by Google's app intros.

Demo:

A demo app is available on Google Play:

Get it on Google Play

Screenshots:

Simple slide Custom slide Fade effect Permission request
Simple slide Custom slide Fade effect Permission request
SimpleSlide.java FragmentSlide.java IntroActivity.java SimpleSlide.java

Features:

  • Material design (check the docs)
  • Easy customization
  • Predefined slide layouts
  • Custom slides
  • Autoplay
  • Parallax slides
  • Fluent API

Table of Contents

  1. Setup
    1. Gradle Dependency
    2. Requirements
  2. Slides
    1. Standard slide
    2. Fragment slide
    3. Custom slide
  3. Customization
    1. Back button
    2. Next button
    3. CTA button
    4. Fullscreen
    5. Scroll duration
  4. Navigation
    1. Block navigation
    2. Navigate to slides
    3. Autoplay
    4. Callbacks
  5. Tips & Tricks
    1. Activity result
    2. Parallax slides
    3. Splash screens
  6. Apps using this library
  7. Changes
  8. Open-source libraries
  9. License

Setup:

Gradle Dependency:

material-intro is available on jitpack.io.

Add this in your root build.gradle file (not your module build.gradle file):

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Add this in your module build.gradle file:

dependencies {
    implementation 'com.heinrichreimersoftware:material-intro:x.y.z'
}

Requirements:

The activity must extend IntroActivity and have a theme extending @style/Theme.Intro:

public class MainIntroActivity extends IntroActivity {
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
	    // Add slides, edit configuration...
    }
}
<manifest ...>
    <application ...>
        <activity 
            android:name=".MainIntroActivity"
            android:theme="@style/Theme.Intro"/>
    </application>
</manifest>

(Unless mentioned otherwise, all of the following method calls should go in the Activity's onCreate().)

Slides:

material-intro has fluent style builders for both a simple text/image slide, as seen in Google's apps, and for slides featuring a custom Fragment or layout resource.

Feel free to submit an issue or pull request if you think any slide types are missing.

Standard slide (SimpleSlide):

Standard slide featuring a title, short description and image like Google's intros.

addSlide(new SimpleSlide.Builder()
        .title(R.string.title_1)
        .description(R.string.description_1)
        .image(R.drawable.image_1)
        .background(R.color.background_1)
        .backgroundDark(R.color.background_dark_1)
        .scrollable(false)
        .permission(Manifest.permission.CAMERA)
        .build());

Fragment slide (FragmentSlide):

Custom slide containing a Fragment or a layout resource.

addSlide(new FragmentSlide.Builder()
        .background(R.color.background_2)
        .backgroundDark(R.color.background_dark_2)
        .fragment(R.layout.fragment_2, R.style.FragmentTheme)
        .build());

(When using FragmentSlide with a Fragment, you should extend SlideFragment to proxy navigation calls to the intro activity.)

Custom slide (Slide):

Base slide. If you want to modify what's shown in your slide this is the way to go.

Customization:

Left ("back") button:

Control left button behavior or hide/show it.

/* Show/hide button */
setButtonBackVisible(true);
/* Use skip button behavior */
setButtonBackFunction(BUTTON_BACK_FUNCTION_SKIP);
/* Use back button behavior */
setButtonBackFunction(BUTTON_BACK_FUNCTION_BACK);

Right ("next") button:

Control right button behavior or hide/show it.

/* Show/hide button */
setButtonNextVisible(true);
/* Use next and finish button behavior */
setButtonNextFunction(BUTTON_NEXT_FUNCTION_NEXT_FINISH);
/* Use next button behavior */
setButtonNextFunction(BUTTON_NEXT_FUNCTION_NEXT);

CTA button:

Change the appearance of the "call to action" button:

/* Show/hide button */
setButtonCtaVisible(getStartedEnabled);
/* Tint button text */
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_TEXT);
/* Tint button background */
setButtonCtaTintMode(BUTTON_CTA_TINT_MODE_BACKGROUND);
/* Set custom CTA label */
setButtonCtaLabel(R.string.start)
/**/
setButtonCtaClickListener(new View.OnClickListener() {

});

Fullscreen:

Display the intro activity at fullscreen. This hides the status bar.

public class MainIntroActivity extends IntroActivity{
    @Override protected void onCreate(Bundle savedInstanceState){
        setFullscreen(true);
        super.onCreate(savedInstanceState);
	...
    }
}

Make sure to call setFullscreen() before calling super.onCreate()

Scroll duration:

Adjust how long a single slide scroll takes.

setPageScrollDuration(500);

(The page scroll duration is dynamically adapted when scrolling more than one position to reflect dynamic durations from the Material design docs. The exact formula for calculating the scroll duration is duration * (distance + sqrt(distance)) / 2.)

Navigation:

Block navigation:

There are three ways to block navigation for a slide:

  1. In a SlideFragment (using a FragmentSlide) by overriding canGoForward()/canGoBackward() methods.
  2. For a SimpleSlide by setting SimpleSlide.Builder#canGoForward(boolean)/SimpleSlide.Builder#canGoBackward(boolean). (If at least one permission is set to the SimpleSlide, navigation is automatically blocked until every permission is granted.)
  3. From your IntroActivity by setting a NavigationPolicy:
    setNavigationPolicy(new NavigationPolicy() {
        @Override public boolean canGoForward(int position) {
            return true;
        }
    
        @Override public boolean canGoBackward(int position) {
            return false;
        }
    });

Navigate to slides

Navigate through the intro manually using one of the following methods e.g. from a listeners callback. Each of them will respect blocked navigation settings.

/* Scroll to any position */
goToSlide(5);

/* Scroll to the next slide in the intro */
nextSlide();

/* Scroll to the previous slide in the intro */
previousSlide();

/* Scroll to the last slide of the intro */
goToLastSlide();

/* Scroll to the first slide of the intro */
goToFirstSlide();

Autoplay

Automatically scroll through the intro until user interacts with the intro.

/* Start an auto slideshow with 2500ms delay between scrolls and infinite repeats */
autoplay(2500, INFINITE);
/* Start an auto slideshow with default configuration  */
autoplay();
/* Cancel the slideshow */
cancelAutoplay()

Callbacks

If any of the above returns false when a user tries to navigate to a slide, a OnNavigationBlockedListener callback is fired that you can use to display a message. Additionally you can add plain-old ViewPager.OnPageChangeListeners to listen for page scrolls:

addOnNavigationBlockedListener(new OnNavigationBlockedListener() {
    @Override public void onNavigationBlocked(int position, int direction) { ... }
});

addOnPageChangeListener(new ViewPager.OnPageChangeListener(){
    @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { ... }
    @Override public void onPageSelected(int position) { ... }
    @Override public void onPageScrollStateChanged(int state) { ... }
});

Tips & Tricks:

Activity result:

You can check if the user canceled the intro (by pressing back) or finished it including all slides. Just call up the activity using startActivityForResult(intent, REQUEST_CODE_INTRO); and then listen for the result:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_CODE_INTRO) {
        if (resultCode == RESULT_OK) {
            // Finished the intro
        } else {
            // Cancelled the intro. You can then e.g. finish this activity too.
            finish();
	}
    }
}

Parallax slides:

You can easily achieve a nice looking parallax effect for any slide by using either ParallaxFrameLayout.java, ParallaxLinearLayout.java or ParallaxRelativeLayout.java and defining layout_parallaxFactor for its direct childrens. A higher factor means a stronger parallax effect, 0 means no parallax effect at all.

<com.heinrichreimersoftware.materialintro.view.parallax.ParallaxLinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    ... >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_parallaxFactor="0"
        ... />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_parallaxFactor="1.25"
        ... />

</com.heinrichreimersoftware.materialintro.view.parallax.ParallaxLinearLayout>

Check the "Canteen"-demo for a layout example.

Splash screens:

If you want to show the intro only at the first app start you can use onActivityResult() to store a shared preference when the user finished the intro.

See the demo app for a sample splash screen implementation:

Apps using this library:

Changes:

See the releases section for changelogs.

Open-source libraries:

material-intro uses the following open-source files:

License:

MIT License

Copyright (c) 2017 Jan Heinrich Reimer

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

material-drawer

Custom drawer implementation for Material design apps.
Java
597
star
2

material-singleinputform

A single EditText instead of a classical form. Library that implements flavienlaurent's singleinputform
Java
194
star
3

android-issue-reporter

A powerful and simple library to open issues on GitHub directly from your app.
Java
119
star
4

open-source-library-request-manager

A place to share ideas for open source library with other developers.
32
star
5

progressbar-ktx

โณ Kotlin extensions for the progressbar JVM library.
Kotlin
28
star
6

android-canteen-balance

Helper library to read out the current balance of canteen cards using NFC.
Java
12
star
7

latex-postage

๐Ÿ“„ Franking letters with ยปDeutsche Postยซ's online postage service ยปInternetmarkeยซ.
TeX
8
star
8

website

๐ŸŒ Personal portfolio website.
SCSS
6
star
9

wayback-api

๐Ÿ•ฐ๏ธ Java wrapper for the Internet Archive's Wayback API.
Kotlin
6
star
10

zotero-git-sync

๐Ÿ“š Simple CLI to sync a collection's Zotero publications to a Git repository.
Python
5
star
11

modern-talking

๐Ÿ—ฃ๏ธ Key-Point Analysis using Pretrained Encoders
Jupyter Notebook
5
star
12

android-wg-planer

Vertretungsplan und Stundenplan des Wilhelm-Gymnasiums
Java
4
star
13

android-shape-touch-listener

Touch listener which only reacts in a given shape.
Java
3
star
14

song-analysis

Analysing the Million Song Dataset.
Kotlin
2
star
15

thuringian-field-names

๐Ÿž๏ธ Explorer for the Thuringian Field Name Archive.
TypeScript
2
star
16

website-orgelverein

๐ŸŒ Orgelverein am Braunschweiger Dom e.V. website.
SCSS
2
star
17

grimjack

๐Ÿคบ Argument retrieval using axiomatic re-ranking and query reformulation.
TeX
2
star
18

website-wedding

๐Ÿ’๏ธ Wedding website for Lena & Heini.
HTML
2
star
19

ghost-theme-material

๐Ÿ‘ป Ghost theme implementing Material design guidelines.
HTML
2
star
20

latex-els-cas-templates

๐Ÿ“„ Copy of Elsevier updated LATEX templates.
TeX
2
star
21

web-archive-api

๐Ÿ—ƒ๏ธ Unified access to web archive CDX and Memento APIs.
Python
2
star
22

Search.jl

Ad hoc information retrieval toolkit for Julia.
Julia
1
star
23

alexa-top-1m

๐ŸŒ Easy access to Alexa top 1M websites.
Kotlin
1
star
24

study-computer-science

๐Ÿ“ฝ๏ธ Video player for the "Informatik studieren" advertisement movie.
TypeScript
1
star
25

text-summarization-reproducability

๐Ÿ“ Reproducability study on "Text Summarization with Pretrained Encoders".
HTML
1
star
26

warc-s3

๐Ÿ’พ Scalable and easy WARC records storage on S3.
Python
1
star
27

elasticsearch-ktx

๐Ÿ”Ž Kotlin Extensions for the Elasticsearch Java High Level REST Client.
Kotlin
1
star
28

reimersoftware-portfolio

๐ŸŒ Reimer Software's portfolio website.
SCSS
1
star
29

france-accidents

๐Ÿšจ Visualizing accidents in France from 2005 to 2020.
Elm
1
star
30

jsonl-serialization

๐Ÿ—œ๏ธ Kotlin serialization for the JSON Lines format.
Kotlin
1
star
31

domain-ktx

๐ŸŒ Kotlin extensions for domains.
Kotlin
1
star
32

hadoop-ktx

๐Ÿ’พ Kotlin Extensions for Apache Hadoop (MapReduce).
Kotlin
1
star
33

android-meine-mensa

Deine Mensen des Studentenwerks Halle.
Java
1
star
34

todoist-git-sync

โœ… Simple CLI to sync a project's Todoist tasks to a Git repository.
Python
1
star
35

wayback-gradle-plugin

๐Ÿ•ฐ๏ธ Gradle plugin for the Internet Archive's Wayback API.
Kotlin
1
star
36

spark-ktx

๐Ÿ’พ Kotlin extensions for Apache Spark.
Kotlin
1
star
37

website-lenamerker

๐ŸŒ Lena Merker's personal website.
HTML
1
star
38

website-kreativwerkstatt

๐ŸŒ Kreativ Werkstatt Reimer's portfolio website.
SCSS
1
star
39

ghost-theme-johannesfoto

๐Ÿ‘ป The Johannes Foto blog Ghost theme.
Handlebars
1
star
40

spark-gradle-plugin

๐Ÿ’พ Gradle plugin for launching Spark applications.
Kotlin
1
star
41

java-ktx

๐Ÿงฐ Kotlin extensions for the JVM.
Kotlin
1
star
42

android-elliptic-curve-chiffre

App to test implementation of elliptic curve chiffre Diffie-Hellman key exchange.
Java
1
star
43

bibtexer

๐Ÿ“š An opinionated BibTeX file cleaner for computer science.
Python
1
star
44

url-canonicalization

๐Ÿ”— Canonicalize URLs based on HTML canonical link relations.
Kotlin
1
star