Giter VIP home page Giter VIP logo

appintro's Introduction

AppIntro

Join the chat at https://kotlinlang.slack.com Pre Merge Checks Android Arsenal Awesome Kotlin Badge

AppIntro is an Android Library that helps you build a cool carousel intro for your App. AppIntro has support for requesting permissions and helps you create a great onboarding experience in just a couple of minutes.

appintro icon appintro sample

Getting Started ๐Ÿ‘ฃ

AppIntro is distributed through JitPack.

Adding a dependency

To use it you need to add the following gradle dependency to your build.gradle file of the module where you want to use AppIntro (NOT the root file).

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
    // AndroidX Capable version
    implementation 'com.github.AppIntro:AppIntro:6.3.1'
    
    // *** OR ***
    
    // Latest version compatible with the old Support Library
    implementation 'com.github.AppIntro:AppIntro:4.2.3'
}

Please note that since AppIntro 5.x, the library supports Android X. If you haven't migrated yet, you probably want to use a previous version of the library that uses the old Support Library packages (or try Jetifier Reverse mode).

Basic usage

To use AppIntro, you simply have to create a new Activity that extends AppIntro like the following:

class MyCustomAppIntro : AppIntro() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // Make sure you don't call setContentView!

        // Call addSlide passing your Fragments.
        // You can use AppIntroFragment to use a pre-built fragment
        addSlide(AppIntroFragment.createInstance(
                title = "Welcome...",
                description = "This is the first slide of the example"
        ))
        addSlide(AppIntroFragment.createInstance(
                title = "...Let's get started!",
                description = "This is the last slide, I won't annoy you more :)"
        ))
    }

    override fun onSkipPressed(currentFragment: Fragment?) {
        super.onSkipPressed(currentFragment)
        // Decide what to do when the user clicks on "Skip"
        finish()
    }

    override fun onDonePressed(currentFragment: Fragment?) {
        super.onDonePressed(currentFragment)
        // Decide what to do when the user clicks on "Done"
        finish()
    }
}

Please note that you must NOT call setContentView. The AppIntro superclass is taking care of it for you.

Also confirm that you're overriding onCreate with a single parameter (Bundle) and you're not using another override (like onCreate(Bundle, PersistableBundle)) instead.

Finally, declare the activity in your Manifest like so:

<activity android:name="com.example.MyCustomAppIntro"
    android:label="My Custom AppIntro" />

We suggest to don't declare MyCustomAppIntro as your first Activity unless you want the intro to launch every time your app starts. Ideally you should show the AppIntro activity only once to the user, and you should hide it once completed (you can use a flag in the SharedPreferences).

Java users

You can find many examples in java language in the examples directory

Migrating ๐Ÿš—

If you're migrating from AppIntro v5.x to v6.x, please expect multiple breaking changes. You can find documentation on how to update your code on this other migration guide.

Features ๐Ÿงฐ

Don't forget to check the changelog to have a look at all the changes in the latest version of AppIntro.

  • API >= 14 compatible.
  • 100% Kotlin Library.
  • AndroidX Compatible.
  • Support for runtime permissions.
  • Dependent only on AndroidX AppCompat/Annotations, ConstraintLayout and Kotlin JDK.
  • Full RTL support.

Creating Slides ๐Ÿ‘ฉโ€๐ŸŽจ

The entry point to add a new slide is the addSlide(fragment: Fragment) function on the AppIntro class. You can easily use it to add a new Fragment to the carousel.

The library comes with several util classes to help you create your Slide with just a couple lines:

AppIntroFragment

You can use the AppIntroFragment if you just want to customize title, description, image and colors. That's the suggested approach if you want to create a quick intro:

addSlide(AppIntroFragment.createInstance(
    title = "The title of your slide",
    description = "A description that will be shown on the bottom",
    imageDrawable = R.drawable.the_central_icon,
    backgroundDrawable = R.drawable.the_background_image,
    titleColorRes = R.color.yellow,
    descriptionColorRes = R.color.red,
    backgroundColorRes = R.color.blue,
    titleTypefaceFontRes = R.font.opensans_regular,
    descriptionTypefaceFontRes = R.font.opensans_regular,
))

All the parameters are optional, so you're free to customize your slide as you wish.

