Skip to content
This repository was archived by the owner on Apr 24, 2018. It is now read-only.

Commit 4ff73d3

Browse files
committed
Merge pull request #322 from amlcurran/doc-updates
Tidy up
2 parents 5115033 + e26e15b commit 4ff73d3

File tree

17 files changed

+92
-71
lines changed

17 files changed

+92
-71
lines changed

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: android
2+
android:
3+
components:
4+
- android-23
5+
- build-tools-22.0.1
6+
- extra-google-m2repository
7+
- extra-android-support
8+
- extra-android-m2repository
9+
10+
script: ./gradlew assemble test check

library/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies {
3232
mavenCentral()
3333
}
3434
compile 'com.android.support:support-annotations:23.1.0'
35+
compile 'com.android.support:support-v4:23.1.0'
3536
}
3637

3738
android {

library/src/main/java/com/github/amlcurran/showcaseview/AnimationFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ interface AnimationFactory {
2626

2727
void animateTargetToPoint(ShowcaseView showcaseView, Point point);
2828

29-
public interface AnimationStartListener {
29+
interface AnimationStartListener {
3030
void onAnimationStart();
3131
}
3232

33-
public interface AnimationEndListener {
33+
interface AnimationEndListener {
3434
void onAnimationEnd();
3535
}
3636
}

library/src/main/java/com/github/amlcurran/showcaseview/AnimatorAnimationFactory.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.github.amlcurran.showcaseview;
1818

19+
import android.animation.AnimatorListenerAdapter;
1920
import android.os.Build.VERSION_CODES;
2021
import android.animation.Animator;
2122
import android.animation.AnimatorSet;
@@ -41,47 +42,27 @@ public AnimatorAnimationFactory() {
4142
@Override
4243
public void fadeInView(View target, long duration, final AnimationStartListener listener) {
4344
ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE, VISIBLE);
44-
oa.setDuration(duration).addListener(new Animator.AnimatorListener() {
45+
oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {
46+
4547
@Override
4648
public void onAnimationStart(Animator animator) {
4749
listener.onAnimationStart();
4850
}
4951

50-
@Override
51-
public void onAnimationEnd(Animator animator) {
52-
}
53-
54-
@Override
55-
public void onAnimationCancel(Animator animator) {
56-
}
57-
58-
@Override
59-
public void onAnimationRepeat(Animator animator) {
60-
}
6152
});
6253
oa.start();
6354
}
6455

6556
@Override
6657
public void fadeOutView(View target, long duration, final AnimationEndListener listener) {
6758
ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE);
68-
oa.setDuration(duration).addListener(new Animator.AnimatorListener() {
69-
@Override
70-
public void onAnimationStart(Animator animator) {
71-
}
59+
oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {
7260

7361
@Override
7462
public void onAnimationEnd(Animator animator) {
7563
listener.onAnimationEnd();
7664
}
7765

78-
@Override
79-
public void onAnimationCancel(Animator animator) {
80-
}
81-
82-
@Override
83-
public void onAnimationRepeat(Animator animator) {
84-
}
8566
});
8667
oa.start();
8768
}

library/src/main/java/com/github/amlcurran/showcaseview/ApiUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import android.os.Build;
2020

21-
public class ApiUtils {
21+
class ApiUtils {
2222

2323
public boolean isCompatWith(int versionCode) {
2424
return Build.VERSION.SDK_INT >= versionCode;

library/src/main/java/com/github/amlcurran/showcaseview/NewShowcaseDrawer.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@
2020
import android.graphics.Bitmap;
2121
import android.graphics.Canvas;
2222

23-
/**
24-
* Created by curraa01 on 13/10/2013.
25-
*/
2623
class NewShowcaseDrawer extends StandardShowcaseDrawer {
2724

2825
private static final int ALPHA_60_PERCENT = 153;
2926
private final float outerRadius;
3027
private final float innerRadius;
3128

32-
public NewShowcaseDrawer(Resources resources) {
33-
super(resources);
29+
public NewShowcaseDrawer(Resources resources, Resources.Theme theme) {
30+
super(resources, theme);
3431
outerRadius = resources.getDimension(R.dimen.showcase_radius_outer);
3532
innerRadius = resources.getDimension(R.dimen.showcase_radius_inner);
3633
}
@@ -64,8 +61,4 @@ public float getBlockedRadius() {
6461
return innerRadius;
6562
}
6663

67-
@Override
68-
public void setBackgroundColour(int backgroundColor) {
69-
this.backgroundColour = backgroundColor;
70-
}
7164
}

library/src/main/java/com/github/amlcurran/showcaseview/NoAnimationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import android.graphics.Point;
44
import android.view.View;
55

6-
public class NoAnimationFactory implements AnimationFactory {
6+
class NoAnimationFactory implements AnimationFactory {
77

88
@Override
99
public void fadeInView(View target, long duration, AnimationStartListener listener) {

library/src/main/java/com/github/amlcurran/showcaseview/OnShowcaseEventListener.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ public interface OnShowcaseEventListener {
2525
* Called when the ShowcaseView has been told to hide. Use {@link #onShowcaseViewDidHide(ShowcaseView)}
2626
* if you want to know when the ShowcaseView has been fully hidden.
2727
*/
28-
public void onShowcaseViewHide(ShowcaseView showcaseView);
28+
void onShowcaseViewHide(ShowcaseView showcaseView);
2929

3030
/**
3131
* Called when the animation hiding the ShowcaseView has finished, and it is no longer visible on the screen.
3232
*/
33-
public void onShowcaseViewDidHide(ShowcaseView showcaseView);
33+
void onShowcaseViewDidHide(ShowcaseView showcaseView);
3434

3535
/**
3636
* Called when the ShowcaseView is shown.
3737
*/
38-
public void onShowcaseViewShow(ShowcaseView showcaseView);
38+
void onShowcaseViewShow(ShowcaseView showcaseView);
3939

4040
/**
4141
* Empty implementation of OnShowcaseViewEventListener such that null
4242
* checks aren't needed
4343
*/
44-
public static final OnShowcaseEventListener NONE = new OnShowcaseEventListener() {
44+
OnShowcaseEventListener NONE = new OnShowcaseEventListener() {
4545
@Override
4646
public void onShowcaseViewHide(ShowcaseView showcaseView) {
4747

library/src/main/java/com/github/amlcurran/showcaseview/ShowcaseDrawer.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,64 @@
1818

1919
import android.graphics.Bitmap;
2020
import android.graphics.Canvas;
21+
import android.support.annotation.ColorInt;
2122

23+
/**
24+
* Class to implement your own drawing of a showcase view, should you want more
25+
* control. See the other implementations for examples
26+
*/
2227
public interface ShowcaseDrawer {
2328

24-
void setShowcaseColour(int color);
29+
/**
30+
* Sets the value of the showcase color from themes. What this does is dependent on
31+
* your implementation of {@link #drawShowcase(Bitmap, float, float, float)}
32+
* @param color the color supplied in the theme
33+
*/
34+
void setShowcaseColour(@ColorInt int color);
2535

36+
/**
37+
* Draw the showcase. How this is performed is up to you!
38+
* @param buffer the bitmap to draw onto
39+
* @param x the x position of the point to showcase
40+
* @param y the y position of the point to showcase
41+
* @param scaleMultiplier a scale factor. Currently unused
42+
*/
2643
void drawShowcase(Bitmap buffer, float x, float y, float scaleMultiplier);
2744

45+
/**
46+
* @return the width of the showcase, used to calculate where to place text
47+
*/
2848
int getShowcaseWidth();
2949

50+
/**
51+
* @return the height of the showcase, used to calculate where to place text
52+
*/
3053
int getShowcaseHeight();
3154

55+
/**
56+
* @return the radius to block touches outside of, if
57+
* {@link ShowcaseView.Builder#setBlocksTouches(boolean)} is set
58+
*/
3259
float getBlockedRadius();
3360

34-
void setBackgroundColour(int backgroundColor);
61+
/**
62+
* Set the background color of the showcase. What this means is up to your implementation,
63+
* but typically this should be the color used to draw in {@link #erase(Bitmap)}
64+
*/
65+
void setBackgroundColour(@ColorInt int backgroundColor);
3566

67+
/**
68+
* Remove all drawing on the bitmap. Typically, this would do a color fill of the background
69+
* color. See {@link StandardShowcaseDrawer} for an example
70+
* @param bitmapBuffer the Bitmap to erase drawing from
71+
*/
3672
void erase(Bitmap bitmapBuffer);
3773

74+
/**
75+
* Draw the commands drawn to the canvas. Typically this is a single implementation, see
76+
* {@link StandardShowcaseDrawer}.
77+
* @param canvas canvas to draw to
78+
* @param bitmapBuffer bitmap to draw
79+
*/
3880
void drawToCanvas(Canvas canvas, Bitmap bitmapBuffer);
3981
}

library/src/main/java/com/github/amlcurran/showcaseview/ShowcaseView.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import android.graphics.Color;
2525
import android.graphics.Point;
2626
import android.graphics.PorterDuff;
27+
import android.graphics.Rect;
2728
import android.support.annotation.IntDef;
2829
import android.text.Layout;
2930
import android.text.TextPaint;
@@ -125,11 +126,11 @@ protected ShowcaseView(Context context, AttributeSet attrs, int defStyle, boolea
125126

126127
mEndButton = (Button) LayoutInflater.from(context).inflate(R.layout.showcase_button, null);
127128
if (newStyle) {
128-
showcaseDrawer = new NewShowcaseDrawer(getResources());
129+
showcaseDrawer = new NewShowcaseDrawer(getResources(), context.getTheme());
129130
} else {
130-
showcaseDrawer = new StandardShowcaseDrawer(getResources());
131+
showcaseDrawer = new StandardShowcaseDrawer(getResources(), context.getTheme());
131132
}
132-
textDrawer = new TextDrawer(getResources(), showcaseAreaCalculator, getContext());
133+
textDrawer = new TextDrawer(getResources(), getContext());
133134

134135
updateStyle(styled, false);
135136

@@ -277,7 +278,8 @@ private void recalculateText() {
277278
boolean recalculatedCling = showcaseAreaCalculator.calculateShowcaseRect(showcaseX, showcaseY, showcaseDrawer);
278279
boolean recalculateText = recalculatedCling || hasAlteredText;
279280
if (recalculateText) {
280-
textDrawer.calculateTextPosition(getMeasuredWidth(), getMeasuredHeight(), this, shouldCentreText);
281+
Rect rect = hasShowcaseView() ? showcaseAreaCalculator.getShowcaseRect() : new Rect();
282+
textDrawer.calculateTextPosition(getMeasuredWidth(), getMeasuredHeight(), shouldCentreText, rect);
281283
}
282284
hasAlteredText = false;
283285
}
@@ -415,7 +417,7 @@ public void showButton() {
415417
*/
416418
public static class Builder {
417419

418-
final ShowcaseView showcaseView;
420+
private final ShowcaseView showcaseView;
419421
private final Activity activity;
420422

421423
private ViewGroup parent;
@@ -454,15 +456,15 @@ public ShowcaseView build() {
454456
* <img alt="Holo showcase example" src="../../../../../../../../example2.png" />
455457
*/
456458
public Builder withHoloShowcase() {
457-
return setShowcaseDrawer(new StandardShowcaseDrawer(activity.getResources()));
459+
return setShowcaseDrawer(new StandardShowcaseDrawer(activity.getResources(), activity.getTheme()));
458460
}
459461

460462
/**
461463
* Draw a new-style showcase.<br/>
462464
* <img alt="Holo showcase example" src="../../../../../../../../example.png" />
463465
*/
464466
public Builder withNewStyleShowcase() {
465-
return setShowcaseDrawer(new NewShowcaseDrawer(activity.getResources()));
467+
return setShowcaseDrawer(new NewShowcaseDrawer(activity.getResources(), activity.getTheme()));
466468
}
467469

468470
/**

0 commit comments

Comments
 (0)