745 lines
30 KiB
Java
745 lines
30 KiB
Java
package androidx.appcompat.widget;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorListenerAdapter;
|
|
import android.annotation.SuppressLint;
|
|
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.Parcelable;
|
|
import android.util.AttributeSet;
|
|
import android.util.SparseArray;
|
|
import android.view.Menu;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewPropertyAnimator;
|
|
import android.view.Window;
|
|
import android.view.WindowInsets;
|
|
import android.widget.OverScroller;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.appcompat.R;
|
|
import androidx.appcompat.view.menu.MenuPresenter;
|
|
import androidx.core.graphics.Insets;
|
|
import androidx.core.view.NestedScrollingParent;
|
|
import androidx.core.view.NestedScrollingParent2;
|
|
import androidx.core.view.NestedScrollingParent3;
|
|
import androidx.core.view.NestedScrollingParentHelper;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.core.view.WindowInsetsCompat;
|
|
import c.d.b.a.a;
|
|
@SuppressLint({"UnknownNullness"})
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public class ActionBarOverlayLayout extends ViewGroup implements DecorContentParent, NestedScrollingParent, NestedScrollingParent2, NestedScrollingParent3 {
|
|
private static final int ACTION_BAR_ANIMATE_DELAY = 600;
|
|
public static final int[] ATTRS = {R.attr.actionBarSize, 16842841};
|
|
private static final String TAG = "ActionBarOverlayLayout";
|
|
private int mActionBarHeight;
|
|
public ActionBarContainer mActionBarTop;
|
|
private ActionBarVisibilityCallback mActionBarVisibilityCallback;
|
|
private final Runnable mAddActionBarHideOffset;
|
|
public boolean mAnimatingForFling;
|
|
private final Rect mBaseContentInsets;
|
|
@NonNull
|
|
private WindowInsetsCompat mBaseInnerInsets;
|
|
private final Rect mBaseInnerInsetsRect;
|
|
private ContentFrameLayout mContent;
|
|
private final Rect mContentInsets;
|
|
public ViewPropertyAnimator mCurrentActionBarTopAnimator;
|
|
private DecorToolbar mDecorToolbar;
|
|
private OverScroller mFlingEstimator;
|
|
private boolean mHasNonEmbeddedTabs;
|
|
private boolean mHideOnContentScroll;
|
|
private int mHideOnContentScrollReference;
|
|
private boolean mIgnoreWindowContentOverlay;
|
|
@NonNull
|
|
private WindowInsetsCompat mInnerInsets;
|
|
private final Rect mInnerInsetsRect;
|
|
private final Rect mLastBaseContentInsets;
|
|
@NonNull
|
|
private WindowInsetsCompat mLastBaseInnerInsets;
|
|
private final Rect mLastBaseInnerInsetsRect;
|
|
@NonNull
|
|
private WindowInsetsCompat mLastInnerInsets;
|
|
private final Rect mLastInnerInsetsRect;
|
|
private int mLastSystemUiVisibility;
|
|
private boolean mOverlayMode;
|
|
private final NestedScrollingParentHelper mParentHelper;
|
|
private final Runnable mRemoveActionBarHideOffset;
|
|
public final AnimatorListenerAdapter mTopAnimatorListener;
|
|
private Drawable mWindowContentOverlay;
|
|
private int mWindowVisibility;
|
|
|
|
/* renamed from: androidx.appcompat.widget.ActionBarOverlayLayout$1 reason: invalid class name */
|
|
public class AnonymousClass1 extends AnimatorListenerAdapter {
|
|
public AnonymousClass1() {
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationCancel(Animator animator) {
|
|
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
|
|
actionBarOverlayLayout.mCurrentActionBarTopAnimator = null;
|
|
actionBarOverlayLayout.mAnimatingForFling = false;
|
|
}
|
|
|
|
@Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
|
|
public void onAnimationEnd(Animator animator) {
|
|
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
|
|
actionBarOverlayLayout.mCurrentActionBarTopAnimator = null;
|
|
actionBarOverlayLayout.mAnimatingForFling = false;
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.appcompat.widget.ActionBarOverlayLayout$2 reason: invalid class name */
|
|
public class AnonymousClass2 implements Runnable {
|
|
public AnonymousClass2() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ActionBarOverlayLayout.this.haltActionBarHideOffsetAnimations();
|
|
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
|
|
actionBarOverlayLayout.mCurrentActionBarTopAnimator = actionBarOverlayLayout.mActionBarTop.animate().translationY(0.0f).setListener(ActionBarOverlayLayout.this.mTopAnimatorListener);
|
|
}
|
|
}
|
|
|
|
/* renamed from: androidx.appcompat.widget.ActionBarOverlayLayout$3 reason: invalid class name */
|
|
public class AnonymousClass3 implements Runnable {
|
|
public AnonymousClass3() {
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
ActionBarOverlayLayout.this.haltActionBarHideOffsetAnimations();
|
|
ActionBarOverlayLayout actionBarOverlayLayout = ActionBarOverlayLayout.this;
|
|
actionBarOverlayLayout.mCurrentActionBarTopAnimator = actionBarOverlayLayout.mActionBarTop.animate().translationY((float) (-ActionBarOverlayLayout.this.mActionBarTop.getHeight())).setListener(ActionBarOverlayLayout.this.mTopAnimatorListener);
|
|
}
|
|
}
|
|
|
|
public interface ActionBarVisibilityCallback {
|
|
void enableContentAnimations(boolean z2);
|
|
|
|
void hideForSystem();
|
|
|
|
void onContentScrollStarted();
|
|
|
|
void onContentScrollStopped();
|
|
|
|
void onWindowVisibilityChanged(int i);
|
|
|
|
void showForSystem();
|
|
}
|
|
|
|
public static class LayoutParams extends ViewGroup.MarginLayoutParams {
|
|
public LayoutParams(int i, int i2) {
|
|
super(i, i2);
|
|
}
|
|
|
|
public LayoutParams(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
}
|
|
|
|
public LayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
super(layoutParams);
|
|
}
|
|
|
|
public LayoutParams(ViewGroup.MarginLayoutParams marginLayoutParams) {
|
|
super(marginLayoutParams);
|
|
}
|
|
}
|
|
|
|
public ActionBarOverlayLayout(@NonNull Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
public ActionBarOverlayLayout(@NonNull Context context, @Nullable AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.mWindowVisibility = 0;
|
|
this.mBaseContentInsets = new Rect();
|
|
this.mLastBaseContentInsets = new Rect();
|
|
this.mContentInsets = new Rect();
|
|
this.mBaseInnerInsetsRect = new Rect();
|
|
this.mLastBaseInnerInsetsRect = new Rect();
|
|
this.mInnerInsetsRect = new Rect();
|
|
this.mLastInnerInsetsRect = new Rect();
|
|
WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat.CONSUMED;
|
|
this.mBaseInnerInsets = windowInsetsCompat;
|
|
this.mLastBaseInnerInsets = windowInsetsCompat;
|
|
this.mInnerInsets = windowInsetsCompat;
|
|
this.mLastInnerInsets = windowInsetsCompat;
|
|
this.mTopAnimatorListener = new AnonymousClass1();
|
|
this.mRemoveActionBarHideOffset = new AnonymousClass2();
|
|
this.mAddActionBarHideOffset = new AnonymousClass3();
|
|
init(context);
|
|
this.mParentHelper = new NestedScrollingParentHelper(this);
|
|
}
|
|
|
|
private void addActionBarHideOffset() {
|
|
haltActionBarHideOffsetAnimations();
|
|
this.mAddActionBarHideOffset.run();
|
|
}
|
|
|
|
private boolean applyInsets(@NonNull View view, @NonNull Rect rect, boolean z2, boolean z3, boolean z4, boolean z5) {
|
|
boolean z6;
|
|
int i;
|
|
int i2;
|
|
int i3;
|
|
int i4;
|
|
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
|
|
if (!z2 || ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin == (i4 = rect.left)) {
|
|
z6 = false;
|
|
} else {
|
|
((ViewGroup.MarginLayoutParams) layoutParams).leftMargin = i4;
|
|
z6 = true;
|
|
}
|
|
if (z3 && ((ViewGroup.MarginLayoutParams) layoutParams).topMargin != (i3 = rect.top)) {
|
|
((ViewGroup.MarginLayoutParams) layoutParams).topMargin = i3;
|
|
z6 = true;
|
|
}
|
|
if (z5 && ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin != (i2 = rect.right)) {
|
|
((ViewGroup.MarginLayoutParams) layoutParams).rightMargin = i2;
|
|
z6 = true;
|
|
}
|
|
if (!z4 || ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin == (i = rect.bottom)) {
|
|
return z6;
|
|
}
|
|
((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin = i;
|
|
return true;
|
|
}
|
|
|
|
private DecorToolbar getDecorToolbar(View view) {
|
|
if (view instanceof DecorToolbar) {
|
|
return (DecorToolbar) view;
|
|
}
|
|
if (view instanceof Toolbar) {
|
|
return ((Toolbar) view).getWrapper();
|
|
}
|
|
StringBuilder L = a.L("Can't make a decor toolbar out of ");
|
|
L.append(view.getClass().getSimpleName());
|
|
throw new IllegalStateException(L.toString());
|
|
}
|
|
|
|
private void init(Context context) {
|
|
TypedArray obtainStyledAttributes = getContext().getTheme().obtainStyledAttributes(ATTRS);
|
|
boolean z2 = false;
|
|
this.mActionBarHeight = obtainStyledAttributes.getDimensionPixelSize(0, 0);
|
|
Drawable drawable = obtainStyledAttributes.getDrawable(1);
|
|
this.mWindowContentOverlay = drawable;
|
|
setWillNotDraw(drawable == null);
|
|
obtainStyledAttributes.recycle();
|
|
if (context.getApplicationInfo().targetSdkVersion < 19) {
|
|
z2 = true;
|
|
}
|
|
this.mIgnoreWindowContentOverlay = z2;
|
|
this.mFlingEstimator = new OverScroller(context);
|
|
}
|
|
|
|
private void postAddActionBarHideOffset() {
|
|
haltActionBarHideOffsetAnimations();
|
|
postDelayed(this.mAddActionBarHideOffset, 600);
|
|
}
|
|
|
|
private void postRemoveActionBarHideOffset() {
|
|
haltActionBarHideOffsetAnimations();
|
|
postDelayed(this.mRemoveActionBarHideOffset, 600);
|
|
}
|
|
|
|
private void removeActionBarHideOffset() {
|
|
haltActionBarHideOffsetAnimations();
|
|
this.mRemoveActionBarHideOffset.run();
|
|
}
|
|
|
|
private boolean shouldHideActionBarOnFling(float f) {
|
|
this.mFlingEstimator.fling(0, 0, 0, (int) f, 0, 0, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
|
return this.mFlingEstimator.getFinalY() > this.mActionBarTop.getHeight();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean canShowOverflowMenu() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.canShowOverflowMenu();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean checkLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return layoutParams instanceof LayoutParams;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void dismissPopups() {
|
|
pullChildren();
|
|
this.mDecorToolbar.dismissPopupMenus();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void draw(Canvas canvas) {
|
|
int i;
|
|
super.draw(canvas);
|
|
if (this.mWindowContentOverlay != null && !this.mIgnoreWindowContentOverlay) {
|
|
if (this.mActionBarTop.getVisibility() == 0) {
|
|
i = (int) (this.mActionBarTop.getTranslationY() + ((float) this.mActionBarTop.getBottom()) + 0.5f);
|
|
} else {
|
|
i = 0;
|
|
}
|
|
this.mWindowContentOverlay.setBounds(0, i, getWidth(), this.mWindowContentOverlay.getIntrinsicHeight() + i);
|
|
this.mWindowContentOverlay.draw(canvas);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public boolean fitSystemWindows(Rect rect) {
|
|
return super.fitSystemWindows(rect);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public LayoutParams generateDefaultLayoutParams() {
|
|
return new LayoutParams(-1, -1);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams layoutParams) {
|
|
return new LayoutParams(layoutParams);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public LayoutParams generateLayoutParams(AttributeSet attributeSet) {
|
|
return new LayoutParams(getContext(), attributeSet);
|
|
}
|
|
|
|
public int getActionBarHideOffset() {
|
|
ActionBarContainer actionBarContainer = this.mActionBarTop;
|
|
if (actionBarContainer != null) {
|
|
return -((int) actionBarContainer.getTranslationY());
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, androidx.core.view.NestedScrollingParent
|
|
public int getNestedScrollAxes() {
|
|
return this.mParentHelper.getNestedScrollAxes();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public CharSequence getTitle() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.getTitle();
|
|
}
|
|
|
|
public void haltActionBarHideOffsetAnimations() {
|
|
removeCallbacks(this.mRemoveActionBarHideOffset);
|
|
removeCallbacks(this.mAddActionBarHideOffset);
|
|
ViewPropertyAnimator viewPropertyAnimator = this.mCurrentActionBarTopAnimator;
|
|
if (viewPropertyAnimator != null) {
|
|
viewPropertyAnimator.cancel();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean hasIcon() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.hasIcon();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean hasLogo() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.hasLogo();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean hideOverflowMenu() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.hideOverflowMenu();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void initFeature(int i) {
|
|
pullChildren();
|
|
if (i == 2) {
|
|
this.mDecorToolbar.initProgress();
|
|
} else if (i == 5) {
|
|
this.mDecorToolbar.initIndeterminateProgress();
|
|
} else if (i == 109) {
|
|
setOverlayMode(true);
|
|
}
|
|
}
|
|
|
|
public boolean isHideOnContentScrollEnabled() {
|
|
return this.mHideOnContentScroll;
|
|
}
|
|
|
|
public boolean isInOverlayMode() {
|
|
return this.mOverlayMode;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean isOverflowMenuShowPending() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.isOverflowMenuShowPending();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean isOverflowMenuShowing() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.isOverflowMenuShowing();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
@RequiresApi(21)
|
|
public WindowInsets onApplyWindowInsets(@NonNull WindowInsets windowInsets) {
|
|
pullChildren();
|
|
WindowInsetsCompat windowInsetsCompat = WindowInsetsCompat.toWindowInsetsCompat(windowInsets);
|
|
boolean applyInsets = applyInsets(this.mActionBarTop, new Rect(windowInsetsCompat.getSystemWindowInsetLeft(), windowInsetsCompat.getSystemWindowInsetTop(), windowInsetsCompat.getSystemWindowInsetRight(), windowInsetsCompat.getSystemWindowInsetBottom()), true, true, false, true);
|
|
ViewCompat.computeSystemWindowInsets(this, windowInsetsCompat, this.mBaseContentInsets);
|
|
Rect rect = this.mBaseContentInsets;
|
|
WindowInsetsCompat inset = windowInsetsCompat.inset(rect.left, rect.top, rect.right, rect.bottom);
|
|
this.mBaseInnerInsets = inset;
|
|
boolean z2 = true;
|
|
if (!this.mLastBaseInnerInsets.equals(inset)) {
|
|
this.mLastBaseInnerInsets = this.mBaseInnerInsets;
|
|
applyInsets = true;
|
|
}
|
|
if (!this.mLastBaseContentInsets.equals(this.mBaseContentInsets)) {
|
|
this.mLastBaseContentInsets.set(this.mBaseContentInsets);
|
|
} else {
|
|
z2 = applyInsets;
|
|
}
|
|
if (z2) {
|
|
requestLayout();
|
|
}
|
|
return windowInsetsCompat.consumeDisplayCutout().consumeSystemWindowInsets().consumeStableInsets().toWindowInsets();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onConfigurationChanged(Configuration configuration) {
|
|
super.onConfigurationChanged(configuration);
|
|
init(getContext());
|
|
ViewCompat.requestApplyInsets(this);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void onDetachedFromWindow() {
|
|
super.onDetachedFromWindow();
|
|
haltActionBarHideOffsetAnimations();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void onLayout(boolean z2, int i, int i2, int i3, int i4) {
|
|
int childCount = getChildCount();
|
|
int paddingLeft = getPaddingLeft();
|
|
int paddingTop = getPaddingTop();
|
|
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
|
|
public void onMeasure(int i, int i2) {
|
|
int i3;
|
|
pullChildren();
|
|
measureChildWithMargins(this.mActionBarTop, i, 0, i2, 0);
|
|
LayoutParams layoutParams = (LayoutParams) this.mActionBarTop.getLayoutParams();
|
|
int max = Math.max(0, this.mActionBarTop.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) layoutParams).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams).rightMargin);
|
|
int max2 = Math.max(0, this.mActionBarTop.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin);
|
|
int combineMeasuredStates = View.combineMeasuredStates(0, this.mActionBarTop.getMeasuredState());
|
|
boolean z2 = (ViewCompat.getWindowSystemUiVisibility(this) & 256) != 0;
|
|
if (z2) {
|
|
i3 = this.mActionBarHeight;
|
|
if (this.mHasNonEmbeddedTabs && this.mActionBarTop.getTabContainer() != null) {
|
|
i3 += this.mActionBarHeight;
|
|
}
|
|
} else {
|
|
i3 = this.mActionBarTop.getVisibility() != 8 ? this.mActionBarTop.getMeasuredHeight() : 0;
|
|
}
|
|
this.mContentInsets.set(this.mBaseContentInsets);
|
|
WindowInsetsCompat windowInsetsCompat = this.mBaseInnerInsets;
|
|
this.mInnerInsets = windowInsetsCompat;
|
|
if (this.mOverlayMode || z2) {
|
|
this.mInnerInsets = new WindowInsetsCompat.Builder(this.mInnerInsets).setSystemWindowInsets(Insets.of(windowInsetsCompat.getSystemWindowInsetLeft(), this.mInnerInsets.getSystemWindowInsetTop() + i3, this.mInnerInsets.getSystemWindowInsetRight(), this.mInnerInsets.getSystemWindowInsetBottom() + 0)).build();
|
|
} else {
|
|
Rect rect = this.mContentInsets;
|
|
rect.top += i3;
|
|
rect.bottom += 0;
|
|
this.mInnerInsets = windowInsetsCompat.inset(0, i3, 0, 0);
|
|
}
|
|
applyInsets(this.mContent, this.mContentInsets, true, true, true, true);
|
|
if (!this.mLastInnerInsets.equals(this.mInnerInsets)) {
|
|
WindowInsetsCompat windowInsetsCompat2 = this.mInnerInsets;
|
|
this.mLastInnerInsets = windowInsetsCompat2;
|
|
ViewCompat.dispatchApplyWindowInsets(this.mContent, windowInsetsCompat2);
|
|
}
|
|
measureChildWithMargins(this.mContent, i, 0, i2, 0);
|
|
LayoutParams layoutParams2 = (LayoutParams) this.mContent.getLayoutParams();
|
|
int max3 = Math.max(max, this.mContent.getMeasuredWidth() + ((ViewGroup.MarginLayoutParams) layoutParams2).leftMargin + ((ViewGroup.MarginLayoutParams) layoutParams2).rightMargin);
|
|
int max4 = Math.max(max2, this.mContent.getMeasuredHeight() + ((ViewGroup.MarginLayoutParams) layoutParams2).topMargin + ((ViewGroup.MarginLayoutParams) layoutParams2).bottomMargin);
|
|
int combineMeasuredStates2 = View.combineMeasuredStates(combineMeasuredStates, this.mContent.getMeasuredState());
|
|
setMeasuredDimension(View.resolveSizeAndState(Math.max(getPaddingRight() + getPaddingLeft() + max3, getSuggestedMinimumWidth()), i, combineMeasuredStates2), View.resolveSizeAndState(Math.max(getPaddingBottom() + getPaddingTop() + max4, 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 z2) {
|
|
if (!this.mHideOnContentScroll || !z2) {
|
|
return false;
|
|
}
|
|
if (shouldHideActionBarOnFling(f2)) {
|
|
addActionBarHideOffset();
|
|
} else {
|
|
removeActionBarHideOffset();
|
|
}
|
|
this.mAnimatingForFling = 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 // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedPreScroll(View view, int i, int i2, int[] iArr, int i3) {
|
|
if (i3 == 0) {
|
|
onNestedPreScroll(view, i, i2, 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) {
|
|
int i5 = this.mHideOnContentScrollReference + i2;
|
|
this.mHideOnContentScrollReference = i5;
|
|
setActionBarHideOffset(i5);
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5) {
|
|
if (i5 == 0) {
|
|
onNestedScroll(view, i, i2, i3, i4);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent3
|
|
public void onNestedScroll(View view, int i, int i2, int i3, int i4, int i5, int[] iArr) {
|
|
onNestedScroll(view, i, i2, i3, i4, i5);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
|
|
public void onNestedScrollAccepted(View view, View view2, int i) {
|
|
this.mParentHelper.onNestedScrollAccepted(view, view2, i);
|
|
this.mHideOnContentScrollReference = getActionBarHideOffset();
|
|
haltActionBarHideOffsetAnimations();
|
|
ActionBarVisibilityCallback actionBarVisibilityCallback = this.mActionBarVisibilityCallback;
|
|
if (actionBarVisibilityCallback != null) {
|
|
actionBarVisibilityCallback.onContentScrollStarted();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onNestedScrollAccepted(View view, View view2, int i, int i2) {
|
|
if (i2 == 0) {
|
|
onNestedScrollAccepted(view, view2, i);
|
|
}
|
|
}
|
|
|
|
@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.mActionBarTop.getVisibility() != 0) {
|
|
return false;
|
|
}
|
|
return this.mHideOnContentScroll;
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public boolean onStartNestedScroll(View view, View view2, int i, int i2) {
|
|
return i2 == 0 && onStartNestedScroll(view, view2, i);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.ViewParent, androidx.core.view.NestedScrollingParent
|
|
public void onStopNestedScroll(View view) {
|
|
if (this.mHideOnContentScroll && !this.mAnimatingForFling) {
|
|
if (this.mHideOnContentScrollReference <= this.mActionBarTop.getHeight()) {
|
|
postRemoveActionBarHideOffset();
|
|
} else {
|
|
postAddActionBarHideOffset();
|
|
}
|
|
}
|
|
ActionBarVisibilityCallback actionBarVisibilityCallback = this.mActionBarVisibilityCallback;
|
|
if (actionBarVisibilityCallback != null) {
|
|
actionBarVisibilityCallback.onContentScrollStopped();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.core.view.NestedScrollingParent2
|
|
public void onStopNestedScroll(View view, int i) {
|
|
if (i == 0) {
|
|
onStopNestedScroll(view);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowSystemUiVisibilityChanged(int i) {
|
|
super.onWindowSystemUiVisibilityChanged(i);
|
|
pullChildren();
|
|
int i2 = this.mLastSystemUiVisibility ^ i;
|
|
this.mLastSystemUiVisibility = i;
|
|
boolean z2 = false;
|
|
boolean z3 = (i & 4) == 0;
|
|
if ((i & 256) != 0) {
|
|
z2 = true;
|
|
}
|
|
ActionBarVisibilityCallback actionBarVisibilityCallback = this.mActionBarVisibilityCallback;
|
|
if (actionBarVisibilityCallback != null) {
|
|
actionBarVisibilityCallback.enableContentAnimations(!z2);
|
|
if (z3 || !z2) {
|
|
this.mActionBarVisibilityCallback.showForSystem();
|
|
} else {
|
|
this.mActionBarVisibilityCallback.hideForSystem();
|
|
}
|
|
}
|
|
if ((i2 & 256) != 0 && this.mActionBarVisibilityCallback != null) {
|
|
ViewCompat.requestApplyInsets(this);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowVisibilityChanged(int i) {
|
|
super.onWindowVisibilityChanged(i);
|
|
this.mWindowVisibility = i;
|
|
ActionBarVisibilityCallback actionBarVisibilityCallback = this.mActionBarVisibilityCallback;
|
|
if (actionBarVisibilityCallback != null) {
|
|
actionBarVisibilityCallback.onWindowVisibilityChanged(i);
|
|
}
|
|
}
|
|
|
|
public void pullChildren() {
|
|
if (this.mContent == null) {
|
|
this.mContent = (ContentFrameLayout) findViewById(R.id.action_bar_activity_content);
|
|
this.mActionBarTop = (ActionBarContainer) findViewById(R.id.action_bar_container);
|
|
this.mDecorToolbar = getDecorToolbar(findViewById(R.id.action_bar));
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void restoreToolbarHierarchyState(SparseArray<Parcelable> sparseArray) {
|
|
pullChildren();
|
|
this.mDecorToolbar.restoreHierarchyState(sparseArray);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void saveToolbarHierarchyState(SparseArray<Parcelable> sparseArray) {
|
|
pullChildren();
|
|
this.mDecorToolbar.saveHierarchyState(sparseArray);
|
|
}
|
|
|
|
public void setActionBarHideOffset(int i) {
|
|
haltActionBarHideOffsetAnimations();
|
|
this.mActionBarTop.setTranslationY((float) (-Math.max(0, Math.min(i, this.mActionBarTop.getHeight()))));
|
|
}
|
|
|
|
public void setActionBarVisibilityCallback(ActionBarVisibilityCallback actionBarVisibilityCallback) {
|
|
this.mActionBarVisibilityCallback = actionBarVisibilityCallback;
|
|
if (getWindowToken() != null) {
|
|
this.mActionBarVisibilityCallback.onWindowVisibilityChanged(this.mWindowVisibility);
|
|
int i = this.mLastSystemUiVisibility;
|
|
if (i != 0) {
|
|
onWindowSystemUiVisibilityChanged(i);
|
|
ViewCompat.requestApplyInsets(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setHasNonEmbeddedTabs(boolean z2) {
|
|
this.mHasNonEmbeddedTabs = z2;
|
|
}
|
|
|
|
public void setHideOnContentScrollEnabled(boolean z2) {
|
|
if (z2 != this.mHideOnContentScroll) {
|
|
this.mHideOnContentScroll = z2;
|
|
if (!z2) {
|
|
haltActionBarHideOffsetAnimations();
|
|
setActionBarHideOffset(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setIcon(int i) {
|
|
pullChildren();
|
|
this.mDecorToolbar.setIcon(i);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setIcon(Drawable drawable) {
|
|
pullChildren();
|
|
this.mDecorToolbar.setIcon(drawable);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setLogo(int i) {
|
|
pullChildren();
|
|
this.mDecorToolbar.setLogo(i);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setMenu(Menu menu, MenuPresenter.Callback callback) {
|
|
pullChildren();
|
|
this.mDecorToolbar.setMenu(menu, callback);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setMenuPrepared() {
|
|
pullChildren();
|
|
this.mDecorToolbar.setMenuPrepared();
|
|
}
|
|
|
|
public void setOverlayMode(boolean z2) {
|
|
this.mOverlayMode = z2;
|
|
this.mIgnoreWindowContentOverlay = z2 && getContext().getApplicationInfo().targetSdkVersion < 19;
|
|
}
|
|
|
|
public void setShowingForActionMode(boolean z2) {
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setUiOptions(int i) {
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setWindowCallback(Window.Callback callback) {
|
|
pullChildren();
|
|
this.mDecorToolbar.setWindowCallback(callback);
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public void setWindowTitle(CharSequence charSequence) {
|
|
pullChildren();
|
|
this.mDecorToolbar.setWindowTitle(charSequence);
|
|
}
|
|
|
|
@Override // android.view.ViewGroup
|
|
public boolean shouldDelayChildPressedState() {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.DecorContentParent
|
|
public boolean showOverflowMenu() {
|
|
pullChildren();
|
|
return this.mDecorToolbar.showOverflowMenu();
|
|
}
|
|
}
|