If you need to programmatically create several slides you can also use the SliderPage class. This class can be passed to AppIntroFragment.createInstance(sliderPage: SliderPage) that will create a new slide starting from that instance.

AppIntroCustomLayoutFragment

If you need further control on the customization of your slide, you can use the AppIntroCustomLayoutFragment. This will allow you pass your custom Layout Resource file:

AppIntroCustomLayoutFragment.newInstance(R.layout.intro_custom_layout1)

This allows you to achieve complex layout and include your custom logic in the Intro (see also Slide Policy):

appintro custom-layout

Configure ๐ŸŽจ

AppIntro offers several configuration option to help you customize your onboarding experience.

Slide Transformer

AppIntro comes with a set of Slide Transformer that you can use out of the box to animate your Slide transition.

Slide Transformers Slide Transformers
Fade
fade
Zoom
zoom
Flow
flow
Slide Over
slideover
Depth
depth
Parallax
parallax

You can simply call setTransformer() and pass one of the subclass of the sealed class AppIntroPageTransformerType:

setTransformer(AppIntroPageTransformerType.Fade)
setTransformer(AppIntroPageTransformerType.Zoom)
setTransformer(AppIntroPageTransformerType.Flow)
setTransformer(AppIntroPageTransformerType.SlideOver)
setTransformer(AppIntroPageTransformerType.Depth)

// You can customize your parallax parameters in the constructors. 
setTransformer(AppIntroPageTransformerType.Parallax(
                titleParallaxFactor = 1.0,
                imageParallaxFactor = -1.0,
                descriptionParallaxFactor = 2.0
))

Custom Slide Transformer

You can also provide your custom Slide Transformer (implementing the ViewPager.PageTransformer interface) with:

setCustomTransformer(ViewPager.PageTransformer)

Color Transition

appintro sample

AppIntro offers the possibility to animate the color transition between two slides background. This feature is disabled by default, and you need to enable it on your AppIntro with:

isColorTransitionsEnabled = true

Once you enable it, the color will be animated between slides with a gradient. Make sure you provide a backgroundColor parameter in your slides.

If you're providing custom Fragments, you can let them support the color transition by implementing the SlideBackgroundColorHolder interface.

Multiple Windows Layout

AppIntro is shipped with two top-level layouts that you can use. The default layout (AppIntro) has textual buttons, while the alternative layout has buttons with icons.

To change the Window layout, you can simply change your superclass to AppIntro2. The methods to add and customize the AppIntro are unchanged.

class MyCustomAppIntro : AppIntro2() {
    // Same code as displayed in the `Basic Usage` section of this README
}
Page AppIntro AppIntro2
standard page layout1-start layout2-start
last page layout1-end layout2-end

Indicators

AppIntro supports two indicators out of the box to show the progress of the Intro experience to the user:

  • DotIndicatorController represented with a list of Dot (the default)
  • ProgressIndicatorController represented with a progress bar.
DotIndicator ProgressIndicator
dotted indicator progress indicator

Moreover, you can supply your own indicator by providing an implementation of the IndicatorController interface.

You can customize the indicator with the following API on the AppIntro class:

// Toggle Indicator Visibility                
isIndicatorEnabled = true

// Change Indicator Color 
setIndicatorColor(
    selectedIndicatorColor = getColor(R.color.red),
    unselectedIndicatorColor = getColor(R.color.blue)
)

// Switch from Dotted Indicator to Progress Indicator
setProgressIndicator()

// Supply your custom `IndicatorController` implementation
indicatorController = MyCustomIndicator(/* initialize me */)

If you don't specify any customization, a DotIndicatorController will be shown.

Vibration

AppIntro supports providing haptic vibration feedback on button clicks. Please note that you need to specify the Vibration permission in your app Manifest (the library is not doing it). If you forget to specify the permission, the app will experience a crash.

<uses-permission android:name="android.permission.VIBRATE" />

You can enable and customize the vibration with:

// Enable vibration and set duration in ms
isVibrate = true
vibrateDuration = 50L

Wizard Mode

appintro wizard1 appintro wizard2

AppIntro supports a Wizard mode where the Skip button will be replaced with the back arrow. This comes handy if you're presenting a Wizard to your users with a set of steps they need to do, and they might frequently go back and forth.

You can enable it with:

isWizardMode = true

