Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String literals should not be duplicated #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Created by tanjunrong on 8/6/15.
*/
public class ToolTilMeasureTest extends ActivityInstrumentationTestCase2<ToolTipMeasureTestActivity> {
public static final String TOURGUIDE_TEST = "tourguide_test";
ToolTipMeasureTestActivity mActivity;
View mToolTip;
public ToolTilMeasureTest() {
Expand All @@ -32,10 +33,10 @@ protected void setUp() throws Exception {

public void testNoCrash(){
// mToolTip.performClick();
Log.d("tourguide_test","height:" + mToolTip.getHeight());
Log.d("tourguide_test","width:" + mToolTip.getWidth());
Log.d("tourguide_test","getX:" + mToolTip.getX());
Log.d("tourguide_test", "screen width:" + getScreenWidth(mActivity));
Log.d(TOURGUIDE_TEST,"height:" + mToolTip.getHeight());
Log.d(TOURGUIDE_TEST,"width:" + mToolTip.getWidth());
Log.d(TOURGUIDE_TEST,"getX:" + mToolTip.getX());
Log.d(TOURGUIDE_TEST, "screen width:" + getScreenWidth(mActivity));
// mToolTip.getViewTreeObserver().addOnGlobalLayoutListener(
// new ViewTreeObserver.OnGlobalLayoutListener() {
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* .
*/
public class SequenceTestActivity extends ActionBarActivity {
public static final String BELLO_THIS_IS_THE_DEFAULT_OVERLAY = "Bello! This is the default Overlay";
public TourGuide mTutorialHandler;
public Activity mActivity;
public Sequence mSequence;
Expand Down Expand Up @@ -116,7 +117,7 @@ private void runOverlayContinueMethod(){
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SequenceTestActivity.this, "Bello! This is the default Overlay", Toast.LENGTH_SHORT).show();
Toast.makeText(SequenceTestActivity.this, BELLO_THIS_IS_THE_DEFAULT_OVERLAY, Toast.LENGTH_SHORT).show();
mTutorialHandler.next();
}
}))
Expand All @@ -136,7 +137,7 @@ public void onClick(View v) {
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SequenceTestActivity.this, "Bello! This is the default Overlay", Toast.LENGTH_SHORT).show();
Toast.makeText(SequenceTestActivity.this, BELLO_THIS_IS_THE_DEFAULT_OVERLAY, Toast.LENGTH_SHORT).show();
mTutorialHandler.next();
}
}))
Expand Down Expand Up @@ -181,7 +182,7 @@ private void runOverlayListenerContinueMethod(){
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(SequenceTestActivity.this, "Bello! This is the default Overlay", Toast.LENGTH_SHORT).show();
Toast.makeText(SequenceTestActivity.this, BELLO_THIS_IS_THE_DEFAULT_OVERLAY, Toast.LENGTH_SHORT).show();
mTutorialHandler.next();
}
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* TODO: document your custom view class.
*/
public class FrameLayoutWithHole extends FrameLayout {
public static final String TOURGUIDE = "tourguide";
private TextPaint mTextPaint;
private Activity mActivity;
private TourGuide.MotionType mMotionType;
Expand Down Expand Up @@ -52,11 +53,11 @@ public void addAnimatorSet(AnimatorSet animatorSet){
mAnimatorSetArrayList.add(animatorSet);
}
private void enforceMotionType(){
Log.d("tourguide", "enforceMotionType 1");
if (mViewHole!=null) {Log.d("tourguide","enforceMotionType 2");
Log.d(TOURGUIDE, "enforceMotionType 1");
if (mViewHole!=null) {Log.d(TOURGUIDE,"enforceMotionType 2");
if (mMotionType!=null && mMotionType == TourGuide.MotionType.ClickOnly) {
Log.d("tourguide","enforceMotionType 3");
Log.d("tourguide","only Clicking");
Log.d(TOURGUIDE,"enforceMotionType 3");
Log.d(TOURGUIDE,"only Clicking");
mViewHole.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Expand All @@ -65,8 +66,8 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
}
});
} else if (mMotionType!=null && mMotionType == TourGuide.MotionType.SwipeOnly) {
Log.d("tourguide","enforceMotionType 4");
Log.d("tourguide","only Swiping");
Log.d(TOURGUIDE,"enforceMotionType 4");
Log.d(TOURGUIDE,"only Swiping");
mViewHole.setClickable(false);
}
}
Expand Down Expand Up @@ -132,8 +133,8 @@ private void init(AttributeSet attrs, int defStyle) {
mEraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mEraser.setFlags(Paint.ANTI_ALIAS_FLAG);

Log.d("tourguide","getHeight: "+ size.y);
Log.d("tourguide","getWidth: " + size.x);
Log.d(TOURGUIDE,"getHeight: "+ size.y);
Log.d(TOURGUIDE,"getWidth: " + size.x);

}

