FloatingActionButton.java
17.7 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
package android.support.design.widget;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.design.R.dimen;
import android.support.design.R.style;
import android.support.design.R.styleable;
import android.support.v4.content.res.ConfigurationHelper;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.AppCompatImageHelper;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewTreeObserver;
import i;
import j;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import k;
import k.1;
import k.a;
import l;
import o;
import r;
import v;
import y;
@CoordinatorLayout.DefaultBehavior(Behavior.class)
public class FloatingActionButton
extends VisibilityAwareImageButton
{
public static final int SIZE_AUTO = -1;
public static final int SIZE_MINI = 1;
public static final int SIZE_NORMAL = 0;
int a;
boolean b;
final Rect c = new Rect();
private ColorStateList d;
private PorterDuff.Mode e;
private int f;
private int g;
private int h;
private int i;
private final Rect j = new Rect();
private AppCompatImageHelper k;
private k l;
public FloatingActionButton(Context paramContext)
{
this(paramContext, null);
}
public FloatingActionButton(Context paramContext, AttributeSet paramAttributeSet)
{
this(paramContext, paramAttributeSet, 0);
}
public FloatingActionButton(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
super(paramContext, paramAttributeSet, paramInt);
r.a(paramContext);
paramContext = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.FloatingActionButton, paramInt, R.style.Widget_Design_FloatingActionButton);
this.d = paramContext.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
this.e = y.a(paramContext.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1));
this.g = paramContext.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
this.h = paramContext.getInt(R.styleable.FloatingActionButton_fabSize, -1);
this.f = paramContext.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
float f1 = paramContext.getDimension(R.styleable.FloatingActionButton_elevation, 0.0F);
float f2 = paramContext.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0.0F);
this.b = paramContext.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
paramContext.recycle();
this.k = new AppCompatImageHelper(this);
this.k.loadFromAttributes(paramAttributeSet, paramInt);
this.i = ((int)getResources().getDimension(R.dimen.design_fab_image_size));
getImpl().a(this.d, this.e, this.g, this.f);
getImpl().a(f1);
paramContext = getImpl();
if (paramContext.i != f2)
{
paramContext.i = f2;
paramContext.a(paramContext.h, f2);
}
}
private static int a(int paramInt1, int paramInt2)
{
int m = View.MeasureSpec.getMode(paramInt2);
paramInt2 = View.MeasureSpec.getSize(paramInt2);
switch (m)
{
case 0:
default:
return paramInt1;
case -2147483648:
return Math.min(paramInt1, paramInt2);
}
return paramInt2;
}
@Nullable
private k.a a(@Nullable final OnVisibilityChangedListener paramOnVisibilityChangedListener)
{
if (paramOnVisibilityChangedListener == null) {
return null;
}
new k.a()
{
public final void a()
{
paramOnVisibilityChangedListener.onShown(FloatingActionButton.this);
}
public final void b()
{
paramOnVisibilityChangedListener.onHidden(FloatingActionButton.this);
}
};
}
private k getImpl()
{
int m;
Object localObject;
if (this.l == null)
{
m = Build.VERSION.SDK_INT;
if (m < 21) {
break label47;
}
localObject = new l(this, new a(), y.a);
}
for (;;)
{
this.l = ((k)localObject);
return this.l;
label47:
if (m >= 14) {
localObject = new j(this, new a(), y.a);
} else {
localObject = new i(this, new a(), y.a);
}
}
}
final void a(OnVisibilityChangedListener paramOnVisibilityChangedListener, boolean paramBoolean)
{
getImpl().b(a(paramOnVisibilityChangedListener), paramBoolean);
}
final void b(@Nullable OnVisibilityChangedListener paramOnVisibilityChangedListener, boolean paramBoolean)
{
getImpl().a(a(paramOnVisibilityChangedListener), paramBoolean);
}
protected void drawableStateChanged()
{
super.drawableStateChanged();
getImpl().a(getDrawableState());
}
@Nullable
public ColorStateList getBackgroundTintList()
{
return this.d;
}
@Nullable
public PorterDuff.Mode getBackgroundTintMode()
{
return this.e;
}
public float getCompatElevation()
{
return getImpl().a();
}
@NonNull
public Drawable getContentBackground()
{
return getImpl().g;
}
public boolean getContentRect(@NonNull Rect paramRect)
{
boolean bool = false;
if (ViewCompat.isLaidOut(this))
{
paramRect.set(0, 0, getWidth(), getHeight());
paramRect.left += this.c.left;
paramRect.top += this.c.top;
paramRect.right -= this.c.right;
paramRect.bottom -= this.c.bottom;
bool = true;
}
return bool;
}
@ColorInt
public int getRippleColor()
{
return this.g;
}
public int getSize()
{
return this.h;
}
int getSizeDimension()
{
int m = this.h;
Resources localResources;
for (;;)
{
localResources = getResources();
switch (m)
{
case 0:
default:
return localResources.getDimensionPixelSize(R.dimen.design_fab_size_normal);
case -1:
if (Math.max(ConfigurationHelper.getScreenWidthDp(localResources), ConfigurationHelper.getScreenHeightDp(localResources)) < 470) {
m = 1;
} else {
m = 0;
}
break;
}
}
return localResources.getDimensionPixelSize(R.dimen.design_fab_size_mini);
}
public boolean getUseCompatPadding()
{
return this.b;
}
public void hide()
{
hide(null);
}
public void hide(@Nullable OnVisibilityChangedListener paramOnVisibilityChangedListener)
{
b(paramOnVisibilityChangedListener, true);
}
@TargetApi(11)
public void jumpDrawablesToCurrentState()
{
super.jumpDrawablesToCurrentState();
getImpl().b();
}
protected void onAttachedToWindow()
{
super.onAttachedToWindow();
k localk = getImpl();
if (localk.d())
{
if (localk.q == null) {
localk.q = new k.1(localk);
}
localk.n.getViewTreeObserver().addOnPreDrawListener(localk.q);
}
}
protected void onDetachedFromWindow()
{
super.onDetachedFromWindow();
k localk = getImpl();
if (localk.q != null)
{
localk.n.getViewTreeObserver().removeOnPreDrawListener(localk.q);
localk.q = null;
}
}
protected void onMeasure(int paramInt1, int paramInt2)
{
int m = getSizeDimension();
this.a = ((m - this.i) / 2);
getImpl().f();
paramInt1 = Math.min(a(m, paramInt1), a(m, paramInt2));
setMeasuredDimension(this.c.left + paramInt1 + this.c.right, paramInt1 + this.c.top + this.c.bottom);
}
public boolean onTouchEvent(MotionEvent paramMotionEvent)
{
switch (paramMotionEvent.getAction())
{
}
do
{
return super.onTouchEvent(paramMotionEvent);
} while ((!getContentRect(this.j)) || (this.j.contains((int)paramMotionEvent.getX(), (int)paramMotionEvent.getY())));
return false;
}
public void setBackgroundColor(int paramInt)
{
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
}
public void setBackgroundDrawable(Drawable paramDrawable)
{
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
}
public void setBackgroundResource(int paramInt)
{
Log.i("FloatingActionButton", "Setting a custom background is not supported.");
}
public void setBackgroundTintList(@Nullable ColorStateList paramColorStateList)
{
if (this.d != paramColorStateList)
{
this.d = paramColorStateList;
getImpl().a(paramColorStateList);
}
}
public void setBackgroundTintMode(@Nullable PorterDuff.Mode paramMode)
{
if (this.e != paramMode)
{
this.e = paramMode;
getImpl().a(paramMode);
}
}
public void setCompatElevation(float paramFloat)
{
getImpl().a(paramFloat);
}
public void setImageResource(@DrawableRes int paramInt)
{
this.k.setImageResource(paramInt);
}
public void setRippleColor(@ColorInt int paramInt)
{
if (this.g != paramInt)
{
this.g = paramInt;
getImpl().a(paramInt);
}
}
public void setSize(int paramInt)
{
if (paramInt != this.h)
{
this.h = paramInt;
requestLayout();
}
}
public void setUseCompatPadding(boolean paramBoolean)
{
if (this.b != paramBoolean)
{
this.b = paramBoolean;
getImpl().c();
}
}
public void show()
{
show(null);
}
public void show(@Nullable OnVisibilityChangedListener paramOnVisibilityChangedListener)
{
a(paramOnVisibilityChangedListener, true);
}
public static class Behavior
extends CoordinatorLayout.Behavior<FloatingActionButton>
{
private Rect a;
private FloatingActionButton.OnVisibilityChangedListener b;
private boolean c;
public Behavior()
{
this.c = true;
}
public Behavior(Context paramContext, AttributeSet paramAttributeSet)
{
super(paramAttributeSet);
paramContext = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.FloatingActionButton_Behavior_Layout);
this.c = paramContext.getBoolean(R.styleable.FloatingActionButton_Behavior_Layout_behavior_autoHide, true);
paramContext.recycle();
}
private boolean a(CoordinatorLayout paramCoordinatorLayout, AppBarLayout paramAppBarLayout, FloatingActionButton paramFloatingActionButton)
{
if (!a(paramAppBarLayout, paramFloatingActionButton)) {
return false;
}
if (this.a == null) {
this.a = new Rect();
}
Rect localRect = this.a;
v.a(paramCoordinatorLayout, paramAppBarLayout, localRect);
if (localRect.bottom <= paramAppBarLayout.getMinimumHeightForVisibleOverlappingContent()) {
paramFloatingActionButton.b(this.b, false);
}
for (;;)
{
return true;
paramFloatingActionButton.a(this.b, false);
}
}
private static boolean a(@NonNull View paramView)
{
paramView = paramView.getLayoutParams();
if ((paramView instanceof CoordinatorLayout.LayoutParams)) {
return ((CoordinatorLayout.LayoutParams)paramView).getBehavior() instanceof BottomSheetBehavior;
}
return false;
}
private boolean a(View paramView, FloatingActionButton paramFloatingActionButton)
{
CoordinatorLayout.LayoutParams localLayoutParams = (CoordinatorLayout.LayoutParams)paramFloatingActionButton.getLayoutParams();
if (!this.c) {
return false;
}
if (localLayoutParams.getAnchorId() != paramView.getId()) {
return false;
}
return paramFloatingActionButton.getUserSetVisibility() == 0;
}
private boolean b(View paramView, FloatingActionButton paramFloatingActionButton)
{
if (!a(paramView, paramFloatingActionButton)) {
return false;
}
CoordinatorLayout.LayoutParams localLayoutParams = (CoordinatorLayout.LayoutParams)paramFloatingActionButton.getLayoutParams();
int i = paramView.getTop();
int j = paramFloatingActionButton.getHeight() / 2;
if (i < localLayoutParams.topMargin + j) {
paramFloatingActionButton.b(this.b, false);
}
for (;;)
{
return true;
paramFloatingActionButton.a(this.b, false);
}
}
public boolean getInsetDodgeRect(@NonNull CoordinatorLayout paramCoordinatorLayout, @NonNull FloatingActionButton paramFloatingActionButton, @NonNull Rect paramRect)
{
paramCoordinatorLayout = paramFloatingActionButton.c;
paramRect.set(paramFloatingActionButton.getLeft() + paramCoordinatorLayout.left, paramFloatingActionButton.getTop() + paramCoordinatorLayout.top, paramFloatingActionButton.getRight() - paramCoordinatorLayout.right, paramFloatingActionButton.getBottom() - paramCoordinatorLayout.bottom);
return true;
}
public boolean isAutoHideEnabled()
{
return this.c;
}
public void onAttachedToLayoutParams(@NonNull CoordinatorLayout.LayoutParams paramLayoutParams)
{
if (paramLayoutParams.dodgeInsetEdges == 0) {
paramLayoutParams.dodgeInsetEdges = 80;
}
}
public boolean onDependentViewChanged(CoordinatorLayout paramCoordinatorLayout, FloatingActionButton paramFloatingActionButton, View paramView)
{
if ((paramView instanceof AppBarLayout)) {
a(paramCoordinatorLayout, (AppBarLayout)paramView, paramFloatingActionButton);
}
for (;;)
{
return false;
if (a(paramView)) {
b(paramView, paramFloatingActionButton);
}
}
}
public boolean onLayoutChild(CoordinatorLayout paramCoordinatorLayout, FloatingActionButton paramFloatingActionButton, int paramInt)
{
int j = 0;
Object localObject1 = paramCoordinatorLayout.getDependencies(paramFloatingActionButton);
int k = ((List)localObject1).size();
int i = 0;
Object localObject2;
if (i < k)
{
localObject2 = (View)((List)localObject1).get(i);
if ((localObject2 instanceof AppBarLayout)) {
if (!a(paramCoordinatorLayout, (AppBarLayout)localObject2, paramFloatingActionButton)) {
break label194;
}
}
}
else
{
label65:
paramCoordinatorLayout.onLayoutChild(paramFloatingActionButton, paramInt);
localObject1 = paramFloatingActionButton.c;
if ((localObject1 != null) && (((Rect)localObject1).centerX() > 0) && (((Rect)localObject1).centerY() > 0))
{
localObject2 = (CoordinatorLayout.LayoutParams)paramFloatingActionButton.getLayoutParams();
if (paramFloatingActionButton.getRight() < paramCoordinatorLayout.getWidth() - ((CoordinatorLayout.LayoutParams)localObject2).rightMargin) {
break label203;
}
paramInt = ((Rect)localObject1).right;
}
}
for (;;)
{
label130:
if (paramFloatingActionButton.getBottom() >= paramCoordinatorLayout.getHeight() - ((CoordinatorLayout.LayoutParams)localObject2).bottomMargin) {
i = ((Rect)localObject1).bottom;
}
for (;;)
{
if (i != 0) {
ViewCompat.offsetTopAndBottom(paramFloatingActionButton, i);
}
if (paramInt != 0) {
ViewCompat.offsetLeftAndRight(paramFloatingActionButton, paramInt);
}
return true;
if ((a((View)localObject2)) && (b((View)localObject2, paramFloatingActionButton))) {
break label65;
}
label194:
i += 1;
break;
label203:
if (paramFloatingActionButton.getLeft() > ((CoordinatorLayout.LayoutParams)localObject2).leftMargin) {
break label252;
}
paramInt = -((Rect)localObject1).left;
break label130;
i = j;
if (paramFloatingActionButton.getTop() <= ((CoordinatorLayout.LayoutParams)localObject2).topMargin) {
i = -((Rect)localObject1).top;
}
}
label252:
paramInt = 0;
}
}
public void setAutoHideEnabled(boolean paramBoolean)
{
this.c = paramBoolean;
}
}
public static abstract class OnVisibilityChangedListener
{
public void onHidden(FloatingActionButton paramFloatingActionButton) {}
public void onShown(FloatingActionButton paramFloatingActionButton) {}
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
public static @interface Size {}
final class a
implements o
{
a() {}
public final float a()
{
return FloatingActionButton.this.getSizeDimension() / 2.0F;
}
public final void a(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
{
FloatingActionButton.this.c.set(paramInt1, paramInt2, paramInt3, paramInt4);
FloatingActionButton.this.setPadding(FloatingActionButton.this.a + paramInt1, FloatingActionButton.this.a + paramInt2, FloatingActionButton.this.a + paramInt3, FloatingActionButton.this.a + paramInt4);
}
public final void a(Drawable paramDrawable)
{
FloatingActionButton.a(FloatingActionButton.this, paramDrawable);
}
public final boolean b()
{
return FloatingActionButton.this.b;
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/design/widget/FloatingActionButton.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/