Immersive Mode

appintro immersive1 appintro immersive2

If you want to display your Intro with a fullscreen experience, you can enable the Immersive mode. This will hide both the Status Bar and the Navigation Bar and the user will have to scroll from the top of the screen to show them again.

This allows you to have more space for your Intro content and graphics.

You can enable it with:

setImmersiveMode()

System Back button

You can lock the System Back button if you don't want your user to go back from intro. This could be useful if you need to request permission and the Intro experience is not optional.

If this is the case, please set to true the following flag:

isSystemBackButtonLocked = true

System UI (Status Bar and Navigation Bar)

appintro system-ui

You can customize the Status Bar, and the Navigation Bar visibility & color with the following methods:

// Hide/Show the status Bar
showStatusBar(true)
// Control the status bar color
setStatusBarColor(Color.GREEN)
setStatusBarColorRes(R.color.green)

// Control the navigation bar color
setNavBarColor(Color.RED)
setNavBarColorRes(R.color.red)

Bottom Bar Margin

By default, the slides use the whole size available in the screen, so it might happen that the bottom bar overlaps the content of the slide if you have set the background color to a non-transparent one. If you want to make sure that the bar doesn't overlap the content, use the setBarMargin function as follows:

setBarMargin(true)

Permission ๐Ÿ”’

appintro permissions

AppIntro simplifies the process of requesting runtime permissions to your user. You can integrate one or more permission request inside a slide with the askForPermissions method inside your activity.

Please note that:

  • slideNumber is in a One-based numbering (it starts from 1)
  • You can specify more than one permission if needed
  • You can specify if the permission is required. If so, users can't proceed if he denies the permission.
// Ask for required CAMERA permission on the second slide. 
askForPermissions(
    permissions = arrayOf(Manifest.permission.CAMERA),
    slideNumber = 2, 
    required = true)

// Ask for both optional ACCESS_FINE_LOCATION and WRITE_EXTERNAL_STORAGE
// permission on the third slide.
askForPermissions(
    permissions = arrayOf(
        Manifest.permission.ACCESS_FINE_LOCATION,
        Manifest.permission.WRITE_EXTERNAL_STORAGE
    ),
    slideNumber = 3, 
    required = false)

Should you need further control on the permission request, you can override those two methods on the AppIntro class:

override fun onUserDeniedPermission(permissionName: String) {
    // User pressed "Deny" on the permission dialog
}
override fun onUserDisabledPermission(permissionName: String) {
    // User pressed "Deny" + "Don't ask again" on the permission dialog
}

Slide Policy

If you want to restrict navigation between your slides (i.e. the user has to toggle a checkbox in order to continue), the SlidePolicy feature might help you.

All you have to do is implement SlidePolicy in your slides.

This interface contains the isPolicyRespected property and the onUserIllegallyRequestedNextPage method that you must implement with your custom logic

class MyFragment : Fragment(), SlidePolicy {
    
    // If user should be allowed to leave this slide
    override val isPolicyRespected: Boolean
        get() = false // Your custom logic here.

    override fun onUserIllegallyRequestedNextPage() {
        // User illegally requested next slide.
        // Show a toast or an informative message to the user.
    }
}

You can find a full working example of SlidePolicy in the example app - CustomSlidePolicyFragment.kt

Example App ๐Ÿ’ก

AppIntro comes with a sample app full of examples and use case that you can use as inspiration for your project. You can find it inside the /example folder.

You can get a debug APK of the sample app from the Pre Merge GitHub Actions job as an output artifact here.

appintro sample app

Translating ๐ŸŒ

Do you want to help AppIntro becoming international ๐ŸŒ? We are more than happy! AppIntro currently supports the following languages.

To add a new translation just add a pull request with a new strings.xml file inside a values-xx folder (where xx is a two-letter ISO 639-1 language code).

In order to provide the translation, your file needs to contain the following strings:

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
    <string name="app_intro_skip_button">[Translation for SKIP]</string>
    <string name="app_intro_next_button">[Translation for NEXT]</string>
    <string name="app_intro_back_button">[Translation for BACK]</string>
    <string name="app_intro_done_button">[Translation for DONE]</string>
    <string name="app_intro_image_content_description">[Translation for "graphics"]</string>
</resources>

