Skip to content

Commit

Permalink
- Small code cleaning
Browse files Browse the repository at this point in the history
- Updated the README file(Added explanation how to get the library from maven central).
  • Loading branch information
itzikBraun committed Jun 9, 2015
1 parent 72d0705 commit dc03d21
Show file tree
Hide file tree
Showing 14 changed files with 290 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-TutorialView-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/1408)
##TutorialView

[![Release](https://img.shields.io/github/release/itzikBraun/TutorialView.svg?label=JitPack)](https://jitpack.io/#itzikBraun/TutorialView)

TutorialView
===============
[![Join the chat at https://gitter.im/itzikBraun/TutorialView](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/itzikBraun/TutorialView?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Release](https://img.shields.io/github/release/itzikBraun/TutorialView.svg?label=JitPack)](https://jitpack.io/#itzikBraun/TutorialView)
![alt tag](http://raw.github.com/ItzikBraun/TutorialView/master/screen_shots/example.gif)

An Android library project providing `Activity` with an explanation about views in your app.
Expand Down Expand Up @@ -91,7 +95,17 @@ overridePendingTransition(R.anim.dummy, R.anim.dummy);
```

###INCLUDING IN YOUR PROJECT
Import the "tutorial_view" module to your project, Then in your build.gradle file add this.(You probably already have the *dependencies* so just add the "*compile project(':tutorial_view')*" ).
######From Maven Central

Add as a dependency to your build.gradle:

dependencies{
compile 'com.github.itzikbraun:TutorialView:0.8.1'
}

######Downloading the source code
Import the "tutorial_view" module to your project,
Then in your build.gradle file add this.(You probably already have the *dependencies* so just add the "*compile project(':tutorial_view')*" ).
```
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
39 changes: 29 additions & 10 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugAndroidTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugAndroidTestSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugAndroidTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
Expand All @@ -26,7 +26,7 @@
</component>
<component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/androidTest/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
Expand All @@ -35,12 +35,12 @@
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/test/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/generated/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
Expand Down Expand Up @@ -69,6 +69,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-core/2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test.espresso/espresso-idling-resource/2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/exposed-instrumentation-api-publish/0.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/rules/0.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support.test/runner/0.2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Expand All @@ -86,6 +91,20 @@
</content>
<orderEntry type="jdk" jdkName="Android API 22 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-core-2.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.1.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.annotation-api-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-library-1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javax.inject-1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-integration-1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-dep-4.10" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="javawriter-2.1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="jsr305-2.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="espresso-idling-resource-2.1" level="project" />
<orderEntry type="module" module-name="tutorial_view" exported="" />
</component>
</module>
24 changes: 22 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,43 @@ apply plugin: 'com.android.application'
def versionMajor = 0
def versionMinor = 8
def versionPatch = 2
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
def versionBuild = 2 // bump for dogfood builds, public betas, etc.

android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
buildToolsVersion "22.0.1"

defaultConfig {
applicationId "com.braunster.tutorialviewapp"
minSdkVersion 15
targetSdkVersion 22

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"


versionCode versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
}

packagingOptions {

exclude 'META-INF/LICENSE.txt'
exclude 'LICENSE.txt'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':tutorial_view')


// App dependencies
compile 'com.android.support:support-annotations:22.1.0'

androidTestCompile 'com.android.support:support-annotations:22.1.0'

// Testing-only dependencies
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package com.braunster.tutorialviewapp;

import android.content.Intent;
import android.graphics.Color;
import android.test.ActivityInstrumentationTestCase2;
import android.test.TouchUtils;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.View;

import com.braunster.tutorialview.TutorialActivity;
import com.braunster.tutorialview.object.Tutorial;
import com.braunster.tutorialview.object.TutorialBuilder;
import com.braunster.tutorialview.object.TutorialIntentBuilder;

import java.util.Random;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.doesNotExist;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
* Created by braunster on 08.05.15.
*/
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {

MainActivity activity;

TutorialActivity tutorialActivity;

private boolean startTutorialForResult = false;

public MainActivityTest() {
super(MainActivity.class);
}

@Override
public void setUp() throws Exception {
super.setUp();

activity = getActivity();
}

@SmallTest
public void testWalkThrough(){

assertNotNull(activity);

onView(withText("T")).check(matches(isDisplayed()));

startWalkThrough();

checkWalkThroughOpen();
}

@SmallTest
public void testClick(){
TouchUtils.clickView(this, activity.findViewById(R.id.view_almost_top_right));


onView(withId(R.id.view_almost_top_right)).check(doesNotExist());
}




public void checkWalkThroughOpen(){

// Tutorial should be open thus the button should not exist.
onView(withText("T")).check(doesNotExist());

assertNotNull(tutorialActivity);

try {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
getInstrumentation().callActivityOnDestroy(tutorialActivity);

getInstrumentation().callActivityOnResume(activity);

onView(withText("T")).check(matches(isDisplayed()));
}
});
} catch (Throwable throwable) {
throwable.printStackTrace();
}

}

public void startWalkThrough(){


Tutorial t1 = getBasicBuilderForTest(activity.findViewById(R.id.view_bottom_left))
.setTutorialInfoTextPosition(Tutorial.InfoPosition.ABOVE)
.setTutorialGotItPosition(Tutorial.GotItPosition.BOTTOM)
.build();

Tutorial t2 = getBasicBuilderForTest(activity.findViewById(R.id.view_top_right))
.setTutorialInfoTextPosition(Tutorial.InfoPosition.LEFT_OF)
.build();

Tutorial t3 = getBasicBuilderForTest(activity.findViewById(R.id.view_almost_top_right))
.setTutorialInfoTextPosition(Tutorial.InfoPosition.RIGHT_OF)
.build();

Tutorial t4 = getBasicBuilderForTest(activity.findViewById(R.id.view_top_left))
.setTutorialInfoTextPosition(Tutorial.InfoPosition.BELOW)
.build();

Tutorial t5 = getBasicBuilderForTest(activity.findViewById(R.id.view_center))
.setTutorialInfoTextPosition(Tutorial.InfoPosition.BELOW)
.setTutorialGotItPosition(Tutorial.GotItPosition.BOTTOM)
.build();


final TutorialIntentBuilder builder = new TutorialIntentBuilder(activity);

// if true the status bar and navigation bar will be colored on Lollipop devices.
builder.changeSystemUiColor(true);

builder.setWalkThroughList(t1, t2, t3, t4, t5);

final Intent intent = builder.getIntent();
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK);

tutorialActivity = (TutorialActivity) getInstrumentation().startActivitySync(intent);

assertNotNull(tutorialActivity);

assertEquals(tutorialActivity.getClass(), TutorialActivity.class);
}

private TutorialBuilder getBasicBuilderForTest(View v){
TutorialBuilder tBuilder = new TutorialBuilder();

tBuilder.setTitle("The Title")
.setViewToSurround(v)
.setInfoText("This is the explanation about the view.")
.setBackgroundColor(randomColor())
.setTutorialTextColor(Color.WHITE)
.setTutorialTextTypeFaceName("fonts/olivier.ttf")
.setTutorialTextSize(30)
.setAnimationDuration(500);

return tBuilder;
}

private int randomColor(){
Random rnd = new Random();
return Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ protected void onCreate(Bundle savedInstanceState) {
tutorialView.setTutorialText("This is some general text that is not that long but also not so short.");

// Only show the walk through when the activity is first created.
if (savedInstanceState == null)
startWalkThrough();
// if (savedInstanceState == null)
// startWalkThrough();
}

@Override
Expand Down Expand Up @@ -199,7 +199,7 @@ public void onClick(View v) {
overridePendingTransition(R.anim.dummy, R.anim.dummy);
}

private void startWalkThrough(){
public void startWalkThrough(){

// Running a walk through as the activity is opened, Tutorial
// building should be wrapped in a runnable that is posted so
Expand Down
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
buildscript {
repositories {
jcenter()
mavenCentral()

}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:1.2.3'
}
}


allprojects {

repositories {
jcenter()
mavenCentral()
}
}


Loading

0 comments on commit dc03d21

Please sign in to comment.