jimu-decompiled/sources/androidx/appcompat/widget/ActionBarOverlayLayout.java
2025-05-13 19:24:51 +02:00

635 lines
21 KiB
Java

package androidx.appcompat.widget;
import android.R;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewPropertyAnimator;
import android.view.Window;
import android.widget.OverScroller;
import androidx.appcompat.R$attr;
import androidx.appcompat.R$id;
import androidx.appcompat.view.menu.MenuPresenter;
import androidx.core.view.NestedScrollingParent;
import androidx.core.view.NestedScrollingParentHelper;
import androidx.core.view.ViewCompat;
import com.ijm.dataencryption.de.DataDecryptTool;
/* loaded from: classes.dex */
public class ActionBarOverlayLayout extends ViewGroup implements DecorContentParent, NestedScrollingParent {
static final int[] C = {R$attr.actionBarSize, R.attr.windowContentOverlay};
private final Runnable A;
private final NestedScrollingParentHelper B;
private int a;
private int b;
private ContentFrameLayout c;
ActionBarContainer d;
private DecorToolbar e;
private Drawable f;
private boolean g;
private boolean h;
private boolean i;
private boolean j;
boolean k;
private int l;
private int m;
private final Rect n;
private final Rect o;
private final Rect p;
private final Rect q;
private final Rect r;
private final Rect s;
private final Rect t;
private ActionBarVisibilityCallback u;
private OverScroller v;
ViewPropertyAnimator x;
final AnimatorListenerAdapter y;
private final Runnable z;
public interface ActionBarVisibilityCallback {
void a();
void a(int i);
void a(boolean z);
void b();
void c();
void d();
}
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
public LayoutParams(int i, int i2) {
super(i, i2);
}
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
}
}
public ActionBarOverlayLayout(Context context) {
this(context, null);
}
private void a(Context context) {
TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(C);
this.a = obtainStyledAttributes.getDimensionPixelSize(0, 0);
this.f = obtainStyledAttributes.getDrawable(1);
setWillNotDraw(this.f == null);
obtainStyledAttributes.recycle();
this.g = context.getApplicationInfo().targetSdkVersion < 19;
this.v = new OverScroller(context);
}
private void k() {
b();
this.A.run();
}
private void l() {
b();
postDelayed(this.A, 600L);
}
private void m() {
b();
postDelayed(this.z, 600L);
}
private void n() {
b();
this.z.run();
}
void b() {
removeCallbacks(this.z);
removeCallbacks(this.A);
ViewPropertyAnimator viewPropertyAnimator = this.x;
if (viewPropertyAnimator != null) {
viewPropertyAnimator.cancel();
}
}
@Override // androidx.appcompat.widget.DecorContentParent
public void c() {
j();
this.e.c();
}
@Override // android.view.ViewGroup
protected boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
return layoutParams instanceof LayoutParams;
}
@Override // androidx.appcompat.widget.DecorContentParent
public boolean d() {
j();
return this.e.d();
}
@Override // android.view.View
public void draw(Canvas canvas) {
super.draw(canvas);
if (this.f == null || this.g) {
return;
}
int bottom = this.d.getVisibility() == 0 ? (int) (this.d.getBottom() + this.d.getTranslationY() + 0.5f) : 0;
this.f.setBounds(0, bottom, getWidth(), this.f.getIntrinsicHeight() + bottom);
this.f.draw(canvas);
}
@Override // androidx.appcompat.widget.DecorContentParent
public boolean e() {
j();
return this.e.e();
}
@Override // androidx.appcompat.widget.DecorContentParent
public boolean f() {
j();
return this.e.f();
}
@Override // android.view.View
protected boolean fitSystemWindows(Rect rect) {
j();
int q = ViewCompat.q(this) & DataDecryptTool.DECRYPT_ALL_FILE;
boolean a = a(this.d, rect, true, true, false, true);
this.q.set(rect);
ViewUtils.a(this, this.q, this.n);
if (!this.r.equals(this.q)) {
this.r.set(this.q);
a = true;
}
if (!this.o.equals(this.n)) {
this.o.set(this.n);
a = true;
}
if (a) {
requestLayout();
}
return true;
}
@Override // androidx.appcompat.widget.DecorContentParent
public boolean g() {
j();
return this.e.g();
}
public int getActionBarHideOffset() {
ActionBarContainer actionBarContainer = this.d;
if (actionBarContainer != null) {
return -((int) actionBarContainer.getTranslationY());
}
return 0;
}
@Override // android.view.ViewGroup
public int getNestedScrollAxes() {
return this.B.a();
}
public CharSequence getTitle() {
j();
return this.e.getTitle();
}
@Override // androidx.appcompat.widget.DecorContentParent
public void h() {
j();
this.e.h();
}
public boolean i() {
return this.h;
}
void j() {
if (this.c == null) {
this.c = (ContentFrameLayout) findViewById(R$id.action_bar_activity_content);
this.d = (ActionBarContainer) findViewById(R$id.action_bar_container);
this.e = a(findViewById(R$id.action_bar));
}
}
@Override // android.view.View
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
a(getContext());
ViewCompat.B(this);
}
@Override // android.view.ViewGroup, android.view.View
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
b();
}
@Override // android.view.ViewGroup, android.view.View
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
int childCount = getChildCount();
int paddingLeft = getPaddingLeft();
getPaddingRight();
int paddingTop = getPaddingTop();
getPaddingBottom();
for (int i5 = 0; i5 < childCount; i5++) {
View childAt = getChildAt(i5);
if (childAt.getVisibility() != 8) {
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
int measuredWidth = childAt.getMeasuredWidth();
int measuredHeight = childAt.getMeasuredHeight();
int i6 = ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + paddingLeft;
int i7 = ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + paddingTop;
childAt.layout(i6, i7, measuredWidth + i6, measuredHeight + i7);
}
}
}
@Override // android.view.View
protected void onMeasure(int i, int i2) {
int measuredHeight;
j();
measureChildWithMargins(this.d, i, 0, i2, 0);
LayoutParams layoutParams = (LayoutParams) this.d.getLayoutParams();
int max = Math.max(0, this.d.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin);
int max2 = Math.max(0, this.d.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin);
int combineMeasuredStates = View.combineMeasuredStates(0, this.d.getMeasuredState());
boolean z = (ViewCompat.q(this) & DataDecryptTool.DECRYPT_ALL_FILE) != 0;
if (z) {
measuredHeight = this.a;
if (this.i && this.d.getTabContainer() != null) {
measuredHeight += this.a;
}
} else {
measuredHeight = this.d.getVisibility() != 8 ? this.d.getMeasuredHeight() : 0;
}
this.p.set(this.n);
this.s.set(this.q);
if (this.h || z) {
Rect rect = this.s;
rect.top += measuredHeight;
rect.bottom += 0;
} else {
Rect rect2 = this.p;
rect2.top += measuredHeight;
rect2.bottom += 0;
}
a(this.c, this.p, true, true, true, true);
if (!this.t.equals(this.s)) {
this.t.set(this.s);
this.c.a(this.s);
}
measureChildWithMargins(this.c, i, 0, i2, 0);
LayoutParams layoutParams2 = (LayoutParams) this.c.getLayoutParams();
int max3 = Math.max(max, this.c.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) layoutParams2).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams2).rightMargin);
int max4 = Math.max(max2, this.c.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams2).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams2).bottomMargin);
int combineMeasuredStates2 = View.combineMeasuredStates(combineMeasuredStates, this.c.getMeasuredState());
setMeasuredDimension(View.resolveSizeAndState(Math.max(max3 + getPaddingLeft() + getPaddingRight(), getSuggestedMinimumWidth()), i, combineMeasuredStates2), View.resolveSizeAndState(Math.max(max4 + getPaddingTop() + getPaddingBottom(), getSuggestedMinimumHeight()), i2, combineMeasuredStates2 << 16));
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public boolean onNestedFling(View view, float f, float f2, boolean z) {
if (!this.j || !z) {
return false;
}
if (a(f, f2)) {
k();
} else {
n();
}
this.k = true;
return true;
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public boolean onNestedPreFling(View view, float f, float f2) {
return false;
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public void onNestedPreScroll(View view, int i, int i2, int[] iArr) {
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public void onNestedScroll(View view, int i, int i2, int i3, int i4) {
this.l += i2;
setActionBarHideOffset(this.l);
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public void onNestedScrollAccepted(View view, View view2, int i) {
this.B.a(view, view2, i);
this.l = getActionBarHideOffset();
b();
ActionBarVisibilityCallback actionBarVisibilityCallback = this.u;
if (actionBarVisibilityCallback != null) {
actionBarVisibilityCallback.d();
}
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public boolean onStartNestedScroll(View view, View view2, int i) {
if ((i & 2) == 0 || this.d.getVisibility() != 0) {
return false;
}
return this.j;
}
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
public void onStopNestedScroll(View view) {
if (this.j && !this.k) {
if (this.l <= this.d.getHeight()) {
m();
} else {
l();
}
}
ActionBarVisibilityCallback actionBarVisibilityCallback = this.u;
if (actionBarVisibilityCallback != null) {
actionBarVisibilityCallback.b();
}
}
@Override // android.view.View
public void onWindowSystemUiVisibilityChanged(int i) {
if (Build.VERSION.SDK_INT >= 16) {
super.onWindowSystemUiVisibilityChanged(i);
}
j();
int i2 = this.m ^ i;
this.m = i;
boolean z = (i & 4) == 0;
boolean z2 = (i & DataDecryptTool.DECRYPT_ALL_FILE) != 0;
ActionBarVisibilityCallback actionBarVisibilityCallback = this.u;
if (actionBarVisibilityCallback != null) {
actionBarVisibilityCallback.a(!z2);
if (z || !z2) {
this.u.a();
} else {
this.u.c();
}
}
if ((i2 & DataDecryptTool.DECRYPT_ALL_FILE) == 0 || this.u == null) {
return;
}
ViewCompat.B(this);
}
@Override // android.view.View
protected void onWindowVisibilityChanged(int i) {
super.onWindowVisibilityChanged(i);
this.b = i;
ActionBarVisibilityCallback actionBarVisibilityCallback = this.u;
if (actionBarVisibilityCallback != null) {
actionBarVisibilityCallback.a(i);
}
}
public void setActionBarHideOffset(int i) {
b();
this.d.setTranslationY(-Math.max(0, Math.min(i, this.d.getHeight())));
}
public void setActionBarVisibilityCallback(ActionBarVisibilityCallback actionBarVisibilityCallback) {
this.u = actionBarVisibilityCallback;
if (getWindowToken() != null) {
this.u.a(this.b);
int i = this.m;
if (i != 0) {
onWindowSystemUiVisibilityChanged(i);
ViewCompat.B(this);
}
}
}
public void setHasNonEmbeddedTabs(boolean z) {
this.i = z;
}
public void setHideOnContentScrollEnabled(boolean z) {
if (z != this.j) {
this.j = z;
if (z) {
return;
}
b();
setActionBarHideOffset(0);
}
}
public void setIcon(int i) {
j();
this.e.setIcon(i);
}
public void setLogo(int i) {
j();
this.e.b(i);
}
public void setOverlayMode(boolean z) {
this.h = z;
this.g = z && getContext().getApplicationInfo().targetSdkVersion < 19;
}
public void setShowingForActionMode(boolean z) {
}
public void setUiOptions(int i) {
}
@Override // androidx.appcompat.widget.DecorContentParent
public void setWindowCallback(Window.Callback callback) {
j();
this.e.setWindowCallback(callback);
}
@Override // androidx.appcompat.widget.DecorContentParent
public void setWindowTitle(CharSequence charSequence) {
j();
this.e.setWindowTitle(charSequence);
}
@Override // android.view.ViewGroup
public boolean shouldDelayChildPressedState() {
return false;
}
public ActionBarOverlayLayout(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
this.b = 0;
this.n = new Rect();
this.o = new Rect();
this.p = new Rect();
this.q = new Rect();
this.r = new Rect();
this.s = new Rect();
this.t = new Rect();
this.y = new AnimatorListenerAdapter() { // from class: androidx.appcompat.widget.ActionBarOverlayLayout.1
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationCancel(Animator animator) {
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
actionBarOverlayLayout.x = null;
actionBarOverlayLayout.k = false;
}
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
public void onAnimationEnd(Animator animator) {
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
actionBarOverlayLayout.x = null;
actionBarOverlayLayout.k = false;
}
};
this.z = new Runnable() { // from class: androidx.appcompat.widget.ActionBarOverlayLayout.2
@Override // java.lang.Runnable
public void run() {
ActionBarOverlayLayout.this.b();
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
actionBarOverlayLayout.x = actionBarOverlayLayout.d.animate().translationY(0.0f).setListener(ActionBarOverlayLayout.this.y);
}
};
this.A = new Runnable() { // from class: androidx.appcompat.widget.ActionBarOverlayLayout.3
@Override // java.lang.Runnable
public void run() {
ActionBarOverlayLayout.this.b();
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
actionBarOverlayLayout.x = actionBarOverlayLayout.d.animate().translationY(-ActionBarOverlayLayout.this.d.getHeight()).setListener(ActionBarOverlayLayout.this.y);
}
};
a(context);
this.B = new NestedScrollingParentHelper(this);
}
/* JADX INFO: Access modifiers changed from: protected */
@Override // android.view.ViewGroup
public LayoutParams generateDefaultLayoutParams() {
return new LayoutParams(-1, -1);
}
@Override // android.view.ViewGroup
public LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new LayoutParams(getContext(), attributeSet);
}
@Override // android.view.ViewGroup
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
return new LayoutParams(layoutParams);
}
public void setIcon(Drawable drawable) {
j();
this.e.setIcon(drawable);
}
/* JADX WARN: Removed duplicated region for block: B:11:0x0021 */
/* JADX WARN: Removed duplicated region for block: B:15:0x002c */
/* JADX WARN: Removed duplicated region for block: B:21:? A[RETURN, SYNTHETIC] */
/* JADX WARN: Removed duplicated region for block: B:7:0x0016 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct code enable 'Show inconsistent code' option in preferences
*/
private boolean a(android.view.View r3, android.graphics.Rect r4, boolean r5, boolean r6, boolean r7, boolean r8) {
/*
r2 = this;
android.view.ViewGroup$LayoutParams r3 = r3.getLayoutParams()
androidx.appcompat.widget.ActionBarOverlayLayout$LayoutParams r3 = (androidx.appcompat.widget.ActionBarOverlayLayout.LayoutParams) r3
r0 = 1
if (r5 == 0) goto L13
int r5 = r3.leftMargin
int r1 = r4.left
if (r5 == r1) goto L13
r3.leftMargin = r1
r5 = 1
goto L14
L13:
r5 = 0
L14:
if (r6 == 0) goto L1f
int r6 = r3.topMargin
int r1 = r4.top
if (r6 == r1) goto L1f
r3.topMargin = r1
r5 = 1
L1f:
if (r8 == 0) goto L2a
int r6 = r3.rightMargin
int r8 = r4.right
if (r6 == r8) goto L2a
r3.rightMargin = r8
r5 = 1
L2a:
if (r7 == 0) goto L35
int r6 = r3.bottomMargin
int r4 = r4.bottom
if (r6 == r4) goto L35
r3.bottomMargin = r4
r5 = 1
L35:
return r5
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.ActionBarOverlayLayout.a(android.view.View, android.graphics.Rect, boolean, boolean, boolean, boolean):boolean");
}
/* JADX WARN: Multi-variable type inference failed */
private DecorToolbar a(View view) {
if (view instanceof DecorToolbar) {
return (DecorToolbar) view;
}
if (view instanceof Toolbar) {
return ((Toolbar) view).getWrapper();
}
throw new IllegalStateException("Can't make a decor toolbar out of " + view.getClass().getSimpleName());
}
private boolean a(float f, float f2) {
this.v.fling(0, 0, 0, (int) f2, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
return this.v.getFinalY() > this.d.getHeight();
}
@Override // androidx.appcompat.widget.DecorContentParent
public void a(int i) {
j();
if (i == 2) {
this.e.n();
} else if (i == 5) {
this.e.o();
} else {
if (i != 109) {
return;
}
setOverlayMode(true);
}
}
@Override // androidx.appcompat.widget.DecorContentParent
public boolean a() {
j();
return this.e.a();
}
@Override // androidx.appcompat.widget.DecorContentParent
public void a(Menu menu, MenuPresenter.Callback callback) {
j();
this.e.a(menu, callback);
}
}