An updated version of the English version translation is available here.

If a translation in your language is already available, please check it and eventually fix it (all the strings should be listed, not just a subset).

Snapshots ๐Ÿ“ฆ

Development of AppIntro happens on the main branch. You can get SNAPSHOT versions directly from JitPack if needed.

repositories {
    maven { url "https://jitpack.io" }
}
dependencies {
  implementation "com.github.AppIntro:AppIntro:main-SNAPSHOT"
}

โš ๏ธ Please note that the latest snapshot might be unstable. Use it at your own risk โš ๏ธ

Contributing ๐Ÿค

We're offering support for AppIntro on the #appintro channel on KotlinLang Slack. Come and join the conversation over there. If you don't have access to KotlinLang Slack, you can request access here.

We're looking for contributors! Don't be shy. ๐Ÿ‘ Feel free to open issues/pull requests to help me improve this project.

  • When reporting a new Issue, make sure to attach Screenshots, Videos or GIFs of the problem you are reporting.
  • When submitting a new PR, make sure tests are all green. Write new tests if necessary.

Acknowledgments ๐ŸŒธ

Maintainers

AppIntro is currently developed and maintained by the AppIntro GitHub Org. When submitting a new PR, please ping one of:

Libraries

AppIntro is not relying on any third party library other than those from AndroidX:

  • androidx.appcompat:appcompat
  • androidx.annotation:annotation
  • androidx.constraintlayout:constraintlayout

License ๐Ÿ“„

    Copyright (C) 2015-2020 AppIntro Developers

    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.

Apps using AppIntro ๐Ÿ“ฑ

If you are using AppIntro in your app and would like to be listed here, please open a pull request and we will be more than happy to include you:

List of Apps using AppIntro

appintro's People

Contributors

anutha02 avatar anuthadev avatar avluis avatar chihung93 avatar cortinico avatar cr5315 avatar cyb3rko avatar danluong avatar dragstor avatar ffloriel avatar fleker avatar friederbluemle avatar hoossayn avatar idish avatar javinator9889 avatar juliocbcotta avatar k0bin avatar llin233 avatar marbat87 avatar maxee avatar mhzdev avatar mwllgr avatar paolorotolo avatar rafag avatar renovate[bot] avatar rohitshampur avatar sandromachado avatar tasomaniac avatar timobaehr avatar voghdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

appintro's Issues

No touch feedback on interactive elements

Hey, cool library you have here. I tried Hermes as a demo, and it seems like none of the interactive UI elements (buttons, etc) have touch feedback. It'd be great to add that.

addslide

when i use it its show error
Error:(20, 13) error: cannot find symbol method addSlide(FirstSlide,Context)

addSlide(new FirstSlide(), getApplicationContext());

Hide done button

Hi there

Thanks for the great library, I'm trying to use it for my personal project and have a quick question regarding done button. Basically, I just want to hide the button at all times (or only hide the button when it reaches to the final slide) and present the user with options to register or login in the final slide (will implement my own buttons for that). Any help would be greatly appreciated.

Many Thanks

Change properties to protected

Hi Paolo, its an amazing job you are doing there. I have a suggestion, can you change all your properties to protected instead of private? This way we can extend and customize any of your classes. Thanks in advance.

Layouts are bugged: indicator not centered

Both intro_layout and intro_layout2 layouts are unstable: they rely on sizes of "skip" and "continue" buttons to center pager indicator. On some devices (mine, for example) this also leads to page indicator being off center. Page indicator should be in separate layout which is overlaid on top of the layout with buttons. This way, it will always be centered horizontally regardless of buttons visibility, size and position.

'Done' button doesn't show when there's only 1 slide

Hi.
I don't know if I'm doing something wrong, but if I have only 1 slide the Done button isn't showing. Instead there's the next arrow button that does nothing.

The issue is with both of the layouts (AppIntro and AppIntro2).

Thanks for any help and great library :)

This is a sample of my code:

Intro.java:

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.github.paolorotolo.appintro.AppIntro2;

public class Intro extends AppIntro2
{
    @Override
    public void init(Bundle savedInstanceState)
    {
        addSlide(new FirstSlide(), getApplicationContext());
    }  

    @Override
    public void onDonePressed() {
        Log.d("myapp", "done pressed");
        startActivity(new Intent(this, MainActivity.class));
    }
}

