Skip to content
This repository was archived by the owner on Apr 24, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
ShowcaseView is deprecated
ShowcaseView Enhanced
====
Currently, ShowcaseView is not under active development; issues cannot be opened and PRs will not be accepted.

I've decided to make this decision because I want to rewrite the project from scratch with a far better API. A lot of things Google keep introducing in Android break ShowcaseView and it is too difficult to make these changes with the project in it's current form.

The project is still available on Maven, see below for the instructions. Please see the new-scv branch for development of the new API.

This is a fork of the ShowcaseView library of amlcurran. The original library will be rewritten, but I needed two changes fast:

* Place the "ok" button above a navigation bar if it is visible
* Place the "ok" button on the left side if the target is on the right side of the screen.

ShowcaseView
---
Expand Down Expand Up @@ -59,6 +57,21 @@ new ShowcaseView.Builder(this)
.build();
~~~

New in ShowcaseView Enhanced
===

If you have a visible navigation bar:

~~~
new ShowcaseView.Builder(this)
.setTarget(new ActionViewTarget(this, ActionViewTarget.Type.HOME))
.setContentTitle("ShowcaseView")
.setContentText("This is highlighting the Home button")
.hideOnTouchOutside()
.setNavigationBarVisible(true)
.build();
~~~

You can use styles to customise how a ShowcaseView looks. I'll write more documentation soon, but for now, check out the sample project's [styles](https://github.com/amlcurran/ShowcaseView/blob/master/sample/src/main/res/values/styles.xml).

Sample Project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class ShowcaseView extends RelativeLayout
private final AnimationFactory animationFactory;
private final ShotStateStore shotStateStore;


// Showcase metrics
private int showcaseX = -1;
private int showcaseY = -1;
Expand All @@ -67,6 +69,9 @@ public class ShowcaseView extends RelativeLayout

private boolean hasAlteredText = false;
private boolean hasNoTarget = false;

private boolean navigationBarVisible = false;

private boolean shouldCentreText;
private Bitmap bitmapBuffer;

Expand Down Expand Up @@ -119,12 +124,13 @@ private void init() {

if (mEndButton.getParent() == null) {
int margin = (int) getResources().getDimension(R.dimen.button_margin);
RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams();
lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
RelativeLayout.LayoutParams lps = getInitialEndButtonLayoutParams();
lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
lps.setMargins(margin, margin, margin, margin);

mEndButton.setLayoutParams(lps);
mEndButton.setText(android.R.string.ok);


if (!hasCustomClickListener) {
mEndButton.setOnClickListener(hideOnClickListener);
}
Expand All @@ -133,6 +139,27 @@ private void init() {

}

private int getNavBarHeight() {
if (navigationBarVisible) {
Resources resources = getContext().getResources();
int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0) {
return resources.getDimensionPixelSize(resourceId);
}
}
return 0;
}


private RelativeLayout.LayoutParams getInitialEndButtonLayoutParams() {
int margin = (int) getResources().getDimension(R.dimen.button_margin);
RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams();

lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
lps.setMargins(margin,margin,margin,margin+getNavBarHeight());
return lps;
}

private boolean hasShot() {
return shotStateStore.hasShot();
}
Expand All @@ -147,8 +174,18 @@ void setShowcasePosition(int x, int y) {
}
showcaseX = x;
showcaseY = y;
int h = getHeight();


if (showcaseX > (float)getWidth()-mEndButton.getWidth()) {
RelativeLayout.LayoutParams lps = getInitialEndButtonLayoutParams();
lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
mEndButton.setLayoutParams(lps);
}

//init();
invalidate();

}

public void setTarget(final Target target) {
Expand Down Expand Up @@ -437,6 +474,17 @@ public Builder setContentText(CharSequence text) {
return this;
}

/**
* If the navigation bar is visible set @visible to true,
* otherwise the button will be placed behind the bar.
* @param visible
* @return
*/
public Builder setNavigationBarVisible(boolean visible) {
showcaseView.navigationBarVisible = visible;
return this;
}

/**
* Set the target of the showcase.
*
Expand All @@ -458,7 +506,7 @@ public Builder setStyle(int theme) {

/**
* Set a listener which will override the button clicks.
* <p/>
*
* Note that you will have to manually hide the ShowcaseView
*/
public Builder setOnClickListener(OnClickListener onClickListener) {
Expand All @@ -469,7 +517,7 @@ public Builder setOnClickListener(OnClickListener onClickListener) {
/**
* Don't make the ShowcaseView block touches on itself. This doesn't
* block touches in the showcased area.
* <p/>
*
* By default, the ShowcaseView does block touches
*/
public Builder doNotBlockTouches() {
Expand All @@ -480,7 +528,7 @@ public Builder doNotBlockTouches() {
/**
* Make this ShowcaseView hide when the user touches outside the showcased area.
* This enables {@link #doNotBlockTouches()} as well.
* <p/>
*
* By default, the ShowcaseView doesn't hide on touch.
*/
public Builder hideOnTouchOutside() {
Expand Down