From 09c6f1b3f292101d7ceacd09bad119b57f00b629 Mon Sep 17 00:00:00 2001 From: aaronliew Date: Fri, 31 Jul 2015 15:49:17 +0800 Subject: [PATCH 01/15] [FEATURE] Added OnClickListener to Overlay --- tourguide/src/main/java/tourguide/tourguide/Overlay.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tourguide/src/main/java/tourguide/tourguide/Overlay.java b/tourguide/src/main/java/tourguide/tourguide/Overlay.java index dceb771..1373173 100644 --- a/tourguide/src/main/java/tourguide/tourguide/Overlay.java +++ b/tourguide/src/main/java/tourguide/tourguide/Overlay.java @@ -1,6 +1,7 @@ package tourguide.tourguide; import android.graphics.Color; +import android.view.View; import android.view.animation.Animation; /** @@ -11,6 +12,7 @@ public class Overlay { public boolean mDisableClick; public Style mStyle; public Animation mEnterAnimation, mExitAnimation; + public View.OnClickListener mOnClickListener; public enum Style { Circle, Rectangle @@ -68,4 +70,10 @@ public Overlay setExitAnimation(Animation exitAnimation){ mExitAnimation = exitAnimation; return this; } + + public Overlay setOnClickListener(View.OnClickListener OnClickListener){ + mOnClickListener=OnClickListener; + return this; + } + } From 13d6c188574d59a00d6f37338e8b73ac23a04cc4 Mon Sep 17 00:00:00 2001 From: aaronliew Date: Fri, 31 Jul 2015 15:51:03 +0800 Subject: [PATCH 02/15] [FEATURE] Added PlayInSequence method to play the TourGuide in sequence one after another --- .../java/tourguide/tourguide/TourGuide.java | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/tourguide/src/main/java/tourguide/tourguide/TourGuide.java b/tourguide/src/main/java/tourguide/tourguide/TourGuide.java index 1b55ccf..ec69dad 100644 --- a/tourguide/src/main/java/tourguide/tourguide/TourGuide.java +++ b/tourguide/src/main/java/tourguide/tourguide/TourGuide.java @@ -46,6 +46,8 @@ public enum MotionType { private ToolTip mToolTip; private Pointer mPointer; private Overlay mOverlay; + private View[] mViews; + private Integer CurrentSequence =0; /************* * @@ -94,11 +96,38 @@ public TourGuide playOn(View view){ return this; } + public TourGuide playInSequence(View... view){ + mViews=view; + mHighlightedView = mViews[CurrentSequence]; + setupView(); + return this; + } + + + + + public TourGuide next() { + cleanUp(); + CurrentSequence += 1; + if (CurrentSequence < mViews.length) { + mHighlightedView = mViews[CurrentSequence]; + setupView(); + }else{ + CurrentSequence =0; + } + return this; + } + + public Integer getCurrentSequence() { + return CurrentSequence; + } + public TourGuide setOverlay(Overlay overlay){ mOverlay = overlay; return this; } + /** * Set the toolTip * @param toolTip @@ -117,6 +146,11 @@ public TourGuide setPointer(Pointer pointer){ mPointer = pointer; return this; } + + public Overlay getOverlay() { + return mOverlay; + } + /** * Clean up the tutorial that is added to the activity */ @@ -171,6 +205,7 @@ public void onGlobalLayout() { /* Initialize a frame layout with a hole */ mFrameLayout = new FrameLayoutWithHole(mActivity, mHighlightedView, mMotionType, mOverlay); + /* handle click disable */ handleDisableClicking(mFrameLayout); @@ -193,12 +228,23 @@ private void handleDisableClicking(FrameLayoutWithHole frameLayoutWithHole){ if (mOverlay != null && mOverlay.mDisableClick) { frameLayoutWithHole.setViewHole(mHighlightedView); frameLayoutWithHole.setSoundEffectsEnabled(false); - frameLayoutWithHole.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Log.d("tourguide", "disable, do nothing"); - } - }); + + //passing Overlay On-Click listener to frame layout + if (mOverlay.mOnClickListener!=null) { + mFrameLayout.setClickable(true); + mFrameLayout.setOnClickListener(mOverlay.mOnClickListener); + } + + else{ + frameLayoutWithHole.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Log.d("tourguide", "disable, do nothing"); + } + }); + + } + } } private void setupToolTip(FrameLayoutWithHole frameLayoutWithHole){ From 5ac5f4acdd6ecc1dcb22f7e6a6fbe5bab2521b7d Mon Sep 17 00:00:00 2001 From: aaronliew Date: Fri, 31 Jul 2015 15:53:07 +0800 Subject: [PATCH 03/15] [EXAMPLE] Added InSequenceOverlayCustomizationActivity to demonstrate how to use TourGuide in Sequence one after another using next and PlayInSequence method --- .idea/.name | 1 + .idea/compiler.xml | 23 ++ .idea/copyright/profiles_settings.xml | 3 + .idea/encodings.xml | 5 + .idea/gradle.xml | 19 ++ .idea/misc.xml | 10 + .idea/modules.xml | 11 + .idea/scopes/scope_settings.xml | 5 + .idea/vcs.xml | 7 + TourGuide.iml | 8 +- app/.idea/.name | 1 + app/.idea/app.iml | 10 + app/.idea/compiler.xml | 23 ++ app/.idea/copyright/profiles_settings.xml | 3 + app/.idea/encodings.xml | 5 + app/.idea/misc.xml | 5 + app/.idea/modules.xml | 9 + app/.idea/scopes/scope_settings.xml | 5 + app/.idea/vcs.xml | 7 + app/.idea/workspace.xml | 218 ++++++++++++++++++ app/app.iml | 14 +- app/src/main/AndroidManifest.xml | 4 + ...nSequenceOverlayCustomizationActivity.java | 103 +++++++++ .../tourguidedemo/TourGuideDemoMain.java | 8 +- tourguide/.idea/.name | 1 + tourguide/.idea/compiler.xml | 23 ++ .../.idea/copyright/profiles_settings.xml | 3 + tourguide/.idea/encodings.xml | 5 + tourguide/.idea/misc.xml | 5 + tourguide/.idea/modules.xml | 9 + tourguide/.idea/scopes/scope_settings.xml | 5 + tourguide/.idea/tourguide.iml | 10 + tourguide/.idea/vcs.xml | 7 + tourguide/.idea/workspace.xml | 218 ++++++++++++++++++ tourguide/tourguide.iml | 17 +- 35 files changed, 785 insertions(+), 25 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/compiler.xml create mode 100644 .idea/copyright/profiles_settings.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/scopes/scope_settings.xml create mode 100644 .idea/vcs.xml create mode 100644 app/.idea/.name create mode 100644 app/.idea/app.iml create mode 100644 app/.idea/compiler.xml create mode 100644 app/.idea/copyright/profiles_settings.xml create mode 100644 app/.idea/encodings.xml create mode 100644 app/.idea/misc.xml create mode 100644 app/.idea/modules.xml create mode 100644 app/.idea/scopes/scope_settings.xml create mode 100644 app/.idea/vcs.xml create mode 100644 app/.idea/workspace.xml create mode 100644 app/src/main/java/tourguide/tourguidedemo/InSequenceOverlayCustomizationActivity.java create mode 100644 tourguide/.idea/.name create mode 100644 tourguide/.idea/compiler.xml create mode 100644 tourguide/.idea/copyright/profiles_settings.xml create mode 100644 tourguide/.idea/encodings.xml create mode 100644 tourguide/.idea/misc.xml create mode 100644 tourguide/.idea/modules.xml create mode 100644 tourguide/.idea/scopes/scope_settings.xml create mode 100644 tourguide/.idea/tourguide.iml create mode 100644 tourguide/.idea/vcs.xml create mode 100644 tourguide/.idea/workspace.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..ab246e6 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +TourGuide \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..99b502c --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..59436c9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c18248d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/TourGuide.iml b/TourGuide.iml index 9bef050..0bb6048 100644 --- a/TourGuide.iml +++ b/TourGuide.iml @@ -1,14 +1,13 @@ - + - + @@ -16,4 +15,5 @@ - \ No newline at end of file + + diff --git a/app/.idea/.name b/app/.idea/.name new file mode 100644 index 0000000..7a0b7f0 --- /dev/null +++ b/app/.idea/.name @@ -0,0 +1 @@ +app \ No newline at end of file diff --git a/app/.idea/app.iml b/app/.idea/app.iml new file mode 100644 index 0000000..ef582b1 --- /dev/null +++ b/app/.idea/app.iml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/app/.idea/compiler.xml b/app/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/app/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/app/.idea/copyright/profiles_settings.xml b/app/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/app/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/app/.idea/encodings.xml b/app/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/app/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/.idea/misc.xml b/app/.idea/misc.xml new file mode 100644 index 0000000..28b71f5 --- /dev/null +++ b/app/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/.idea/modules.xml b/app/.idea/modules.xml new file mode 100644 index 0000000..d1d947c --- /dev/null +++ b/app/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/app/.idea/scopes/scope_settings.xml b/app/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/app/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/app/.idea/vcs.xml b/app/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/app/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/.idea/workspace.xml b/app/.idea/workspace.xml new file mode 100644 index 0000000..23e455f --- /dev/null +++ b/app/.idea/workspace.xml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + 1438237027057 + 1438237027057 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/app.iml b/app/app.iml index b7dee86..a4b7ee6 100644 --- a/app/app.iml +++ b/app/app.iml @@ -1,5 +1,5 @@ - + @@ -13,11 +13,8 @@ - + @@ -98,4 +95,5 @@ - \ No newline at end of file + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 31cad0b..9100cca 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -39,6 +39,10 @@ + + diff --git a/app/src/main/java/tourguide/tourguidedemo/InSequenceOverlayCustomizationActivity.java b/app/src/main/java/tourguide/tourguidedemo/InSequenceOverlayCustomizationActivity.java new file mode 100644 index 0000000..9599c67 --- /dev/null +++ b/app/src/main/java/tourguide/tourguidedemo/InSequenceOverlayCustomizationActivity.java @@ -0,0 +1,103 @@ +package tourguide.tourguidedemo; + +import android.app.Activity; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.view.Gravity; +import android.view.View; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.widget.Button; + +import tourguide.tourguide.Overlay; +import tourguide.tourguide.Pointer; +import tourguide.tourguide.ToolTip; +import tourguide.tourguide.TourGuide; + +/** + * InSequenceActivity demonstrates how to use TourGuide in sequence one after another + */ +public class InSequenceOverlayCustomizationActivity extends ActionBarActivity { + public TourGuide mTutorialHandler, mTutorialHandler2; + public Activity mActivity; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + mActivity = this; + setContentView(R.layout.activity_in_sequence); + + /* Get 3 buttons from layout */ + Button button = (Button)findViewById(R.id.button); + final Button button2 = (Button)findViewById(R.id.button2); + final Button button3 = (Button)findViewById(R.id.button3); + + /* setup enter and exit animation */ + Animation enterAnimation = new AlphaAnimation(0f, 1f); + enterAnimation.setDuration(600); + enterAnimation.setFillAfter(true); + + Animation exitAnimation = new AlphaAnimation(1f, 0f); + exitAnimation.setDuration(600); + exitAnimation.setFillAfter(true); + + /* initialize TourGuide without playOn() */ + mTutorialHandler = TourGuide.init(this).with(TourGuide.Technique.Click) + .setPointer(new Pointer()) + .setToolTip(new ToolTip() + .setTitle("Hey!") + .setDescription("I'm the top fellow") + .setGravity(Gravity.RIGHT)) + .setOverlay(new Overlay() + .setEnterAnimation(enterAnimation) + .setExitAnimation(exitAnimation) + .setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + if (mTutorialHandler.getCurrentSequence()==0){ + mTutorialHandler.setToolTip(new ToolTip().setTitle("Hey there!").setDescription("Just the middle man").setGravity(Gravity.BOTTOM|Gravity.LEFT)).next(); + } + else if (mTutorialHandler.getCurrentSequence()==1) { + mTutorialHandler.setToolTip(new ToolTip().setTitle("Hey there!").setDescription("It's time to say goodbye").setGravity(Gravity.TOP|Gravity.RIGHT)).next(); + } + + else if (mTutorialHandler.getCurrentSequence()==2){ + mTutorialHandler.next(); // if there is no view on the next sequence, it will do cleanup itself. + } + + } + }) + ); + + + View[] views = {button, button2, button3}; + + + /* setup 1st button, when clicked, cleanUp() and re-run TourGuide on button2 */ + button.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View view) { + mTutorialHandler.setToolTip(new ToolTip().setTitle("Hey there!").setDescription("Just the middle man").setGravity(Gravity.BOTTOM|Gravity.LEFT)).next(); //it will do cleanup itself + } + }); + + /* setup 2nd button, when clicked, cleanUp() and re-run TourGuide on button3 */ + button2.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View view) { + mTutorialHandler.setToolTip(new ToolTip().setTitle("Hey there!").setDescription("It's time to say goodbye").setGravity(Gravity.TOP|Gravity.RIGHT)).next(); + } + }); + + /* setup 3rd button, when clicked, run cleanUp() */ + button3.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View view) { + mTutorialHandler.cleanUp(); + } + }); + + mTutorialHandler.playInSequence(views); + } +} diff --git a/app/src/main/java/tourguide/tourguidedemo/TourGuideDemoMain.java b/app/src/main/java/tourguide/tourguidedemo/TourGuideDemoMain.java index 1802399..709e936 100644 --- a/app/src/main/java/tourguide/tourguidedemo/TourGuideDemoMain.java +++ b/app/src/main/java/tourguide/tourguidedemo/TourGuideDemoMain.java @@ -31,8 +31,8 @@ class CustomAdapter extends BaseAdapter { public Object getItem(int arg0) { return null;} public long getItemId(int position) { return position; } public int getCount() { - return 16; -// return 17; +// return 16; + return 17; } public View getView(final int position, View convertView, ViewGroup parent) { @@ -107,7 +107,11 @@ public View getView(final int position, View convertView, ViewGroup parent) { } else if (position == 15) { intent = new Intent(mActivity, InSequenceActivity.class); text.setText("In Sequence"); + } else if (position == 16) { + intent = new Intent(mActivity, InSequenceOverlayCustomizationActivity.class); + text.setText("In Sequence Overlay Customization"); } + // else if (position == 16){ // intent = new Intent(mActivity, MemoryLeakTestActivity.class); // text.setText("Memory Leak Test"); diff --git a/tourguide/.idea/.name b/tourguide/.idea/.name new file mode 100644 index 0000000..c804bef --- /dev/null +++ b/tourguide/.idea/.name @@ -0,0 +1 @@ +tourguide \ No newline at end of file diff --git a/tourguide/.idea/compiler.xml b/tourguide/.idea/compiler.xml new file mode 100644 index 0000000..217af47 --- /dev/null +++ b/tourguide/.idea/compiler.xml @@ -0,0 +1,23 @@ + + + + + + diff --git a/tourguide/.idea/copyright/profiles_settings.xml b/tourguide/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/tourguide/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/tourguide/.idea/encodings.xml b/tourguide/.idea/encodings.xml new file mode 100644 index 0000000..e206d70 --- /dev/null +++ b/tourguide/.idea/encodings.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tourguide/.idea/misc.xml b/tourguide/.idea/misc.xml new file mode 100644 index 0000000..28b71f5 --- /dev/null +++ b/tourguide/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/tourguide/.idea/modules.xml b/tourguide/.idea/modules.xml new file mode 100644 index 0000000..f8dbbab --- /dev/null +++ b/tourguide/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tourguide/.idea/scopes/scope_settings.xml b/tourguide/.idea/scopes/scope_settings.xml new file mode 100644 index 0000000..922003b --- /dev/null +++ b/tourguide/.idea/scopes/scope_settings.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/tourguide/.idea/tourguide.iml b/tourguide/.idea/tourguide.iml new file mode 100644 index 0000000..ef582b1 --- /dev/null +++ b/tourguide/.idea/tourguide.iml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tourguide/.idea/vcs.xml b/tourguide/.idea/vcs.xml new file mode 100644 index 0000000..def6a6a --- /dev/null +++ b/tourguide/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tourguide/.idea/workspace.xml b/tourguide/.idea/workspace.xml new file mode 100644 index 0000000..5199520 --- /dev/null +++ b/tourguide/.idea/workspace.xml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost + 5050 + + + + + + + 1438237307100 + 1438237307100 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tourguide/tourguide.iml b/tourguide/tourguide.iml index 0ccf64e..a281d11 100644 --- a/tourguide/tourguide.iml +++ b/tourguide/tourguide.iml @@ -1,5 +1,5 @@ - + @@ -13,11 +13,8 @@ - + @@ -65,7 +62,6 @@ - @@ -85,9 +81,7 @@ - - @@ -98,4 +92,5 @@ - \ No newline at end of file + + From 770fd80369f0bd37d8ed56fc716ba4b27f03a4d2 Mon Sep 17 00:00:00 2001 From: aaronliew Date: Fri, 31 Jul 2015 17:05:41 +0800 Subject: [PATCH 04/15] [FEATURE] Added IsShowing to check the visibility of TourGuide --- tourguide/src/main/java/tourguide/tourguide/TourGuide.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tourguide/src/main/java/tourguide/tourguide/TourGuide.java b/tourguide/src/main/java/tourguide/tourguide/TourGuide.java index ec69dad..94a8321 100644 --- a/tourguide/src/main/java/tourguide/tourguide/TourGuide.java +++ b/tourguide/src/main/java/tourguide/tourguide/TourGuide.java @@ -104,8 +104,6 @@ public TourGuide playInSequence(View... view){ } - - public TourGuide next() { cleanUp(); CurrentSequence += 1; @@ -161,6 +159,10 @@ public void cleanUp(){ } } + public boolean isShowing(){ + return ((mFrameLayout.isShown())); + } + /****** * * Private methods From 74a71c2b40d07407e46f094868c12ab32c3b85fd Mon Sep 17 00:00:00 2001 From: aaronliew Date: Fri, 31 Jul 2015 17:07:23 +0800 Subject: [PATCH 05/15] [EXAMPLE] Added FirstTimeUserIsShowing Activity to demonstrate isShowing method --- .../FirstTimeUserIsShowingActivity.java | 78 +++++++++++++++++++ app/src/main/res/layout/activity_basic.xml | 14 ++++ 2 files changed, 92 insertions(+) create mode 100644 app/src/main/java/tourguide/tourguidedemo/FirstTimeUserIsShowingActivity.java diff --git a/app/src/main/java/tourguide/tourguidedemo/FirstTimeUserIsShowingActivity.java b/app/src/main/java/tourguide/tourguidedemo/FirstTimeUserIsShowingActivity.java new file mode 100644 index 0000000..bb17c94 --- /dev/null +++ b/app/src/main/java/tourguide/tourguidedemo/FirstTimeUserIsShowingActivity.java @@ -0,0 +1,78 @@ +package tourguide.tourguidedemo; + +import android.app.Activity; +import android.content.Intent; +import android.graphics.Color; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.view.Gravity; +import android.view.View; +import android.widget.Button; +import android.widget.Toast; + +import tourguide.tourguide.Overlay; +import tourguide.tourguide.Pointer; +import tourguide.tourguide.ToolTip; +import tourguide.tourguide.TourGuide; + + +public class FirstTimeUserIsShowingActivity extends ActionBarActivity { + public TourGuide mTutorialHandler; + public Activity mActivity; + public static final String COLOR_DEMO = "color_demo"; + public static final String GRAVITY_DEMO = "gravity_demo"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + /* Get parameters from main activity */ + Intent intent = getIntent(); + boolean color_demo = intent.getBooleanExtra(COLOR_DEMO, false); + boolean gravity_demo = intent.getBooleanExtra(GRAVITY_DEMO, false); + + super.onCreate(savedInstanceState); + mActivity = this; + setContentView(R.layout.activity_basic); + + Button button = (Button)findViewById(R.id.button); + Button checkVisibilityButton = (Button)findViewById(R.id.check_visibility_button); + + ToolTip toolTip = new ToolTip(). + setTitle("Welcome!"). + setDescription("Click on Get Started to begin...") + .setGravity(Gravity.TOP); + + // Setup pointer for demo + Pointer pointer = new Pointer(); + if (color_demo) { + pointer.setColor(Color.RED); + } + if (gravity_demo) { + pointer.setGravity(Gravity.BOTTOM|Gravity.RIGHT); + } + + // the return handler is used to manipulate the cleanup of all the tutorial elements + mTutorialHandler = TourGuide.init(this).with(TourGuide.Technique.Click) + .setPointer(pointer) + .setToolTip(toolTip) + .setOverlay(new Overlay().setBackgroundColor(Color.parseColor("#66FF0000")).disableClick(false)) + .playOn(button); + + button.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View view) { + mTutorialHandler.cleanUp(); + } + }); + + checkVisibilityButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mTutorialHandler.isShowing()) { + Toast.makeText(FirstTimeUserIsShowingActivity.this, "TourGuide is Showing", Toast.LENGTH_LONG).show(); + }else{ + Toast.makeText(FirstTimeUserIsShowingActivity.this, "TourGuide is not showing", Toast.LENGTH_LONG).show(); + } + } + }); + } +} diff --git a/app/src/main/res/layout/activity_basic.xml b/app/src/main/res/layout/activity_basic.xml index 55619a8..75c8ee7 100644 --- a/app/src/main/res/layout/activity_basic.xml +++ b/app/src/main/res/layout/activity_basic.xml @@ -25,6 +25,20 @@ android:text="Get Started" android:textColor="#fbfcfc" /> +