FirstSlide.Java:

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class FirstSlide extends Fragment
{
    public static FirstSlide newInstance()
    {
        FirstSlide fragment = new FirstSlide();
        Bundle args = new Bundle();
        fragment.setArguments(args);
        return fragment;
    }

    public FirstSlide()
    {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                              Bundle savedInstanceState)
    {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_first_slide, container, false);
    }

    @Override
    public void onAttach(Activity activity)
    {
        super.onAttach(activity);
    }

    @Override
    public void onDetach()
    {
        super.onDetach();
    }
}

Retrieve slide fragment from IntroActivity

I'm using AppIntro to make a configuration wizard for my app. In order to do that I added a few widgets to my slide fragment layouts (i.e. a datepicker) and now I'm trying to get and save its values in the onDonePressed method of my IntroActivity.

Since every variable in the AppIntro class is private and there are no getters... is there a way to do this?

Thank you.

Show status bar

Hi,

Is there a better way for showing status bar? Right now I am using:
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

I was wondering if any such method is included in library for showing status bar.

Custom animation inside view

Hello! I'm so interested in your lib, but I've some doubts about it. Transition animations are so cool but I'm also interested in set an animation inside my custom view. I would like to show a screenshot of my app and then show a description changing the alpha value of a TextView. That's easy but I need to know when my view will be shown and then start the animation. So, is there any easy option to notify my fragment when it will appear?

Thanks for all your work.

Correct way to get the fragment reference after configuration change

Hi!

Thank you for great library. It saves much time

While using the Library I faced with the problem of getting the reference to a fragment, which is already added to ViewPager
The simple way for getting the fragment is to use its tag or id (in my case the tag is more preferable). However I didn't find any way of using tag with your library

Say, you have a code like this:

public class ActivityStart extends AppIntro2 {

    private FragmentSlidePassword fragmentSlidePassword;

    @Override
    public void init(Bundle bundle) {
        if (bundle == null) {
            fragmentSlidePassword = new FragmentSlidePassword();
        } else {
            List<Fragment> fragments = getSupportFragmentManager().getFragments();
            for (Fragment fragment : fragments) {
                if (fragment instanceof FragmentSlidePassword) {
                    fragmentSlidePassword = (FragmentSlidePassword) fragment;
                }
            }
        }
        if (fragmentSlidePassword != null) {
            addSlide(fragmentSlidePassword);
        }
    }

}

As you see, this part of code:

List<Fragment> fragments = getSupportFragmentManager().getFragments();
for (Fragment fragment : fragments) {
    if (fragment instanceof FragmentSlidePassword) {
        fragmentSlidePassword = (FragmentSlidePassword) fragment;
    }
}

is used to get the reference to a specific fragment. This code, however, is not a correct way of getting the reference.

Could you please suggest a more elegant way of getting such references?

Thanks

Bundle args not working

I'm using such fragment

public class WelcomeSlide extends Fragment {

    public static final String SLIDE_NAME = "slideName";

    @InjectView(R.id.welcome_slide_title)
    TextView mWelcomeSlideTitle;

    @InjectView(R.id.welcome_slide_image)
    ImageView mWelcomeSlideImage;

    @InjectView(R.id.welcome_slide_text)
    TextView mWelcomeSlideText;

