-
Notifications
You must be signed in to change notification settings - Fork 523
Expand file tree
/
Copy pathMaterialShowcaseView.java
More file actions
873 lines (708 loc) · 25.8 KB
/
MaterialShowcaseView.java
File metadata and controls
873 lines (708 loc) · 25.8 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
package uk.co.deanwild.materialshowcaseview;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import uk.co.deanwild.materialshowcaseview.shape.CircleShape;
import uk.co.deanwild.materialshowcaseview.shape.NoShape;
import uk.co.deanwild.materialshowcaseview.shape.RectangleShape;
import uk.co.deanwild.materialshowcaseview.shape.Shape;
import uk.co.deanwild.materialshowcaseview.target.Target;
import uk.co.deanwild.materialshowcaseview.target.ViewTarget;
/**
* Helper class to show a sequence of showcase views.
*/
public class MaterialShowcaseView extends FrameLayout implements View.OnTouchListener, View.OnClickListener {
private int mOldHeight;
private int mOldWidth;
private Bitmap mBitmap;// = new WeakReference<>(null);
private Canvas mCanvas;
private Paint mEraser;
private Target mTarget;
private Shape mShape;
private int mXPosition;
private int mYPosition;
private boolean mWasDismissed = false;
private int mShapePadding = ShowcaseConfig.DEFAULT_SHAPE_PADDING;
private View mContentBox;
private TextView mTitleTextView;
private TextView mContentTextView;
private TextView mDismissButton;
private int mGravity;
private int mContentBottomMargin;
private int mContentTopMargin;
private boolean mDismissOnTouch = false;
private boolean mShouldRender = false; // flag to decide when we should actually render
private boolean mRenderOverNav = false;
private int mMaskColour;
private AnimationFactory mAnimationFactory;
private boolean mShouldAnimate = true;
private long mFadeDurationInMillis = ShowcaseConfig.DEFAULT_FADE_TIME;
private Handler mHandler;
private long mDelayInMillis = ShowcaseConfig.DEFAULT_DELAY;
private int mBottomMargin = 0;
private boolean mSingleUse = false; // should display only once
private PrefsManager mPrefsManager; // used to store state doe single use mode
List<IShowcaseListener> mListeners; // external listeners who want to observe when we show and dismiss
private UpdateOnGlobalLayout mLayoutListener;
private IDetachedListener mDetachedListener;
private boolean mTargetTouchable = false;
private boolean mDismissOnTargetTouch = true;
public MaterialShowcaseView(Context context) {
super(context);
init(context);
}
public MaterialShowcaseView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public MaterialShowcaseView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MaterialShowcaseView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
private void init(Context context) {
setWillNotDraw(false);
// create our animation factory
mAnimationFactory = new AnimationFactory();
mListeners = new ArrayList<>();
// make sure we add a global layout listener so we can adapt to changes
mLayoutListener = new UpdateOnGlobalLayout();
getViewTreeObserver().addOnGlobalLayoutListener(mLayoutListener);
// consume touch events
setOnTouchListener(this);
mMaskColour = Color.parseColor(ShowcaseConfig.DEFAULT_MASK_COLOUR);
setVisibility(INVISIBLE);
View contentView = LayoutInflater.from(getContext()).inflate(R.layout.showcase_content, this, true);
mContentBox = contentView.findViewById(R.id.content_box);
mTitleTextView = (TextView) contentView.findViewById(R.id.tv_title);
mContentTextView = (TextView) contentView.findViewById(R.id.tv_content);
mDismissButton = (TextView) contentView.findViewById(R.id.tv_dismiss);
mDismissButton.setOnClickListener(this);
}
/**
* Interesting drawing stuff.
* We draw a block of semi transparent colour to fill the whole screen then we draw of transparency
* to create a circular "viewport" through to the underlying content
*
* @param canvas
*/
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// don't bother drawing if we're not ready
if (!mShouldRender) return;
// get current dimensions
final int width = getMeasuredWidth();
final int height = getMeasuredHeight();
// don't bother drawing if there is nothing to draw on
if(width <= 0 || height <= 0) return;
// build a new canvas if needed i.e first pass or new dimensions
if (mBitmap == null || mCanvas == null || mOldHeight != height || mOldWidth != width) {
if (mBitmap != null) mBitmap.recycle();
mBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mCanvas = new Canvas(mBitmap);
}
// save our 'old' dimensions
mOldWidth = width;
mOldHeight = height;
// clear canvas
mCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// draw solid background
mCanvas.drawColor(mMaskColour);
// Prepare eraser Paint if needed
if (mEraser == null) {
mEraser = new Paint();
mEraser.setColor(0xFFFFFFFF);
mEraser.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mEraser.setFlags(Paint.ANTI_ALIAS_FLAG);
}
// draw (erase) shape
mShape.draw(mCanvas, mEraser, mXPosition, mYPosition, mShapePadding);
// Draw the bitmap on our views canvas.
canvas.drawBitmap(mBitmap, 0, 0, null);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
/**
* If we're being detached from the window without the mWasDismissed flag then we weren't purposefully dismissed
* Probably due to an orientation change or user backed out of activity.
* Ensure we reset the flag so the showcase display again.
*/
if (!mWasDismissed && mSingleUse && mPrefsManager != null) {
mPrefsManager.resetShowcase();
}
notifyOnDismissed();
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (mDismissOnTouch) {
hide();
}
if(mTargetTouchable && mTarget.getBounds().contains((int)event.getX(), (int)event.getY())){
if(mDismissOnTargetTouch){
hide();
}
return false;
}
return true;
}
private void notifyOnDisplayed() {
if(mListeners != null){
for (IShowcaseListener listener : mListeners) {
listener.onShowcaseDisplayed(this);
}
}
}
private void notifyOnDismissed() {
if (mListeners != null) {
for (IShowcaseListener listener : mListeners) {
listener.onShowcaseDismissed(this);
}
mListeners.clear();
mListeners = null;
}
/**
* internal listener used by sequence for storing progress within the sequence
*/
if (mDetachedListener != null) {
mDetachedListener.onShowcaseDetached(this, mWasDismissed);
}
}
/**
* Dismiss button clicked
*
* @param v
*/
@Override
public void onClick(View v) {
hide();
}
/**
* Tells us about the "Target" which is the view we want to anchor to.
* We figure out where it is on screen and (optionally) how big it is.
* We also figure out whether to place our content and dismiss button above or below it.
*
* @param target
*/
public void setTarget(Target target) {
mTarget = target;
// update dismiss button state
updateDismissButton();
if (mTarget != null) {
/**
* If we're on lollipop then make sure we don't draw over the nav bar
*/
if (!mRenderOverNav && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mBottomMargin = getSoftButtonsBarSizePort((Activity) getContext());
FrameLayout.LayoutParams contentLP = (LayoutParams) getLayoutParams();
if (contentLP != null && contentLP.bottomMargin != mBottomMargin)
contentLP.bottomMargin = mBottomMargin;
}
// apply the target position
Point targetPoint = mTarget.getPoint();
Rect targetBounds = mTarget.getBounds();
setPosition(targetPoint);
// now figure out whether to put content above or below it
int height = getMeasuredHeight();
int midPoint = height / 2;
int yPos = targetPoint.y;
int radius = Math.max(targetBounds.height(), targetBounds.width()) / 2;
if (mShape != null) {
mShape.updateTarget(mTarget);
radius = mShape.getHeight() / 2;
}
if (yPos > midPoint) {
// target is in lower half of screen, we'll sit above it
mContentTopMargin = 0;
mContentBottomMargin = (height - yPos) + radius + mShapePadding;
mGravity = Gravity.BOTTOM;
} else {
// target is in upper half of screen, we'll sit below it
mContentTopMargin = yPos + radius + mShapePadding;
mContentBottomMargin = 0;
mGravity = Gravity.TOP;
}
}
applyLayoutParams();
}
private void applyLayoutParams() {
if (mContentBox != null && mContentBox.getLayoutParams() != null) {
FrameLayout.LayoutParams contentLP = (LayoutParams) mContentBox.getLayoutParams();
boolean layoutParamsChanged = false;
if (contentLP.bottomMargin != mContentBottomMargin) {
contentLP.bottomMargin = mContentBottomMargin;
layoutParamsChanged = true;
}
if (contentLP.topMargin != mContentTopMargin) {
contentLP.topMargin = mContentTopMargin;
layoutParamsChanged = true;
}
if (contentLP.gravity != mGravity) {
contentLP.gravity = mGravity;
layoutParamsChanged = true;
}
/**
* Only apply the layout params if we've actually changed them, otherwise we'll get stuck in a layout loop
*/
if (layoutParamsChanged)
mContentBox.setLayoutParams(contentLP);
}
}
/**
* SETTERS
*/
void setPosition(Point point) {
setPosition(point.x, point.y);
}
void setPosition(int x, int y) {
mXPosition = x;
mYPosition = y;
}
private void setTitleText(CharSequence contentText) {
if (mTitleTextView != null) {
mTitleTextView.setText(contentText);
}
}
private void setContentText(CharSequence contentText) {
if (mContentTextView != null) {
mContentTextView.setText(contentText);
}
}
private void setDismissText(CharSequence dismissText) {
if (mDismissButton != null) {
mDismissButton.setText(dismissText);
updateDismissButton();
}
}
private void setTitleTextColor(int textColor) {
if (mTitleTextView != null) {
mTitleTextView.setTextColor(textColor);
}
}
private void setContentTextColor(int textColor) {
if (mContentTextView != null) {
mContentTextView.setTextColor(textColor);
}
}
private void setDismissTextColor(int textColor) {
if (mDismissButton != null) {
mDismissButton.setTextColor(textColor);
}
}
private void setTitleTextSize(float textSize) {
if (mTitleTextView != null) {
mTitleTextView.setTextSize(textSize);
}
}
private void setContentTextSize(float textSize) {
if (mContentTextView != null) {
mContentTextView.setTextSize(textSize);
}
}
private void setShapePadding(int padding) {
mShapePadding = padding;
}
private void setDismissOnTouch(boolean dismissOnTouch) {
mDismissOnTouch = dismissOnTouch;
}
private void setShouldRender(boolean shouldRender) {
mShouldRender = shouldRender;
}
private void setMaskColour(int maskColour) {
mMaskColour = maskColour;
}
private void setDelay(long delayInMillis) {
mDelayInMillis = delayInMillis;
}
private void setFadeDuration(long fadeDurationInMillis) {
mFadeDurationInMillis = fadeDurationInMillis;
}
private void setTargetTouchable(boolean targetTouchable){
mTargetTouchable = targetTouchable;
}
private void setDismissOnTargetTouch(boolean dismissOnTargetTouch){
mDismissOnTargetTouch = dismissOnTargetTouch;
}
public void addShowcaseListener(IShowcaseListener showcaseListener) {
if(mListeners != null)
mListeners.add(showcaseListener);
}
public void removeShowcaseListener(MaterialShowcaseSequence showcaseListener) {
if ((mListeners != null) && mListeners.contains(showcaseListener)) {
mListeners.remove(showcaseListener);
}
}
void setDetachedListener(IDetachedListener detachedListener) {
mDetachedListener = detachedListener;
}
public void setShape(Shape mShape) {
this.mShape = mShape;
}
/**
* Set properties based on a config object
*
* @param config
*/
public void setConfig(ShowcaseConfig config) {
setDelay(config.getDelay());
setFadeDuration(config.getFadeDuration());
setContentTextColor(config.getContentTextColor());
setDismissTextColor(config.getDismissTextColor());
setMaskColour(config.getMaskColor());
setShape(config.getShape());
setShapePadding(config.getShapePadding());
setRenderOverNavigationBar(config.getRenderOverNavigationBar());
}
private void updateDismissButton() {
// hide or show button
if (mDismissButton != null) {
if (TextUtils.isEmpty(mDismissButton.getText())) {
mDismissButton.setVisibility(GONE);
} else {
mDismissButton.setVisibility(VISIBLE);
}
}
}
public boolean hasFired() {
return mPrefsManager.hasFired();
}
/**
* REDRAW LISTENER - this ensures we redraw after activity finishes laying out
*/
private class UpdateOnGlobalLayout implements ViewTreeObserver.OnGlobalLayoutListener {
@Override
public void onGlobalLayout() {
setTarget(mTarget);
}
}
/**
* BUILDER CLASS
* Gives us a builder utility class with a fluent API for eaily configuring showcase views
*/
public static class Builder {
private static final int CIRCLE_SHAPE = 0;
private static final int RECTANGLE_SHAPE = 1;
private static final int NO_SHAPE = 2;
private boolean fullWidth = false;
private int shapeType = CIRCLE_SHAPE;
final MaterialShowcaseView showcaseView;
private final Activity activity;
public Builder(Activity activity) {
this.activity = activity;
showcaseView = new MaterialShowcaseView(activity);
}
/**
* Set the title text shown on the ShowcaseView.
*/
public Builder setTarget(View target) {
showcaseView.setTarget(new ViewTarget(target));
return this;
}
/**
* Set the title text shown on the ShowcaseView.
*/
public Builder setDismissText(int resId) {
return setDismissText(activity.getString(resId));
}
public Builder setDismissText(CharSequence dismissText) {
showcaseView.setDismissText(dismissText);
return this;
}
/**
* Set the content text shown on the ShowcaseView.
*/
public Builder setContentText(int resId) {
return setContentText(activity.getString(resId));
}
/**
* Set the descriptive text shown on the ShowcaseView.
*/
public Builder setContentText(CharSequence text) {
showcaseView.setContentText(text);
return this;
}
/**
* Set the title text shown on the ShowcaseView.
*/
public Builder setTitleText(int resId) {
return setTitleText(activity.getString(resId));
}
/**
* Set the descriptive text shown on the ShowcaseView as the title.
*/
public Builder setTitleText(CharSequence text) {
showcaseView.setTitleText(text);
return this;
}
/**
* Set whether or not the target view can be touched while the showcase is visible.
*
* False by default.
*/
public Builder setTargetTouchable(boolean targetTouchable){
showcaseView.setTargetTouchable(targetTouchable);
return this;
}
/**
* Set whether or not the showcase should dismiss when the target is touched.
*
* True by default.
*/
public Builder setDismissOnTargetTouch(boolean dismissOnTargetTouch){
showcaseView.setDismissOnTargetTouch(dismissOnTargetTouch);
return this;
}
public Builder setDismissOnTouch(boolean dismissOnTouch) {
showcaseView.setDismissOnTouch(dismissOnTouch);
return this;
}
public Builder setMaskColour(int maskColour) {
showcaseView.setMaskColour(maskColour);
return this;
}
public Builder setTitleTextColor(int textColor) {
showcaseView.setTitleTextColor(textColor);
return this;
}
public Builder setContentTextColor(int textColor) {
showcaseView.setContentTextColor(textColor);
return this;
}
public Builder setDismissTextColor(int textColor) {
showcaseView.setDismissTextColor(textColor);
return this;
}
public Builder setTitleTextSize(float textSize) {
showcaseView.setTitleTextSize(textSize);
return this;
}
public Builder setContentTextSize(float textSize) {
showcaseView.setContentTextSize(textSize);
return this;
}
public Builder setDelay(int delayInMillis) {
showcaseView.setDelay(delayInMillis);
return this;
}
public Builder setFadeDuration(int fadeDurationInMillis) {
showcaseView.setFadeDuration(fadeDurationInMillis);
return this;
}
public Builder setListener(IShowcaseListener listener) {
showcaseView.addShowcaseListener(listener);
return this;
}
public Builder singleUse(String showcaseID) {
showcaseView.singleUse(showcaseID);
return this;
}
public Builder setShape(Shape shape) {
showcaseView.setShape(shape);
return this;
}
public Builder withCircleShape() {
shapeType = CIRCLE_SHAPE;
return this;
}
public Builder withoutShape() {
shapeType = NO_SHAPE;
return this;
}
public Builder setShapePadding(int padding) {
showcaseView.setShapePadding(padding);
return this;
}
public Builder withRectangleShape() {
return withRectangleShape(false);
}
public Builder withRectangleShape(boolean fullWidth) {
this.shapeType = RECTANGLE_SHAPE;
this.fullWidth = fullWidth;
return this;
}
public Builder renderOverNavigationBar() {
// Note: This only has an effect in Lollipop or above.
showcaseView.setRenderOverNavigationBar(true);
return this;
}
public MaterialShowcaseView build() {
if (showcaseView.mShape == null) {
switch (shapeType) {
case RECTANGLE_SHAPE: {
showcaseView.setShape(new RectangleShape(showcaseView.mTarget.getBounds(), fullWidth));
break;
}
case CIRCLE_SHAPE: {
showcaseView.setShape(new CircleShape(showcaseView.mTarget));
break;
}
case NO_SHAPE: {
showcaseView.setShape(new NoShape());
break;
}
default:
throw new IllegalArgumentException("Unsupported shape type: " + shapeType);
}
}
return showcaseView;
}
public MaterialShowcaseView show() {
build().show(activity);
return showcaseView;
}
}
private void singleUse(String showcaseID) {
mSingleUse = true;
mPrefsManager = new PrefsManager(getContext(), showcaseID);
}
public void removeFromWindow() {
if (getParent() != null && getParent() instanceof ViewGroup) {
((ViewGroup) getParent()).removeView(this);
}
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
mEraser = null;
mAnimationFactory = null;
mCanvas = null;
mHandler = null;
getViewTreeObserver().removeGlobalOnLayoutListener(mLayoutListener);
mLayoutListener = null;
if (mPrefsManager != null)
mPrefsManager.close();
mPrefsManager = null;
}
/**
* Reveal the showcaseview. Returns a boolean telling us whether we actually did show anything
*
* @param activity
* @return
*/
public boolean show(final Activity activity) {
/**
* if we're in single use mode and have already shot our bolt then do nothing
*/
if (mSingleUse) {
if (mPrefsManager.hasFired()) {
return false;
} else {
mPrefsManager.setFired();
}
}
((ViewGroup) activity.getWindow().getDecorView()).addView(this);
setShouldRender(true);
mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (mShouldAnimate) {
fadeIn();
} else {
setVisibility(VISIBLE);
notifyOnDisplayed();
}
}
}, mDelayInMillis);
updateDismissButton();
return true;
}
public void hide() {
/**
* This flag is used to indicate to onDetachedFromWindow that the showcase view was dismissed purposefully (by the user or programmatically)
*/
mWasDismissed = true;
if (mShouldAnimate) {
fadeOut();
} else {
removeFromWindow();
}
}
public void fadeIn() {
setVisibility(INVISIBLE);
mAnimationFactory.fadeInView(this, mFadeDurationInMillis,
new IAnimationFactory.AnimationStartListener() {
@Override
public void onAnimationStart() {
setVisibility(View.VISIBLE);
notifyOnDisplayed();
}
}
);
}
public void fadeOut() {
mAnimationFactory.fadeOutView(this, mFadeDurationInMillis, new IAnimationFactory.AnimationEndListener() {
@Override
public void onAnimationEnd() {
setVisibility(INVISIBLE);
removeFromWindow();
}
});
}
public void resetSingleUse() {
if (mSingleUse && mPrefsManager != null) mPrefsManager.resetShowcase();
}
/**
* Static helper method for resetting single use flag
*
* @param context
* @param showcaseID
*/
public static void resetSingleUse(Context context, String showcaseID) {
PrefsManager.resetShowcase(context, showcaseID);
}
/**
* Static helper method for resetting all single use flags
*
* @param context
*/
public static void resetAll(Context context) {
PrefsManager.resetAll(context);
}
public static int getSoftButtonsBarSizePort(Activity activity) {
// getRealMetrics is only available with API 17 and +
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int usableHeight = metrics.heightPixels;
activity.getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
int realHeight = metrics.heightPixels;
if (realHeight > usableHeight)
return realHeight - usableHeight;
else
return 0;
}
return 0;
}
private void setRenderOverNavigationBar(boolean mRenderOverNav) {
this.mRenderOverNav = mRenderOverNav;
}
}