Skip to content

Commit

Permalink
Merge pull request #31 from TangoAgency/release/0.0.4
Browse files Browse the repository at this point in the history
Release/0.0.4
  • Loading branch information
radzio authored Oct 12, 2016
2 parents 83cc0d2 + 970ebc6 commit 646324c
Show file tree
Hide file tree
Showing 30 changed files with 190 additions and 99 deletions.
30 changes: 27 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
language: android

jdk:
- oraclejdk8

android:
components:
- tools
- tools
- platform-tools
- build-tools-24.0.2
- build-tools-24.0.3
- android-24
- extra-google-google_play_services
- extra-google-m2repository
- extra-android-m2repository
jdk:
- oraclejdk8

licenses:
- '.+'

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/

cache:
directories:
- $HOME/.m2
- $HOME/.gradle

before_install:
- mkdir "$ANDROID_HOME/licenses" || true
- echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
- echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"

notifications:
slack:
secure: qIOOj57yVyinyTs9SinZmp/aVN5Or/9LDg+l9SYMqVCaqM9zDk7s1/m/L7VNPdWCuWOzLf9g1+0ReBcwZ6vh+HWBQ4T1V4HQd09whhUGyW9kMj3BKE0gWpIJLYKuhM551auv3FVzTp3u27q4W0zgiXB8qHWatTQu9rcPumG+IJaZD1uHsbhrQq0RLD8n8hWjQAdkRKRtSo4UR55sTK35uGRZbMFcyJSiStBXRP43w2kTR1MxIst4r9NeOx/sjebBQ/XxabKJgqAHhue80O3Cy8s0u59NDHOMpqJOu00cdKbtmhePQsY0FUl5/689Xdc+bDs3OcwGWbokaFEjXLwA1De+CIz0NMjgdtyHIbEGWcYav8jujke4wYaAtQRPgKHtVL9EpIUX07jPznstRNV8T3H1qrf2S5xHW6elZ7nLOnYuDKsgETmEuDQLAg8ibYQTF4zNBYGFwvC3GOJCqCu+o40OwmFghyohmXxSmo8Cg019V/hOtmYThaFcyDQhN8QGkUSqHrjDNRxyyye2JHvU+bJlTshonZlPh2gM9NA9Tf/3fMEobtnA5XYurntj43UhdZ4HdsYjbrFhbOrXEBRx1mG8gcCFgexz/3E9wq7GN0fqm6LMB8radqUbP0hAd2cADlN9suCWWLVnufLAiS5iqo55M2e9u749p+e+ESCLXIo=
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## CHANGELOG:

#### 0.0.4
- Added support for showing snackbars
- Added support for asking permissions in custom slides
- Fix: canMoveFurther() method works on last slide
- Fix: Library isn't crashing when no slides provided

#### 0.0.3
- Added onFinish method

#### 0.0.3
- Added onFinish method

#### 0.0.2
- Added API for animations
- Added Travis config file
- Added Splash Screen for example app
- Bug fixes

