Code Monkey home page Code Monkey logo

welcome-coordinator's Introduction

WelcomeCoordinator

Welcome Coordinator is a library for Android that will help you create really awesome welcome wizards for your apps, but that's not all. You can also use the library to create form wizards really nicely. Take a look to how you would integrate Welcome Coordinator into your app.

Latest Version

Download Build Status Android Arsenal

How to use

1.- Configuring your Project Dependencies

Add the library dependency to your build.gradle file.

dependencies {
    ...
    compile 'com.redbooth:WelcomeCoordinator:1.0.1'
}

2.- Adding and Customizing the View

Add the view to your xml layout file.

<com.redbooth.WelcomeCoordinatorLayout
        android:id="@+id/coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

3.- Modeling the Pages

Modeling your welcome pages is really easy. You only need to create a simple layout resource. Let me an appointment about WelcomePageLayout, the behavior of the layout is the same of the RelativeLayout.

<com.redbooth.WelcomePageLayout
    xmlns:android="http://schemas.android.com/apk/res/android">
    
    ...
    
</com.redbooth.WelcomePageLayout>

WARNING Don't forget to create a WelcomePageLayout as the root element of your page.

4.- Adding the Pages to Coordinator

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...
    final WelcomeCoordinatorLayout coordinatorLayout 
            = (WelcomeCoordinatorLayout)findViewById(R.id.coordinator); 
    coordinatorLayout.addPage(R.layout.welcome_page_1,
                              ...,
                              R.layout.welcome_page_4);
}

5.- Building your own Behaviors

If you want to have behavior on your page views when the user navigate inside of your welcome, you can create you own behaviors.

public class ParallaxTitleBehaviour extends WelcomePageBehavior {
    @Override
    protected void onCreate(WelcomeCoordinatorLayout coordinator) {
        ...
    }
    
    @Override
    protected void onPlaytimeChange(WelcomeCoordinatorLayout coordinator,
                                    float newPlaytime,
                                    float newScrollPosition) {
        ...
    }
}

6.- Setting Up Your Own Behaviors

<com.redbooth.WelcomePageLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    
    <TextView
        ...
        app:view_behavior=".ParallaxTitleBehaviour" />
            
</com.redbooth.WelcomePageLayout>

Developers

Motivation

We created this view as a little piece of the Redbooth app for Android.

License

Copyright Txus Ballesteros & Francisco Sirvent 2016

This file is part of some open source application.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.

welcome-coordinator's People

Contributors

brendankirby avatar ivbaranov avatar narfss avatar txusballesteros 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

welcome-coordinator's Issues

Wrong background color output (demo app)

Thanks for this awesome library!

I'm having some issues with the background color transition in the demo app.
To make this bug visible change the page colors in the demo app to this:

<color name="page1">#ff0000</color>
<color name="page2">#ffffff</color>
<color name="page3">#000000</color>
<color name="page4">#0000FF</color>

The expected output is that page 1 is red, page 2 white, page 3 black, page 4 blue.
Actual output:
Welcome coordinator color bug

I think this bug is due to float to int conversion.
I've tried to change this (here):

int maximumScroll = getMeasuredWidth() * numOfPages;

to this:

float maximumScroll = getMeasuredWidth() * numOfPages;

but that doesn't work.

Also why are the parameters in onScrollPage are not like the ViewPager.OnPageChangeListener parameters?

So from this:

public void onScrollPage(View v, float progress, float maximum)

to this:

public void onScrollPage(View v, int position, float positionOffset, int positionOffsetPixels)

Behaviours doesnt work in nested Layouts?

I have tried to use LinearLayout app:view_behavior for TextViews nested within a LinearLayout but they wont move. Outside of the linearlayout it is working, the examples doesnt show any view with behaviour within a layout as well.
Is there a work around to make layouting easier?

Weird behavior using view_behavior

Hi,

i'm using the welcome-coordinator with five pages, each page has two textviews with a ParallaxTitleBehavior / ParallaxSubtitleBehavior, the same behaviors you use in your demo app.
Scrolling through the pages i get this weird behavior, the text you can see plopping in and out comes from the next page.

ezgif com-video-to-gif 3

I use exact the same classes as you do, so why does this happen?

Change indicator size to dip

I think it is better if the indicator size changed from pixel to dp, so it will be same size across multiple density devices

Getting error, help required urgently

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.VelocityTracker.addMovement(android.view.MotionEvent)' on a null object reference

Rotating view

When rotating view state is not saved and position is weird between pages (half of previous page and half of current page).