    SlideName mSlideName;

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }

    public enum SlideName {
        AD,
        BADGE,
        BUZZER,
        CHAT,
        MEGAPHONE,
        NEWS
    }

    public WelcomeSlide() {}

    public static WelcomeSlide newInstance(SlideName slideName) {
        WelcomeSlide welcomeSlide = new WelcomeSlide();
        Bundle bundle = new Bundle();
        String slideNameString = slideName.name();
        Log.d("SLIDE", slideNameString);

        bundle.putString(SLIDE_NAME, slideName.name());
        welcomeSlide.mSlideName = slideName;
        welcomeSlide.setArguments(bundle);
        return welcomeSlide;
    }


    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null && getArguments().containsKey(SLIDE_NAME)) {
            mSlideName = SlideName.valueOf(getArguments().getString(SLIDE_NAME, ""));
        } else {
            Log.d("SLIDE", "empty args");
        }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_slide_welcome, container, false);
        ButterKnife.inject(this, v);

        int drawable = R.drawable.ic_news;
        int width = getScreenWidth();
        String slideTitle = "";
        String slideText = "";
        v.setBackgroundResource(R.color.primary);

        switch (mSlideName) {
            case NEWS:
                slideTitle = getString(R.string.slide_news_title);
                slideText = getString(R.string.slide_news_text);
                drawable = R.drawable.ic_news;
                break;
            case AD:
                slideTitle = getString(R.string.slide_advertisements_title);
                slideText = getString(R.string.slide_advertisements_text);
                drawable = R.drawable.ic_ad;
                break;
            case CHAT:
                slideTitle = getString(R.string.slide_chat_title);
                slideText = getString(R.string.slide_chat_text);
                drawable = R.drawable.ic_chat;
                break;
            case MEGAPHONE:
                slideTitle = getString(R.string.slide_respublic_title);
                slideText = getString(R.string.slide_respublic_text);
                drawable = R.drawable.ic_megaphone;
                break;
            case BADGE:
                slideTitle = getString(R.string.slide_datings_title);
                slideText = getString(R.string.slide_datings_text);
                drawable = R.drawable.ic_badge;
                break;
            default:
                slideTitle = getString(R.string.slide_news_title);
                slideText = getString(R.string.slide_news_text);
                drawable = R.drawable.ic_news;
                break;
        }

        mWelcomeSlideTitle.setText(slideTitle);
        mWelcomeSlideText.setText(slideText);
        Picasso.with(getActivity())
                .load(drawable)
                .resize(0, (width / 3) * 2)
                .into(mWelcomeSlideImage);

        return v;
    }

    private int getScreenWidth() {
        Display display = getActivity().getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        return size.x;
    }
}

Creating intro class

public class WelcomeActivity extends AppIntro2 {

    public static final String IS_FROM_SEETINGS = "fromSettings";

    @Override
    public void init(Bundle bundle) {
        addSlide(WelcomeSlide.newInstance(WelcomeSlide.SlideName.NEWS), this);
        addSlide(WelcomeSlide.newInstance(WelcomeSlide.SlideName.CHAT), this);
        addSlide(WelcomeSlide.newInstance(WelcomeSlide.SlideName.MEGAPHONE), this);
        addSlide(WelcomeSlide.newInstance(WelcomeSlide.SlideName.AD), this);
        addSlide(WelcomeSlide.newInstance(WelcomeSlide.SlideName.BADGE), this);

    }

    @Override
    public void onDonePressed() {
        if (!getIntent().getBooleanExtra(IS_FROM_SEETINGS, false)) {
            startActivity(new Intent(this, AuthActivity.class));
        }
        this.finish();
    }
}

And looks like your addSlide in AppIntro2

public void addSlide(@NonNull Fragment fragment, @NonNull Context context) {
        this.fragments.add(Fragment.instantiate(context, fragment.getClass().getName()));
        this.mPagerAdapter.notifyDataSetChanged();
    }

is ignoring my fragment at all

Cannot Add it to my Project

Well, A few days ago, I tried adding this to my project for the people who are new to it.
Successfully Imported this into android studio, added the required stuff, but when I execute, It crashes at the start.
Can you help me add it to my project? Any kind of help is appreciated.

Regards.

Adding Slide directly into Fragment

Is there anyway we can "addSlides" straight thru the SampleSlide Fragment? I'm facing a Java Multiple Inheritance problem where I can't extend my class to AppIntro2.

Extend AppCompatActivity rather than FragmentActivity

Because AppIntro and AppIntro2 use FragmentActivity as their base class, the material for pre-Lollipop doesn't take effect in the Fragments. I'm going to make a fork and test out using AppCompatActivity instead.

Create 2 apps

I added this intro to my app but when i install it to may mobile phone i get two apps:
My Intro and My App name.

So if i open my intro i will have the slides and after the My App Name.
If i open My App Name i will not have My Intro.

if i unistall My Intro, i will unistall both, same if i unistall My App Name

So how can i hide the My Intro (apk) that will only exists in My App Name?

scusa ma sono noob

Touch Events bleed through

If you have a button on a view, touch events for subsequent slides bleed through to the button even though it is not on screen.

Done ImageButton is not selectable on Amazon Fire TV