#### 0.0.1
- Initial commit with library
4 changes: 4 additions & 0 deletions CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Contribute
Feel free to contribute code to Material Intro Screen. You can do it by forking the repository via Github and sending pull request with changes.

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. Also be sure that all tests are passing.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Android Material Intro Screen
[ ![Download](https://api.bintray.com/packages/tangoagency/maven/material-intro-screen/images/download.svg) ](https://bintray.com/tangoagency/maven/material-intro-screen/_latestVersion)
[![Build Status](https://travis-ci.org/TangoAgency/material-intro-screen.svg?branch=master)](https://travis-ci.org/TangoAgency/material-intro-screen)
[![Android Arsenal Material Intro Screen](https://img.shields.io/badge/Android%20Arsenal-Material--Intro--Screen-green.svg?style=true)](http://android-arsenal.com/details/1/4368)

Material intro screen is inspired by [Material Intro] and developed with love from scratch. I decided to rewrite completely almost all features in order to make Android intro screen easy to use for everyone and extensible as possible.
## Features
Expand Down Expand Up @@ -53,7 +54,7 @@ public class IntroActivity extends MaterialIntroActivity
new MessageButtonBehaviour(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(IntroActivity.this, "We provide solutions to make you love your work", Toast.LENGTH_SHORT).show();
showMessage("We provide solutions to make you love your work");
}
}, "Work with love"));
}
Expand All @@ -73,7 +74,7 @@ public class IntroActivity extends MaterialIntroActivity

You can set enter, default and exit translation for every view in intro activity. To achive this you need to get translation wrapper for chosen view (for example: ```getNextButtonTranslationWrapper()```) and set there new class which will implement ```IViewTranslation```
```java
getNextButtonTranslationWrapper()
getBackButtonTranslationWrapper()
.setEnterTranslation(new IViewTranslation() {
@Override
public void translate(View view, @FloatRange(from = 0, to = 1.0) float percentage) {
Expand Down Expand Up @@ -117,6 +118,21 @@ All features which are not available in simple Slide Fragment are shown here: [C
- [InkPageIndicator.java] by [@NickButcher]
- Images used to create sample app are from [freepik]

## Getting Help

To report a specific problem or feature request, [open a new issue on Github](https://github.com/TangoAgency/material-intro-screen/issues/new).

## Company

[![Facebook](https://github.com/TangoAgency/material-intro-screen/blob/master/images/facebook.png)](https://www.facebook.com/TangoDigitalAgency)     [![Twitter](https://github.com/TangoAgency/material-intro-screen/blob/master/images/twitter.png)](https://twitter.com/Tango_Agency)     [![LinkedIn](https://github.com/TangoAgency/material-intro-screen/blob/master/images/linkedin.png)](https://www.linkedin.com/company/tango-digital-agency)

[Here](https://github.com/TangoAgency/) you can see open source work developed by Tango Agency.

Whether you're searching for a new partner or trusted team for creating your new great product we are always ready to start work with you.

You can contact us via [email protected].
Thanks in advance.

[Custom Slide]: <https://github.com/TangoAgency/material-intro-screen/blob/master/app/src/main/java/agency/tango/materialintro/CustomSlide.java>
[Material Intro]: <https://github.com/HeinrichReimer/material-intro/tree/master/library/src/main/java/com/heinrichreimersoftware/materialintro/view/parallax>
[@HeinrichReimer]: <https://github.com/HeinrichReimer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
enableLastSlideAlphaExitTransition(true);

getNextButtonTranslationWrapper()
getBackButtonTranslationWrapper()
.setEnterTranslation(new IViewTranslation() {
@Override
public void translate(View view, @FloatRange(from = 0, to = 1.0) float percentage) {
Expand All @@ -36,7 +36,7 @@ public void translate(View view, @FloatRange(from = 0, to = 1.0) float percentag
new MessageButtonBehaviour(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(IntroActivity.this, "We provide solutions to make you love your work", Toast.LENGTH_SHORT).show();
showMessage("We provide solutions to make you love your work");
}
}, "Work with love"));

Expand All @@ -61,7 +61,7 @@ public void onClick(View v) {
new MessageButtonBehaviour(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(IntroActivity.this, "Try us", Toast.LENGTH_SHORT).show();
showMessage("Try us!");
}
}, "Tools"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, IntroActivity.class);
MainActivity.this.startActivity(intent);
startActivity(intent);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-rc2'
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.novoda:bintray-release:0.3.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Binary file added images/facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import agency.tango.materialintroscreen.listeners.MessageButtonBehaviourOnPageSelected;
import agency.tango.materialintroscreen.listeners.SwipeStateTouchListener;
import agency.tango.materialintroscreen.listeners.ViewBehavioursOnPageChangeListener;
import agency.tango.materialintroscreen.listeners.clickListeners.FinishScreenClickListener;
import agency.tango.materialintroscreen.listeners.clickListeners.PermissionNotGrantedClickListener;
import agency.tango.materialintroscreen.listeners.scrollListeners.ParallaxScrollListener;
import agency.tango.materialintroscreen.widgets.InkPageIndicator;
Expand Down Expand Up @@ -95,16 +94,20 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initOnPageChangeListeners();

permissionNotGrantedClickListener = new PermissionNotGrantedClickListener(this, nextButtonTranslationWrapper);
finishScreenClickListener = new FinishScreenClickListener(this);
finishScreenClickListener = new FinishScreenClickListener();

setBackButtonVisible();

viewPager.post(new Runnable() {
@Override
public void run() {
int currentItem = viewPager.getCurrentItem();
messageButtonBehaviourOnPageSelected.pageSelected(currentItem);
nextButtonBehaviour(currentItem, adapter.getItem(currentItem));
if (adapter.slidesCount() == 0) {
finish();
} else {
int currentItem = viewPager.getCurrentItem();
messageButtonBehaviourOnPageSelected.pageSelected(currentItem);
nextButtonBehaviour(currentItem, adapter.getItem(currentItem));
}
}
});
}
Expand All @@ -113,7 +116,7 @@ public void run() {
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
SlideFragment fragment = adapter.getItem(viewPager.getCurrentItem());
boolean hasPermissionToGrant = fragment.hasNeededPermissionsToGrant();
if (hasPermissionToGrant == false) {
if (!hasPermissionToGrant) {
viewPager.setAllowedSwipeDirection(SwipeableViewPager.SwipeDirection.all);
nextButtonBehaviour(viewPager.getCurrentItem(), fragment);
messageButtonBehaviourOnPageSelected.pageSelected(viewPager.getCurrentItem());
Expand Down Expand Up @@ -170,7 +173,7 @@ public void pageScrolled(final int position, float offset) {
viewPager.post(new Runnable() {
@Override
public void run() {
if (adapter.getItem(position).hasNeededPermissionsToGrant() || adapter.getItem(position).canMoveFurther() == false) {
if (adapter.getItem(position).hasNeededPermissionsToGrant() || !adapter.getItem(position).canMoveFurther()) {
viewPager.setCurrentItem(position);
pageIndicator.clearJoiningFractions();
}
Expand Down Expand Up @@ -237,6 +240,7 @@ private int color(@ColorRes int color) {
*
* @param slideFragment Fragment to add
*/
@SuppressWarnings("unused")
public void addSlide(SlideFragment slideFragment) {
adapter.addItem(slideFragment);
}
Expand All @@ -247,6 +251,7 @@ public void addSlide(SlideFragment slideFragment) {
* @param slideFragment Fragment to add
* @param messageButtonBehaviour Add behaviour for message button
*/
@SuppressWarnings("unused")
public void addSlide(SlideFragment slideFragment, MessageButtonBehaviour messageButtonBehaviour) {
adapter.addItem(slideFragment);
messageButtonBehaviours.put(adapter.getLastItemPosition(), messageButtonBehaviour);
Expand All @@ -263,8 +268,8 @@ public void setSkipButtonVisible() {
skipButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (int position = viewPager.getCurrentItem(); position < adapter.getCalculatedCount(); position++) {
if (adapter.getItem(position).canMoveFurther() == false) {
for (int position = viewPager.getCurrentItem(); position < adapter.slidesCount(); position++) {
if (!adapter.getItem(position).canMoveFurther()) {
viewPager.setCurrentItem(position);
showError(adapter.getItem(position).cantMoveFurtherErrorMessage());
return;
Expand Down Expand Up @@ -313,6 +318,7 @@ public ViewTranslationWrapper getNextButtonTranslationWrapper() {
*
* @return ViewTranslationWrapper
*/
@SuppressWarnings("unused")
public ViewTranslationWrapper getBackButtonTranslationWrapper() {
return backButtonTranslationWrapper;
}
Expand All @@ -322,6 +328,7 @@ public ViewTranslationWrapper getBackButtonTranslationWrapper() {
*
* @return ViewTranslationWrapper
*/
@SuppressWarnings("unused")
public ViewTranslationWrapper getPageIndicatorTranslationWrapper() {
return pageIndicatorTranslationWrapper;
}
Expand All @@ -331,6 +338,7 @@ public ViewTranslationWrapper getPageIndicatorTranslationWrapper() {
*
* @return ViewTranslationWrapper
*/
@SuppressWarnings("unused")
public ViewTranslationWrapper getViewPagerTranslationWrapper() {
return viewPagerTranslationWrapper;
}
Expand All @@ -340,6 +348,7 @@ public ViewTranslationWrapper getViewPagerTranslationWrapper() {
*
* @return ViewTranslationWrapper
*/
@SuppressWarnings("unused")
public ViewTranslationWrapper getSkipButtonTranslationWrapper() {
return skipButtonTranslationWrapper;
}
Expand All @@ -352,6 +361,15 @@ public void enableLastSlideAlphaExitTransition(boolean enableAlphaExitTransition
adapter.addEmptySlide(new LastEmptySlideFragment());
}

/**
* Show snackbar message
*
* @param message Message which will be visible to user
*/
public void showMessage(String message) {
showError(message);
}

/**
* Override to execute this method on finish intro activity
*/
Expand Down Expand Up @@ -392,4 +410,18 @@ private void tintButtons(ColorStateList color) {
ViewCompat.setBackgroundTintList(skipButton, color);
}
}

private class FinishScreenClickListener implements View.OnClickListener {
@Override
public void onClick(View v) {
SlideFragment slideFragment = adapter.getItem(adapter.getLastItemPosition());
if (!slideFragment.canMoveFurther()) {
nextButtonTranslationWrapper.error();
showError(slideFragment.cantMoveFurtherErrorMessage());
} else {
onFinish();
finish();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.view.View;

@SuppressWarnings("unused")
public class MessageButtonBehaviour {
private View.OnClickListener clickListener;
private String messageButtonText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.View;
import android.widget.LinearLayout;

@SuppressWarnings("unused")
public class MoveUpBehaviour extends CoordinatorLayout.Behavior<LinearLayout> {
public MoveUpBehaviour(Context context, AttributeSet attrs) {
super(context, attrs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static SlideFragment createInstance(SlideFragmentBuilder builder) {
}

public static boolean isNotNullOrEmpty(String string) {
return string != null && string.isEmpty() == false;
return string != null && !string.isEmpty();
}

@Nullable
Expand Down Expand Up @@ -93,7 +93,7 @@ public int buttonsColor() {

public boolean hasAnyPermissionsToGrant() {
boolean hasPermissionToGrant = hasPermissionsToGrant(neededPermissions);
if (hasPermissionToGrant == false) {
if (!hasPermissionToGrant) {
hasPermissionToGrant = hasPermissionsToGrant(possiblePermissions);
}
return hasPermissionToGrant;
Expand Down Expand Up @@ -144,14 +144,14 @@ public void askForPermissions() {
}

String[] permissionsToGrant = removeEmptyAndNullStrings(notGrantedPermissions);
ActivityCompat.requestPermissions(this.getActivity(), permissionsToGrant, PERMISSIONS_REQUEST_CODE);
ActivityCompat.requestPermissions(getActivity(), permissionsToGrant, PERMISSIONS_REQUEST_CODE);
}

private boolean hasPermissionsToGrant(String[] permissions) {
if (permissions != null) {
for (int i = 0; i < permissions.length; i++) {
if (isNotNullOrEmpty(permissions[i])) {
if (ContextCompat.checkSelfPermission(getContext(), permissions[i]) != PackageManager.PERMISSION_GRANTED) {
for (String permission : permissions) {
if (isNotNullOrEmpty(permission)) {
if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED) {
return true;
}
}
Expand All @@ -160,6 +160,7 @@ private boolean hasPermissionsToGrant(String[] permissions) {
return false;
}

@SuppressWarnings("SuspiciousMethodCalls")
private String[] removeEmptyAndNullStrings(final ArrayList<String> permissions) {
List<String> list = new ArrayList<>(permissions);
list.removeAll(Collections.singleton(null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;

@SuppressWarnings({"unused", "WeakerAccess"})
public class SlideFragmentBuilder {
int backgroundColor;
int buttonsColor;
Expand Down
Loading

0 comments on commit 646324c

Please sign in to comment.