Handling button clicks in Welcome Pages?

Hi,

I'm having some issues detecting click events from Buttons on the Welcome Pages themselves. Simply adding a button to the welcome_page_4.xml layout file for example. Where is the best place to handle the clicks? I'm using this library in an Onboarding Activity and would like to return to the main activity once completed.

Many thanks,

Shaun

EditText textAlignment="center" causes welcome coordinator to move to last page

Hi,

I have a welcome coordinator with a total of 3 pages. A EditText on the 2nd page. When I set the textAlignment="center" for the EditText, the last page is opened once the EditText gains focus.

The EditText looks like this:

<EditText
        android:id="@+id/et_welcome_phone"
        android:inputType="phone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="25dp"
        android:layout_marginRight="25dp"
        android:layout_marginBottom="20dp"
        android:textAlignment="center"
        android:singleLine="true" />

After a bit of debugging, I found out that scrollTo(int x, int y) from the class HorizontalScrollView is called. But not from the WelcomeCoordinator classes.

Do you have a hint why this is so and how to fix it?

If you need additional information please tell me.

Thanks!

Force closes

on initializePages() method i have this error
Binary XML file line #28: Error inflating class com.redbooth.demo.RectangleWithCapCircleView
/MessageQueue-JNI: java.lang.NullPointerException: Attempt to invoke virtual method 'com.nineoldandroids.animation.ValueAnimator com.nineoldandroids.animation.ValueAnimator.setDuration(long)' on a null object reference
Android 6
I follow the sample

ScrollView inside WelcomePageLayout

When i use ScrollView inside WelcomePageLayout, when scroll to right from first layout, an error will occur and application will be force closed.
Here is the stack trace:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.VelocityTracker.addMovement(android.view.MotionEvent)' on a null object reference at com.redbooth.WelcomeCoordinatorTouchController.onTouchEvent(WelcomeCoordinatorTouchController.java:98) at com.redbooth.WelcomeCoordinatorLayout.onTouchEvent(WelcomeCoordinatorLayout.java:244) at android.view.View.dispatchTouchEvent(View.java:8472) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2400) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2093) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2406) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2107) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2406) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2107) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2406) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2107) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2406) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2107) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2406) at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2107) at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2625) at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1770) at android.app.Activity.dispatchTouchEvent(Activity.java:2742) at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2586) at android.view.View.dispatchPointerEvent(View.java:8667) at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4129) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3995) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3550) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3603) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3569) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3686) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3577) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3743) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3550) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3603) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3569) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3577) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3550) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5813) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5787) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5758) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5903) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185) at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method) at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:176) at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:5874) at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:5926) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767) at android.view.Choreographer.doCallbacks(Choreographer.java:580) at android.view.Choreographer.doFrame(Choreographer.java:548) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135)

Readme gif

Please, can you provide a gif, video or screenshot of how it is displayed?

Exploring libraries from phone (with @gitskarios) is not so easy, i can't download the project or test it

NullPointerException when trying to scroll

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.VelocityTracker.addMovement(android.view.MotionEvent)' on a null object reference
                                                                                  at com.redbooth.WelcomeCoordinatorTouchController.onTouchEvent(WelcomeCoordinatorTouchController.java:98)
                                                                                  at com.redbooth.WelcomeCoordinatorLayout.onTouchEvent(WelcomeCoordinatorLayout.java:244)
...

It seems like there's a null check in the case MotionEvent.ACTION_DOWN of the switch but not on MotionEvent. ACTION_MOVE. ACTION_MOVE happens before velocityTracker gets obtained.

           case MotionEvent.ACTION_DOWN:
                if (velocityTracker == null) {
                    velocityTracker = VelocityTracker.obtain();
                } else {
                    velocityTracker.clear();
                }
                velocityTracker.addMovement(event);
                currentScrollX = view.getScrollX();
                iniEventX = event.getX();
                break;
            case MotionEvent.ACTION_MOVE:
                setScrollX(scrollLimited(event.getX()));
                velocityTracker.addMovement(event);
                velocityTracker.computeCurrentVelocity(CURRENT_VELOCITY);
                break;

Additionally, it looks like it only happens when the initial touch for scrolling is on an EditText. If it is anywhere else it works.

Click event of a button contained in a WelcomePageLayout

Let's say I have a button inside a WelcomePageLayout, how should I access its click listener? throughout behaviours or directly on the main activity which holds the coordinator? Is the coordinator layout inflating all WelcomePageLayout thus I can access any view contained on them?

Cheers and thanks!

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.