Amazon Fire TV is based on Android 4.2.2. Done button is not selectable in intro_layout2.

FIX:
/res/layout/intro_layout2.xml
Instead of android:background="null" for both ImageButtons use
android:background="?attr/selectableItemBackgroundBorderless"

Buttons are white when pressed

In AppIntro (not AppIntro2), when you use Appcompat theme, buttons are becoming white when pressed (this bug is reproduced in your example app). I guess this is because new appcompat requires to extend AppCompatActivity for button color tinting to work. I think you should upgrade your library to support proper button theming.

AppIntroFragment.newInstance() not using background color passed in

In CustomIntro.java you have

addSlide(AppIntroFragment.newInstance("Title here", "Description here...\nYeah, I've added this fragment programmatically",
            R.drawable.ic_slide1, R.color.material_blue_grey_800));

but the color you passed in is not being used for the background. I have tried this in my own app and the color I pass int still doesn't work either. I am on nexus 5 emulator running API 21.

Blending background colors

Hello. Great work with this. I'm can't say that I'm very noob but also not very good in Android. I do not know If if missing something but is it possible to make the background colors of every Fragment slides blending every page (i.e, from blue background of first slide, blending to magenta background color which is very much like how Google's app intros were implemented)? Thanks.

addSlide - why are you recreating the fragment?

public void addSlide(@NonNull Fragment fragment, @NonNull Context context) adds a fragment to the intro fragments list. But why are you recreating them if you already get some created fragments?

It would make sense to me to use addSlide(Class<T extends Fragment> clazz, Context context) for such a thing. BUT the current addSlide should stay and just add the orignial fragment to the list...

I wanted to use something like following:

public class Intro extends AppIntro
{
    @Override
    public void init(Bundle savedInstanceState)
    {
        addSlide(Slide.newInstance(0), getApplicationContext());
        addSlide(Slide.newInstance(1), getApplicationContext());
        addSlide(Slide.newInstance(2), getApplicationContext());
        addSlide(Slide.newInstance(3), getApplicationContext());
        addSlide(Slide.newInstance(4), getApplicationContext());
    }
}

This fails, as you don't use my fragments but create new ones, so all my initialising in newInstance (creating an argument bundle) is lost...

Support for Android TV (Intro2)

I can navigate between slides using the Dpad, but I can't finish the intro. There's no way of pressing the done button.

In my Intro class, which extended AppIntro2, I added this method. I recommend that you include this in the class. I can fork the project and make a pull request if you want.

@Override
public boolean onKeyDown(int code, KeyEvent kvent) {
    if(code == KeyEvent.KEYCODE_ENTER || code == KeyEvent.KEYCODE_BUTTON_A) {
        ViewPager vp  = (ViewPager)this.findViewById(com.github.paolorotolo.appintro.R.id.view_pager);
            if(vp.getCurrentItem() == vp.getAdapter().getCount()-1) {
                onDonePressed();
             } else {
                vp.setCurrentItem(vp.getCurrentItem()+1);
            }
            return false;
        }
        return super.onKeyDown(code, kvent);
    }

Error:(42, 66) error: cannot find symbol variable skip

in MyIntro.java i got this error:
Error:(42, 66) error: cannot find symbol variable skip

the code is:

@Override
public void onSkipPressed() {
    loadMainActivity();
    Toast.makeText(getApplicationContext(),getString(R.string.skip), Toast.LENGTH_SHORT).show();
}

line:
Toast.makeText(getApplicationContext(),getString(R.string.skip),

what's the problem?

run it just once?

thanks for this library... :)
I added this to my project but it does not start before my main activity! how to call it when app starts?
and show it just once! I mean when app is recently installed?

ViewPager.setOnPageChangeListener is deprecated

ViewPager.setOnPageChangeListener is now deprecated.
We have to use ViewPager.addOnPageChangeListener instead.

.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) {

        }
    });

Issue for 1 slide only

Hi,

When I create a class with only 1 slide, the "next" button is shown in place of "done" button and it does nothing.
Could you please fix it?

I also would really appreciate if you make the library compatible with API 8.
I made I locally (using nineoldandroid) and it's very easy, but then is boring to merge code when you make updates.
Let me know if you need help with this.

P.S. I'm Italian too :)

Regards,
Marcello

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.