├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── CHANGELOG.md
├── HintCase
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── joanfuentes
│ │ └── hintcase
│ │ ├── ContentHolder.java
│ │ ├── ContentHolderAnimator.java
│ │ ├── HintCase.java
│ │ ├── HintCaseView.java
│ │ ├── RectangularShape.java
│ │ ├── Shape.java
│ │ ├── ShapeAnimator.java
│ │ └── utils
│ │ ├── DimenUtils.java
│ │ └── RoundRect.java
│ └── res
│ └── values
│ └── strings.xml
├── HintCaseAssets
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── joanfuentes
│ │ └── hintcaseassets
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── joanfuentes
│ │ └── hintcaseassets
│ │ ├── contentholderanimators
│ │ ├── FadeInContentHolderAnimator.java
│ │ ├── FadeOutContentHolderAnimator.java
│ │ ├── SlideInFromRightContentHolderAnimator.java
│ │ └── SlideOutFromRightContentHolderAnimator.java
│ │ ├── extracontentholders
│ │ ├── ExtraContentHolder.java
│ │ └── SimpleButtonContentHolder.java
│ │ ├── hintcontentholders
│ │ ├── ByLayoutHintContentHolder.java
│ │ ├── HintContentHolder.java
│ │ └── SimpleHintContentHolder.java
│ │ ├── shapeanimators
│ │ ├── FadeInShapeAnimator.java
│ │ ├── FadeOutShapeAnimator.java
│ │ ├── RevealCircleShapeAnimator.java
│ │ ├── RevealRectangularShapeAnimator.java
│ │ ├── UnrevealCircleShapeAnimator.java
│ │ └── UnrevealRectangularShapeAnimator.java
│ │ └── shapes
│ │ └── CircularShape.java
│ └── res
│ └── values
│ └── strings.xml
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── joanfuentes
│ │ └── hintcaseexample
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── joanfuentes
│ │ └── hintcaseexample
│ │ ├── CustomHintActivity.java
│ │ ├── FullHintActivity.java
│ │ ├── MainActivity.java
│ │ ├── TargetHintActivity.java
│ │ └── customBlock
│ │ ├── CustomHintContentHolder.java
│ │ └── TriangleShapeView.java
│ └── res
│ ├── drawable
│ ├── animated_image.gif
│ ├── bubble_border_background.xml
│ └── test.jpg
│ ├── layout
│ ├── activity_custom_hint.xml
│ ├── activity_full_hint.xml
│ ├── activity_main.xml
│ ├── activity_target_hint.xml
│ ├── content_custom_hint.xml
│ ├── content_full_hint.xml
│ ├── content_main.xml
│ └── content_target_hint.xml
│ ├── menu
│ └── menu_target_hint.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── assets
├── bubble_demo.gif
├── consecutive_hints.gif
├── fade_in_out_animator.gif
├── fade_in_out_contentholder_animator.gif
├── reveal_unreveal_circle_animator.gif
├── reveal_unreveal_rectangular_animator.gif
├── slide_in_out_contentholder_animator.gif
└── welcome_demo.gif
├── build.gradle
├── buildsystem
└── dependencies.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | hintcase
--------------------------------------------------------------------------------
/.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 |
20 |
21 |
--------------------------------------------------------------------------------
/.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 |
49 |
50 | 1.7
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | #Changelog
2 |
3 | #1.0.4 (10/11/2016)
4 | - Fixed a crash using the library from a Fragment.
5 |
6 | #1.0.3 (28/09/2016)
7 | - Fixed a bug passing the click event to the target view.
8 |
9 | #1.0.2 (09/06/2016)
10 | - Refactored the way the offset is configured (now is done from setTarget(...) instead of setShapeAnimators(...)))
11 | - Fixed a Crash with Andoid N Beta.
12 | - Fixed a bug with the use of the offset in Shapes and ContentHolders.
13 |
14 | #1.0.1 (07/06/2016)
15 | - Fixed a bug where the rectangular shape was not being fully animated.
16 | - Fixed a bug where the corresponding parent was not being passed on to ExtraContentHolders.
17 | - Added setStartDelay() method to ContentHolderAnimators and ShapeAnimators. Now you can concatenate animations based on duration and start time.
18 |
19 | #1.0.0 (31/05/2016)
20 | - Initial release
--------------------------------------------------------------------------------
/HintCase/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/HintCase/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 |
4 | def globalConfiguration = rootProject.extensions.getByName("ext")
5 |
6 | android {
7 | compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
8 | buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")
9 |
10 | defaultConfig {
11 | minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
12 | targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
13 | versionCode globalConfiguration.getAt("androidVersionCodeMainLibrary")
14 | versionName globalConfiguration.getAt("androidVersionNameMainLibrary")
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | def libraryDependencies = globalConfiguration.mainLibraryDependencies
25 | compile libraryDependencies.AndroidAnnotations
26 | }
27 |
28 | publish {
29 | Properties properties = new Properties()
30 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
31 |
32 | userOrg = globalConfiguration.getAt("jcenterUserOrganization")
33 | groupId = globalConfiguration.getAt("jcenterGroupId")
34 | artifactId = globalConfiguration.getAt("jcenterArtifactIdMainLibrary")
35 | publishVersion = globalConfiguration.getAt("androidVersionNameMainLibrary")
36 | desc = globalConfiguration.getAt("jcenterDescriptionMainLibrary")
37 | website = globalConfiguration.getAt("jcenterWebsite")
38 | repository = globalConfiguration.getAt("jcenterRepository")
39 | bintrayUser = properties.getProperty("bintrayUser")
40 | bintrayKey = properties.getProperty("bintrayKey")
41 | }
42 |
--------------------------------------------------------------------------------
/HintCase/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/joan/Utilidades/SDKs/android-sdk-macosx/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 |
--------------------------------------------------------------------------------
/HintCase/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/ContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.ViewGroup;
6 |
7 | public abstract class ContentHolder {
8 | abstract public View getView(Context context, HintCase hintCase, ViewGroup parent);
9 |
10 | public void onLayout() { }
11 | }
12 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/ContentHolderAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.view.View;
5 |
6 | public abstract class ContentHolderAnimator {
7 | public static final int DEFAULT_ANIMATION_DURATION_IN_MILLISECONDS = 300;
8 | public static final ContentHolderAnimator NO_ANIMATOR = null;
9 | public static final OnFinishListener NO_CALLBACK = null;
10 | protected int durationInMilliseconds;
11 | protected long startDelayInMilliseconds;
12 |
13 | public ContentHolderAnimator() {
14 | durationInMilliseconds = DEFAULT_ANIMATION_DURATION_IN_MILLISECONDS;
15 | }
16 |
17 | public ContentHolderAnimator(int durationInMilliseconds) {
18 | this.durationInMilliseconds = durationInMilliseconds;
19 | }
20 |
21 | public ValueAnimator getAnimator(View view) {
22 | return getAnimator(view, NO_CALLBACK);
23 | }
24 |
25 | abstract public ValueAnimator getAnimator(View view, OnFinishListener onFinishListener);
26 |
27 | public interface OnFinishListener {
28 | void onFinish();
29 | }
30 |
31 | public ContentHolderAnimator setStartDelay(long startDelayInMilliseconds) {
32 | this.startDelayInMilliseconds = startDelayInMilliseconds;
33 | return this;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/HintCase.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.support.annotation.DimenRes;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.utils.DimenUtils;
9 |
10 | public class HintCase {
11 | public static final int DEFAULT_SHAPE_OFFSET_IN_DP = 10;
12 | public static final int NO_OFFSET_IN_PX = 0;
13 | public static final int BACKGROUND_COLOR_TRANSPARENT = 0x00000000;
14 | public static final int HINT_BLOCK_POSITION_LEFT = 0;
15 | public static final int HINT_BLOCK_POSITION_TOP = 1;
16 | public static final int HINT_BLOCK_POSITION_RIGHT = 2;
17 | public static final int HINT_BLOCK_POSITION_BOTTOM = 3;
18 | public static final int HINT_BLOCK_POSITION_CENTER = 4;
19 | public static final boolean TARGET_IS_CLICKABLE = true;
20 | public static final boolean TARGET_IS_NOT_CLICKABLE = false;
21 |
22 | private HintCaseView hintCaseView;
23 | private Context context;
24 |
25 | public Shape getShape() {
26 | return this.hintCaseView.getShape();
27 | }
28 |
29 | public void hide() {
30 | this.hintCaseView.performHide();
31 | this.hintCaseView = null;
32 | }
33 |
34 | public interface OnClosedListener {
35 | void onClosed();
36 | }
37 |
38 | public HintCase(View view) {
39 | this.context = view.getContext();
40 | this.hintCaseView = new HintCaseView(context, this);
41 | this.hintCaseView.setTargetInfo(null, new RectangularShape(), NO_OFFSET_IN_PX,
42 | TARGET_IS_NOT_CLICKABLE);
43 | this.hintCaseView.setParentView(view);
44 | }
45 |
46 | public View getView() {
47 | return this.hintCaseView;
48 | }
49 |
50 | public HintCase setTarget(View target) {
51 | int offsetInPx = DimenUtils.dipToPixels(context, HintCase.DEFAULT_SHAPE_OFFSET_IN_DP);
52 | return setCompleteTarget(target, new RectangularShape(), offsetInPx, TARGET_IS_CLICKABLE);
53 | }
54 |
55 | public HintCase setTarget(View target, @DimenRes int offsetResId) {
56 | int offsetInPx = context.getResources().getDimensionPixelSize(offsetResId);
57 | return setCompleteTarget(target, new RectangularShape(), offsetInPx, TARGET_IS_CLICKABLE);
58 | }
59 |
60 | public HintCase setTarget(View target, boolean isTargetClickable) {
61 | int offsetInPx = DimenUtils.dipToPixels(context, HintCase.DEFAULT_SHAPE_OFFSET_IN_DP);
62 | return setCompleteTarget(target, new RectangularShape(), offsetInPx, isTargetClickable);
63 | }
64 |
65 | public HintCase setTarget(View target, boolean isTargetClickable, @DimenRes int offsetResId) {
66 | int offsetInPx = context.getResources().getDimensionPixelSize(offsetResId);
67 | return setCompleteTarget(target, new RectangularShape(), offsetInPx, isTargetClickable);
68 | }
69 |
70 | public HintCase setTarget(View target, Shape shape) {
71 | int offsetInPx = DimenUtils.dipToPixels(context, HintCase.DEFAULT_SHAPE_OFFSET_IN_DP);
72 | return setCompleteTarget(target, shape, offsetInPx, TARGET_IS_CLICKABLE);
73 | }
74 |
75 | public HintCase setTarget(View target, Shape shape, @DimenRes int offsetResId) {
76 | int offsetInPx = context.getResources().getDimensionPixelSize(offsetResId);
77 | return setCompleteTarget(target, shape, offsetInPx, TARGET_IS_CLICKABLE);
78 | }
79 |
80 | public HintCase setTarget(View target, Shape shape, boolean isTargetClickable) {
81 | int offsetInPx = DimenUtils.dipToPixels(context, HintCase.DEFAULT_SHAPE_OFFSET_IN_DP);
82 | return setCompleteTarget(target, shape, offsetInPx, isTargetClickable);
83 | }
84 |
85 | public HintCase setTarget(View target, Shape shape, boolean isTargetClickable,
86 | @DimenRes int offsetResId) {
87 | int offsetInPx = context.getResources().getDimensionPixelSize(offsetResId);
88 | return setCompleteTarget(target, shape, offsetInPx, isTargetClickable);
89 | }
90 |
91 | private HintCase setCompleteTarget(View target, Shape shape, int offsetInPx,
92 | boolean isTargetClickable) {
93 | this.hintCaseView.setTargetInfo(target, shape, offsetInPx, isTargetClickable);
94 | return this;
95 | }
96 |
97 | public HintCase setBackgroundColor(int color) {
98 | this.hintCaseView.setBackgroundColor(color);
99 | return this;
100 | }
101 |
102 | public HintCase setBackgroundColorByResourceId(int resourceId) {
103 | this.hintCaseView.setBackgroundColor(context.getResources().getColor(resourceId));
104 | return this;
105 | }
106 |
107 | public HintCase setShapeAnimators(ShapeAnimator showShapeAnimator) {
108 | return setShapeAnimators(showShapeAnimator, ShapeAnimator.NO_ANIMATOR);
109 | }
110 |
111 | public HintCase setShapeAnimators(ShapeAnimator showShapeAnimator,
112 | ShapeAnimator hideShapeAnimator) {
113 | this.hintCaseView.setShape(showShapeAnimator, hideShapeAnimator);
114 | return this;
115 | }
116 |
117 | public HintCase setHintBlock(ContentHolder contentHolder) {
118 | this.hintCaseView.setHintBlock(contentHolder, ContentHolderAnimator.NO_ANIMATOR, ContentHolderAnimator.NO_ANIMATOR);
119 | return this;
120 | }
121 |
122 | public HintCase setHintBlock(ContentHolder contentHolder, ContentHolderAnimator showContentHolderAnimator) {
123 | this.hintCaseView.setHintBlock(contentHolder, showContentHolderAnimator, ContentHolderAnimator.NO_ANIMATOR);
124 | return this;
125 | }
126 |
127 | public HintCase setHintBlock(ContentHolder contentHolder, ContentHolderAnimator showContentHolderAnimator,
128 | ContentHolderAnimator hideContentHolderAnimator) {
129 | this.hintCaseView.setHintBlock(contentHolder, showContentHolderAnimator, hideContentHolderAnimator);
130 | return this;
131 | }
132 |
133 | public HintCase setExtraBlock(ContentHolder contentHolder) {
134 | this.hintCaseView.setExtraBlock(contentHolder, ContentHolderAnimator.NO_ANIMATOR, ContentHolderAnimator.NO_ANIMATOR);
135 | return this;
136 | }
137 |
138 | public HintCase setExtraBlock(ContentHolder contentHolder, ContentHolderAnimator showContentHolderAnimator) {
139 | this.hintCaseView.setExtraBlock(contentHolder, showContentHolderAnimator, ContentHolderAnimator.NO_ANIMATOR);
140 | return this;
141 | }
142 |
143 | public HintCase setExtraBlock(ContentHolder contentHolder, ContentHolderAnimator showContentHolderAnimator,
144 | ContentHolderAnimator hideContentHolderAnimator) {
145 | this.hintCaseView.setExtraBlock(contentHolder, showContentHolderAnimator, hideContentHolderAnimator);
146 | return this;
147 | }
148 |
149 | public HintCase setCloseOnTouchView(boolean closeOnTouch) {
150 | this.hintCaseView.setCloseOnTouch(closeOnTouch);
151 | return this;
152 | }
153 |
154 | public HintCase setOverDecorView(boolean setOver, Activity activity) {
155 | if (activity != null) {
156 | setOverDecorView(setOver, activity.getWindow().getDecorView());
157 | } else {
158 | //TODO throw exception
159 | }
160 | return this;
161 | }
162 |
163 | public HintCase setOverDecorView(boolean setOver, View decorView) {
164 | if (setOver) {
165 | this.hintCaseView.setOverDecorView(decorView);
166 | }
167 | return this;
168 | }
169 |
170 | public HintCase setOnClosedListener(OnClosedListener onClosedListener) {
171 | this.hintCaseView.setOnClosedListener(onClosedListener);
172 | return this;
173 | }
174 |
175 | public int getBlockInfoPosition() {
176 | return this.hintCaseView.getHintBlockPosition();
177 | }
178 |
179 | public void show() {
180 | //TODO: Add controls to have minimum info.
181 | this.hintCaseView.show();
182 | }
183 | }
184 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/RectangularShape.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase;
2 |
3 | import android.annotation.TargetApi;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.os.Build;
7 | import android.view.MotionEvent;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.joanfuentes.hintcase.utils.RoundRect;
12 |
13 | public class RectangularShape extends Shape {
14 | private static final float DEFAULT_MIN_HEIGHT = 50;
15 | private static final float DEFAULT_MAX_HEIGHT = 10000;
16 |
17 | private float maxHeight = DEFAULT_MAX_HEIGHT;
18 | private float minHeight = DEFAULT_MIN_HEIGHT;
19 | private float minWidth = DEFAULT_MIN_HEIGHT;
20 | private float maxWidth = DEFAULT_MAX_HEIGHT;
21 | private float currentHeight = DEFAULT_MAX_HEIGHT;
22 | private float currentWidth = DEFAULT_MAX_HEIGHT;
23 |
24 | public RectangularShape() {
25 | super();
26 | }
27 |
28 | @Override
29 | public void setMinimumValue() {
30 | currentWidth = minWidth;
31 | currentHeight = minHeight;
32 | }
33 |
34 | @Override
35 | public void setShapeInfo(View targetView, ViewGroup parent, int offset, Context context) {
36 | if (targetView != null) {
37 | minHeight = targetView.getMeasuredHeight() + (offset * 2);
38 | minWidth = targetView.getMeasuredWidth() + (offset * 2);
39 | maxHeight = parent.getHeight() * 2;
40 | maxWidth = parent.getWidth() * 2;
41 | int[] targetViewLocationInWindow = new int[2];
42 | targetView.getLocationInWindow(targetViewLocationInWindow);
43 | setCenterX(targetViewLocationInWindow[0] + targetView.getWidth() / 2);
44 | setCenterY(targetViewLocationInWindow[1] + targetView.getHeight() / 2);
45 | setLeft(targetViewLocationInWindow[0] - offset);
46 | setRight(targetViewLocationInWindow[0] + (int)minWidth - offset);
47 | setTop(targetViewLocationInWindow[1] - offset);
48 | setBottom(targetViewLocationInWindow[1] + (int)minHeight - offset);
49 | setWidth(minWidth);
50 | setHeight(minHeight);
51 | } else {
52 | if (parent != null) {
53 | minHeight = 0;
54 | minWidth = 0;
55 | maxHeight = parent.getHeight();
56 | maxWidth = parent.getWidth();
57 | setCenterX(parent.getMeasuredWidth() / 2);
58 | setCenterY(parent.getMeasuredHeight() / 2);
59 | setLeft(0);
60 | setTop(0);
61 | setRight(0);
62 | setBottom(0);
63 | }
64 | }
65 | currentHeight = maxHeight;
66 | currentWidth = maxWidth;
67 | }
68 |
69 | @Override
70 | public boolean isTouchEventInsideTheHint(MotionEvent event) {
71 | return event.getRawX() <= getRight()
72 | && event.getRawX() >= getLeft()
73 | && event.getRawY() <= getBottom()
74 | && event.getRawY() >= getTop();
75 | }
76 |
77 | @Override
78 | public void draw(Canvas canvas) {
79 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
80 | drawRoundRectAfterLollipop(canvas);
81 | } else {
82 | drawRoundRectPreLollipop(canvas);
83 | }
84 | }
85 |
86 | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
87 | private void drawRoundRectAfterLollipop(Canvas canvas) {
88 | canvas.drawRoundRect(getCenterX() - (currentWidth / 2),
89 | getCenterY() - (currentHeight / 2),
90 | getCenterX() + (currentWidth / 2),
91 | getCenterY() + (currentHeight / 2),
92 | 10f,
93 | 10f,
94 | getShapePaint());
95 | }
96 |
97 | private void drawRoundRectPreLollipop(Canvas canvas) {
98 | RoundRect roundRect = new RoundRect(getCenterX() - (currentWidth / 2),
99 | getCenterY() - (currentHeight / 2),
100 | getCenterX() + (currentWidth / 2),
101 | getCenterY() + (currentHeight / 2),
102 | 10f,
103 | 10f);
104 | canvas.drawPath(roundRect.getPath(), getShapePaint());
105 | }
106 |
107 | public float getMinHeight() {
108 | return minHeight;
109 | }
110 |
111 | public float getMaxHeight() {
112 | return maxHeight;
113 | }
114 |
115 | public float getMinWidth() {
116 | return minWidth;
117 | }
118 |
119 | public float getMaxWidth() {
120 | return maxWidth;
121 | }
122 |
123 | public float getCurrentHeight() {
124 | return currentHeight;
125 | }
126 |
127 | public void setCurrentHeight(float currentHeight) {
128 | this.currentHeight = currentHeight;
129 | }
130 |
131 | public void setCurrentWidth(float currentWidth) {
132 | this.currentWidth = currentWidth;
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/Shape.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Paint;
6 | import android.graphics.PorterDuff;
7 | import android.graphics.PorterDuffXfermode;
8 | import android.view.MotionEvent;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 |
12 | public abstract class Shape {
13 | private static final int DEFAULT_COLOR = 0xFFFFFF;
14 | private static final int DEFAULT_ALPHA = 0;
15 | private int left;
16 | private int top;
17 | private int right;
18 | private int bottom;
19 | private float centerX;
20 | private float centerY;
21 | private float width;
22 | private float height;
23 | private Paint shapePaint;
24 |
25 | public Shape() {
26 | shapePaint = getInitializedTypePaint();
27 | }
28 |
29 | private Paint getInitializedTypePaint() {
30 | Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
31 | paint.setColor(DEFAULT_COLOR);
32 | paint.setAlpha(DEFAULT_ALPHA);
33 | paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
34 | return paint;
35 | }
36 |
37 | public int getLeft() {
38 | return left;
39 | }
40 |
41 | public void setLeft(int left) {
42 | this.left = left;
43 | }
44 |
45 | public int getTop() {
46 | return top;
47 | }
48 |
49 | public void setTop(int top) {
50 | this.top = top;
51 | }
52 |
53 | public int getRight() {
54 | return right;
55 | }
56 |
57 | public void setRight(int right) {
58 | this.right = right;
59 | }
60 |
61 | public int getBottom() {
62 | return bottom;
63 | }
64 |
65 | public void setBottom(int bottom) {
66 | this.bottom = bottom;
67 | }
68 |
69 | public float getCenterX() {
70 | return centerX;
71 | }
72 |
73 | public void setCenterX(float centerX) {
74 | this.centerX = centerX;
75 | }
76 |
77 | public float getCenterY() {
78 | return centerY;
79 | }
80 |
81 | public void setCenterY(float centerY) {
82 | this.centerY = centerY;
83 | }
84 |
85 | public float getWidth() {
86 | return width;
87 | }
88 |
89 | public void setWidth(float width) {
90 | this.width = width;
91 | }
92 |
93 | public float getHeight() {
94 | return height;
95 | }
96 |
97 | public void setHeight(float height) {
98 | this.height = height;
99 | }
100 |
101 | public Paint getShapePaint() {
102 | return shapePaint;
103 | }
104 |
105 | abstract public void setMinimumValue();
106 | abstract public void setShapeInfo(View targetView, ViewGroup parent, int offset, Context context);
107 | abstract public boolean isTouchEventInsideTheHint(MotionEvent event);
108 | abstract public void draw(Canvas canvas);
109 | }
110 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/ShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.view.View;
5 |
6 | public abstract class ShapeAnimator {
7 | public static final int DEFAULT_ANIMATION_DURATION_IN_MILLISECONDS = 300;
8 | public static final ShapeAnimator NO_ANIMATOR = null;
9 | public static final OnFinishListener NO_CALLBACK = null;
10 | protected int durationInMilliseconds;
11 | protected long startDelayInMilliseconds;
12 |
13 | public ShapeAnimator() {
14 | durationInMilliseconds = DEFAULT_ANIMATION_DURATION_IN_MILLISECONDS;
15 | }
16 |
17 | public ShapeAnimator(int durationInMilliseconds) {
18 | this.durationInMilliseconds = durationInMilliseconds;
19 | }
20 |
21 | abstract public ValueAnimator getAnimator(View view, Shape shape, OnFinishListener onFinishListener);
22 |
23 | public ValueAnimator getAnimator(View view, Shape shape) {
24 | return getAnimator(view, shape, NO_CALLBACK);
25 | }
26 |
27 | public interface OnFinishListener {
28 | void onFinish();
29 | }
30 |
31 | public ShapeAnimator setStartDelay(long startDelayInMilliseconds) {
32 | this.startDelayInMilliseconds = startDelayInMilliseconds;
33 | return this;
34 | }
35 | }
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/utils/DimenUtils.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase.utils;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.Resources;
6 | import android.graphics.Point;
7 | import android.os.Build;
8 | import android.util.DisplayMetrics;
9 | import android.util.TypedValue;
10 | import android.view.ContextThemeWrapper;
11 | import android.view.Display;
12 | import android.view.View;
13 | import android.view.WindowManager;
14 |
15 | public class DimenUtils {
16 | public static int getStatusBarHeight(Context context) {
17 | int statusBarHeight = 0;
18 | Resources resources = context.getResources();
19 | int id = resources.getIdentifier("status_bar_height", "dimen", "android");
20 | if (id > 0) {
21 | statusBarHeight = resources.getDimensionPixelSize(id);
22 | }
23 | return statusBarHeight;
24 | }
25 |
26 | public static int getActionBarHeight(Context context) {
27 | int actionBarHeight = 0;
28 | TypedValue tv = new TypedValue();
29 | if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
30 | actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
31 | context.getResources().getDisplayMetrics());
32 | }
33 | return actionBarHeight;
34 | }
35 |
36 | public static int dipToPixels(Context context, float valueInDP) {
37 | DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
38 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, valueInDP, displayMetrics);
39 | }
40 |
41 | public static Point getNavigationBarSizeIfExistAtTheBottom(Context context) {
42 | Point appUsableSize = getAppUsableScreenSize(context);
43 | Point realScreenSize = getRealScreenSize(context);
44 | Point navigationPoint;
45 | boolean navigationBarIsPresent = appUsableSize.y < realScreenSize.y;
46 | if (navigationBarIsPresent) {
47 | navigationPoint = new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);
48 | } else {
49 | navigationPoint = new Point();
50 | }
51 | return navigationPoint;
52 | }
53 |
54 | public static Point getNavigationBarSizeIfExistOnTheRight(Context context) {
55 | Point appUsableSize = getAppUsableScreenSize(context);
56 | Point realScreenSize = getRealScreenSize(context);
57 | Point navigationPoint;
58 | boolean navigationBarIsPresent = appUsableSize.x < realScreenSize.x;
59 | if (navigationBarIsPresent) {
60 | navigationPoint = new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);
61 | } else {
62 | navigationPoint = new Point();
63 | }
64 | return navigationPoint;
65 | }
66 |
67 | public static Point getAppUsableScreenSize(Context context) {
68 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
69 | Display display = windowManager.getDefaultDisplay();
70 | Point size = new Point();
71 | display.getSize(size);
72 | return size;
73 | }
74 |
75 | public static Point getRealScreenSize(Context context) {
76 | Point size = new Point();
77 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
78 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
79 | Display display = windowManager.getDefaultDisplay();
80 | display.getRealSize(size);
81 | } else {
82 | View decorView = null;
83 | if(context instanceof Activity) {
84 | decorView = ((Activity) context).getWindow().getDecorView();
85 | } else if(context instanceof ContextThemeWrapper) {
86 | Context baseContext = ((ContextThemeWrapper) context).getBaseContext();
87 | if(baseContext instanceof Activity) {
88 | decorView = ((Activity) baseContext).getWindow().getDecorView();
89 | }
90 | }
91 | if(decorView != null) {
92 | size.x = decorView.getWidth();
93 | size.y = decorView.getHeight();
94 | }
95 | }
96 | return size;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/HintCase/src/main/java/com/joanfuentes/hintcase/utils/RoundRect.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcase.utils;
2 |
3 | import android.graphics.Path;
4 |
5 | public class RoundRect {
6 | private Path path;
7 |
8 | public RoundRect(float left, float top, float right, float bottom, float rx, float ry) {
9 | init(left, top, right, bottom, rx, ry, true, true, true, true);
10 | }
11 |
12 | public RoundRect(float left, float top, float right, float bottom, float rx, float ry,
13 | boolean tl, boolean tr, boolean br, boolean bl) {
14 | init(left, top, right, bottom, rx, ry, tl, tr, br, bl);
15 | }
16 |
17 | private void init(float left, float top, float right, float bottom, float rx, float ry,
18 | boolean applyRoundToTopLeft, boolean applyRoundToTopRight,
19 | boolean applyRoundToBottomRight, boolean applyRoundToBottomLeft) {
20 | float width = right - left;
21 | float height = bottom - top;
22 | rx = normalizeValue(rx, 0, width / 2);
23 | ry = normalizeValue(ry, 0, height / 2);
24 | float widthMinusCorners = (width - (2 * rx));
25 | float heightMinusCorners = (height - (2 * ry));
26 | path = new Path();
27 | path.moveTo(right, top + ry);
28 | drawTopRightCorner(rx, ry, applyRoundToTopRight);
29 | path.rLineTo(-widthMinusCorners, 0);
30 | drawTopLeftCorner(rx, ry, applyRoundToTopLeft);
31 | path.rLineTo(0, heightMinusCorners);
32 | drawBottomLeftCorner(rx, ry, applyRoundToBottomLeft);
33 | path.rLineTo(widthMinusCorners, 0);
34 | drawBottomRightCorner(rx, ry, applyRoundToBottomRight);
35 | path.rLineTo(0, -heightMinusCorners);
36 | path.close();
37 | }
38 |
39 | private void drawBottomRightCorner(float rx, float ry, boolean applyRoundToBottomRight) {
40 | if (applyRoundToBottomRight) {
41 | path.rQuadTo(rx, 0, rx, -ry);
42 | } else {
43 | path.rLineTo(rx, 0);
44 | path.rLineTo(0, -ry);
45 | }
46 | }
47 |
48 | private void drawBottomLeftCorner(float rx, float ry, boolean applyRoundToBottomLeft) {
49 | if (applyRoundToBottomLeft) {
50 | path.rQuadTo(0, ry, rx, ry);
51 | } else {
52 | path.rLineTo(0, ry);
53 | path.rLineTo(rx, 0);
54 | }
55 | }
56 |
57 | private void drawTopLeftCorner(float rx, float ry, boolean applyRoundToTopLeft) {
58 | if (applyRoundToTopLeft) {
59 | path.rQuadTo(-rx, 0, -rx, ry);
60 | } else {
61 | path.rLineTo(-rx, 0);
62 | path.rLineTo(0, ry);
63 | }
64 | }
65 |
66 | private void drawTopRightCorner(float rx, float ry, boolean applyRoundToTopRight) {
67 | if (applyRoundToTopRight) {
68 | path.rQuadTo(0, -ry, -rx, -ry);
69 | } else {
70 | path.rLineTo(0, -ry);
71 | path.rLineTo(-rx, 0);
72 | }
73 | }
74 |
75 | private float normalizeValue(float value, float min, float max) {
76 | if (value < min) {
77 | value = 0;
78 | }
79 | if (value > max) {
80 | value = max;
81 | }
82 | return value;
83 | }
84 |
85 | public Path getPath() {
86 | return path;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/HintCase/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Hint Case
3 |
4 |
--------------------------------------------------------------------------------
/HintCaseAssets/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/HintCaseAssets/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.novoda.bintray-release'
3 |
4 | def globalConfiguration = rootProject.extensions.getByName("ext")
5 |
6 | android {
7 | compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
8 | buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")
9 |
10 | defaultConfig {
11 | minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
12 | targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
13 | versionCode globalConfiguration.getAt("androidVersionCodeAssetsLibrary")
14 | versionName globalConfiguration.getAt("androidVersionNameAssetsLibrary")
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | def libraryDependencies = globalConfiguration.assetsLibraryDependencies
25 | compile project(':HintCase')
26 | compile libraryDependencies.AppCompat
27 | }
28 |
29 | publish {
30 | Properties properties = new Properties()
31 | properties.load(project.rootProject.file('local.properties').newDataInputStream())
32 |
33 | userOrg = globalConfiguration.getAt("jcenterUserOrganization")
34 | groupId = globalConfiguration.getAt("jcenterGroupId")
35 | artifactId = globalConfiguration.getAt("jcenterArtifactIdAssetsLibrary")
36 | publishVersion = globalConfiguration.getAt("androidVersionNameAssetsLibrary")
37 | desc = globalConfiguration.getAt("jcenterDescriptionAssetsLibrary")
38 | website = globalConfiguration.getAt("jcenterWebsite")
39 | repository = globalConfiguration.getAt("jcenterRepository")
40 | bintrayUser = properties.getProperty("bintrayUser")
41 | bintrayKey = properties.getProperty("bintrayKey")
42 | }
43 |
--------------------------------------------------------------------------------
/HintCaseAssets/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/joan/Utilidades/SDKs/android-sdk-macosx/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 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/androidTest/java/com/joanfuentes/hintcaseassets/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets;
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 | }
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/contentholderanimators/FadeInContentHolderAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.contentholderanimators;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.ContentHolderAnimator;
9 |
10 | public class FadeInContentHolderAnimator extends ContentHolderAnimator {
11 |
12 | public FadeInContentHolderAnimator() {
13 | super();
14 | }
15 |
16 | public FadeInContentHolderAnimator(int durationInMilliseconds) {
17 | super(durationInMilliseconds);
18 | }
19 |
20 | @Override
21 | public ValueAnimator getAnimator(View view, final OnFinishListener onFinishListener) {
22 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
23 | animator.setDuration(durationInMilliseconds);
24 | animator.setStartDelay(startDelayInMilliseconds);
25 | if (onFinishListener != NO_CALLBACK) {
26 | animator.addListener(new Animator.AnimatorListener() {
27 | @Override
28 | public void onAnimationStart(Animator animation) { }
29 |
30 | @Override
31 | public void onAnimationEnd(Animator animation) {
32 | onFinishListener.onFinish();
33 | }
34 |
35 | @Override
36 | public void onAnimationCancel(Animator animation) { }
37 |
38 | @Override
39 | public void onAnimationRepeat(Animator animation) { }
40 | });
41 | }
42 | return animator;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/contentholderanimators/FadeOutContentHolderAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.contentholderanimators;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.ContentHolderAnimator;
9 |
10 | public class FadeOutContentHolderAnimator extends ContentHolderAnimator {
11 |
12 | public FadeOutContentHolderAnimator() {
13 | super();
14 | }
15 |
16 | public FadeOutContentHolderAnimator(int durationInMilliseconds) {
17 | super(durationInMilliseconds);
18 | }
19 |
20 | @Override
21 | public ValueAnimator getAnimator(View view, final OnFinishListener onFinishListener) {
22 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0);
23 | animator.setDuration(durationInMilliseconds);
24 | animator.setStartDelay(startDelayInMilliseconds);
25 | if (onFinishListener != NO_CALLBACK) {
26 | animator.addListener(new Animator.AnimatorListener() {
27 | @Override
28 | public void onAnimationStart(Animator animation) { }
29 |
30 | @Override
31 | public void onAnimationEnd(Animator animation) {
32 | onFinishListener.onFinish();
33 | }
34 |
35 | @Override
36 | public void onAnimationCancel(Animator animation) { }
37 |
38 | @Override
39 | public void onAnimationRepeat(Animator animation) { }
40 | });
41 | }
42 | return animator;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/contentholderanimators/SlideInFromRightContentHolderAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.contentholderanimators;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.ContentHolderAnimator;
9 |
10 | public class SlideInFromRightContentHolderAnimator extends ContentHolderAnimator {
11 |
12 | public SlideInFromRightContentHolderAnimator() {
13 | super();
14 | }
15 |
16 | public SlideInFromRightContentHolderAnimator(int durationInMilliseconds) {
17 | super(durationInMilliseconds);
18 | }
19 |
20 | @Override
21 | public ValueAnimator getAnimator(final View view, final OnFinishListener onFinishListener) {
22 | float spaceUntilRightSide = view.getRootView().getWidth() - view.getLeft();
23 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X,
24 | spaceUntilRightSide, 0);
25 | animator.setDuration(durationInMilliseconds);
26 | animator.setStartDelay(startDelayInMilliseconds);
27 | animator.addListener(new Animator.AnimatorListener() {
28 | @Override
29 | public void onAnimationStart(Animator animation) {
30 | view.setAlpha(1);
31 | }
32 |
33 | @Override
34 | public void onAnimationEnd(Animator animation) {
35 | if (onFinishListener != NO_CALLBACK) {
36 | onFinishListener.onFinish();
37 | }
38 | }
39 |
40 | @Override
41 | public void onAnimationCancel(Animator animation) { }
42 |
43 | @Override
44 | public void onAnimationRepeat(Animator animation) { }
45 | });
46 | return animator;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/contentholderanimators/SlideOutFromRightContentHolderAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.contentholderanimators;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.ContentHolderAnimator;
9 |
10 | public class SlideOutFromRightContentHolderAnimator extends ContentHolderAnimator {
11 |
12 | public SlideOutFromRightContentHolderAnimator() {
13 | super();
14 | }
15 |
16 | public SlideOutFromRightContentHolderAnimator(int durationInMilliseconds) {
17 | super(durationInMilliseconds);
18 | }
19 |
20 | @Override
21 | public ValueAnimator getAnimator(final View view, final OnFinishListener onFinishListener) {
22 | float spaceUntilRightSide = view.getRootView().getWidth() - view.getLeft();
23 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.TRANSLATION_X, 0,
24 | spaceUntilRightSide);
25 | animator.setDuration(durationInMilliseconds);
26 | animator.setStartDelay(startDelayInMilliseconds);
27 | animator.addListener(new Animator.AnimatorListener() {
28 | @Override
29 | public void onAnimationStart(Animator animation) {
30 | view.setAlpha(1);
31 | }
32 |
33 | @Override
34 | public void onAnimationEnd(Animator animation) {
35 | if (onFinishListener != NO_CALLBACK) {
36 | onFinishListener.onFinish();
37 | }
38 | }
39 |
40 | @Override
41 | public void onAnimationCancel(Animator animation) { }
42 |
43 | @Override
44 | public void onAnimationRepeat(Animator animation) { }
45 | });
46 | return animator;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/extracontentholders/ExtraContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.extracontentholders;
2 |
3 | import android.widget.RelativeLayout;
4 |
5 | import com.joanfuentes.hintcase.ContentHolder;
6 |
7 | public abstract class ExtraContentHolder extends ContentHolder {
8 | public RelativeLayout.LayoutParams getParentLayoutParams(int width, int height, int... rules) {
9 | RelativeLayout.LayoutParams layoutParams =
10 | new RelativeLayout.LayoutParams(width,height);
11 | for (int rule : rules) {
12 | layoutParams.addRule(rule);
13 | }
14 | return layoutParams;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/extracontentholders/SimpleButtonContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.extracontentholders;
2 |
3 | import android.content.Context;
4 | import android.support.v7.view.ContextThemeWrapper;
5 | import android.support.v7.widget.AppCompatButton;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.joanfuentes.hintcase.HintCase;
10 |
11 | public class SimpleButtonContentHolder extends ExtraContentHolder {
12 | private int width;
13 | private int height;
14 | private int[] rules;
15 | private CharSequence text;
16 | private int buttonStyleId;
17 | private boolean closeHintOnClick;
18 | private OnClickButtonListener onClickButtonListener;
19 |
20 | SimpleButtonContentHolder() {
21 | this.closeHintOnClick = false;
22 | }
23 |
24 | @Override
25 | public View getView(Context context, final HintCase hintCase, ViewGroup parent) {
26 | AppCompatButton button;
27 | if (buttonStyleId != 0) {
28 | ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, buttonStyleId);
29 | button = new AppCompatButton(contextThemeWrapper);
30 | } else {
31 | button = new AppCompatButton(context);
32 | }
33 | button.setText(text);
34 | button.setOnClickListener(new View.OnClickListener() {
35 | @Override
36 | public void onClick(View v) {
37 | if (onClickButtonListener != null) {
38 | onClickButtonListener.onClick();
39 | }
40 | if (closeHintOnClick) {
41 | hintCase.hide();
42 | }
43 | }
44 | });
45 | button.setLayoutParams(getParentLayoutParams(width, height, rules));
46 | return button;
47 | }
48 |
49 | public static class Builder {
50 | private SimpleButtonContentHolder buttonBlock;
51 | private Context context;
52 |
53 | public Builder(Context context) {
54 | this.context = context;
55 | buttonBlock = new SimpleButtonContentHolder();
56 | buttonBlock.width = ViewGroup.LayoutParams.WRAP_CONTENT;
57 | buttonBlock.height = ViewGroup.LayoutParams.WRAP_CONTENT;
58 | buttonBlock.rules = new int[0];
59 | }
60 |
61 | public Builder setWidth(int width) {
62 | buttonBlock.width = width;
63 | return this;
64 | }
65 |
66 | public Builder setHeight(int height) {
67 | buttonBlock.height = height;
68 | return this;
69 | }
70 |
71 | public Builder setRules(int... rules) {
72 | buttonBlock.rules = rules;
73 | return this;
74 | }
75 |
76 | public Builder setButtonText(CharSequence text) {
77 | buttonBlock.text = text;
78 | return this;
79 | }
80 |
81 | public Builder setButtonText(int resId) {
82 | buttonBlock.text = context.getString(resId);
83 | return this;
84 | }
85 |
86 | public Builder setButtonStyle(int resId) {
87 | buttonBlock.buttonStyleId = resId;
88 | return this;
89 | }
90 |
91 | public Builder setOnClick(OnClickButtonListener listener) {
92 | buttonBlock.onClickButtonListener = listener;
93 | return this;
94 | }
95 |
96 | public Builder setCloseHintCaseOnClick(boolean closeHintOnClick) {
97 | buttonBlock.closeHintOnClick = closeHintOnClick;
98 | return this;
99 | }
100 |
101 | public SimpleButtonContentHolder build() {
102 | return buttonBlock;
103 | }
104 | }
105 |
106 | public interface OnClickButtonListener {
107 | void onClick();
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/hintcontentholders/ByLayoutHintContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.hintcontentholders;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 |
8 | import com.joanfuentes.hintcase.HintCase;
9 |
10 | public class ByLayoutHintContentHolder extends HintContentHolder {
11 | int resLayoutId;
12 |
13 | public ByLayoutHintContentHolder(int resLayoutId) {
14 | super();
15 | this.resLayoutId = resLayoutId;
16 | }
17 |
18 | @Override
19 | public View getView(Context context, HintCase hintCase, ViewGroup parent) {
20 | LayoutInflater layoutInflater = LayoutInflater.from(context);
21 | View view = layoutInflater.inflate(resLayoutId, parent, false);
22 | return view;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/hintcontentholders/HintContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.hintcontentholders;
2 |
3 | import android.widget.FrameLayout;
4 |
5 | import com.joanfuentes.hintcase.ContentHolder;
6 |
7 | public abstract class HintContentHolder extends ContentHolder {
8 | public FrameLayout.LayoutParams getParentLayoutParams(int width, int height, int gravity) {
9 | return new FrameLayout.LayoutParams(width, height, gravity);
10 | }
11 |
12 | public FrameLayout.LayoutParams getParentLayoutParams(int width, int height, int gravity,
13 | int marginLeft, int marginTop,
14 | int marginRight, int marginBottom) {
15 | FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(width, height, gravity);
16 | layoutParams.setMargins(marginLeft, marginTop, marginRight, marginBottom);
17 | return layoutParams;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/hintcontentholders/SimpleHintContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.hintcontentholders;
2 |
3 | import android.content.Context;
4 | import android.text.SpannableString;
5 | import android.text.style.TextAppearanceSpan;
6 | import android.view.Gravity;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.FrameLayout;
10 | import android.widget.ImageView;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 |
14 | import com.joanfuentes.hintcase.HintCase;
15 |
16 | public class SimpleHintContentHolder extends HintContentHolder {
17 | public static final int NO_IMAGE = -1;
18 |
19 | private ImageView imageView;
20 | private int imageResourceId;
21 | private CharSequence contentTitle;
22 | private CharSequence contentText;
23 | private int titleStyleId;
24 | private int textStyleId;
25 | private int marginLeft;
26 | private int marginTop;
27 | private int marginRight;
28 | private int marginBottom;
29 | private int gravity;
30 |
31 | @Override
32 | public View getView(Context context, final HintCase hintCase, ViewGroup parent) {
33 | FrameLayout.LayoutParams frameLayoutParamsBlock = getParentLayoutParams(
34 | ViewGroup.LayoutParams.WRAP_CONTENT,
35 | ViewGroup.LayoutParams.WRAP_CONTENT,
36 | gravity, marginLeft, marginTop, marginRight, marginBottom);
37 | LinearLayout linearLayout = new LinearLayout(context);
38 | linearLayout.setLayoutParams(frameLayoutParamsBlock);
39 | linearLayout.setGravity(Gravity.CENTER);
40 | linearLayout.setOrientation(LinearLayout.VERTICAL);
41 | if (contentTitle != null) {
42 | linearLayout.addView(getTextViewTitle(context));
43 | }
44 | if (existImage()) {
45 | linearLayout.addView(getImage(context, imageView, imageResourceId));
46 | }
47 | if (contentText != null) {
48 | linearLayout.addView(getTextViewDescription(context));
49 | }
50 | return linearLayout;
51 | }
52 |
53 | private ImageView getImage(Context context, ImageView image, int imageResourceId) {
54 | LinearLayout.LayoutParams linearLayoutParamsImage =
55 | new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
56 | ViewGroup.LayoutParams.WRAP_CONTENT,
57 | 1.0f);
58 | linearLayoutParamsImage.setMargins(0, 20, 0, 50);
59 | if (image == null) {
60 | image = new ImageView(context);
61 | }
62 | if (imageResourceId != SimpleHintContentHolder.NO_IMAGE) {
63 | image.setImageResource(imageResourceId);
64 | }
65 | image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
66 | image.setAdjustViewBounds(true);
67 | image.setLayoutParams(linearLayoutParamsImage);
68 | return image;
69 | }
70 |
71 | private View getTextViewTitle(Context context) {
72 | LinearLayout.LayoutParams linearLayoutParamsTitle =
73 | new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
74 | ViewGroup.LayoutParams.WRAP_CONTENT);
75 | linearLayoutParamsTitle.setMargins(0, 20, 0, 20);
76 | TextView textViewTitle = new TextView(context);
77 | textViewTitle.setLayoutParams(linearLayoutParamsTitle);
78 | textViewTitle.setGravity(Gravity.CENTER_HORIZONTAL);
79 | SpannableString spannableStringTitle= new SpannableString(contentTitle);
80 | TextAppearanceSpan titleTextAppearanceSpan = new TextAppearanceSpan(context, titleStyleId);
81 | spannableStringTitle.setSpan(titleTextAppearanceSpan, 0, spannableStringTitle.length(), 0);
82 | textViewTitle.setText(spannableStringTitle);
83 | return textViewTitle;
84 | }
85 |
86 | private View getTextViewDescription(Context context) {
87 | LinearLayout.LayoutParams linearLayoutParamsText =
88 | new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
89 | ViewGroup.LayoutParams.WRAP_CONTENT);
90 | TextView textViewDescription = new TextView(context);
91 | textViewDescription.setLayoutParams(linearLayoutParamsText);
92 | textViewDescription.setGravity(Gravity.CENTER_HORIZONTAL);
93 | SpannableString spannableStringText= new SpannableString(contentText);
94 | TextAppearanceSpan textTextAppearanceSpan = new TextAppearanceSpan(context, textStyleId);
95 | spannableStringText.setSpan(textTextAppearanceSpan, 0, spannableStringText.length(), 0);
96 | textViewDescription.setText(spannableStringText);
97 | return textViewDescription;
98 | }
99 |
100 | private boolean existImage() {
101 | return imageView != null ||
102 | imageResourceId != SimpleHintContentHolder.NO_IMAGE;
103 | }
104 |
105 | public static class Builder {
106 | private SimpleHintContentHolder blockInfo;
107 | private Context context;
108 |
109 | public Builder(Context context) {
110 | this.context = context;
111 | this.blockInfo = new SimpleHintContentHolder();
112 | this.blockInfo.imageResourceId = NO_IMAGE;
113 | this.blockInfo.gravity = Gravity.CENTER;
114 | }
115 |
116 | public Builder setImageDrawableId(int resourceId) {
117 | blockInfo.imageResourceId = resourceId;
118 | return this;
119 | }
120 |
121 | public Builder setImageView(ImageView imageView) {
122 | blockInfo.imageView = imageView;
123 | return this;
124 | }
125 |
126 | public Builder setContentTitle(CharSequence title) {
127 | blockInfo.contentTitle = title;
128 | return this;
129 | }
130 |
131 | public Builder setContentTitle(int resId) {
132 | blockInfo.contentTitle = context.getString(resId);
133 | return this;
134 | }
135 |
136 | public Builder setTitleStyle(int resId) {
137 | blockInfo.titleStyleId = resId;
138 | return this;
139 | }
140 |
141 | public Builder setContentText(CharSequence text) {
142 | blockInfo.contentText = text;
143 | return this;
144 | }
145 |
146 | public Builder setContentText(int resId) {
147 | blockInfo.contentText = context.getString(resId);
148 | return this;
149 | }
150 |
151 | public Builder setContentStyle(int resId) {
152 | blockInfo.textStyleId = resId;
153 | return this;
154 | }
155 |
156 | public Builder setGravity(int gravity) {
157 | blockInfo.gravity = gravity;
158 | return this;
159 | }
160 |
161 | public Builder setMargin(int left, int top, int right, int bottom) {
162 | blockInfo.marginLeft = left;
163 | blockInfo.marginTop = top;
164 | blockInfo.marginRight = right;
165 | blockInfo.marginBottom = bottom;
166 | return this;
167 | }
168 |
169 | public Builder setMarginByResourcesId(int left, int top, int right, int bottom) {
170 | blockInfo.marginLeft = context.getResources().getDimensionPixelSize(left);
171 | blockInfo.marginTop = context.getResources().getDimensionPixelSize(top);
172 | blockInfo.marginRight = context.getResources().getDimensionPixelSize(right);
173 | blockInfo.marginBottom = context.getResources().getDimensionPixelSize(bottom);
174 | return this;
175 | }
176 |
177 | public SimpleHintContentHolder build() {
178 | return blockInfo;
179 | }
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapeanimators/FadeInShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapeanimators;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.ShapeAnimator;
9 | import com.joanfuentes.hintcase.Shape;
10 |
11 | public class FadeInShapeAnimator extends ShapeAnimator {
12 |
13 | public FadeInShapeAnimator() {
14 | super();
15 | }
16 |
17 | public FadeInShapeAnimator(int durationInMilliseconds) {
18 | super(durationInMilliseconds);
19 | }
20 |
21 | @Override
22 | public ValueAnimator getAnimator(View view, Shape shape,
23 | final OnFinishListener onFinishListener) {
24 | shape.setMinimumValue();
25 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
26 | animator.setDuration(durationInMilliseconds);
27 | animator.setStartDelay(startDelayInMilliseconds);
28 | if (onFinishListener != NO_CALLBACK) {
29 | animator.addListener(new Animator.AnimatorListener() {
30 | @Override
31 | public void onAnimationStart(Animator animation) { }
32 |
33 | @Override
34 | public void onAnimationEnd(Animator animation) {
35 | onFinishListener.onFinish();
36 | }
37 |
38 | @Override
39 | public void onAnimationCancel(Animator animation) { }
40 |
41 | @Override
42 | public void onAnimationRepeat(Animator animation) { }
43 | });
44 | }
45 | return animator;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapeanimators/FadeOutShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapeanimators;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.animation.ValueAnimator;
6 | import android.view.View;
7 |
8 | import com.joanfuentes.hintcase.ShapeAnimator;
9 | import com.joanfuentes.hintcase.Shape;
10 |
11 | public class FadeOutShapeAnimator extends ShapeAnimator {
12 |
13 | public FadeOutShapeAnimator() {
14 | super();
15 | }
16 |
17 | public FadeOutShapeAnimator(int durationInMilliseconds) {
18 | super(durationInMilliseconds);
19 | }
20 |
21 | @Override
22 | public ValueAnimator getAnimator(View view, Shape shape,
23 | final OnFinishListener onFinishListener) {
24 | shape.setMinimumValue();
25 | ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1, 0);
26 | animator.setDuration(durationInMilliseconds);
27 | animator.setStartDelay(startDelayInMilliseconds);
28 | if (onFinishListener != NO_CALLBACK) {
29 | animator.addListener(new Animator.AnimatorListener() {
30 | @Override
31 | public void onAnimationStart(Animator animation) { }
32 |
33 | @Override
34 | public void onAnimationEnd(Animator animation) {
35 | onFinishListener.onFinish();
36 | }
37 |
38 | @Override
39 | public void onAnimationCancel(Animator animation) { }
40 |
41 | @Override
42 | public void onAnimationRepeat(Animator animation) { }
43 | });
44 | }
45 | return animator;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapeanimators/RevealCircleShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapeanimators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.view.View;
5 |
6 | import com.joanfuentes.hintcase.ShapeAnimator;
7 | import com.joanfuentes.hintcaseassets.shapes.CircularShape;
8 | import com.joanfuentes.hintcase.Shape;
9 |
10 | public class RevealCircleShapeAnimator extends ShapeAnimator {
11 |
12 | public RevealCircleShapeAnimator() {
13 | super();
14 | }
15 |
16 | public RevealCircleShapeAnimator(int durationInMilliseconds) {
17 | super(durationInMilliseconds);
18 | }
19 |
20 | @Override
21 | public ValueAnimator getAnimator(final View view, Shape shape,
22 | final OnFinishListener onFinishListener) {
23 | final CircularShape circularShape = (CircularShape) shape;
24 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(circularShape.getMaxRadius(),
25 | circularShape.getMinRadius());
26 | valueAnimator.setStartDelay(startDelayInMilliseconds);
27 | valueAnimator.setDuration(durationInMilliseconds)
28 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
29 | @Override
30 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
31 | circularShape.setCurrentRadius((Float) valueAnimator.getAnimatedValue());
32 | if (circularShape.getCurrentRadius() == circularShape.getMinRadius()) {
33 | if (onFinishListener != null) {
34 | onFinishListener.onFinish();
35 | }
36 | }
37 | view.invalidate();
38 | }
39 | });
40 | return valueAnimator;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapeanimators/RevealRectangularShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapeanimators;
2 |
3 | import android.animation.FloatEvaluator;
4 | import android.animation.ValueAnimator;
5 | import android.view.View;
6 |
7 | import com.joanfuentes.hintcase.ShapeAnimator;
8 | import com.joanfuentes.hintcase.RectangularShape;
9 | import com.joanfuentes.hintcase.Shape;
10 |
11 | public class RevealRectangularShapeAnimator extends ShapeAnimator {
12 | private FloatEvaluator floatEvaluator;
13 |
14 | public RevealRectangularShapeAnimator() {
15 | super();
16 | init();
17 | }
18 |
19 | public RevealRectangularShapeAnimator(int durationInMilliseconds) {
20 | super(durationInMilliseconds);
21 | init();
22 | }
23 |
24 | private void init() {
25 | floatEvaluator = new FloatEvaluator();
26 | }
27 |
28 | @Override
29 | public ValueAnimator getAnimator(final View view, Shape shape,
30 | final OnFinishListener onFinishListener) {
31 | final RectangularShape rectangularShape = (RectangularShape) shape;
32 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(rectangularShape.getMaxHeight(),
33 | rectangularShape.getMinHeight());
34 | valueAnimator.setStartDelay(startDelayInMilliseconds);
35 | valueAnimator.setDuration(durationInMilliseconds)
36 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
39 | rectangularShape.setCurrentHeight((Float) valueAnimator.getAnimatedValue());
40 | float fraction = valueAnimator.getAnimatedFraction();
41 | rectangularShape.setCurrentWidth(
42 | floatEvaluator.evaluate(fraction, rectangularShape.getMaxWidth(),
43 | rectangularShape.getMinWidth()));
44 | if (rectangularShape.getCurrentHeight() == rectangularShape.getMinHeight()) {
45 | rectangularShape.setMinimumValue();
46 | if (onFinishListener != null) {
47 | onFinishListener.onFinish();
48 | }
49 | }
50 | view.invalidate();
51 | }
52 | });
53 | return valueAnimator;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapeanimators/UnrevealCircleShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapeanimators;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.view.View;
5 |
6 | import com.joanfuentes.hintcase.ShapeAnimator;
7 | import com.joanfuentes.hintcaseassets.shapes.CircularShape;
8 | import com.joanfuentes.hintcase.Shape;
9 |
10 | public class UnrevealCircleShapeAnimator extends ShapeAnimator {
11 |
12 | public UnrevealCircleShapeAnimator() {
13 | super();
14 | }
15 |
16 | public UnrevealCircleShapeAnimator(int durationInMilliseconds) {
17 | super(durationInMilliseconds);
18 | }
19 |
20 | @Override
21 | public ValueAnimator getAnimator(final View view, Shape shape,
22 | final OnFinishListener onFinishListener) {
23 | final CircularShape circularShape = (CircularShape) shape;
24 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(circularShape.getMinRadius(),
25 | circularShape.getMaxRadius());
26 | valueAnimator.setStartDelay(startDelayInMilliseconds);
27 | valueAnimator.setDuration(durationInMilliseconds)
28 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
29 | @Override
30 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
31 | circularShape.setCurrentRadius((Float) valueAnimator.getAnimatedValue());
32 | if (circularShape.getCurrentRadius() == circularShape.getMaxRadius()) {
33 | if (onFinishListener != null) {
34 | onFinishListener.onFinish();
35 | }
36 | }
37 | view.invalidate();
38 | }
39 | });
40 | return valueAnimator;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapeanimators/UnrevealRectangularShapeAnimator.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapeanimators;
2 |
3 | import android.animation.FloatEvaluator;
4 | import android.animation.ValueAnimator;
5 | import android.view.View;
6 |
7 | import com.joanfuentes.hintcase.ShapeAnimator;
8 | import com.joanfuentes.hintcase.RectangularShape;
9 | import com.joanfuentes.hintcase.Shape;
10 |
11 | public class UnrevealRectangularShapeAnimator extends ShapeAnimator {
12 | private FloatEvaluator floatEvaluator;
13 |
14 | public UnrevealRectangularShapeAnimator() {
15 | super();
16 | init();
17 | }
18 |
19 | public UnrevealRectangularShapeAnimator(int durationInMilliseconds) {
20 | super(durationInMilliseconds);
21 | init();
22 | }
23 |
24 | private void init() {
25 | floatEvaluator = new FloatEvaluator();
26 | }
27 |
28 | @Override
29 | public ValueAnimator getAnimator(final View view, Shape shape,
30 | final OnFinishListener onFinishListener) {
31 | final RectangularShape rectangularShape = (RectangularShape) shape;
32 | ValueAnimator valueAnimator = ValueAnimator.ofFloat(rectangularShape.getMinHeight(),
33 | rectangularShape.getMaxHeight());
34 | valueAnimator.setStartDelay(startDelayInMilliseconds);
35 | valueAnimator.setDuration(durationInMilliseconds)
36 | .addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
37 | @Override
38 | public void onAnimationUpdate(ValueAnimator valueAnimator) {
39 | rectangularShape.setCurrentHeight((Float) valueAnimator.getAnimatedValue());
40 | float fraction = valueAnimator.getAnimatedFraction();
41 | rectangularShape.setCurrentWidth(
42 | floatEvaluator.evaluate(fraction, rectangularShape.getMinWidth(),
43 | rectangularShape.getMaxWidth()));
44 | if (rectangularShape.getCurrentHeight() == rectangularShape.getMaxHeight()) {
45 | if (onFinishListener != null) {
46 | onFinishListener.onFinish();
47 | }
48 | }
49 | view.invalidate();
50 | }
51 | });
52 | return valueAnimator;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/java/com/joanfuentes/hintcaseassets/shapes/CircularShape.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseassets.shapes;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.view.MotionEvent;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 |
9 | import com.joanfuentes.hintcase.Shape;
10 |
11 | public class CircularShape extends Shape {
12 | private static final float DEFAULT_MIN_RADIUS = 50;
13 | private static final float DEFAULT_MAX_RADIUS = 10000;
14 |
15 | private float minRadius = DEFAULT_MIN_RADIUS;
16 | private float maxRadius = DEFAULT_MAX_RADIUS;
17 | private float currentRadius = DEFAULT_MAX_RADIUS;
18 |
19 | public float getMinRadius() {
20 | return minRadius;
21 | }
22 |
23 | public float getMaxRadius() {
24 | return maxRadius;
25 | }
26 |
27 | public float getCurrentRadius() {
28 | return currentRadius;
29 | }
30 |
31 | public void setCurrentRadius(float currentRadius) {
32 | this.currentRadius = currentRadius;
33 | }
34 |
35 | @Override
36 | public void setMinimumValue() {
37 | currentRadius = minRadius;
38 | }
39 |
40 | @Override
41 | public void setShapeInfo(View targetView, ViewGroup parent, int offset, Context context) {
42 | if (targetView != null) {
43 | minRadius = (Math.max(targetView.getMeasuredWidth(),targetView.getMeasuredHeight()) / 2) + offset;
44 | maxRadius = Math.max(parent.getHeight(), parent.getWidth());
45 | int[] targetViewLocationInWindow = new int[2];
46 | targetView.getLocationInWindow(targetViewLocationInWindow);
47 | setCenterX(targetViewLocationInWindow[0] + targetView.getWidth() / 2);
48 | setCenterY(targetViewLocationInWindow[1] + targetView.getHeight() / 2);
49 | setLeft((int) (getCenterX() - minRadius));
50 | setRight((int) (getCenterX() + minRadius));
51 | setTop((int) (getCenterY() - minRadius));
52 | setBottom((int) (getCenterY() + minRadius));
53 | setWidth(minRadius * 2);
54 | setHeight(minRadius * 2);
55 | } else {
56 | if (parent != null) {
57 | minRadius = 0;
58 | maxRadius = parent.getHeight();
59 | setCenterX(parent.getMeasuredWidth() / 2);
60 | setCenterY(parent.getMeasuredHeight() / 2);
61 | setLeft(0);
62 | setTop(0);
63 | setRight(0);
64 | setBottom(0);
65 | }
66 | }
67 | currentRadius = maxRadius;
68 | }
69 |
70 | @Override
71 | public boolean isTouchEventInsideTheHint(MotionEvent event) {
72 | float xDelta = Math.abs(event.getRawX() - getCenterX());
73 | float yDelta = Math.abs(event.getRawY() - getCenterY());
74 | double distanceFromFocus = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2));
75 | return distanceFromFocus <= minRadius;
76 | }
77 |
78 | @Override
79 | public void draw(Canvas canvas) {
80 | canvas.drawCircle(getCenterX(), getCenterY(), currentRadius, getShapePaint());
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/HintCaseAssets/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HintCase assets
3 |
4 |
--------------------------------------------------------------------------------
/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 | HintCase
2 | ==================
3 |
4 | HintCase is a library for Android that will help you create really awesome hints/tips for your apps. You can find a secondary library (HintCaseAssets) with multiple content holders and animators that you can use with HintCase library. Take a look to how you would integrate HintCase into your app.
5 |
6 | With HintCase library you can apply shape animations to highlight a specific view and show a HintBlock and/or multiple ExtraBlocks all of them with optional animations to show/hide them. All is very easy, but if you don't have time to implement shapes, blocks and animations, with the HintCaseAssets library you can use some predefined items.
7 |
8 | [](http://www.youtube.com/watch?v=GT3D-kJrKAA) [](http://www.youtube.com/watch?v=1O-SRAZqYAo)
9 |
10 | ## Latest Version
11 |
12 | [ ](https://bintray.com/joanfuentes/maven/HintCase/_latestVersion)    [](http://android-arsenal.com/details/1/3707)
13 |
14 |
15 | ## How to use
16 |
17 | ### 1.- Configuring your Project Dependencies
18 |
19 | Add the library dependency to your build.gradle file.
20 |
21 | ```groovy
22 | dependencies {
23 | ...
24 | compile 'com.joanfuentes:HintCase:1.0.4'
25 | }
26 | ```
27 |
28 | #### 1.1- Optional Project Dependency
29 |
30 | You can add the optional assets library dependency to your build.gradle file.
31 |
32 | ```groovy
33 | dependencies {
34 | ...
35 | compile 'com.joanfuentes:HintCaseAssets:1.0.4'
36 | }
37 | ```
38 |
39 | ### 2.- Showing a Hint
40 |
41 | All you need to do is create a new HintCase object, configure it and call the **show()** method.
42 |
43 | #### 2.1.- Passing a view to the constructor
44 |
45 | You need to pass a view to the constructor of HintCase object. This view should be the parent where you want to show the Hint.
46 | For example, is you are executing it from an onClick event, you could use a **view.getRootView()**, and **from an activity** you can use **getActivity().getWindow().getDecorView()** to get the full screen view.
47 |
48 | ```java
49 | protected void showHint() {
50 | ...
51 | parentView = getActivity().getWindow().getDecorView();
52 | new HintCase(parentView)
53 | ...
54 | .show();
55 | }
56 | ```
57 |
58 | #### 2.2.- Configuring a Target (OPTIONAL)
59 |
60 | You can configure a target view which will be highlighted. You can then configure the shape type, a margin between the shape and the target view (named offset) and if the target should be clickable or not.
61 |
62 | If no offset is specified, the default offset value is 10dp.
63 |
64 | ```java
65 | .setTarget(findViewById(R.id.textView), new RectangularShape(), HintCase.TARGET_IS_NOT_CLICKABLE)
66 | ```
67 |
68 | By default, if Target is not configured, a rectangular shape is used, the whole parent view is used as target, there is no offset and the target is not clickable.
69 |
70 | In HintCaseAssets you can find an extra shape (CircularShape), which is ideal to use with action menu icons, and FAB buttons.
71 |
72 | #### 2.3.- Configure animations to show/hide shapes (OPTIONAL)
73 |
74 | You can show animations when you show/hide a target with a shape. To do it, call the method **setShapeAnimators(..)**.
75 | You can use a ShapeAnimator to show and another ShapeAnimator to hide. You can find some ShapeAnimators in HintCaseAssets library. Feel free to use them or create your own awesome animators.
76 |
77 | ##### FadeInShapeAnimator and FadeOutShapeAnimator
78 |
79 | Fade in/out effects. You can set the time in the constructor. If no time is specified, 300ms are the default value.
80 | You can configure a delay for the animation with setStartDelay(long startDelayTimeInMillis).
81 |
82 | [](http://www.youtube.com/watch?v=67MZVrnhaAI)
83 |
84 | ##### RevealCircleShapeAnimator and UnrevealCircleShapeAnimator
85 |
86 | Reveal/Unreveal effects to highlight a target with a circle shape. You can set the time in the constructor. If no time is specified, 300ms are the default value.
87 | You can configure a delay for the animation with setStartDelay(long startDelayTimeInMillis).
88 |
89 | [](http://www.youtube.com/watch?v=-U4Ish1NKSM)
90 |
91 | ##### RevealRectangularShapeAnimator and UnrevealRectangularShapeAnimator
92 |
93 | Reveal/Unreveal effects to highlight a target with a rectangular shape. You can set the time in the constructor. If no time is specified, 300ms are the default value.
94 | You can configure a delay for the animation with setStartDelay(long startDelayTimeInMillis).
95 |
96 | [](http://www.youtube.com/watch?v=6Nd-1CaLyQI)
97 |
98 | Finally to configure shapeAnimators you need to call:
99 |
100 | ```java
101 | .setShapeAnimators(new RevealRectangularShapeAnimator(), ShapeAnimator.NO_ANIMATOR)
102 | ```
103 |
104 | If you don't want an animation you can use ***ShapeAnimator.NO_ANIMATOR***
105 |
106 | #### 2.4.- Configure a Background color (OPTIONAL)
107 |
108 | You can specify a background color for the shape of the hint. You can use:
109 |
110 | ```java
111 | .setBackgroundColor(0x00000000)
112 | ```
113 | or
114 | ```java
115 | .setBackgroundColorByResourceId(R.color.colorPrimary)
116 | ```
117 |
118 | #### 2.4.- Configure to close the hint on click on it (OPTIONAL)
119 |
120 | By default, the hint is closed when the user click on it. If you don't want it, you can change this behavior with:
121 |
122 | ```java
123 | .setCloseOnTouchView(false)
124 | ```
125 |
126 | #### 2.5.- Configure the Hint Block (OPTIONAL)
127 |
128 | You can create a hint block which depends on the target position to show itself.
129 | The hint block will be positioned on the biggest free space on the screen between the target view and the borders of the parent.
130 | If no target was configured, the hint block will be positioned in the center of the parent view.
131 | For example, if the parent view is the full screen, the hint block will be a view positioned in the center of the screen.
132 |
133 | You can define your own HintContenHolder or use some of the existing in the HintCaseAssets library:
134 |
135 | ##### ByLayoutHintContentHolder
136 |
137 | A HintContentHolder which inflates a specified layout. This is a fast way to create different hints with a specified layout for every hint.
138 |
139 | ```java
140 | ByLayoutHintContentHolder hintBlock = new ByLayoutHintContentHolder(R.layout.hint_welcome)
141 | ```
142 |
143 | ##### SimpleHintContentHolder
144 |
145 | A HintContentHolder which can show a title, an image and a description. all 3 items are optional.
146 |
147 | ```java
148 | SimpleHintContentHolder hintBlock = new SimpleHintContentHolder.Builder(context)
149 | .setContentTitle(R.string.title)
150 | .setContentText(R.string.description)
151 | .setTitleStyle(R.style.title)
152 | .setContentStyle(R.style.content)
153 | .setImageDrawableId(R.drawable.happy_welcome)
154 | .build();
155 | ```
156 |
157 | The image can be passed as an imageView instead of a drawable so, you can use awesome libraries as Glide to pass fabulous animated gifs. In that case you need to use the **.setImageView(imageView)** method.
158 |
159 | Finally, you can configure ContentHolderAnimators to show or hide the hint block.
160 |
161 | ```java
162 | .setHintBlock(hintBlock, new FadeInContentHolderAnimator(), new FadeOutContentHolderAnimator())
163 | ```
164 |
165 | If you don't want to create your own ContentHolderAnimators, you can use some existing in HintCaseAssets library as:
166 |
167 | ##### FadeInContentHolderAnimator and FadeOutContentHolderAnimator
168 |
169 | Fade in/out effects. You can set the time in the constructor. If no time is specified, 300ms are the default value.
170 | You can configure a delay for the animation with setStartDelay(long startDelayTimeInMillis).
171 |
172 | [](http://www.youtube.com/watch?v=MGxyC1XZpXs)
173 |
174 | ##### SlideInFromRightContentHolderAnimator and SlideOutFromRightContentHolderAnimator
175 |
176 | Slide in/out movements from right position. You can set the time in the constructor. If no time is specified, 300ms are the default value.
177 | You can configure a delay for the animation with setStartDelay(long startDelayTimeInMillis).
178 |
179 | [](http://www.youtube.com/watch?v=8ewF5wEz988)
180 |
181 | #### 2.6.- Configure an Extra Block (OPTIONAL)
182 |
183 | You can create multiple extra blocks which will be placed on a specified position of the parent view.
184 |
185 | You can create your own ExtraContentHolders. You can find on HintCaseAssets library an example with SimpleButtonContentHolder:
186 |
187 | ##### SimpleButtonContentHolder
188 |
189 | A HintContentHolder which show a button on the hint. It can be positioned based on rules of RelativeLayout.
190 |
191 | ```java
192 | SimpleButtonContentHolder okBlock = new SimpleButtonContentHolder.Builder(context)
193 | .setWidth(ViewGroup.LayoutParams.WRAP_CONTENT)
194 | .setHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
195 | .setRules(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.ALIGN_PARENT_RIGHT)
196 | .setButtonText(R.string.ok)
197 | .setCloseHintCaseOnClick(true)
198 | .setButtonStyle(R.style.buttonNice)
199 | .build();
200 | ```
201 |
202 | You can configure the button to close the hint on clock with **.setCloseHintCaseOnClick(true)** and define the button style with **.setButtonStyle(R.style.buttonNice)**.
203 |
204 | Finally, you can configure ContentHolderAnimators to show or hide the extra block.
205 |
206 | ```java
207 | .setExtraBlock(okBlock, new SlideInFromRightContentHolderAnimator(), new SlideOutFromRightContentHolderAnimator())
208 | ```
209 |
210 | If you don't want to create your own ContentHolderAnimators, you can use some existing in HintCaseAssets library.
211 |
212 | #### 2.7.- Configure a listener when the hint is closed (OPTIONAL)
213 |
214 | You can set a listener to execute when the hint is closed:
215 |
216 | ```java
217 | .setOnClosedListener(new HintCase.OnClosedListener() {
218 | @Override
219 | public void onClosed() {
220 | Snackbar.make(view, "Hint closed", Snackbar.LENGTH_SHORT).show();
221 | }
222 | })
223 | ```
224 |
225 | ### 3.- Concatenate several hints (OPTIONAL)
226 |
227 | You can concatenate several hints simply using the OnClosedListener to launch the next HintCase. Even you can configure hints to avoid some animations so that the user does not perceive that are different hints.
228 |
229 | For example:
230 | ```java
231 | SimpleHintContentHolder hintBlock = new SimpleHintContentHolder.Builder(view.getContext())
232 | .setContentTitle("Attention!")
233 | .setContentText("You can find here your notifications")
234 | .setTitleStyle(R.style.title)
235 | .setContentStyle(R.style.content)
236 | .build();
237 | new HintCase(view.getRootView())
238 | .setTarget(findViewById(R.id.textView), new CircularShape(), HintCase.TARGET_IS_NOT_CLICKABLE)
239 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
240 | .setShapeAnimators(new RevealCircleShapeAnimator(), ShapeAnimator.NO_ANIMATOR)
241 | .setHintBlock(hintBlock, new FadeInContentHolderAnimator(), new SlideOutFromRightContentHolderAnimator())
242 | .setOnClosedListener(new HintCase.OnClosedListener() {
243 | @Override
244 | public void onClosed() {
245 | SimpleHintContentHolder secondHintBlock = new SimpleHintContentHolder.Builder(view.getContext())
246 | .setContentTitle("Notifications center is your best friend")
247 | .setContentText("Every time you purchase a game, a notification will be generated")
248 | .setTitleStyle(R.style.title)
249 | .setContentStyle(R.style.content)
250 | .build();
251 | new HintCase(view.getRootView())
252 | .setTarget(findViewById(R.id.textView), new CircularShape())
253 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
254 | .setShapeAnimators(ShapeAnimator.NO_ANIMATOR, new UnrevealCircleShapeAnimator())
255 | .setHintBlock(secondHintBlock, new SlideInFromRightContentHolderAnimator())
256 | .show();
257 | }
258 | })
259 | .show();
260 | ```
261 |
262 | In this example, the fist hint is configured to show a reveal animation for the shape but with no animation to hide the hint. The next hint doesn't show an animation to show so, the effect is that the shape was fixed and there was no change with it.
263 | The hint block was showed with a fade in animation but to hide it was shown an slideOut animation, and the hint block in the next screen was showed with a slideIn animation.
264 | The result was this:
265 |
266 | [](http://www.youtube.com/watch?v=uyE6bNGVwGc)
267 |
268 | ### 4.- Building your own ContentHolder (OPTIONAL)
269 |
270 | Building your own content holder is really easy. If you want that you contentHolder was showed on the biggest free space in the screen you should extend from HintContentHolder. Otherwise, if you want that your ContentHolder can fill all the parent view extends from ExtraContentHolder.
271 | Both of the base classes (HintContentHolder and ExtraContentHolder) extends from ContentHolder and define its specific getParentLayoutParams to use in your custom ContentHolder.
272 |
273 | In your custom ContentHolder you will need to define your own getView method to return the view that you generated for your hint.
274 | You receive the context, the parent viewgroup and the full hintcase so you can even know where the target is to mount your own contentHolder.
275 | ```java
276 | @Override
277 | public View getView(Context context, final HintCase hintCase, ViewGroup parent) {
278 | ...
279 | }
280 | ```
281 |
282 | as an optional you can define the onLayout method that you listen when the layout is inflated so you can configure your contentHolder based on the calculated position for the HintContentHolder
283 | ```ave
284 | @Override
285 | public void onLayout() {
286 | ...
287 | }
288 | ```
289 | In the app example you can find a CustomHintContentHolder that override and use both methods.
290 |
291 | ### 5.- Building your own ContentHolderAnimator (OPTIONAL)
292 |
293 | Building your own content holder animator is really easy. You should extend from ContentHolderAnimator.
294 |
295 | In Your custom ContentHolderAnimator you will need to define your own getAnimator method to return the ValueAnimator of the contentHolder.
296 | You receive the view for which is the animator applied and a onFinishListener to call when the animator is finished.
297 |
298 | ```java
299 | @Override
300 | public ValueAnimator getAnimator(View view, OnFinishListener onFinishListener) {
301 | ...
302 | }
303 | ```
304 |
305 | ### 6.- Building your own Shape (OPTIONAL)
306 |
307 | A rectangular and a Circular shape are provided with the main library and the assets library, but if you need to do your own shape, you can do it!.
308 |
309 | In your Shape you will need to define some methods:
310 | ```java
311 | @Override
312 | public void setMinimumValue() {
313 | ...
314 | }
315 |
316 | @Override
317 | public void setShapeInfo(View targetView, ViewGroup parent, int offset, Context context) {
318 | ...
319 | }
320 |
321 | public boolean isTouchEventInsideTheHint(MotionEvent event) {
322 | ...
323 | }
324 |
325 | public void draw(Canvas canvas) {
326 | ...
327 | }
328 |
329 | ```
330 | - setMinimumValue : you should set the minimum size of the shape in this method.
331 | - setShapeInfo : you should set all the necessary info of the shape for use on ShapeAnimators.
332 | - isTouchEventInsideTheHint: this method should return if the user performed a touch event inside the Highlighted item.
333 | - draw: this method should draw the shape in the canvas.
334 |
335 | You can check the code of CircularShape & RectangularShape to se some examples.
336 |
337 | ### 7.- Building your own ShapeAnimator (OPTIONAL)
338 |
339 | Building your own shape animator is really easy. You should extend from ShapeAnimator.
340 |
341 | In Your custom ShapeAnimator wou will need to define your own getAnimator method to return the ValueAnimator of the contentHolder.
342 | You receive the view on which is the animator applied, the shape to animate and a onFinishListener to call when the animator is finished.
343 |
344 | ```java
345 | @Override
346 | public ValueAnimator getAnimator(View view, Shape shape, OnFinishListener onFinishListener) {
347 | ...
348 | }
349 | ```
350 |
351 | ## Developers
352 |
353 | * Joan Fuentes ([@Nescafemix](https://github.com/nescafemix))
354 |
355 | ## Special Thanks to
356 |
357 | * Txus Ballesteros ([@Txusballesteros](https://github.com/txusballesteros))
358 |
359 | ## Motivation
360 |
361 | We created this view as a little piece of the [Redbooth](https://redbooth.com/) app for [Android](https://play.google.com/store/apps/details?id=com.redbooth).
362 |
363 | ## Currently using in
364 |
365 | * [Redbooth](https://play.google.com/store/apps/details?id=com.redbooth)
366 |
367 | If you use this library in your project and you want to be in this section, please, let us know it at [@Nescafemix](https://twitter.com/Nescafemix).
368 |
369 | ## License
370 |
371 | Copyright Joan Fuentes 2016
372 |
373 | This file is part of some open source application.
374 |
375 | Licensed to the Apache Software Foundation (ASF) under one
376 | or more contributor license agreements. See the NOTICE file
377 | distributed with this work for additional information
378 | regarding copyright ownership. The ASF licenses this file
379 | to you under the Apache License, Version 2.0 (the
380 | "License"); you may not use this file except in compliance
381 | with the License. You may obtain a copy of the License at
382 |
383 | http://www.apache.org/licenses/LICENSE-2.0
384 |
385 | Unless required by applicable law or agreed to in writing,
386 | software distributed under the License is distributed on an
387 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
388 | KIND, either express or implied. See the License for the
389 | specific language governing permissions and limitations
390 | under the License.
391 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | def globalConfiguration = rootProject.extensions.getByName("ext")
4 |
5 | android {
6 | compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
7 | buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")
8 |
9 | defaultConfig {
10 | applicationId "${globalConfiguration.getAt("androidApplicationId")}.hintcaseexample"
11 | minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
12 | targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
13 | versionCode globalConfiguration.getAt("androidVersionCodeExample")
14 | versionName globalConfiguration.getAt("androidVersionNameExample")
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | }
21 | }
22 | }
23 |
24 | dependencies {
25 | def dependencies = globalConfiguration.exampleDependencies
26 | compile project(':HintCase')
27 | compile project(':HintCaseAssets')
28 | compile dependencies.AppCompat
29 | compile dependencies.DesignLibrary
30 | compile dependencies.SupportLibrary
31 | compile dependencies.GlideLibrary
32 | compile dependencies.ButterKnife
33 | }
34 |
--------------------------------------------------------------------------------
/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/joan/Utilidades/SDKs/android-sdk-macosx/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/com/joanfuentes/hintcaseexample/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample;
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 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/joanfuentes/hintcaseexample/CustomHintActivity.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample;
2 |
3 | import android.app.Activity;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Button;
12 | import android.widget.RelativeLayout;
13 |
14 | import com.joanfuentes.hintcase.HintCase;
15 | import com.joanfuentes.hintcaseassets.contentholderanimators.FadeInContentHolderAnimator;
16 | import com.joanfuentes.hintcaseassets.contentholderanimators.FadeOutContentHolderAnimator;
17 | import com.joanfuentes.hintcaseassets.contentholderanimators.SlideInFromRightContentHolderAnimator;
18 | import com.joanfuentes.hintcaseassets.contentholderanimators.SlideOutFromRightContentHolderAnimator;
19 | import com.joanfuentes.hintcaseassets.extracontentholders.SimpleButtonContentHolder;
20 | import com.joanfuentes.hintcaseexample.customBlock.CustomHintContentHolder;
21 |
22 | public class CustomHintActivity extends AppCompatActivity {
23 |
24 | public Activity getActivity() {
25 | return this;
26 | }
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_custom_hint);
32 | configureToolbar();
33 | setViews();
34 | }
35 |
36 | private void configureToolbar() {
37 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
38 | if (toolbar != null) {
39 | toolbar.setTitle("Hintcase - Custom hints");
40 | setSupportActionBar(toolbar);
41 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
42 | getSupportActionBar().setDisplayShowHomeEnabled(true);
43 | }
44 | }
45 | @Override
46 | public boolean onOptionsItemSelected(MenuItem item) {
47 | switch (item.getItemId()) {
48 | case android.R.id.home:
49 | onBackPressed();
50 | return true;
51 | default:
52 | return super.onOptionsItemSelected(item);
53 | }
54 | }
55 |
56 | private void setViews() {
57 | Button buttonUp = (Button) findViewById(R.id.button_up);
58 | if(buttonUp != null) {
59 | buttonUp.setOnClickListener(new View.OnClickListener() {
60 | @Override
61 | public void onClick(View view) {
62 | showHint(view);
63 | }
64 | });
65 | }
66 |
67 | Button buttonDown = (Button) findViewById(R.id.button_down);
68 | if(buttonDown != null) {
69 | buttonDown.setOnClickListener(new View.OnClickListener() {
70 | @Override
71 | public void onClick(View view) {
72 | showHint(view);
73 | }
74 | });
75 | }
76 |
77 | Button buttonRight = (Button) findViewById(R.id.button_right);
78 | if(buttonRight != null) {
79 | buttonRight.setOnClickListener(new View.OnClickListener() {
80 | @Override
81 | public void onClick(View view) {
82 | showHint(view);
83 | }
84 | });
85 | }
86 |
87 | Button buttonLeft = (Button) findViewById(R.id.button_left);
88 | if(buttonLeft != null) {
89 | buttonLeft.setOnClickListener(new View.OnClickListener() {
90 | @Override
91 | public void onClick(View view) {
92 | showHint(view);
93 | }
94 | });
95 | }
96 | }
97 |
98 | private void showHint(final View view) {
99 | SimpleButtonContentHolder okBlock = new SimpleButtonContentHolder.Builder(view.getContext())
100 | .setWidth(ViewGroup.LayoutParams.WRAP_CONTENT)
101 | .setHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
102 | .setRules(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.ALIGN_PARENT_RIGHT)
103 | .setButtonText("OK")
104 | .setCloseHintCaseOnClick(true)
105 | .setButtonStyle(R.style.buttonNice)
106 | .build();
107 | CustomHintContentHolder blockInfo = new CustomHintContentHolder.Builder(view.getContext())
108 | .setContentTitle("Custom Hint Content Holder!")
109 | .setContentText("This hint was done with a custom hint content holder and it only can be closed clicking over the blue OK button")
110 | .setBorder(R.dimen.bubble_border, android.R.color.holo_blue_dark)
111 | .setArrowSize(R.dimen.arrow_width, R.dimen.arrow_height)
112 | .setBackgroundColor(Color.WHITE)
113 | .setTitleStyle(R.style.title)
114 | .setMargingByResourcesId(R.dimen.activity_vertical_margin,
115 | R.dimen.activity_horizontal_margin,
116 | R.dimen.activity_vertical_margin,
117 | R.dimen.activity_horizontal_margin)
118 | .setContentPaddingByResourcesId(R.dimen.small_margin,
119 | R.dimen.small_margin,
120 | R.dimen.small_margin,
121 | R.dimen.small_margin)
122 | .setContentStyle(R.style.content_dark)
123 | .build();
124 | new HintCase(getActivity().getWindow().getDecorView())
125 | .setTarget(view, R.dimen.zero_margin)
126 | .setBackgroundColor(0x00000000)
127 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator(),
128 | new FadeOutContentHolderAnimator())
129 | .setExtraBlock(okBlock, new SlideInFromRightContentHolderAnimator(),
130 | new SlideOutFromRightContentHolderAnimator())
131 | .setCloseOnTouchView(false)
132 | .show();
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/app/src/main/java/com/joanfuentes/hintcaseexample/FullHintActivity.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.annotation.NonNull;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.MenuItem;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 |
13 | import com.bumptech.glide.Glide;
14 | import com.bumptech.glide.load.engine.DiskCacheStrategy;
15 | import com.bumptech.glide.load.resource.drawable.GlideDrawable;
16 | import com.bumptech.glide.load.resource.transcode.BitmapToGlideDrawableTranscoder;
17 | import com.joanfuentes.hintcase.HintCase;
18 | import com.joanfuentes.hintcase.RectangularShape;
19 | import com.joanfuentes.hintcase.ShapeAnimator;
20 | import com.joanfuentes.hintcaseassets.contentholderanimators.FadeInContentHolderAnimator;
21 | import com.joanfuentes.hintcaseassets.contentholderanimators.FadeOutContentHolderAnimator;
22 | import com.joanfuentes.hintcaseassets.contentholderanimators.SlideInFromRightContentHolderAnimator;
23 | import com.joanfuentes.hintcaseassets.contentholderanimators.SlideOutFromRightContentHolderAnimator;
24 | import com.joanfuentes.hintcaseassets.hintcontentholders.SimpleHintContentHolder;
25 | import com.joanfuentes.hintcaseassets.shapeanimators.FadeInShapeAnimator;
26 | import com.joanfuentes.hintcaseassets.shapeanimators.FadeOutShapeAnimator;
27 | import com.joanfuentes.hintcaseassets.shapeanimators.RevealCircleShapeAnimator;
28 | import com.joanfuentes.hintcaseassets.shapeanimators.RevealRectangularShapeAnimator;
29 | import com.joanfuentes.hintcaseassets.shapeanimators.UnrevealCircleShapeAnimator;
30 | import com.joanfuentes.hintcaseassets.shapeanimators.UnrevealRectangularShapeAnimator;
31 | import com.joanfuentes.hintcaseassets.shapes.CircularShape;
32 |
33 | public class FullHintActivity extends AppCompatActivity {
34 | private static final View NO_VIEW_AS_TARGET = null;
35 |
36 | public Activity getActivity() {
37 | return this;
38 | }
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_full_hint);
44 | configureToolbar();
45 | setViews();
46 | }
47 |
48 | private void configureToolbar() {
49 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
50 | if (toolbar != null) {
51 | toolbar.setTitle("Hintcase - Full Screen");
52 | setSupportActionBar(toolbar);
53 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
54 | getSupportActionBar().setDisplayShowHomeEnabled(true);
55 | }
56 | }
57 |
58 | @Override
59 | public boolean onOptionsItemSelected(MenuItem item) {
60 | switch (item.getItemId()) {
61 | case android.R.id.home:
62 | onBackPressed();
63 | return true;
64 | default:
65 | return super.onOptionsItemSelected(item);
66 | }
67 | }
68 |
69 | private void setViews() {
70 | Button buttonExample1 = (Button) findViewById(R.id.button_example_1);
71 | if(buttonExample1 != null) {
72 | buttonExample1.setOnClickListener(new View.OnClickListener() {
73 | @Override
74 | public void onClick(View view) {
75 | ImageView animatedImageView = getGifLoadedUsingGlide();
76 | SimpleHintContentHolder blockInfo =
77 | getSimpleHintContentHolder(view, animatedImageView);
78 | new HintCase(view.getRootView())
79 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
80 | .setShapeAnimators(new FadeInShapeAnimator(), new FadeOutShapeAnimator())
81 | .setHintBlock(blockInfo)
82 | .show();
83 | }
84 | });
85 | }
86 |
87 | Button buttonExample2 = (Button) findViewById(R.id.button_example_2);
88 | if(buttonExample2 != null) {
89 | buttonExample2.setOnClickListener(new View.OnClickListener() {
90 | @Override
91 | public void onClick(View view) {
92 | ImageView animatedImageView = getGifLoadedUsingGlide();
93 | SimpleHintContentHolder blockInfo =
94 | getSimpleHintContentHolder(view, animatedImageView);
95 | new HintCase(view.getRootView())
96 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
97 | .setTarget(NO_VIEW_AS_TARGET, new CircularShape())
98 | .setShapeAnimators(new RevealCircleShapeAnimator(),
99 | new UnrevealCircleShapeAnimator())
100 | .setHintBlock(blockInfo)
101 | .show();
102 |
103 | }
104 | });
105 | }
106 |
107 | Button buttonExample3 = (Button) findViewById(R.id.button_example_3);
108 | if(buttonExample3 != null) {
109 | buttonExample3.setOnClickListener(new View.OnClickListener() {
110 | @Override
111 | public void onClick(View view) {
112 | ImageView animatedImageView = getGifLoadedUsingGlide();
113 | SimpleHintContentHolder blockInfo =
114 | getSimpleHintContentHolder(view, animatedImageView);
115 | new HintCase(view.getRootView())
116 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
117 | .setTarget(NO_VIEW_AS_TARGET, new RectangularShape())
118 | .setShapeAnimators(new RevealRectangularShapeAnimator(),
119 | new UnrevealRectangularShapeAnimator())
120 | .setHintBlock(blockInfo)
121 | .show();
122 | }
123 | });
124 | }
125 |
126 | Button buttonExample4 = (Button) findViewById(R.id.button_example_4);
127 | if(buttonExample4 != null) {
128 | buttonExample4.setOnClickListener(new View.OnClickListener() {
129 | @Override
130 | public void onClick(View view) {
131 | ImageView animatedImageView = getGifLoadedUsingGlide();
132 | SimpleHintContentHolder blockInfo =
133 | getSimpleHintContentHolder(view, animatedImageView);
134 | new HintCase(view.getRootView())
135 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
136 | .setShapeAnimators(new FadeInShapeAnimator(), new FadeOutShapeAnimator())
137 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator(),
138 | new FadeOutContentHolderAnimator())
139 | .show();
140 | }
141 | });
142 | }
143 |
144 | Button buttonExample5 = (Button) findViewById(R.id.button_example_5);
145 | if(buttonExample5 != null) {
146 | buttonExample5.setOnClickListener(new View.OnClickListener() {
147 | @Override
148 | public void onClick(View view) {
149 | ImageView animatedImageView = getGifLoadedUsingGlide();
150 | SimpleHintContentHolder blockInfo =
151 | getSimpleHintContentHolder(view, animatedImageView);
152 | new HintCase(view.getRootView())
153 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
154 | .setTarget(NO_VIEW_AS_TARGET, new CircularShape())
155 | .setShapeAnimators(new RevealCircleShapeAnimator(),
156 | new UnrevealCircleShapeAnimator())
157 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator(),
158 | new FadeOutContentHolderAnimator())
159 | .show();
160 |
161 | }
162 | });
163 | }
164 |
165 | Button buttonExample6 = (Button) findViewById(R.id.button_example_6);
166 | if(buttonExample6 != null) {
167 | buttonExample6.setOnClickListener(new View.OnClickListener() {
168 | @Override
169 | public void onClick(View view) {
170 | ImageView animatedImageView = getGifLoadedUsingGlide();
171 | SimpleHintContentHolder blockInfo =
172 | getSimpleHintContentHolder(view, animatedImageView);
173 | new HintCase(view.getRootView())
174 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
175 | .setTarget(NO_VIEW_AS_TARGET, new CircularShape())
176 | .setShapeAnimators(new RevealCircleShapeAnimator(),
177 | new UnrevealCircleShapeAnimator())
178 | .setHintBlock(blockInfo, new SlideInFromRightContentHolderAnimator(),
179 | new SlideOutFromRightContentHolderAnimator())
180 | .show();
181 |
182 | }
183 | });
184 | }
185 |
186 | Button buttonExample7 = (Button) findViewById(R.id.button_example_7);
187 | if(buttonExample7 != null) {
188 | buttonExample7.setOnClickListener(new View.OnClickListener() {
189 | @Override
190 | public void onClick(final View view) {
191 | launchFirstHint(view);
192 | }
193 | });
194 | }
195 | }
196 |
197 | private void launchFirstHint(final View view) {
198 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
199 | .setContentTitle("Attention!")
200 | .setContentText("This is your first advice. Please, be careful")
201 | .setTitleStyle(R.style.title)
202 | .setContentStyle(R.style.content)
203 | .build();
204 | new HintCase(view.getRootView())
205 | .setTarget(findViewById(R.id.textView), new CircularShape(), HintCase.TARGET_IS_NOT_CLICKABLE)
206 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
207 | .setShapeAnimators(new RevealCircleShapeAnimator(), ShapeAnimator.NO_ANIMATOR)
208 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator(), new SlideOutFromRightContentHolderAnimator())
209 | .setOnClosedListener(new HintCase.OnClosedListener() {
210 | @Override
211 | public void onClosed() {
212 | launchSecondHint(view);
213 | }
214 | })
215 | .show();
216 | }
217 |
218 | private void launchSecondHint(View view) {
219 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
220 | .setContentTitle("Attention again!")
221 | .setContentText("Are you really reading these messages?")
222 | .setTitleStyle(R.style.title)
223 | .setContentStyle(R.style.content)
224 | .build();
225 | new HintCase(view.getRootView())
226 | .setTarget(findViewById(R.id.textView), new CircularShape())
227 | .setBackgroundColor(getResources().getColor(R.color.colorPrimary))
228 | .setShapeAnimators(ShapeAnimator.NO_ANIMATOR, new UnrevealCircleShapeAnimator())
229 | .setHintBlock(blockInfo, new SlideInFromRightContentHolderAnimator())
230 | .show();
231 | }
232 |
233 | @NonNull
234 | private ImageView getGifLoadedUsingGlide() {
235 | ImageView animatedImageView = new ImageView(getActivity());
236 | animatedImageView.setMaxHeight(900);
237 | Glide.with(getActivity())
238 | .load(R.drawable.animated_image)
239 | .diskCacheStrategy(DiskCacheStrategy.SOURCE)
240 | .thumbnail(Glide.with(getActivity())
241 | .load(R.drawable.animated_image)
242 | .asBitmap()
243 | .transcode(new BitmapToGlideDrawableTranscoder(getActivity()), GlideDrawable.class)
244 | .diskCacheStrategy(DiskCacheStrategy.ALL)
245 | )
246 | .into(animatedImageView);
247 | return animatedImageView;
248 | }
249 |
250 | private SimpleHintContentHolder getSimpleHintContentHolder(View view, ImageView animatedImageView) {
251 | return new SimpleHintContentHolder.Builder(view.getContext())
252 | .setContentTitle("The truth behind the veil")
253 | .setContentText("True story")
254 | .setImageView(animatedImageView)
255 | .setTitleStyle(R.style.title)
256 | .setContentStyle(R.style.content)
257 | .setMarginByResourcesId(R.dimen.activity_horizontal_margin,
258 | R.dimen.activity_vertical_margin, R.dimen.activity_horizontal_margin,
259 | R.dimen.activity_vertical_margin)
260 | .build();
261 | }
262 | }
263 |
--------------------------------------------------------------------------------
/app/src/main/java/com/joanfuentes/hintcaseexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample;
2 |
3 | import android.app.Activity;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.support.v7.widget.Toolbar;
8 | import android.view.View;
9 | import android.widget.Button;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | public Activity getActivity() {
14 | return this;
15 | }
16 |
17 | @Override
18 | protected void onCreate(Bundle savedInstanceState) {
19 | super.onCreate(savedInstanceState);
20 | setContentView(R.layout.activity_main);
21 | configureToolbar();
22 | setViews();
23 | }
24 |
25 | private void setViews() {
26 | Button buttonFullScreen = (Button) findViewById(R.id.button_full_screen_hints);
27 | if (buttonFullScreen!= null) {
28 | buttonFullScreen.setOnClickListener(new View.OnClickListener() {
29 | @Override
30 | public void onClick(View v) {
31 | startActivity(new Intent(getActivity(), FullHintActivity.class));
32 | }
33 | });
34 | }
35 |
36 | Button buttonTargetHints = (Button) findViewById(R.id.button_target_hints);
37 | if (buttonTargetHints!= null) {
38 | buttonTargetHints.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View v) {
41 | startActivity(new Intent(getActivity(), TargetHintActivity.class));
42 | }
43 | });
44 | }
45 |
46 | Button buttonCustomHints = (Button) findViewById(R.id.button_custom_hints);
47 | if (buttonCustomHints!= null) {
48 | buttonCustomHints.setOnClickListener(new View.OnClickListener() {
49 | @Override
50 | public void onClick(View v) {
51 | startActivity(new Intent(getActivity(), CustomHintActivity.class));
52 | }
53 | });
54 | }
55 | }
56 |
57 | private void configureToolbar() {
58 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
59 | setSupportActionBar(toolbar);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/joanfuentes/hintcaseexample/TargetHintActivity.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.os.Handler;
6 | import android.support.design.widget.Snackbar;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.support.v7.widget.Toolbar;
9 | import android.view.Gravity;
10 | import android.view.Menu;
11 | import android.view.MenuItem;
12 | import android.view.View;
13 | import android.widget.Button;
14 | import android.widget.CompoundButton;
15 | import android.widget.Switch;
16 |
17 | import com.joanfuentes.hintcase.HintCase;
18 | import com.joanfuentes.hintcaseassets.contentholderanimators.FadeInContentHolderAnimator;
19 | import com.joanfuentes.hintcaseassets.hintcontentholders.SimpleHintContentHolder;
20 | import com.joanfuentes.hintcaseassets.shapeanimators.RevealCircleShapeAnimator;
21 | import com.joanfuentes.hintcaseassets.shapeanimators.RevealRectangularShapeAnimator;
22 | import com.joanfuentes.hintcaseassets.shapeanimators.UnrevealCircleShapeAnimator;
23 | import com.joanfuentes.hintcaseassets.shapeanimators.UnrevealRectangularShapeAnimator;
24 | import com.joanfuentes.hintcaseassets.shapes.CircularShape;
25 |
26 | public class TargetHintActivity extends AppCompatActivity {
27 |
28 | public Activity getActivity() {
29 | return this;
30 | }
31 |
32 | @Override
33 | protected void onCreate(Bundle savedInstanceState) {
34 | super.onCreate(savedInstanceState);
35 | setContentView(R.layout.activity_target_hint);
36 | configureToolbar();
37 | setViews();
38 | }
39 |
40 | private void configureToolbar() {
41 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
42 | if (toolbar != null) {
43 | toolbar.setTitle("Hintcase - Target View");
44 | setSupportActionBar(toolbar);
45 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
46 | getSupportActionBar().setDisplayShowHomeEnabled(true);
47 |
48 | }
49 | }
50 |
51 | @Override
52 | public boolean onOptionsItemSelected(MenuItem item) {
53 | switch (item.getItemId()) {
54 | case android.R.id.home:
55 | onBackPressed();
56 | return true;
57 | default:
58 | return super.onOptionsItemSelected(item);
59 | }
60 | }
61 |
62 | @Override
63 | public boolean onCreateOptionsMenu(Menu menu) {
64 | super.onCreateOptionsMenu(menu);
65 | getMenuInflater().inflate(R.menu.menu_target_hint, menu);
66 | launchAutomaticHint();
67 | return true;
68 | }
69 |
70 | private void launchAutomaticHint() {
71 | new Handler().postDelayed(new Runnable() {
72 | @Override
73 | public void run() {
74 | View actionSearchView = findViewById(R.id.action_search);
75 | if (actionSearchView != null) {
76 | SimpleHintContentHolder blockInfo =
77 | new SimpleHintContentHolder.Builder(actionSearchView.getContext())
78 | .setContentTitle("Search")
79 | .setContentText("This is an automatic example of a hint over a toolbar item")
80 | .setTitleStyle(R.style.title)
81 | .setContentStyle(R.style.content)
82 | .setMarginByResourcesId(R.dimen.activity_vertical_margin,
83 | R.dimen.activity_horizontal_margin,
84 | R.dimen.activity_vertical_margin,
85 | R.dimen.activity_horizontal_margin)
86 | .build();
87 | new HintCase(actionSearchView.getRootView())
88 | .setTarget(actionSearchView, new CircularShape())
89 | .setShapeAnimators(new RevealCircleShapeAnimator(),
90 | new UnrevealCircleShapeAnimator())
91 | .setHintBlock(blockInfo)
92 | .show();
93 | }
94 | }
95 | }, 500);
96 | }
97 |
98 | private void setViews() {
99 | Button buttonExample1 = (Button) findViewById(R.id.button_example_1);
100 | if(buttonExample1 != null) {
101 | buttonExample1.setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View view) {
104 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
105 | .setContentTitle("Attention!")
106 | .setContentText("This is a hint related with a button.")
107 | .setTitleStyle(R.style.title)
108 | .setContentStyle(R.style.content)
109 | .build();
110 | new HintCase(view.getRootView())
111 | .setTarget(findViewById(R.id.button),HintCase.TARGET_IS_NOT_CLICKABLE)
112 | .setBackgroundColorByResourceId(R.color.colorPrimary)
113 | .setShapeAnimators(new RevealRectangularShapeAnimator(), new UnrevealRectangularShapeAnimator())
114 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator())
115 | .show();
116 | }
117 | });
118 | }
119 |
120 | Button buttonExample2 = (Button) findViewById(R.id.button_example_2);
121 | if(buttonExample2 != null) {
122 | buttonExample2.setOnClickListener(new View.OnClickListener() {
123 | @Override
124 | public void onClick(View view) {
125 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
126 | .setContentTitle("Attention!")
127 | .setContentText("This is a hint related with a text.. Please, be careful")
128 | .setTitleStyle(R.style.title)
129 | .setContentStyle(R.style.content)
130 | .build();
131 | new HintCase(view.getRootView())
132 | .setTarget(findViewById(R.id.textView), new CircularShape(), HintCase.TARGET_IS_NOT_CLICKABLE)
133 | .setBackgroundColorByResourceId(R.color.colorPrimary)
134 | .setShapeAnimators(new RevealCircleShapeAnimator(), new UnrevealCircleShapeAnimator())
135 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator())
136 | .show();
137 | }
138 | });
139 | }
140 |
141 | Switch switchButton = (Switch) findViewById(R.id.switch_button);
142 | if (switchButton != null) {
143 | switchButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
144 | @Override
145 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
146 | Snackbar.make(getActivity().getWindow().getDecorView(), "Switch was changed", Snackbar.LENGTH_SHORT).show();
147 | }
148 | });
149 | }
150 |
151 | Button buttonExample3 = (Button) findViewById(R.id.button_example_3);
152 | if(buttonExample3 != null) {
153 | buttonExample3.setOnClickListener(new View.OnClickListener() {
154 | @Override
155 | public void onClick(View view) {
156 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
157 | .setContentTitle("Activate your powers!")
158 | .setContentText("you have the full control over your power. On to be a Hero, Off to be a looser.")
159 | .setTitleStyle(R.style.title_light)
160 | .setContentStyle(R.style.content_light)
161 | .setGravity(Gravity.CENTER)
162 | .setMarginByResourcesId(R.dimen.activity_vertical_margin,
163 | R.dimen.activity_horizontal_margin,
164 | R.dimen.activity_vertical_margin,
165 | R.dimen.activity_horizontal_margin)
166 | .build();
167 | new HintCase(view.getRootView())
168 | .setTarget(findViewById(R.id.switch_button), HintCase.TARGET_IS_CLICKABLE)
169 | .setBackgroundColorByResourceId(android.R.color.holo_blue_dark)
170 | .setShapeAnimators(new RevealRectangularShapeAnimator(),
171 | new UnrevealRectangularShapeAnimator())
172 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator())
173 | .show();
174 | }
175 | });
176 | }
177 |
178 | Button buttonExample4 = (Button) findViewById(R.id.button_example_4);
179 | if(buttonExample4 != null) {
180 | buttonExample4.setOnClickListener(new View.OnClickListener() {
181 | @Override
182 | public void onClick(View view) {
183 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
184 | .setContentTitle("Attention!")
185 | .setContentText("This is a hint related with a radio button.")
186 | .setTitleStyle(R.style.title)
187 | .setContentStyle(R.style.content)
188 | .setGravity(Gravity.CENTER)
189 | .setMarginByResourcesId(R.dimen.activity_vertical_margin,
190 | R.dimen.activity_horizontal_margin,
191 | R.dimen.activity_vertical_margin,
192 | R.dimen.activity_horizontal_margin)
193 | .build();
194 | new HintCase(view.getRootView())
195 | .setTarget(findViewById(R.id.radio_button), HintCase.TARGET_IS_CLICKABLE)
196 | .setBackgroundColor(0xCC000000)
197 | .setShapeAnimators(new RevealRectangularShapeAnimator(), new UnrevealRectangularShapeAnimator())
198 | .setHintBlock(blockInfo, new FadeInContentHolderAnimator())
199 | .show();
200 | }
201 | });
202 | }
203 |
204 | Button buttonExample5 = (Button) findViewById(R.id.button_example_5);
205 | if(buttonExample5 != null) {
206 | buttonExample5.setOnClickListener(new View.OnClickListener() {
207 | @Override
208 | public void onClick(View view) {
209 | SimpleHintContentHolder blockInfo = new SimpleHintContentHolder.Builder(view.getContext())
210 | .setContentTitle("FAB button power!")
211 | .setContentText("The FAB button is gonna help you with the main action of every screen.")
212 | .setTitleStyle(R.style.title)
213 | .setContentStyle(R.style.content)
214 | .build();
215 | new HintCase(view.getRootView())
216 | .setTarget(findViewById(R.id.fab), new CircularShape())
217 | .setShapeAnimators(new RevealCircleShapeAnimator(),
218 | new UnrevealCircleShapeAnimator())
219 | .setHintBlock(blockInfo)
220 | .show();
221 | }
222 | });
223 | }
224 |
225 | Button buttonExample6 = (Button) findViewById(R.id.button_example_6);
226 | if(buttonExample6 != null) {
227 | buttonExample6.setOnClickListener(new View.OnClickListener() {
228 | @Override
229 | public void onClick(View view) {
230 | View actionCameraView = findViewById(R.id.action_camera);
231 | if (actionCameraView != null) {
232 | actionCameraView.setOnClickListener(new View.OnClickListener() {
233 | @Override
234 | public void onClick(View v) {
235 | Snackbar.make(getActivity().getWindow().getDecorView(), "Camera was clicked", Snackbar.LENGTH_SHORT).show();
236 | }
237 | });
238 | SimpleHintContentHolder blockInfo =
239 | new SimpleHintContentHolder.Builder(actionCameraView.getContext())
240 | .setContentTitle("Camera icon!")
241 | .setContentText("This is an example of a hint over a toolbar item")
242 | .setTitleStyle(R.style.title)
243 | .setContentStyle(R.style.content)
244 | .setMarginByResourcesId(R.dimen.activity_vertical_margin,
245 | R.dimen.activity_horizontal_margin,
246 | R.dimen.activity_vertical_margin,
247 | R.dimen.activity_horizontal_margin)
248 | .build();
249 | new HintCase(actionCameraView.getRootView())
250 | .setTarget(actionCameraView, new CircularShape(), HintCase.TARGET_IS_CLICKABLE)
251 | .setShapeAnimators(new RevealCircleShapeAnimator(),
252 | new UnrevealCircleShapeAnimator())
253 | .setHintBlock(blockInfo)
254 | .show();
255 | }
256 | }
257 | });
258 | }
259 | }
260 | }
261 |
--------------------------------------------------------------------------------
/app/src/main/java/com/joanfuentes/hintcaseexample/customBlock/CustomHintContentHolder.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample.customBlock;
2 |
3 | import android.content.Context;
4 | import android.graphics.drawable.GradientDrawable;
5 | import android.graphics.drawable.LayerDrawable;
6 | import android.text.SpannableString;
7 | import android.text.style.TextAppearanceSpan;
8 | import android.view.Gravity;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.FrameLayout;
12 | import android.widget.ImageView;
13 | import android.widget.LinearLayout;
14 | import android.widget.RelativeLayout;
15 | import android.widget.TextView;
16 |
17 | import com.joanfuentes.hintcase.HintCase;
18 | import com.joanfuentes.hintcase.utils.DimenUtils;
19 | import com.joanfuentes.hintcaseassets.hintcontentholders.HintContentHolder;
20 | import com.joanfuentes.hintcaseexample.R;
21 |
22 | import java.util.ArrayList;
23 |
24 | /**
25 | * Created by joanFuentes on 26/05/16
26 | *
27 | * Example of a custom HintContentHolder which includes an arrow and the necessary methods
28 | * for positioning the arrow based on the position of the hint.
29 | */
30 | public class CustomHintContentHolder extends HintContentHolder {
31 | public static final int NO_IMAGE = -1;
32 | public static final int BACKGROUND_COLOR_TRANSPARENT = 0x00000000;
33 | private static final int DEFAULT_ARROW_SIZE_IN_PX = 50;
34 |
35 | private int borderColor;
36 | private int backgroundColor;
37 | private int borderSize;
38 | private ImageView imageView;
39 | private int imageResourceId;
40 | private CharSequence contentTitle;
41 | private CharSequence contentText;
42 | private int titleStyleId;
43 | private int textStyleId;
44 | private int marginLeft;
45 | private int marginTop;
46 | private int marginRight;
47 | private int marginBottom;
48 | private ArrayList alignBlockRules;
49 | private ArrayList alignArrowRules;
50 | private int contentTopMargin;
51 | private int contentBottomMargin;
52 | private int contentRightMargin;
53 | private int contentLeftMargin;
54 | private int contentTopPadding;
55 | private int contentBottomPadding;
56 | private int contentRightPadding;
57 | private int contentLeftPadding;
58 | private int gravity;
59 | private float xTranslationImage;
60 | private float yTranslationImage;
61 | private TriangleShapeView arrow;
62 | private HintCase hintCase;
63 | private ViewGroup parent;
64 | private LinearLayout contentLinearLayout;
65 | private int arrowWidth;
66 | private int arrowHeight;
67 | private int shadowSize;
68 | private boolean useBorder;
69 | private TriangleShapeView.Direction arrowDirection;
70 |
71 | @Override
72 | public View getView(Context context, final HintCase hintCase, ViewGroup parent) {
73 | this.hintCase = hintCase;
74 | this.parent = parent;
75 |
76 | calculateDataToPutTheArroW(hintCase);
77 | setArrow(context);
78 |
79 | FrameLayout.LayoutParams frameLayoutParamsBlock = getParentLayoutParams(
80 | ViewGroup.LayoutParams.MATCH_PARENT,
81 | ViewGroup.LayoutParams.MATCH_PARENT,
82 | gravity, marginLeft, marginTop, marginRight, marginBottom);
83 |
84 | RelativeLayout fullBlockLayout = new RelativeLayout(context);
85 | fullBlockLayout.setLayoutParams(frameLayoutParamsBlock);
86 |
87 | RelativeLayout.LayoutParams relativeLayoutParamsLinear =
88 | new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
89 | ViewGroup.LayoutParams.WRAP_CONTENT);
90 | for (int rule : alignBlockRules) {
91 | relativeLayoutParamsLinear.addRule(rule);
92 | }
93 | relativeLayoutParamsLinear.topMargin = contentTopMargin;
94 | relativeLayoutParamsLinear.bottomMargin = contentBottomMargin;
95 | relativeLayoutParamsLinear.rightMargin = contentRightMargin;
96 | relativeLayoutParamsLinear.leftMargin = contentLeftMargin;
97 | contentLinearLayout = new LinearLayout(context);
98 | contentLinearLayout.setBackgroundResource(R.drawable.bubble_border_background);
99 | LayerDrawable layerDrawable = (LayerDrawable) contentLinearLayout.getBackground().getCurrent();
100 | GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable.getDrawable(layerDrawable.getNumberOfLayers() - 1);
101 | gradientDrawable.setColor(backgroundColor);
102 | if (useBorder) {
103 | gradientDrawable.setStroke(borderSize, borderColor);
104 | }
105 |
106 | contentLinearLayout.setLayoutParams(relativeLayoutParamsLinear);
107 | contentLinearLayout.setGravity(Gravity.CENTER);
108 | int padding = borderSize + shadowSize;
109 | contentLinearLayout.setPadding(padding + contentLeftPadding,
110 | padding + contentTopPadding,
111 | padding + contentRightPadding,
112 | padding + contentBottomPadding);
113 | contentLinearLayout.setOrientation(LinearLayout.VERTICAL);
114 |
115 | if (contentTitle != null) {
116 | contentLinearLayout.addView(getTextViewTitle(context));
117 | }
118 | if (existImage()) {
119 | contentLinearLayout.addView(getImage(context, imageView, imageResourceId));
120 | }
121 | if (contentText != null) {
122 | contentLinearLayout.addView(getTextViewDescription(context));
123 | }
124 | fullBlockLayout.addView(contentLinearLayout);
125 | fullBlockLayout.addView(arrow);
126 | return fullBlockLayout;
127 | }
128 |
129 | @Override
130 | public void onLayout() {
131 | calculateArrowTranslation();
132 | arrow.setTranslationX(xTranslationImage);
133 | arrow.setTranslationY(yTranslationImage);
134 | if (hintCase.getBlockInfoPosition() == HintCase.HINT_BLOCK_POSITION_RIGHT
135 | || hintCase.getBlockInfoPosition() == HintCase.HINT_BLOCK_POSITION_LEFT) {
136 | if (arrow.getBottom() >= contentLinearLayout.getBottom()) {
137 | float translationY = arrow.getY() + (arrow.getHeight()/2) - contentLinearLayout.getY() - (contentLinearLayout.getHeight()/2);
138 | contentLinearLayout.setTranslationY(translationY);
139 | }
140 | }
141 | }
142 |
143 | private void setArrow(Context context) {
144 | RelativeLayout.LayoutParams relativeLayoutParamsArrow =
145 | new RelativeLayout.LayoutParams(arrowWidth, arrowHeight);
146 | for (int rule : alignArrowRules) {
147 | relativeLayoutParamsArrow.addRule(rule);
148 | }
149 | arrow = new TriangleShapeView(context);
150 | arrow.setBackgroundColor(backgroundColor);
151 | if (useBorder) {
152 | arrow.setBorder(borderSize, borderColor);
153 | }
154 | arrow.setDirection(arrowDirection);
155 | arrow.setShadowSize(shadowSize);
156 | arrow.setLayoutParams(relativeLayoutParamsArrow);
157 | }
158 |
159 | private void calculateArrowTranslation() {
160 | int textPosition = hintCase.getBlockInfoPosition();
161 | switch (textPosition) {
162 | case HintCase.HINT_BLOCK_POSITION_TOP:
163 | xTranslationImage = hintCase.getShape().getCenterX() - parent.getWidth()/2;
164 | yTranslationImage = 0;
165 | break;
166 | case HintCase.HINT_BLOCK_POSITION_BOTTOM:
167 | xTranslationImage = hintCase.getShape().getCenterX() - parent.getWidth()/2;
168 | yTranslationImage = 0;
169 | break;
170 | case HintCase.HINT_BLOCK_POSITION_RIGHT:
171 | xTranslationImage = 0;
172 | yTranslationImage = hintCase.getShape().getCenterY()
173 | - parent.getHeight()/2
174 | - DimenUtils.getStatusBarHeight(hintCase.getView().getContext());
175 | break;
176 | case HintCase.HINT_BLOCK_POSITION_LEFT:
177 | xTranslationImage = 0;
178 | yTranslationImage = hintCase.getShape().getCenterY()
179 | - (parent.getHeight()/2)
180 | - DimenUtils.getStatusBarHeight(hintCase.getView().getContext());
181 | break;
182 | default:
183 | xTranslationImage = 0;
184 | yTranslationImage = 0;
185 | }
186 | }
187 |
188 | private void calculateDataToPutTheArroW(HintCase hintCase) {
189 | int textPosition = hintCase.getBlockInfoPosition();
190 | alignArrowRules = new ArrayList<>();
191 | alignBlockRules = new ArrayList<>();
192 |
193 | switch (textPosition) {
194 | case HintCase.HINT_BLOCK_POSITION_TOP:
195 | alignBlockRules.add(RelativeLayout.ALIGN_PARENT_BOTTOM);
196 | alignArrowRules.add(RelativeLayout.CENTER_HORIZONTAL);
197 | alignArrowRules.add(RelativeLayout.ALIGN_PARENT_BOTTOM);
198 | gravity = Gravity.BOTTOM;
199 | contentRightMargin = 0;
200 | contentLeftMargin = 0;
201 | contentTopMargin = 0;
202 | contentBottomMargin = arrowHeight - borderSize - shadowSize;
203 | arrowDirection = TriangleShapeView.Direction.DOWN;
204 | marginBottom = 0;
205 | break;
206 | case HintCase.HINT_BLOCK_POSITION_BOTTOM:
207 | alignBlockRules.add(RelativeLayout.ALIGN_PARENT_TOP);
208 | alignArrowRules.add(RelativeLayout.CENTER_HORIZONTAL);
209 | alignArrowRules.add(RelativeLayout.ALIGN_PARENT_TOP);
210 | gravity = Gravity.TOP;
211 | contentRightMargin = 0;
212 | contentLeftMargin = 0;
213 | contentTopMargin = arrowHeight - borderSize - shadowSize;
214 | contentBottomMargin = 0;
215 | arrowDirection = TriangleShapeView.Direction.UP;
216 | marginTop = 0;
217 | break;
218 | case HintCase.HINT_BLOCK_POSITION_RIGHT:
219 | alignBlockRules.add(RelativeLayout.ALIGN_PARENT_LEFT);
220 | alignArrowRules.add(RelativeLayout.CENTER_VERTICAL);
221 | alignArrowRules.add(RelativeLayout.ALIGN_PARENT_LEFT);
222 | gravity = Gravity.LEFT;
223 | contentRightMargin = 0;
224 | contentLeftMargin = arrowHeight;
225 | contentTopMargin = 0;
226 | contentBottomMargin = 0;
227 | arrowDirection = TriangleShapeView.Direction.LEFT;
228 | marginLeft = 0;
229 | break;
230 | case HintCase.HINT_BLOCK_POSITION_LEFT:
231 | alignBlockRules.add(RelativeLayout.ALIGN_PARENT_RIGHT);
232 | alignArrowRules.add(RelativeLayout.ALIGN_PARENT_RIGHT);
233 | alignArrowRules.add(RelativeLayout.CENTER_VERTICAL);
234 | gravity = Gravity.RIGHT;
235 | contentRightMargin = arrowHeight;
236 | contentLeftMargin = 0;
237 | contentTopMargin = 0;
238 | contentBottomMargin = 0;
239 | arrowDirection = TriangleShapeView.Direction.RIGHT;
240 | marginRight = 0;
241 | break;
242 | default:
243 | alignBlockRules.add(RelativeLayout.CENTER_HORIZONTAL);
244 | alignArrowRules.add(RelativeLayout.CENTER_IN_PARENT);
245 | gravity = Gravity.CENTER;
246 | contentRightMargin = 0;
247 | contentLeftMargin = 0;
248 | contentTopMargin = 0;
249 | contentBottomMargin = 0;
250 | xTranslationImage = 0;
251 | yTranslationImage = 0;
252 | }
253 | }
254 |
255 | private ImageView getImage(Context context, ImageView image, int imageResourceId) {
256 | LinearLayout.LayoutParams linearLayoutParamsImage =
257 | new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
258 | ViewGroup.LayoutParams.WRAP_CONTENT,
259 | 1.0f);
260 | linearLayoutParamsImage.setMargins(0, 20, 0, 50);
261 | if (image == null) {
262 | image = new ImageView(context);
263 | }
264 | if (imageResourceId != CustomHintContentHolder.NO_IMAGE) {
265 | image.setImageResource(imageResourceId);
266 | }
267 | image.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
268 | image.setAdjustViewBounds(true);
269 | image.setLayoutParams(linearLayoutParamsImage);
270 | return image;
271 | }
272 |
273 | private View getTextViewTitle(Context context) {
274 | LinearLayout.LayoutParams linearLayoutParamsTitle =
275 | new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
276 | ViewGroup.LayoutParams.WRAP_CONTENT);
277 | linearLayoutParamsTitle.setMargins(0, 0, 0, 20);
278 | TextView textViewTitle = new TextView(context);
279 | textViewTitle.setLayoutParams(linearLayoutParamsTitle);
280 | textViewTitle.setGravity(Gravity.CENTER_HORIZONTAL);
281 | SpannableString spannableStringTitle= new SpannableString(contentTitle);
282 | TextAppearanceSpan titleTextAppearanceSpan = new TextAppearanceSpan(context, titleStyleId);
283 | spannableStringTitle.setSpan(titleTextAppearanceSpan, 0, spannableStringTitle.length(), 0);
284 | textViewTitle.setText(spannableStringTitle);
285 | return textViewTitle;
286 | }
287 |
288 | private View getTextViewDescription(Context context) {
289 | LinearLayout.LayoutParams linearLayoutParamsText =
290 | new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
291 | ViewGroup.LayoutParams.WRAP_CONTENT);
292 | TextView textViewDescription = new TextView(context);
293 | textViewDescription.setLayoutParams(linearLayoutParamsText);
294 | textViewDescription.setGravity(Gravity.CENTER_HORIZONTAL);
295 | SpannableString spannableStringText= new SpannableString(contentText);
296 | TextAppearanceSpan textTextAppearanceSpan = new TextAppearanceSpan(context, textStyleId);
297 | spannableStringText.setSpan(textTextAppearanceSpan, 0, spannableStringText.length(), 0);
298 | textViewDescription.setText(spannableStringText);
299 | return textViewDescription;
300 | }
301 |
302 | private boolean existImage() {
303 | return imageView != null ||
304 | imageResourceId != CustomHintContentHolder.NO_IMAGE;
305 | }
306 |
307 | public static class Builder {
308 | private CustomHintContentHolder blockInfo;
309 | private Context context;
310 |
311 | public Builder(Context context) {
312 | this.context = context;
313 | this.blockInfo = new CustomHintContentHolder();
314 | this.blockInfo.imageResourceId = NO_IMAGE;
315 | this.blockInfo.arrowWidth = DEFAULT_ARROW_SIZE_IN_PX;
316 | this.blockInfo.arrowHeight = DEFAULT_ARROW_SIZE_IN_PX;
317 | this.blockInfo.useBorder = false;
318 | this.blockInfo.shadowSize = context.getResources().getDimensionPixelSize(R.dimen.shadow);
319 | }
320 |
321 | public Builder setBorder(int resourceId, int resId) {
322 | blockInfo.useBorder = true;
323 | blockInfo.borderSize = context.getResources().getDimensionPixelSize(resourceId);
324 | blockInfo.borderColor = context.getResources().getColor(resId);
325 | return this;
326 | }
327 |
328 | public Builder setBackgroundColorFromResource(int resId) {
329 | blockInfo.backgroundColor = context.getResources().getColor(resId);
330 | return this;
331 | }
332 |
333 | public Builder setBackgroundColor(int color) {
334 | blockInfo.backgroundColor = color;
335 | return this;
336 | }
337 |
338 | public Builder setImageDrawableId(int resourceId) {
339 | blockInfo.imageResourceId = resourceId;
340 | return this;
341 | }
342 |
343 | public Builder setImageView(ImageView imageView) {
344 | blockInfo.imageView = imageView;
345 | return this;
346 | }
347 |
348 | public Builder setContentTitle(CharSequence title) {
349 | blockInfo.contentTitle = title;
350 | return this;
351 | }
352 |
353 | public Builder setContentTitle(int resId) {
354 | blockInfo.contentTitle = context.getString(resId);
355 | return this;
356 | }
357 |
358 | public Builder setTitleStyle(int resId) {
359 | blockInfo.titleStyleId = resId;
360 | return this;
361 | }
362 |
363 | public Builder setContentText(CharSequence text) {
364 | blockInfo.contentText = text;
365 | return this;
366 | }
367 |
368 | public Builder setContentText(int resId) {
369 | blockInfo.contentText = context.getString(resId);
370 | return this;
371 | }
372 |
373 | public Builder setContentStyle(int resId) {
374 | blockInfo.textStyleId = resId;
375 | return this;
376 | }
377 |
378 | public Builder setMargin(int left, int top, int right, int bottom) {
379 | blockInfo.marginLeft = left;
380 | blockInfo.marginTop = top;
381 | blockInfo.marginRight = right;
382 | blockInfo.marginBottom = bottom;
383 | return this;
384 | }
385 |
386 | public Builder setMargingByResourcesId(int left, int top, int right, int bottom) {
387 | blockInfo.marginLeft = context.getResources().getDimensionPixelSize(left);
388 | blockInfo.marginTop = context.getResources().getDimensionPixelSize(top);
389 | blockInfo.marginRight = context.getResources().getDimensionPixelSize(right);
390 | blockInfo.marginBottom = context.getResources().getDimensionPixelSize(bottom);
391 | return this;
392 | }
393 |
394 | public Builder setContentPadding(int left, int top, int right, int bottom) {
395 | blockInfo.contentLeftPadding = left;
396 | blockInfo.contentTopPadding = top;
397 | blockInfo.contentRightPadding = right;
398 | blockInfo.contentBottomPadding = bottom;
399 | return this;
400 | }
401 |
402 | public Builder setContentPaddingByResourcesId(int left, int top, int right, int bottom) {
403 | blockInfo.contentLeftPadding = context.getResources().getDimensionPixelSize(left);
404 | blockInfo.contentTopPadding = context.getResources().getDimensionPixelSize(top);
405 | blockInfo.contentRightPadding = context.getResources().getDimensionPixelSize(right);
406 | blockInfo.contentBottomPadding = context.getResources().getDimensionPixelSize(bottom);
407 | return this;
408 | }
409 |
410 | public Builder setArrowSize(int widthResId, int heightResId) {
411 | blockInfo.arrowWidth = context.getResources().getDimensionPixelSize(widthResId);
412 | blockInfo.arrowHeight = context.getResources().getDimensionPixelSize(heightResId);
413 | return this;
414 | }
415 |
416 | public CustomHintContentHolder build() {
417 | return blockInfo;
418 | }
419 | }
420 | }
421 |
--------------------------------------------------------------------------------
/app/src/main/java/com/joanfuentes/hintcaseexample/customBlock/TriangleShapeView.java:
--------------------------------------------------------------------------------
1 | package com.joanfuentes.hintcaseexample.customBlock;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.graphics.Path;
8 | import android.util.AttributeSet;
9 | import android.view.View;
10 |
11 | public class TriangleShapeView extends View {
12 | private static Direction DEFAULT_TRIANGLE_DIRECTION = Direction.UP;
13 |
14 | public enum Direction { UP, DOWN, RIGHT, LEFT }
15 |
16 | private Path pathBackground = new Path();
17 | private Path pathLines = new Path();
18 | private Paint paintBackground = new Paint();
19 | private Paint paintLines = new Paint(Paint.ANTI_ALIAS_FLAG);
20 | private int borderColor;
21 | private int backgroundColor;
22 | private int borderWith;
23 | private int shadowSize;
24 | private boolean useBorder;
25 | private Direction direction;
26 |
27 | public TriangleShapeView(Context context) {
28 | super(context);
29 | init();
30 | }
31 |
32 | public TriangleShapeView(Context context, AttributeSet attrs, int defStyle) {
33 | super(context, attrs, defStyle);
34 | init();
35 | }
36 |
37 | public TriangleShapeView(Context context, AttributeSet attrs) {
38 | super(context, attrs);
39 | init();
40 | }
41 |
42 | private void init() {
43 | direction = DEFAULT_TRIANGLE_DIRECTION;
44 | useBorder = false;
45 | pathBackground = new Path();
46 | paintBackground = new Paint();
47 | pathLines = new Path();
48 | paintLines = new Paint(Paint.ANTI_ALIAS_FLAG);
49 | paintLines.setStyle(Paint.Style.STROKE);
50 | }
51 |
52 | protected void onDraw(Canvas canvas) {
53 | super.onDraw(canvas);
54 | int width = getWidth();
55 | int height = getHeight();
56 | drawBackground(canvas, width, height);
57 | if (useBorder) {
58 | drawBorder(canvas, width, height);
59 | }
60 | if (direction != Direction.UP) {
61 | rotateView(direction);
62 | }
63 | }
64 |
65 | private void drawBorder(Canvas canvas, float width, float height) {
66 | paintLines.setColor(borderColor);
67 | paintLines.setStrokeWidth(borderWith);
68 | pathLines.reset();
69 | pathLines.moveTo(0, height);
70 | pathLines.lineTo(width / 2, height / 3);
71 | pathLines.lineTo(width, height);
72 | pathLines.lineTo(width / 2, height / 3);
73 | pathLines.lineTo(0, height);
74 | pathLines.close();
75 | canvas.drawPath(pathLines, paintLines);
76 | }
77 |
78 | private void drawBackground(Canvas canvas, float width, float height) {
79 | paintBackground.setColor(backgroundColor);
80 | pathBackground.reset();
81 | pathBackground.moveTo(0, height);
82 | pathBackground.lineTo(width / 2, height / 3);
83 | pathBackground.lineTo(width, height);
84 | pathBackground.close();
85 | paintBackground.setShadowLayer(shadowSize, 1, 1, Color.BLACK);
86 | setLayerType(LAYER_TYPE_SOFTWARE, null);
87 | canvas.drawPath(pathBackground, paintBackground);
88 | }
89 |
90 | private void rotateView(Direction direction) {
91 | switch (direction) {
92 | case RIGHT:
93 | this.setRotation(90);
94 | break;
95 | case DOWN:
96 | this.setRotation(180);
97 | break;
98 | case LEFT:
99 | this.setRotation(270);
100 | }
101 | }
102 |
103 | public void setBackgroundColor(int color) {
104 | this.backgroundColor = color;
105 | }
106 |
107 | public void setBorder(int width, int color) {
108 | this.useBorder = true;
109 | this.borderWith = width;
110 | this.borderColor = color;
111 | }
112 |
113 | public void setDirection(Direction direction) {
114 | this.direction = direction;
115 | }
116 |
117 | public void setShadowSize(int shadowSize) {
118 | this.shadowSize = shadowSize;
119 | }
120 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/animated_image.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/drawable/animated_image.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bubble_border_background.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 |
49 |
50 |
51 |
52 |
53 | -
54 |
56 |
58 |
61 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/drawable/test.jpg
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_custom_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_full_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_target_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
23 |
24 |
25 |
26 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_custom_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
18 |
25 |
26 |
33 |
34 |
41 |
42 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_full_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
26 |
27 |
34 |
35 |
42 |
43 |
50 |
51 |
58 |
59 |
66 |
67 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
22 |
23 |
31 |
32 |
33 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_target_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
25 |
26 |
32 |
33 |
40 |
41 |
48 |
49 |
56 |
57 |
64 |
65 |
72 |
73 |
74 |
75 |
80 |
81 |
88 |
89 |
98 |
99 |
107 |
108 |
109 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_target_hint.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/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 | #ff3F51B5
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 |
7 | 3dp
8 | 40dp
9 | 20dp
10 | 7dp
11 | 10dp
12 | 8dp
13 | 0dp
14 |
15 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | HintCase
3 | Main2Activity
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
24 |
27 |
28 |
32 |
33 |
36 |
37 |
40 |
41 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/assets/bubble_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/bubble_demo.gif
--------------------------------------------------------------------------------
/assets/consecutive_hints.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/consecutive_hints.gif
--------------------------------------------------------------------------------
/assets/fade_in_out_animator.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/fade_in_out_animator.gif
--------------------------------------------------------------------------------
/assets/fade_in_out_contentholder_animator.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/fade_in_out_contentholder_animator.gif
--------------------------------------------------------------------------------
/assets/reveal_unreveal_circle_animator.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/reveal_unreveal_circle_animator.gif
--------------------------------------------------------------------------------
/assets/reveal_unreveal_rectangular_animator.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/reveal_unreveal_rectangular_animator.gif
--------------------------------------------------------------------------------
/assets/slide_in_out_contentholder_animator.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/slide_in_out_contentholder_animator.gif
--------------------------------------------------------------------------------
/assets/welcome_demo.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/assets/welcome_demo.gif
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: 'buildsystem/dependencies.gradle'
3 |
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.2.0'
10 | classpath 'com.novoda:bintray-release:0.3.4'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | }
14 | }
15 |
16 | allprojects {
17 | repositories {
18 | jcenter()
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/buildsystem/dependencies.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright Txus Ballesteros 2016 (@txusballesteros)
3 | *
4 | * This file is part of some open source application.
5 | *
6 | * Licensed to the Apache Software Foundation (ASF) under one
7 | * or more contributor license agreements. See the NOTICE file
8 | * distributed with this work for additional information
9 | * regarding copyright ownership. The ASF licenses this file
10 | * to you under the Apache License, Version 2.0 (the
11 | * "License"); you may not use this file except in compliance
12 | * with the License. You may obtain a copy of the License at
13 | *
14 | * http://www.apache.org/licenses/LICENSE-2.0
15 | *
16 | * Unless required by applicable law or agreed to in writing,
17 | * software distributed under the License is distributed on an
18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 | * KIND, either express or implied. See the License for the
20 | * specific language governing permissions and limitations
21 | * under the License.
22 | *
23 | * Contact: Txus Ballesteros
24 | */
25 | allprojects {
26 | repositories {
27 | jcenter()
28 | }
29 | }
30 |
31 | ext {
32 | //Android
33 | androidApplicationId = "com.joanfuentes"
34 | androidBuildToolsVersion = "24.0.2"
35 | androidMinSdkVersion = 14
36 | androidTargetSdkVersion = 24
37 | androidCompileSdkVersion = 24
38 | androidVersionCodeExample = 5
39 | androidVersionNameExample = "1.0.4"
40 | androidVersionCodeMainLibrary = 5
41 | androidVersionNameMainLibrary = "1.0.4"
42 | androidVersionCodeAssetsLibrary = 5
43 | androidVersionNameAssetsLibrary = "1.0.4"
44 |
45 | //Libraries Versions
46 | androidSupportVersion = "24.2.1"
47 | butterKnifeVersion = "7.0.1"
48 | glideVersion = "3.7.0"
49 |
50 | //JCenter
51 | jcenterUserOrganization = "joanfuentes"
52 | jcenterGroupId = "com.joanfuentes"
53 | jcenterArtifactIdMainLibrary = "HintCase"
54 | jcenterArtifactIdAssetsLibrary = "HintCaseAssets"
55 | jcenterWebsite = "https://github.com/nescafemix"
56 | jcenterDescriptionMainLibrary = "HintCase library for Android"
57 | jcenterDescriptionAssetsLibrary = "HintCase assets library for use with the HintCase Android library"
58 | jcenterRepository = "https://github.com/nescafemix/hintcase"
59 |
60 | exampleDependencies = [
61 | AppCompat: "com.android.support:appcompat-v7:${androidSupportVersion}",
62 | DesignLibrary: "com.android.support:design:${androidSupportVersion}",
63 | SupportLibrary: "com.android.support:support-v4:${androidSupportVersion}",
64 | GlideLibrary: "com.github.bumptech.glide:glide:${glideVersion}",
65 | ButterKnife: "com.jakewharton:butterknife:${butterKnifeVersion}",
66 | ]
67 |
68 | mainLibraryDependencies = [
69 | AndroidAnnotations: "com.android.support:support-annotations:${androidSupportVersion}",
70 | ]
71 |
72 | assetsLibraryDependencies = [
73 | AppCompat: "com.android.support:appcompat-v7:${androidSupportVersion}",
74 | ]
75 | }
--------------------------------------------------------------------------------
/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/Nescafemix/hintcase/6b41f080d7d4b73cc9a7d2e986b99b57d3f9e6f8/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Sep 28 16:13:47 CEST 2016
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-2.14.1-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', ':HintCase', ':HintCaseAssets'
2 |
--------------------------------------------------------------------------------