Expand All @@ -151,7 +152,7 @@ private void performOverlayExitAnimation(){
if (!mCleanUpLock) {
final FrameLayout _pointerToFrameLayout = this;
mCleanUpLock = true;
Log.d("tourguide","Overlay exit animation listener is overwritten...");
Log.d(TOURGUIDE,"Overlay exit animation listener is overwritten...");
mOverlay.mExitAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override public void onAnimationStart(Animation animation) {}
@Override public void onAnimationRepeat(Animation animation) {}
Expand Down Expand Up @@ -203,7 +204,7 @@ private void dumpEvent(MotionEvent event) {
sb.append(";" );
}
sb.append("]" );
Log.d("tourguide", sb.toString());
Log.d(TOURGUIDE, sb.toString());
}

@Override
Expand All @@ -229,7 +230,7 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
// Log.d("tourguide", "[dispatchTouchEvent] Y higher bound: "+(pos[1] +mViewHole.getHeight()));

if(isWithinButton(ev) && mOverlay != null && mOverlay.mDisableClickThroughHole) {
Log.d("tourguide", "block user clicking through hole");
Log.d(TOURGUIDE, "block user clicking through hole");
// block it
return true;
} else if (isWithinButton(ev)) {
Expand Down
54 changes: 30 additions & 24 deletions tourguide/src/main/java/tourguide/tourguide/TourGuide.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
* Created by tanjunrong on 2/10/15.
*/
public class TourGuide {

public static final String ALPHA = "alpha";
public static final String SCALE_X = "scaleX";
public static final String SCALE_Y = "scaleY";
public static final String TRANSLATION_X = "translationX";

/**
* This describes the animation techniques
* */
Expand Down Expand Up @@ -489,26 +495,26 @@ public void onAnimationEnd(Animator animator) {
long fadeOutDuration = goLeftXDuration;
float translationX = getScreenWidth()/2;

final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, ALPHA, 0f, 1f);
fadeInAnim.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, SCALE_X, 1f, 0.85f);
scaleDownX.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, SCALE_Y, 1f, 0.85f);
scaleDownY.setDuration(scaleDownDuration);
final ObjectAnimator goLeftX = ObjectAnimator.ofFloat(view, "translationX", -translationX);
final ObjectAnimator goLeftX = ObjectAnimator.ofFloat(view, TRANSLATION_X, -translationX);
goLeftX.setDuration(goLeftXDuration);
final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, ALPHA, 1f, 0f);
fadeOutAnim.setDuration(fadeOutDuration);

final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, ALPHA, 0f, 1f);
fadeInAnim2.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, SCALE_X, 1f, 0.85f);
scaleDownX2.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, SCALE_Y, 1f, 0.85f);
scaleDownY2.setDuration(scaleDownDuration);
final ObjectAnimator goLeftX2 = ObjectAnimator.ofFloat(view, "translationX", -translationX);
final ObjectAnimator goLeftX2 = ObjectAnimator.ofFloat(view, TRANSLATION_X, -translationX);
goLeftX2.setDuration(goLeftXDuration);
final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, ALPHA, 1f, 0f);
fadeOutAnim2.setDuration(fadeOutDuration);

animatorSet.play(fadeInAnim);
Expand Down Expand Up @@ -565,34 +571,34 @@ public void onAnimationEnd(Animator animator) {
long fadeOutDuration = 800;
long delay = 1000;

final ValueAnimator delayAnim = ObjectAnimator.ofFloat(view, "translationX", 0);
final ValueAnimator delayAnim = ObjectAnimator.ofFloat(view, TRANSLATION_X, 0);
delayAnim.setDuration(delay);
final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
final ValueAnimator fadeInAnim = ObjectAnimator.ofFloat(view, ALPHA, 0f, 1f);
fadeInAnim.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
final ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(view, SCALE_X, 1f, 0.85f);
scaleDownX.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
final ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(view, SCALE_Y, 1f, 0.85f);
scaleDownY.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(view, "scaleX", 0.85f, 1f);
final ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(view, SCALE_X, 0.85f, 1f);
scaleUpX.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(view, "scaleY", 0.85f, 1f);
final ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(view, SCALE_Y, 0.85f, 1f);
scaleUpY.setDuration(scaleDownDuration);
final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
final ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(view, ALPHA, 1f, 0f);
fadeOutAnim.setDuration(fadeOutDuration);

final ValueAnimator delayAnim2 = ObjectAnimator.ofFloat(view, "translationX", 0);
final ValueAnimator delayAnim2 = ObjectAnimator.ofFloat(view, TRANSLATION_X, 0);
delayAnim2.setDuration(delay);
final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
final ValueAnimator fadeInAnim2 = ObjectAnimator.ofFloat(view, ALPHA, 0f, 1f);
fadeInAnim2.setDuration(fadeInDuration);
final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0.85f);
final ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(view, SCALE_X, 1f, 0.85f);
scaleDownX2.setDuration(scaleDownDuration);
final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0.85f);
final ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(view, SCALE_Y, 1f, 0.85f);
scaleDownY2.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpX2 = ObjectAnimator.ofFloat(view, "scaleX", 0.85f, 1f);
final ObjectAnimator scaleUpX2 = ObjectAnimator.ofFloat(view, SCALE_X, 0.85f, 1f);
scaleUpX2.setDuration(scaleDownDuration);
final ObjectAnimator scaleUpY2 = ObjectAnimator.ofFloat(view, "scaleY", 0.85f, 1f);
final ObjectAnimator scaleUpY2 = ObjectAnimator.ofFloat(view, SCALE_Y, 0.85f, 1f);
scaleUpY2.setDuration(scaleDownDuration);
final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
final ValueAnimator fadeOutAnim2 = ObjectAnimator.ofFloat(view, ALPHA, 1f, 0f);
fadeOutAnim2.setDuration(fadeOutDuration);
view.setAlpha(0);
animatorSet.setStartDelay(mToolTip != null ? mToolTip.mEnterAnimation.getDuration() : 0);
Expand Down