Skip to content

Commit

Permalink
modify for rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
tttakaoka committed Apr 22, 2016
1 parent 27759be commit 1d19dc8
Show file tree
Hide file tree
Showing 17 changed files with 88 additions and 435 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ buildscript {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public void setShowcaseColour(int color) {
}

@Override
public void drawShowcase(Bitmap buffer, float x, float y, float scaleMultiplier) {
public void drawShowcase(Bitmap buffer, float x, float y, float width, float height) {
Canvas bufferCanvas = new Canvas(buffer);
bufferCanvas.drawCircle(x, y, radius, eraserPaint);
bufferCanvas.drawRect(x - width / 2, y - height / 2, x + width / 2, y + height / 2, eraserPaint);
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@ public interface ShowcaseDrawer {

/**
* Sets the value of the showcase color from themes. What this does is dependent on
* your implementation of {@link #drawShowcase(Bitmap, float, float, float)}
* your implementation of {@link #drawShowcase(Bitmap, float, float, float, float)}
*
* @param color the color supplied in the theme
*/
void setShowcaseColour(@ColorInt int color);

/**
* Draw the showcase. How this is performed is up to you!
*
* @param buffer the bitmap to draw onto
* @param x the x position of the point to showcase
* @param y the y position of the point to showcase
* @param scaleMultiplier a scale factor. Currently unused
* @param x the x position of the point to showcase
* @param y the y position of the point to showcase
*/
void drawShowcase(Bitmap buffer, float x, float y, float scaleMultiplier);
void drawShowcase(Bitmap buffer, float x, float y, float width, float height);

/**
* @return the width of the showcase, used to calculate where to place text
Expand All @@ -67,14 +68,16 @@ public interface ShowcaseDrawer {
/**
* Remove all drawing on the bitmap. Typically, this would do a color fill of the background
* color. See {@link StandardShowcaseDrawer} for an example
*
* @param bitmapBuffer the Bitmap to erase drawing from
*/
void erase(Bitmap bitmapBuffer);

/**
* Draw the commands drawn to the canvas. Typically this is a single implementation, see
* {@link StandardShowcaseDrawer}.
* @param canvas canvas to draw to
*
* @param canvas canvas to draw to
* @param bitmapBuffer bitmap to draw
*/
void drawToCanvas(Canvas canvas, Bitmap bitmapBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public class ShowcaseView extends RelativeLayout
private int showcaseY = -1;
private float scaleMultiplier = 1f;

private int showcaseWidth = 0;
private int showcaseHeight = 0;

// Touch items
private boolean hasCustomClickListener = false;
private boolean blockTouches = true;
Expand Down Expand Up @@ -121,11 +124,7 @@ protected ShowcaseView(Context context, AttributeSet attrs, int defStyle, boolea
fadeOutMillis = getResources().getInteger(android.R.integer.config_mediumAnimTime);

mEndButton = (Button) LayoutInflater.from(context).inflate(R.layout.showcase_button, null);
if (newStyle) {
showcaseDrawer = new NewShowcaseDrawer(getResources(), context.getTheme());
} else {
showcaseDrawer = new StandardShowcaseDrawer(getResources(), context.getTheme());
}
showcaseDrawer = new MaterialShowcaseDrawer(getResources());
textDrawer = new TextDrawer(getResources(), getContext());

updateStyle(styled, false);
Expand Down Expand Up @@ -173,6 +172,21 @@ void setShowcasePosition(int x, int y) {
invalidate();
}

void setShowcaseSize(Target.Size size) {
setShowcaseSize(size.getWidth(), size.getHeight());
}

void setShowcaseSize(int width, int height) {
if (shotStateStore.hasShot()) {
return;
}
showcaseWidth = width;
showcaseHeight = height;

recalculateText();
invalidate();
}

public void setTarget(final Target target) {
setShowcase(target, false);
}
Expand All @@ -189,12 +203,14 @@ public void run() {
}

Point targetPoint = target.getPoint();
if (targetPoint != null) {
Target.Size targetSize = target.getSize();
if (targetPoint != null && targetSize != null) {
hasNoTarget = false;
if (animate) {
animationFactory.animateTargetToPoint(ShowcaseView.this, targetPoint);
} else {
setShowcasePosition(targetPoint);
setShowcaseSize(targetSize);
}
} else {
hasNoTarget = true;
Expand Down Expand Up @@ -298,7 +314,7 @@ protected void dispatchDraw(Canvas canvas) {

// Draw the showcase drawable
if (!hasNoTarget) {
showcaseDrawer.drawShowcase(bitmapBuffer, showcaseX, showcaseY, scaleMultiplier);
showcaseDrawer.drawShowcase(bitmapBuffer, showcaseX, showcaseY, showcaseWidth, showcaseHeight);
showcaseDrawer.drawToCanvas(canvas, bitmapBuffer);
}

Expand Down Expand Up @@ -442,11 +458,6 @@ public Builder(Activity activity) {
this(activity, false);
}

/**
* @param useNewStyle should use "new style" showcase (see {@link #withNewStyleShowcase()}
* @deprecated use {@link #withHoloShowcase()}, {@link #withNewStyleShowcase()}, or
* {@link #setShowcaseDrawer(ShowcaseDrawer)}
*/
@Deprecated
public Builder(Activity activity, boolean useNewStyle) {
this.activity = activity;
Expand All @@ -466,22 +477,6 @@ public ShowcaseView build() {
return showcaseView;
}

/**
* Draw a holo-style showcase. This is the default.<br/>
* <img alt="Holo showcase example" src="../../../../../../../../example2.png" />
*/
public Builder withHoloShowcase() {
return setShowcaseDrawer(new StandardShowcaseDrawer(activity.getResources(), activity.getTheme()));
}

/**
* Draw a new-style showcase.<br/>
* <img alt="Holo showcase example" src="../../../../../../../../example.png" />
*/
public Builder withNewStyleShowcase() {
return setShowcaseDrawer(new NewShowcaseDrawer(activity.getResources(), activity.getTheme()));
}

/**
* Draw a material style showcase.
* <img alt="Material showcase" src="../../../../../../../../material.png" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public Point getPoint() {
return new ViewTarget(mActionBarWrapper.getActionItem(mItemId)).getPoint();
}

@Override
public Size getSize() {
return new ViewTarget(mActionBarWrapper.getActionItem(mItemId)).getSize();
}

protected void setUp() {
Reflector reflector = ReflectorFactory.getReflectorForActivity(mActivity);
ViewParent p = reflector.getActionBarView(); //ActionBarView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public Point getPoint() {
return internal.getPoint();
}

@Override
public Size getSize() {
return null;
}

public enum Type {
SPINNER, HOME, TITLE, OVERFLOW, MEDIA_ROUTE_BUTTON
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public PointTarget(int xValue, int yValue) {
public Point getPoint() {
return mPoint;
}

@Override
public Size getSize() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,32 @@ public interface Target {
public Point getPoint() {
return new Point(1000000, 1000000);
}

@Override
public Size getSize() {
return new Size(0, 0);
}
};

Point getPoint();

Size getSize();

class Size {
private int width;
private int height;

public Size(int width, int height) {
this.width = width;
this.height = height;
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}
}
}
Loading

0 comments on commit 1d19dc8

Please sign in to comment.