├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── libraries
│ ├── com_android_support_animated_vector_drawable_23_2_1.xml
│ ├── com_android_support_appcompat_v7_23_2_1.xml
│ ├── com_android_support_design_23_2_1.xml
│ ├── com_android_support_recyclerview_v7_23_2_1.xml
│ ├── com_android_support_support_annotations_23_2_1_jar.xml
│ ├── com_android_support_support_v4_23_2_1.xml
│ ├── com_android_support_support_vector_drawable_23_2_1.xml
│ ├── junit_junit_4_12_jar.xml
│ └── org_hamcrest_hamcrest_core_1_3_jar.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
├── vcs.xml
└── workspace.xml
├── LICENSE
├── README.md
├── ShowcaseView.iml
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── showcaseview
│ │ └── outlander
│ │ └── showcaseviewdemo
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── showcaseview
│ │ │ └── outlander
│ │ │ └── showcaseviewdemo
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── anim
│ │ ├── scale_down.xml
│ │ └── scale_up.xml
│ │ ├── drawable
│ │ ├── arrow_up.png
│ │ ├── ic_cross.xml
│ │ ├── ic_launcher.png
│ │ └── images.jpeg
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── button_description_view_bottom.xml
│ │ ├── button_description_view_top.xml
│ │ ├── content_main.xml
│ │ ├── fab_description_view.xml
│ │ ├── image_description_view.xml
│ │ ├── skip_layout.xml
│ │ └── textview_description_view.xml
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── showcaseview
│ └── outlander
│ └── showcaseviewdemo
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── projectFilesBackup
└── .idea
│ └── workspace.xml
├── settings.gradle
└── showcaseview
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── showcaseview.iml
└── src
├── androidTest
└── java
│ └── outlander
│ └── showcaseview
│ └── ApplicationTest.java
├── main
├── AndroidManifest.xml
├── java
│ └── outlander
│ │ └── showcaseview
│ │ ├── RippleBackground.java
│ │ └── ShowcaseViewBuilder.java
└── res
│ └── values
│ ├── attrs.xml
│ └── strings.xml
└── test
└── java
└── outlander
└── showcaseview
└── ExampleUnitTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Log Files
26 | *.log
27 |
28 | # Android Studio Navigation editor temp files
29 | .navigation/
30 |
31 | # Android Studio captures folder
32 | captures/
33 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_animated_vector_drawable_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_appcompat_v7_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_design_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_recyclerview_v7_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_annotations_23_2_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_v4_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/com_android_support_support_vector_drawable_23_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ShowcaseView
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | This ShowcaseView library can be used to showcase any specific part of the UI or can even be used during OnBoarding of a user to give a short intro about different widgets visible on the screen. You may add any number of views (ImageView, TextView, FrameLayout, etc displaying images, videos, GIF, text etc) to describe the showcasing view.
10 |
11 | Try out sample application on Android PlayStore
12 |
13 | # Usage
14 |
15 | For a working implementation of this project see the /app folder
16 |
17 |
18 | Include the library as local library project or add this dependency in your build.gradle.
19 |
20 |
21 | dependencies {
22 | compile 'com.outlander.showcaseview:showcaseview:1.3.0'
23 | }
24 |
25 |
26 |
27 |
28 | Initialise the ShowcaseViewBuilder as follows:
29 |
30 |
31 | ShowcaseViewBuilder showcaseViewBuilder;
32 | ...
33 | showcaseViewBuilder = ShowcaseViewBuilder.init(this)
34 | .setTargetView(fab)
35 | .setBackgroundOverlayColor(0xdd4d4d4d)
36 | .setRingColor(0xcc8e8e8e)
37 | .setRingWidth((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()))
38 | .setMarkerDrawable(getResources().getDrawable(R.drawable.arrow_up), Gravity.LEFT)
39 | .addCustomView(R.layout.description_view, Gravity.TOP)
40 | .addCustomView(R.layout.skip_layout)
41 | .setCustomViewMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 70, getResources().getDisplayMetrics()));
42 |
43 | showcaseViewBuilder.show();
44 |
45 |
46 |
47 |
48 | Register click listeners on the customView added as follows:
49 |
50 |
51 | showcaseViewBuilder.setClickListenerOnView(R.id.exit_btn, new View.OnClickListener() {
52 | @Override
53 | public void onClick(View v) {
54 | //TODO: Add thing to do when clicked.
55 | }
56 | });
57 |
58 |
59 |
60 |
61 | To hide the showcaseView just call:
62 |
63 |
64 | showcaseViewBuilder.hide()
65 |
66 |
67 |
68 |
69 | To hide the showcaseView when user clicks on the overlay, just set the following flag: showcaseViewBuilder.setHideOnTouchOutside(true);
By default, this is always false.
70 |
71 |
72 |
73 | #Things to keep in mind
74 |
75 |
76 | Call the showcaseViewBuilder.show()
only after adding all the customViews and MarkerDrawable.
77 |
78 |
79 | setRingWidth(float width) and other margin setters take pixels as parameters. So make sure to send into density independent pixels (dp) value to support multiple screen sizes (See the sample code snippet above for reference)
80 |
81 |
82 | Once showcaseViewBuilder.hide()
is called, all the click listeners get deregistered .
83 | Thus, you will have to set them back if showing it again. Better to register all the click listeners in a single method which can be called when showing the showcaseView.
84 |
85 |
86 |
87 | #Method Definitions
88 |
89 |
90 | setTargetView(View v)
: Sets the view which needs to be showcased.
91 |
92 |
93 | setBackgroundOverlayColor(int color)
: Sets the color of the overlay to be shown.
94 |
95 |
96 | setRingColor(int color)
: Sets the color of the ring around the showcaseView.
97 |
98 |
99 | setRingWidth(float width)
: Sets the width of the ring around the showcaseView. Default value is 10px
100 |
101 |
102 | setMarkerDrawable(Drawable drawable, int gravity)
: Sets the marker drawable if any to point the showcaseView. Also, sets a gravity for the drawable (TOP, LEFT, RIGHT, BOTTOM) around the showcasing view.
103 |
104 |
105 | setDrawableLeftMargin(float margin)
: Sets the marker drawable left margin.
106 |
107 |
108 | setDrawableTopMargin(float margin)
: Sets the marker drawable top margin.
109 |
110 |
111 | addCustomView(View view, int gravity)
: Sets the custom description view to describe the showcaseView. Also, sets a gravity for the view (TOP, LEFT, RIGHT, BOTTOM) around the showcasing view.
112 |
113 |
114 | addCustomView(View view)
: Sets the custom description view to describe the showcaseView. This doesn't takes any gravity as an argument and renders the view as per the gravity defined in the layout file.
115 |
116 |
117 | setCustomViewMargin(int margin)
: Sets the custom description view margin from the showcaseView in the direction of the gravity defined, if any. If no gravity defined, then no point in using this method.
118 |
119 |
120 | setHideOnTouchOutside(boolean hide)
: Sets the flag which decide whether to hide the showcase overlay when user touches on the screen anywhere.
121 |
122 |
123 | setClickListenerOnView(int id, View.OnClickListener clickListener)
: Sets clicklistener on the components of the customView(s) added.
124 |
125 |
126 | show()
: Start showcasing the targetView.
127 |
128 |
129 | hide()
: Stop showcasing the targetView.
130 |
131 |
132 |
133 | #Developed by
134 |
139 |
140 | #License
141 |
142 | Copyright Aashish Totla © 2016. All rights reserved.
143 |
144 | Licensed under the Apache License, Version 2.0 (the "License");
145 | you may not use this file except in compliance with the License.
146 | You may obtain a copy of the License at
147 |
148 | http://www.apache.org/licenses/LICENSE-2.0
149 |
150 | Unless required by applicable law or agreed to in writing, software
151 | distributed under the License is distributed on an "AS IS" BASIS,
152 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
153 | See the License for the specific language governing permissions and
154 | limitations under the License.
155 |
--------------------------------------------------------------------------------
/ShowcaseView.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Log Files
26 | *.log
27 |
28 | # Android Studio Navigation editor temp files
29 | .navigation/
30 |
31 | # Android Studio captures folder
32 | captures/
33 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | signingConfigs {
5 | config {
6 | keyAlias 'MyReleaseKey'
7 | keyPassword 'IAmSmartEnoughtToHideThis'
8 | storeFile file('/Users/ashish/Documents/Personal/ShowcaseViewDemo/MyReleaseKeyStore.jks')
9 | storePassword 'IAmSmartEnoughToHideThis'
10 | }
11 | }
12 |
13 | compileSdkVersion 23
14 | buildToolsVersion "23.0.2"
15 | defaultConfig {
16 | applicationId "showcaseview.outlander.showcaseviewdemo"
17 | minSdkVersion 11
18 | targetSdkVersion 23
19 | versionCode 6
20 | versionName "1.1"
21 | }
22 | buildTypes {
23 | release {
24 | shrinkResources true
25 | minifyEnabled true
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | debuggable false
28 | signingConfig signingConfigs.config
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | compile fileTree(dir: 'libs', include: ['*.jar'])
35 | compile project(':showcaseview')
36 | testCompile 'junit:junit:4.12'
37 | compile 'com.android.support:appcompat-v7:23.2.1'
38 | compile 'com.android.support:design:23.2.1'
39 | //compile 'com.outlander.showcaseview:showcaseview:1.2.0'
40 | }
41 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/ashish/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/showcaseview/outlander/showcaseviewdemo/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package showcaseview.outlander.showcaseviewdemo;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/showcaseview/outlander/showcaseviewdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package showcaseview.outlander.showcaseviewdemo;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.support.v7.widget.Toolbar;
7 | import android.util.TypedValue;
8 | import android.view.Gravity;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.animation.AnimationUtils;
12 | import android.widget.Button;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | import outlander.showcaseview.RippleBackground;
17 | import outlander.showcaseview.ShowcaseViewBuilder;
18 |
19 | public class MainActivity extends AppCompatActivity {
20 |
21 | public ShowcaseViewBuilder showcaseViewBuilder;
22 |
23 | private FloatingActionButton fab;
24 | private TextView textView;
25 | private ImageView imageView;
26 | private Button button;
27 | private RippleBackground fabHighlighter, tvHighlighter, btnHighlighter;
28 |
29 | @Override
30 | protected void onCreate(Bundle savedInstanceState) {
31 | super.onCreate(savedInstanceState);
32 | setContentView(R.layout.activity_main);
33 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
34 | setSupportActionBar(toolbar);
35 |
36 | textView = (TextView) findViewById(R.id.textView);
37 | textView.setOnClickListener(new View.OnClickListener() {
38 | @Override
39 | public void onClick(View v) {
40 | showcaseTextView();
41 | }
42 | });
43 |
44 | imageView = (ImageView) findViewById(R.id.imgBtn);
45 | imageView.setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 | showcaseImage();
49 | }
50 | });
51 |
52 | button = (Button) findViewById(R.id.magic_btn);
53 | button.setOnClickListener(new View.OnClickListener() {
54 | @Override
55 | public void onClick(View v) {
56 | showcaseButton();
57 | }
58 | });
59 |
60 | fab = (FloatingActionButton) findViewById(R.id.fab);
61 | fab.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View view) {
64 | showcaseFab();
65 | }
66 | });
67 |
68 | fabHighlighter = (RippleBackground) findViewById(R.id.fab_highlighter);
69 | tvHighlighter = (RippleBackground) findViewById(R.id.tv_highlighter);
70 | btnHighlighter = (RippleBackground) findViewById(R.id.btn_highlighter);
71 |
72 | showcaseViewBuilder = ShowcaseViewBuilder.init(this);
73 |
74 | showcaseFab();
75 |
76 | }
77 |
78 | private void showcaseFab() {
79 | if (!fabHighlighter.isRippleAnimationRunning()) {
80 | fabHighlighter.startRippleAnimation();
81 | } else {
82 | fabHighlighter.stopRippleAnimation();
83 | showcaseViewBuilder.setTargetView(fab)
84 | .setBackgroundOverlayColor(0xcc000000)
85 | .setBgOverlayShape(ShowcaseViewBuilder.ROUND_RECT)
86 | .setRoundRectCornerDirection(ShowcaseViewBuilder.TOP_LEFT)
87 | .setRoundRectOffset(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 170, getResources().getDisplayMetrics()))
88 | .setRingColor(0xcc8e8e8e)
89 | .setShowcaseShape(ShowcaseViewBuilder.SHAPE_CIRCLE)
90 | .setRingWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()))
91 | .setMarkerDrawable(getResources().getDrawable(R.drawable.arrow_up), Gravity.LEFT)
92 | .addCustomView(R.layout.fab_description_view, Gravity.LEFT, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, -228, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, -80, getResources().getDisplayMetrics()) ,0);
93 | // .addCustomView(R.layout.fab_description_view, Gravity.CENTER);
94 |
95 | showcaseViewBuilder.show();
96 |
97 | showcaseViewBuilder.setClickListenerOnView(R.id.btn, new View.OnClickListener() {
98 | @Override
99 | public void onClick(View v) {
100 | showcaseViewBuilder.hide();
101 | }
102 | });
103 | }
104 | }
105 |
106 | private void showcaseTextView() {
107 | showcaseViewBuilder.setTargetView(textView)
108 | .setBackgroundOverlayColor(0xcc000000)
109 | .setBgOverlayShape(ShowcaseViewBuilder.ROUND_RECT)
110 | .setRoundRectCornerDirection(ShowcaseViewBuilder.BOTTOM_RIGHT)
111 | .setRoundRectOffset(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 170, getResources().getDisplayMetrics()))
112 | .setRingColor(0xccb9e797)
113 | .setShowcaseShape(ShowcaseViewBuilder.SHAPE_SKEW)
114 | .setHideOnTouchOutside(true)
115 | .setRingWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics()))
116 | .setShowcaseMargin(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()))
117 | .setMarkerDrawable(getResources().getDrawable(android.R.drawable.arrow_down_float), Gravity.BOTTOM)
118 | .setDrawableLeftMargin(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()))
119 | .addCustomView(R.layout.textview_description_view, Gravity.BOTTOM, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 50, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics()) ,0)
120 | .addCustomView(R.layout.skip_layout);
121 |
122 | showcaseViewBuilder.show();
123 |
124 | showcaseViewBuilder.setClickListenerOnView(R.id.skip_btn, new View.OnClickListener() {
125 | @Override
126 | public void onClick(View v) {
127 | showcaseViewBuilder.hide();
128 | }
129 | });
130 | }
131 |
132 | private void showcaseButton() {
133 | showcaseViewBuilder.setTargetView(button)
134 | .setBackgroundOverlayColor(0xcc000000)
135 | .setBgOverlayShape(ShowcaseViewBuilder.FULL_SCREEN)
136 | .setRingColor(0xcc8e8e8e)
137 | .setShowcaseShape(ShowcaseViewBuilder.SHAPE_SKEW)
138 | .setRingWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics()))
139 | .setShowcaseMargin(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()))
140 | .setMarkerDrawable(getResources().getDrawable(android.R.drawable.arrow_up_float), Gravity.BOTTOM)
141 | .setDrawableLeftMargin(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()))
142 | .addCustomView(R.layout.button_description_view_bottom, Gravity.BOTTOM, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics()) ,0)
143 | .addCustomView(R.layout.skip_layout)
144 | .addCustomView(R.layout.button_description_view_top, Gravity.TOP, TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, -30, getResources().getDisplayMetrics()), TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0, getResources().getDisplayMetrics()) ,0)
145 | .setCustomViewMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, getResources().getDisplayMetrics()));
146 |
147 | showcaseViewBuilder.show();
148 |
149 | showcaseViewBuilder.setClickListenerOnView(R.id.skip_btn, new View.OnClickListener() {
150 | @Override
151 | public void onClick(View v) {
152 | showcaseViewBuilder.hide();
153 | }
154 | });
155 | // if (!btnHighlighter.isRippleAnimationRunning()) {
156 | // btnHighlighter.startRippleAnimation();
157 | // } else {
158 | // btnHighlighter.stopRippleAnimation();
159 | // }
160 | }
161 |
162 | private void showcaseImage() {
163 | View view = LayoutInflater.from(this).inflate(R.layout.image_description_view, null, false);
164 | view.findViewById(R.id.tv_test).startAnimation(AnimationUtils.loadAnimation(this, R.anim.scale_down));
165 | showcaseViewBuilder.setTargetView(imageView)
166 | .setBackgroundOverlayColor(0xee4d4d4d)
167 | .setRingColor(0xcc8e8e8e)
168 | .setRingWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()))
169 | .setMarkerDrawable(getResources().getDrawable(android.R.drawable.arrow_down_float), Gravity.BOTTOM)
170 | .setDrawableLeftMargin(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()))
171 | .addCustomView(view, Gravity.BOTTOM)
172 | .setHideOnTouchOutside(true)
173 | .setCustomViewMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24, getResources().getDisplayMetrics()));
174 |
175 | showcaseViewBuilder.show();
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/scale_down.xml:
--------------------------------------------------------------------------------
1 |
3 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/scale_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/arrow_up.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/outlander24/ShowcaseView/77b88df1f82663120508fc17f694ace0242c5896/app/src/main/res/drawable/arrow_up.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_cross.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/outlander24/ShowcaseView/77b88df1f82663120508fc17f694ace0242c5896/app/src/main/res/drawable/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/images.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/outlander24/ShowcaseView/77b88df1f82663120508fc17f694ace0242c5896/app/src/main/res/drawable/images.jpeg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
36 |
37 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/button_description_view_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/button_description_view_top.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
23 |
24 |
33 |
34 |
35 |
36 |
45 |
46 |
54 |
55 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fab_description_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
26 |
27 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/image_description_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
28 |
29 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/skip_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/textview_description_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShowcaseViewDemo
3 | Settings
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/showcaseview/outlander/showcaseviewdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package showcaseview.outlander.showcaseviewdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | google()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:3.1.0'
10 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
11 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | google()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/outlander24/ShowcaseView/77b88df1f82663120508fc17f694ace0242c5896/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 04 18:43:26 IST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':showcaseview'
2 |
--------------------------------------------------------------------------------
/showcaseview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/showcaseview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | ext {
4 | bintrayRepo = 'maven'
5 | bintrayName = 'showcaseview'
6 |
7 | publishedGroupId = 'com.outlander.showcaseview'
8 | libraryName = 'showcaseview'
9 | artifact = 'showcaseview'
10 |
11 | libraryDescription = 'Use this to add showcaseview to your application. For example : Showing short demo while onBoarding.'
12 |
13 | siteUrl = 'https://github.com/OuTlAnDeR24/ShowcaseView'
14 | gitUrl = 'https://github.com/OuTlAnDeR24/ShowcaseView.git'
15 |
16 | libraryVersion = '1.3.1'
17 |
18 | developerId = 'outlander'
19 | developerName = 'Ashish Totla'
20 | developerEmail = 'ashishtotla956@gmail.com'
21 |
22 | licenseName = 'The Apache Software License, Version 2.0'
23 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
24 | allLicenses = ["Apache-2.0"]
25 | }
26 |
27 | android {
28 | compileSdkVersion 23
29 | buildToolsVersion "23.0.2"
30 |
31 | defaultConfig {
32 | minSdkVersion 11
33 | targetSdkVersion 23
34 | versionCode 1
35 | versionName "1.3.1"
36 | }
37 | buildTypes {
38 | release {
39 | minifyEnabled false
40 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
41 | }
42 | }
43 | }
44 |
45 | dependencies {
46 | compile fileTree(dir: 'libs', include: ['*.jar'])
47 | testCompile 'junit:junit:4.12'
48 | compile 'com.android.support:appcompat-v7:23.2.1'
49 | }
50 |
51 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
52 | apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
--------------------------------------------------------------------------------
/showcaseview/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/ashish/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/showcaseview/showcaseview.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | generateDebugSources
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
--------------------------------------------------------------------------------
/showcaseview/src/androidTest/java/outlander/showcaseview/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package outlander.showcaseview;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/showcaseview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/showcaseview/src/main/java/outlander/showcaseview/RippleBackground.java:
--------------------------------------------------------------------------------
1 | package outlander.showcaseview;
2 |
3 | /**
4 | * Created by aashish on 4/5/18.
5 | */
6 |
7 | import android.animation.Animator;
8 | import android.animation.AnimatorSet;
9 | import android.animation.ObjectAnimator;
10 | import android.annotation.TargetApi;
11 | import android.content.Context;
12 | import android.content.res.TypedArray;
13 | import android.graphics.Canvas;
14 | import android.graphics.Paint;
15 | import android.os.Build;
16 | import android.util.AttributeSet;
17 | import android.view.View;
18 | import android.view.animation.AccelerateDecelerateInterpolator;
19 | import android.widget.RelativeLayout;
20 |
21 | import java.util.ArrayList;
22 |
23 | public class RippleBackground extends RelativeLayout {
24 |
25 | private static final int DEFAULT_RIPPLE_COUNT = 6;
26 | private static final int DEFAULT_DURATION_TIME = 3000;
27 | private static final float DEFAULT_SCALE = 6.0f;
28 | private static final int DEFAULT_FILL_TYPE = 0;
29 |
30 | private int rippleColor;
31 | private float rippleStrokeWidth;
32 | private float rippleRadius;
33 | private int rippleDurationTime;
34 | private int rippleAmount;
35 | private int rippleDelay;
36 | private float rippleScale;
37 | private int rippleType;
38 | private Paint paint;
39 | private boolean animationRunning = false;
40 | private AnimatorSet animatorSet;
41 | private ArrayList animatorList;
42 | private LayoutParams rippleParams;
43 | private ArrayList rippleViewList = new ArrayList();
44 |
45 | public RippleBackground(Context context) {
46 | super(context);
47 | }
48 |
49 | public RippleBackground(Context context, AttributeSet attrs) {
50 | super(context, attrs);
51 | init(context, attrs);
52 | }
53 |
54 | public RippleBackground(Context context, AttributeSet attrs, int defStyleAttr) {
55 | super(context, attrs, defStyleAttr);
56 | init(context, attrs);
57 | }
58 |
59 | @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
60 | private void init(final Context context, final AttributeSet attrs) {
61 | if (isInEditMode())
62 | return;
63 |
64 | if (null == attrs) {
65 | throw new IllegalArgumentException("Attributes should be provided to this view,");
66 | }
67 |
68 | final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
69 | rippleColor = typedArray.getColor(R.styleable.RippleBackground_rb_color, getResources().getColor(android.R.color.holo_red_light));
70 | rippleStrokeWidth = typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, 4);
71 | rippleRadius = typedArray.getDimension(R.styleable.RippleBackground_rb_radius, 4);
72 | rippleDurationTime = typedArray.getInt(R.styleable.RippleBackground_rb_duration, DEFAULT_DURATION_TIME);
73 | rippleAmount = typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount, DEFAULT_RIPPLE_COUNT);
74 | rippleScale = typedArray.getFloat(R.styleable.RippleBackground_rb_scale, DEFAULT_SCALE);
75 | rippleType = typedArray.getInt(R.styleable.RippleBackground_rb_type, DEFAULT_FILL_TYPE);
76 | typedArray.recycle();
77 |
78 | rippleDelay = rippleDurationTime / rippleAmount;
79 |
80 | paint = new Paint();
81 | paint.setAntiAlias(true);
82 | if (rippleType == DEFAULT_FILL_TYPE) {
83 | rippleStrokeWidth = 0;
84 | paint.setStyle(Paint.Style.FILL);
85 | } else
86 | paint.setStyle(Paint.Style.STROKE);
87 | paint.setColor(rippleColor);
88 |
89 | rippleParams = new LayoutParams((int) (2 * (rippleRadius + rippleStrokeWidth)), (int) (2 * (rippleRadius + rippleStrokeWidth)));
90 | rippleParams.addRule(CENTER_IN_PARENT, TRUE);
91 |
92 | animatorSet = new AnimatorSet();
93 | animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
94 | animatorList = new ArrayList();
95 |
96 | for (int i = 0; i < rippleAmount; i++) {
97 | RippleView rippleView = new RippleView(getContext());
98 | addView(rippleView, rippleParams);
99 | rippleViewList.add(rippleView);
100 | final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleX", 1.0f, rippleScale);
101 | scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
102 | scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
103 | scaleXAnimator.setStartDelay(i * rippleDelay);
104 | scaleXAnimator.setDuration(rippleDurationTime);
105 | animatorList.add(scaleXAnimator);
106 | final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, "ScaleY", 1.0f, rippleScale);
107 | scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
108 | scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
109 | scaleYAnimator.setStartDelay(i * rippleDelay);
110 | scaleYAnimator.setDuration(rippleDurationTime);
111 | animatorList.add(scaleYAnimator);
112 | final ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, "Alpha", 1.0f, 0f);
113 | alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
114 | alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
115 | alphaAnimator.setStartDelay(i * rippleDelay);
116 | alphaAnimator.setDuration(rippleDurationTime);
117 | animatorList.add(alphaAnimator);
118 | }
119 |
120 | animatorSet.playTogether(animatorList);
121 | }
122 |
123 | private class RippleView extends View {
124 |
125 | public RippleView(Context context) {
126 | super(context);
127 | this.setVisibility(View.INVISIBLE);
128 | }
129 |
130 | @Override
131 | protected void onDraw(Canvas canvas) {
132 | int radius = (Math.min(getWidth(), getHeight())) / 2;
133 | canvas.drawCircle(radius, radius, radius - rippleStrokeWidth, paint);
134 | }
135 | }
136 |
137 | public void startRippleAnimation() {
138 | if (!isRippleAnimationRunning()) {
139 | for (RippleView rippleView : rippleViewList) {
140 | rippleView.setVisibility(VISIBLE);
141 | }
142 | animatorSet.start();
143 | animationRunning = true;
144 | }
145 | }
146 |
147 | public void stopRippleAnimation() {
148 | if (isRippleAnimationRunning()) {
149 | animatorSet.end();
150 | animationRunning = false;
151 | }
152 | }
153 |
154 | public boolean isRippleAnimationRunning() {
155 | return animationRunning;
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/showcaseview/src/main/java/outlander/showcaseview/ShowcaseViewBuilder.java:
--------------------------------------------------------------------------------
1 | package outlander.showcaseview;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.graphics.Bitmap;
6 | import android.graphics.Canvas;
7 | import android.graphics.Paint;
8 | import android.graphics.PorterDuff;
9 | import android.graphics.PorterDuffXfermode;
10 | import android.graphics.Rect;
11 | import android.graphics.RectF;
12 | import android.graphics.drawable.Drawable;
13 | import android.util.AttributeSet;
14 | import android.util.DisplayMetrics;
15 | import android.util.Log;
16 | import android.view.Gravity;
17 | import android.view.LayoutInflater;
18 | import android.view.MotionEvent;
19 | import android.view.View;
20 | import android.view.ViewGroup;
21 | import android.view.ViewTreeObserver;
22 | import android.widget.LinearLayout;
23 |
24 | import java.util.ArrayList;
25 | import java.util.HashMap;
26 | import java.util.List;
27 |
28 | /**
29 | * Created by aashish totla.
30 | */
31 | public class ShowcaseViewBuilder extends View implements View.OnTouchListener {
32 |
33 | private Activity mActivity;
34 | private View mTargetView;
35 | private List mCustomView = new ArrayList<>();
36 | private List mCustomViewLeftMargins = new ArrayList<>();
37 | private List mCustomViewTopMargins = new ArrayList<>();
38 | private List mCustomViewRightMargins = new ArrayList<>();
39 | private List mCustomViewBottomMargins = new ArrayList<>();
40 | private List mCustomViewGravity = new ArrayList<>();
41 | private float mCenterX, mCenterY, mRadius;
42 | private Drawable mMarkerDrawable;
43 | private int mMarkerDrawableGravity;
44 | private int ringColor, backgroundOverlayColor;
45 | private int mCustomViewMargin, mShape = SHAPE_CIRCLE, mBgOverlayShape = FULL_SCREEN;
46 | private int mRoundRectCorner;
47 | private HashMap idsRectMap = new HashMap<>();
48 | private HashMap idsClickListenerMap = new HashMap<>();
49 | private boolean mHideOnTouchOutside;
50 | private float mRingWidth = 10, mShowcaseMargin = 12, mRoundRectOffset = 170;
51 | private float mMarkerDrawableLeftMargin = 0, mMarkerDrawableRightMargin = 0,
52 | mMarkerDrawableTopMargin = 0, mMarkerDrawableBottomMargin = 0;
53 | private Canvas tempCanvas;
54 | private Paint backgroundPaint, transparentPaint, ringPaint;
55 | private Rect mTargetViewGlobalRect;
56 | private static final String TAG = "SHOWCASE_VIEW";
57 | //Showcase Shapes constants
58 | public static final int SHAPE_CIRCLE = 0; //Default Shape
59 | public static final int SHAPE_SKEW = 1;
60 | //Bg Overlay Shapes constants
61 | public static final int FULL_SCREEN = 2; //Default Shape
62 | public static final int ROUND_RECT = 3;
63 | //Round rect corner direction constants
64 | public static final int BOTTOM_LEFT = 4;
65 | public static final int BOTTOM_RIGHT = 5;
66 | public static final int TOP_LEFT = 6;
67 | public static final int TOP_RIGHT = 7;
68 |
69 | private ShowcaseViewBuilder(Context context) {
70 | super(context);
71 | }
72 |
73 | private ShowcaseViewBuilder(Context context, AttributeSet attrs) {
74 | super(context, attrs);
75 | }
76 |
77 | public static ShowcaseViewBuilder init(Activity activity) {
78 | ShowcaseViewBuilder showcaseViewBuilder = new ShowcaseViewBuilder(activity);
79 | showcaseViewBuilder.mActivity = activity;
80 | showcaseViewBuilder.setClickable(true);
81 | return showcaseViewBuilder;
82 | }
83 |
84 | public ShowcaseViewBuilder setTargetView(View view) {
85 | mTargetView = view;
86 | return this;
87 | }
88 |
89 | private void calculateRadiusAndCenter() {
90 | int width = mTargetView.getMeasuredWidth();
91 | int height = mTargetView.getMeasuredHeight();
92 |
93 | int[] xy = {0, 0};
94 | mTargetView.getLocationInWindow(xy);
95 |
96 | mCenterX = xy[0] + (width / 2);
97 | mCenterY = xy[1] + (height / 2);
98 |
99 | if (width > height) {
100 | mRadius = 7 * (width) / 12;
101 | } else {
102 | mRadius = 7 * (height) / 12;
103 | }
104 | }
105 |
106 | public ShowcaseViewBuilder setHideOnTouchOutside(boolean value) {
107 | this.mHideOnTouchOutside = value;
108 | return this;
109 | }
110 |
111 | public ShowcaseViewBuilder setMarkerDrawable(Drawable drawable, int gravity) {
112 | this.mMarkerDrawable = drawable;
113 | this.mMarkerDrawableGravity = gravity;
114 | return this;
115 | }
116 |
117 | public ShowcaseViewBuilder setDrawableLeftMargin(float margin) {
118 | this.mMarkerDrawableLeftMargin = margin;
119 | return this;
120 | }
121 |
122 | public ShowcaseViewBuilder setRoundRectOffset(float roundRectOffset) {
123 | this.mRoundRectOffset = roundRectOffset;
124 | return this;
125 | }
126 |
127 | public ShowcaseViewBuilder setDrawableRightMargin(float margin) {
128 | this.mMarkerDrawableRightMargin = margin;
129 | return this;
130 | }
131 |
132 | public ShowcaseViewBuilder setDrawableTopMargin(float margin) {
133 | this.mMarkerDrawableTopMargin = margin;
134 | return this;
135 | }
136 |
137 | public ShowcaseViewBuilder setDrawableBottomMargin(float margin) {
138 | this.mMarkerDrawableBottomMargin = margin;
139 | return this;
140 | }
141 |
142 | public ShowcaseViewBuilder setShowcaseShape(int shape) {
143 | this.mShape = shape;
144 | return this;
145 | }
146 |
147 | public ShowcaseViewBuilder setBgOverlayShape(int bgOverlayShape) {
148 | this.mBgOverlayShape = bgOverlayShape;
149 | return this;
150 | }
151 |
152 | public ShowcaseViewBuilder setRoundRectCornerDirection(int roundRectCornerDirection) {
153 | this.mRoundRectCorner = roundRectCornerDirection;
154 | return this;
155 | }
156 |
157 | public ShowcaseViewBuilder addCustomView(int layoutId, int gravity) {
158 | View view = LayoutInflater.from(mActivity).inflate(layoutId, null);
159 | LinearLayout linearLayout = new LinearLayout(mActivity);
160 | linearLayout.addView(view);
161 | linearLayout.setGravity(Gravity.CENTER);
162 |
163 | DisplayMetrics metrics = new DisplayMetrics();
164 | mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
165 |
166 | Rect rect = new Rect();
167 | rect.set(0, 0, metrics.widthPixels, metrics.heightPixels);
168 |
169 | int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY);
170 | int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY);
171 |
172 | linearLayout.measure(widthSpec, heightSpec);
173 | mCustomView.add(linearLayout);
174 | mCustomViewGravity.add(gravity);
175 | mCustomViewLeftMargins.add(0f);
176 | mCustomViewTopMargins.add(0f);
177 | mCustomViewRightMargins.add(0f);
178 | mCustomViewBottomMargins.add(0f);
179 | return this;
180 | }
181 |
182 | public ShowcaseViewBuilder addCustomView(View view, int gravity) {
183 | LinearLayout linearLayout = new LinearLayout(mActivity);
184 | linearLayout.addView(view);
185 | linearLayout.setGravity(Gravity.CENTER);
186 |
187 | DisplayMetrics metrics = new DisplayMetrics();
188 | mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
189 |
190 | Rect rect = new Rect();
191 | rect.set(0, 0, metrics.widthPixels, metrics.heightPixels);
192 |
193 | int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY);
194 | int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY);
195 |
196 | linearLayout.measure(widthSpec, heightSpec);
197 | mCustomView.add(linearLayout);
198 | mCustomViewGravity.add(gravity);
199 | mCustomViewLeftMargins.add(0f);
200 | mCustomViewTopMargins.add(0f);
201 | mCustomViewRightMargins.add(0f);
202 | mCustomViewBottomMargins.add(0f);
203 | return this;
204 | }
205 |
206 | public ShowcaseViewBuilder addCustomView(int layoutId, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
207 | View view = LayoutInflater.from(mActivity).inflate(layoutId, null);
208 | LinearLayout linearLayout = new LinearLayout(mActivity);
209 | linearLayout.addView(view);
210 | linearLayout.setGravity(Gravity.CENTER);
211 |
212 | DisplayMetrics metrics = new DisplayMetrics();
213 | mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
214 |
215 | Rect rect = new Rect();
216 | rect.set(0, 0, metrics.widthPixels, metrics.heightPixels);
217 |
218 | int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY);
219 | int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY);
220 |
221 | linearLayout.measure(widthSpec, heightSpec);
222 | mCustomView.add(linearLayout);
223 | mCustomViewGravity.add(gravity);
224 | mCustomViewLeftMargins.add(leftMargin);
225 | mCustomViewTopMargins.add(topMargin);
226 | mCustomViewRightMargins.add(rightMargin);
227 | mCustomViewBottomMargins.add(bottomMargin);
228 | return this;
229 | }
230 |
231 | public ShowcaseViewBuilder addCustomView(View view, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
232 | LinearLayout linearLayout = new LinearLayout(mActivity);
233 | linearLayout.addView(view);
234 | linearLayout.setGravity(Gravity.CENTER);
235 |
236 | DisplayMetrics metrics = new DisplayMetrics();
237 | mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
238 |
239 | Rect rect = new Rect();
240 | rect.set(0, 0, metrics.widthPixels, metrics.heightPixels);
241 |
242 | int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY);
243 | int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY);
244 |
245 | linearLayout.measure(widthSpec, heightSpec);
246 | mCustomView.add(linearLayout);
247 | mCustomViewGravity.add(gravity);
248 | mCustomViewLeftMargins.add(leftMargin);
249 | mCustomViewTopMargins.add(topMargin);
250 | mCustomViewRightMargins.add(rightMargin);
251 | mCustomViewBottomMargins.add(bottomMargin);
252 | return this;
253 | }
254 |
255 | public ShowcaseViewBuilder addCustomView(View view) {
256 | DisplayMetrics metrics = new DisplayMetrics();
257 | mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
258 |
259 | Rect rect = new Rect();
260 | rect.set(0, 0, metrics.widthPixels, metrics.heightPixels);
261 |
262 | int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY);
263 | int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY);
264 |
265 | view.measure(widthSpec, heightSpec);
266 | mCustomView.add(view);
267 | mCustomViewGravity.add(0);
268 | mCustomViewLeftMargins.add(0f);
269 | mCustomViewTopMargins.add(0f);
270 | mCustomViewRightMargins.add(0f);
271 | mCustomViewBottomMargins.add(0f);
272 | return this;
273 | }
274 |
275 | public ShowcaseViewBuilder addCustomView(int layoutId) {
276 | final View view = LayoutInflater.from(mActivity).inflate(layoutId, null);
277 |
278 | DisplayMetrics metrics = new DisplayMetrics();
279 | mActivity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
280 |
281 | Rect rect = new Rect();
282 | rect.set(0, 0, metrics.widthPixels, metrics.heightPixels);
283 |
284 | int widthSpec = View.MeasureSpec.makeMeasureSpec(rect.width(), MeasureSpec.EXACTLY);
285 | int heightSpec = View.MeasureSpec.makeMeasureSpec(rect.height(), MeasureSpec.EXACTLY);
286 |
287 | view.measure(widthSpec, heightSpec);
288 | mCustomView.add(view);
289 | mCustomViewGravity.add(0);
290 | mCustomViewLeftMargins.add(0f);
291 | mCustomViewTopMargins.add(0f);
292 | mCustomViewRightMargins.add(0f);
293 | mCustomViewBottomMargins.add(0f);
294 | return this;
295 | }
296 |
297 | /**
298 | * Deprecated. Use @addCustomView(int layoutId, int gravity, int leftMargin, int topMargin, int rightMargin, int bottomMargin) instead
299 | *
300 | * @param margin
301 | * @return
302 | */
303 | public ShowcaseViewBuilder setCustomViewMargin(int margin) {
304 | this.mCustomViewMargin = margin;
305 | return this;
306 | }
307 |
308 | public ShowcaseViewBuilder setRingColor(int color) {
309 | this.ringColor = color;
310 | return this;
311 | }
312 |
313 | public ShowcaseViewBuilder setRingWidth(float ringWidth) {
314 | this.mRingWidth = ringWidth;
315 | return this;
316 | }
317 |
318 | public ShowcaseViewBuilder setShowcaseMargin(float showcaseMargin) {
319 | this.mShowcaseMargin = showcaseMargin;
320 | return this;
321 | }
322 |
323 | public ShowcaseViewBuilder setBackgroundOverlayColor(int color) {
324 | this.backgroundOverlayColor = color;
325 | return this;
326 | }
327 |
328 | public void show() {
329 | transparentPaint = new Paint();
330 | ringPaint = new Paint();
331 | backgroundPaint = new Paint();
332 | if (mTargetView != null) {
333 | if (mTargetView.getWidth() == 0 || mTargetView.getHeight() == 0) {
334 | mTargetView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
335 | @Override
336 | public void onGlobalLayout() {
337 | invalidate();
338 | addShowcaseView();
339 | mTargetView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
340 | }
341 | });
342 | } else {
343 | invalidate();
344 | addShowcaseView();
345 | }
346 | }
347 | setOnTouchListener(this);
348 | }
349 |
350 | private void addShowcaseView() {
351 | ((ViewGroup) mActivity.getWindow().getDecorView()).addView(this);
352 | }
353 |
354 | public void hide() {
355 | mCustomView.clear();
356 | mCustomViewGravity.clear();
357 | mCustomViewLeftMargins.clear();
358 | mCustomViewRightMargins.clear();
359 | mCustomViewTopMargins.clear();
360 | mCustomViewBottomMargins.clear();
361 | idsClickListenerMap.clear();
362 | idsRectMap.clear();
363 | mHideOnTouchOutside = false;
364 | ((ViewGroup) mActivity.getWindow().getDecorView()).removeView(this);
365 | }
366 |
367 | @Override
368 | protected void onDraw(Canvas canvas) {
369 | if (mTargetView != null) {
370 | setShowcase(canvas);
371 | drawMarkerDrawable(canvas);
372 | addCustomView(canvas);
373 | }
374 | super.onDraw(canvas);
375 | }
376 |
377 | private void drawMarkerDrawable(Canvas canvas) {
378 | if (mMarkerDrawable != null) {
379 | switch (mMarkerDrawableGravity) {
380 | case Gravity.LEFT:
381 | case Gravity.START:
382 | mMarkerDrawable.setBounds((int) (mCenterX + mMarkerDrawableLeftMargin - mRadius - mMarkerDrawable.getMinimumWidth() - mRingWidth - 10),
383 | (int) (mCenterY + mMarkerDrawableTopMargin - mMarkerDrawable.getMinimumHeight()),
384 | (int) (mCenterX + mMarkerDrawableLeftMargin - mRadius - mRingWidth - 10), (int) (mCenterY + mMarkerDrawableTopMargin));
385 | break;
386 |
387 | case Gravity.TOP:
388 | mMarkerDrawable.setBounds((int) (mCenterX + mMarkerDrawableLeftMargin - mMarkerDrawable.getMinimumWidth()),
389 | (int) (mCenterY + mMarkerDrawableTopMargin - mRadius - mMarkerDrawable.getMinimumHeight() - mRingWidth - 10),
390 | (int) (mCenterX + mMarkerDrawableLeftMargin), (int) (mCenterY + mMarkerDrawableTopMargin - mRadius - mRingWidth - 10));
391 | break;
392 |
393 | case Gravity.RIGHT:
394 | case Gravity.END:
395 | mMarkerDrawable.setBounds((int) (mCenterX + mMarkerDrawableLeftMargin + mRadius + mRingWidth + 10),
396 | (int) (mCenterY + mMarkerDrawableTopMargin - mMarkerDrawable.getMinimumHeight()),
397 | (int) (mCenterX + mMarkerDrawableLeftMargin + mRadius + mMarkerDrawable.getMinimumWidth() + mRingWidth + 10),
398 | (int) (mCenterY + mMarkerDrawableTopMargin));
399 | break;
400 |
401 | case Gravity.BOTTOM:
402 | mMarkerDrawable.setBounds((int) (mCenterX + mMarkerDrawableLeftMargin - mMarkerDrawable.getMinimumWidth()),
403 | (int) (mCenterY + mMarkerDrawableTopMargin + mRadius + mRingWidth + 10), (int) (mCenterX + mMarkerDrawableLeftMargin),
404 | (int) (mCenterY + mMarkerDrawableTopMargin + mRadius + mMarkerDrawable.getMinimumHeight() + mRingWidth + 10));
405 | break;
406 | }
407 |
408 | mMarkerDrawable.draw(canvas);
409 | } else {
410 | Log.d(TAG, "No marker drawable defined");
411 | }
412 | }
413 |
414 | private void addCustomView(Canvas canvas) {
415 | if (mCustomView.size() != 0) {
416 | for (int i = 0; i < mCustomView.size(); i++) {
417 | float cy = mCustomView.get(i).getMeasuredHeight() / 2, cx = mCustomView.get(i).getMeasuredWidth() / 2;
418 | float diffY, diffX;
419 | float marginTop = mCustomViewTopMargins.get(i);
420 | float marginLeft = mCustomViewLeftMargins.get(i);
421 | float marginRight = mCustomViewRightMargins.get(i);
422 | float marginBottom = mCustomViewBottomMargins.get(i);
423 | mTargetViewGlobalRect = new Rect();
424 | mTargetView.getGlobalVisibleRect(mTargetViewGlobalRect);
425 | View view = mCustomView.get(i);
426 | switch (mCustomViewGravity.get(i)) {
427 | case Gravity.START:
428 | case Gravity.LEFT:
429 | diffY = mCenterY - cy;
430 | diffX = mCenterX - cx;
431 | if (diffX < 0) {
432 | view.layout(0, 0, (int) (mCenterX - view.getMeasuredWidth() - 2 * marginRight),
433 | (int) (mCustomView.get(i).getMeasuredHeight() + 2 * (diffY + marginTop)));
434 | } else {
435 | view.layout((int) diffX, 0, (int) (view.getMeasuredWidth() - diffX - 2 * marginRight),
436 | (int) (mCustomView.get(i).getMeasuredHeight() + 2 * (diffY + marginTop)));
437 | }
438 | break;
439 |
440 | case Gravity.TOP:
441 | diffY = mCenterY - cy - 2 * mTargetView.getMeasuredHeight();
442 | view.layout((int) (-marginLeft), 0, (int) (view.getMeasuredWidth() + marginLeft),
443 | (int) (mCustomView.get(i).getMeasuredHeight() + 2 * (diffY + marginTop)));
444 | break;
445 |
446 | case Gravity.END:
447 | case Gravity.RIGHT:
448 | diffY = mCenterY - cy;
449 | view.layout(-2 * mTargetViewGlobalRect.right, 0,
450 | (int) (view.getMeasuredWidth() + 4 * marginLeft), (int) (mCustomView.get(i).getMeasuredHeight() + 2 * (diffY + marginTop)));
451 | break;
452 |
453 | case Gravity.BOTTOM:
454 | diffY = mCenterY - cy + 2 * mTargetView.getMeasuredHeight();
455 | view.layout((int) (-marginLeft), 0, (int) (view.getMeasuredWidth() + marginLeft),
456 | (int) (mCustomView.get(i).getMeasuredHeight() + 2 * (diffY + marginTop)));
457 | break;
458 |
459 | default:
460 | mCustomView.get(i).layout(0, 0, mCustomView.get(i).getMeasuredWidth(), mCustomView.get(i).getMeasuredHeight());
461 | }
462 | mCustomView.get(i).draw(canvas);
463 | }
464 | } else {
465 | Log.d(TAG, "No Custom View defined");
466 | }
467 | }
468 |
469 | private ArrayList getAllChildren(View v) {
470 | if (!(v instanceof ViewGroup)) {
471 | ArrayList viewArrayList = new ArrayList<>();
472 | viewArrayList.add(v);
473 | return viewArrayList;
474 | }
475 |
476 | ArrayList result = new ArrayList<>();
477 |
478 | ViewGroup viewGroup = (ViewGroup) v;
479 | for (int i = 0; i < viewGroup.getChildCount(); i++) {
480 | View child = viewGroup.getChildAt(i);
481 | ArrayList viewArrayList = new ArrayList<>();
482 | viewArrayList.add(v);
483 | viewArrayList.addAll(getAllChildren(child));
484 |
485 | result.addAll(viewArrayList);
486 | }
487 | return result;
488 | }
489 |
490 | private void setShowcase(Canvas canvas) {
491 | calculateRadiusAndCenter();
492 | Bitmap bitmap = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
493 | tempCanvas = new Canvas(bitmap);
494 |
495 | backgroundPaint.setColor(backgroundOverlayColor);
496 | backgroundPaint.setAntiAlias(true);
497 |
498 | transparentPaint.setColor(getResources().getColor(android.R.color.transparent));
499 | transparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
500 | transparentPaint.setAntiAlias(true);
501 |
502 | ringPaint.setColor(ringColor);
503 | ringPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
504 | ringPaint.setAntiAlias(true);
505 |
506 | if (mBgOverlayShape == ROUND_RECT) {
507 | RectF oval = new RectF();
508 | switch (mRoundRectCorner) {
509 | case BOTTOM_LEFT:
510 | oval.set(-mRoundRectOffset, -tempCanvas.getHeight(), 2 * tempCanvas.getWidth() + mRoundRectOffset, tempCanvas.getHeight());
511 | tempCanvas.drawArc(oval, 90F, 90F, true, backgroundPaint);
512 | break;
513 |
514 | case BOTTOM_RIGHT:
515 | oval.set(-tempCanvas.getWidth() - mRoundRectOffset, -tempCanvas.getHeight(), tempCanvas.getWidth() + mRoundRectOffset, tempCanvas.getHeight());
516 | tempCanvas.drawArc(oval, 360F, 90F, true, backgroundPaint);
517 | break;
518 |
519 | case TOP_LEFT:
520 | oval.set(-mRoundRectOffset, 0, 2 * tempCanvas.getWidth() + mRoundRectOffset, 2 * tempCanvas.getHeight());
521 | tempCanvas.drawArc(oval, 180F, 90F, true, backgroundPaint);
522 | break;
523 |
524 | case TOP_RIGHT:
525 | oval.set(-tempCanvas.getWidth() - mRoundRectOffset, 0, tempCanvas.getWidth() + mRoundRectOffset, 2 * tempCanvas.getHeight());
526 | tempCanvas.drawArc(oval, 270F, 90F, true, backgroundPaint);
527 | break;
528 |
529 | default:
530 | oval.set(-mRoundRectOffset, -tempCanvas.getHeight(), 2 * tempCanvas.getWidth() + mRoundRectOffset, tempCanvas.getHeight());
531 | tempCanvas.drawArc(oval, 90F, 90F, true, backgroundPaint);
532 | break;
533 | }
534 | } else {
535 | tempCanvas.drawRect(0, 0, tempCanvas.getWidth(), tempCanvas.getHeight(), backgroundPaint);
536 | }
537 |
538 | if (mShape == SHAPE_SKEW) {
539 | Rect r = new Rect();
540 | Rect ring = new Rect();
541 | mTargetView.getGlobalVisibleRect(r);
542 | mTargetView.getGlobalVisibleRect(ring);
543 | //Showcase rect
544 | r.top -= mShowcaseMargin;
545 | r.left -= mShowcaseMargin;
546 | r.right += mShowcaseMargin;
547 | r.bottom += mShowcaseMargin;
548 | //Showcase ring rect
549 | ring.top -= mShowcaseMargin + mRingWidth;
550 | ring.left -= mShowcaseMargin + mRingWidth;
551 | ring.right += mShowcaseMargin + mRingWidth;
552 | ring.bottom += mShowcaseMargin + mRingWidth;
553 | tempCanvas.drawRect(ring, ringPaint);
554 | tempCanvas.drawRect(r, transparentPaint);
555 | } else {
556 | tempCanvas.drawCircle(mCenterX, mCenterY, mRadius + mRingWidth, ringPaint);
557 | tempCanvas.drawCircle(mCenterX, mCenterY, mRadius, transparentPaint);
558 | }
559 |
560 | canvas.drawBitmap(bitmap, 0, 0, new Paint());
561 | }
562 |
563 | public void setClickListenerOnView(int id, final View.OnClickListener clickListener) {
564 | idsClickListenerMap.put(id, clickListener);
565 | }
566 |
567 | private int getAbsoluteLeft(View myView) {
568 | if (myView == null) {
569 | return 0;
570 | }
571 | if (myView.getParent() == myView.getRootView())
572 | return myView.getLeft();
573 | else
574 | return myView.getLeft() + getAbsoluteLeft((View) myView.getParent());
575 | }
576 |
577 | private int getAbsoluteTop(View myView) {
578 | if (myView == null) {
579 | return 0;
580 | }
581 | if (myView.getParent() == myView.getRootView())
582 | return myView.getTop();
583 | else
584 | return myView.getTop() + getAbsoluteTop((View) myView.getParent());
585 | }
586 |
587 | @Override
588 | public boolean onTouch(View v, MotionEvent event) {
589 | if (idsRectMap.isEmpty()) {
590 | for (View parentView : mCustomView) {
591 | List childrenViews = getAllChildren(parentView);
592 | for (final View view : childrenViews) {
593 | Rect rect = new Rect();
594 | rect.set(getAbsoluteLeft(view), getAbsoluteTop(view),
595 | getAbsoluteLeft(view) + view.getMeasuredWidth(), getAbsoluteTop(view) + view.getMeasuredHeight());
596 | if (view.getId() > 0) {
597 | idsRectMap.put(rect, view.getId());
598 | }
599 | }
600 | }
601 | }
602 |
603 | if (event.getAction() == MotionEvent.ACTION_UP) {
604 | float X = event.getX();
605 | float Y = event.getY();
606 | Object[] keys = idsRectMap.keySet().toArray();
607 | for (int i = 0; i < idsRectMap.size(); i++) {
608 | Rect r = (Rect) keys[i];
609 | if (r.contains((int) X, (int) Y)) {
610 | int id = idsRectMap.get(r);
611 | if (idsClickListenerMap.get(id) != null) {
612 | idsClickListenerMap.get(id).onClick(v);
613 | return true;
614 | }
615 | }
616 | }
617 |
618 | if (mHideOnTouchOutside) {
619 | hide();
620 | return true;
621 | }
622 | }
623 | return false;
624 | }
625 | }
626 |
627 |
--------------------------------------------------------------------------------
/showcaseview/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/showcaseview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShowcaseView
3 |
4 |
--------------------------------------------------------------------------------
/showcaseview/src/test/java/outlander/showcaseview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package outlander.showcaseview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------