package androidx.appcompat.widget; import android.R; import android.content.Context; import android.graphics.drawable.Drawable; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.view.ViewParent; import android.view.Window; import androidx.appcompat.R$attr; import androidx.appcompat.R$drawable; import androidx.appcompat.R$id; import androidx.appcompat.R$string; import androidx.appcompat.R$styleable; import androidx.appcompat.content.res.AppCompatResources; import androidx.appcompat.view.menu.ActionMenuItem; import androidx.appcompat.view.menu.MenuBuilder; import androidx.appcompat.view.menu.MenuPresenter; import androidx.appcompat.widget.Toolbar; import androidx.core.view.ViewCompat; import androidx.core.view.ViewPropertyAnimatorCompat; import androidx.core.view.ViewPropertyAnimatorListenerAdapter; /* loaded from: classes.dex */ public class ToolbarWidgetWrapper implements DecorToolbar { Toolbar a; private int b; private View c; private View d; private Drawable e; private Drawable f; private Drawable g; private boolean h; CharSequence i; private CharSequence j; private CharSequence k; Window.Callback l; boolean m; private ActionMenuPresenter n; private int o; private int p; private Drawable q; public ToolbarWidgetWrapper(Toolbar toolbar, boolean z) { this(toolbar, z, R$string.abc_action_bar_up_description, R$drawable.abc_ic_ab_back_material); } private int p() { if (this.a.getNavigationIcon() == null) { return 11; } this.q = this.a.getNavigationIcon(); return 15; } private void q() { if ((this.b & 4) != 0) { if (TextUtils.isEmpty(this.k)) { this.a.setNavigationContentDescription(this.p); } else { this.a.setNavigationContentDescription(this.k); } } } private void r() { if ((this.b & 4) == 0) { this.a.setNavigationIcon((Drawable) null); return; } Toolbar toolbar = this.a; Drawable drawable = this.g; if (drawable == null) { drawable = this.q; } toolbar.setNavigationIcon(drawable); } private void s() { Drawable drawable; int i = this.b; if ((i & 2) == 0) { drawable = null; } else if ((i & 1) != 0) { drawable = this.f; if (drawable == null) { drawable = this.e; } } else { drawable = this.e; } this.a.setLogo(drawable); } public void a(Drawable drawable) { this.f = drawable; s(); } @Override // androidx.appcompat.widget.DecorToolbar public void a(boolean z) { } @Override // androidx.appcompat.widget.DecorToolbar public Context b() { return this.a.getContext(); } public void c(CharSequence charSequence) { this.h = true; d(charSequence); } @Override // androidx.appcompat.widget.DecorToolbar public void collapseActionView() { this.a.c(); } public void d(int i) { if (i == this.p) { return; } this.p = i; if (TextUtils.isEmpty(this.a.getNavigationContentDescription())) { e(this.p); } } @Override // androidx.appcompat.widget.DecorToolbar public boolean e() { return this.a.h(); } @Override // androidx.appcompat.widget.DecorToolbar public boolean f() { return this.a.g(); } @Override // androidx.appcompat.widget.DecorToolbar public boolean g() { return this.a.k(); } @Override // androidx.appcompat.widget.DecorToolbar public CharSequence getTitle() { return this.a.getTitle(); } @Override // androidx.appcompat.widget.DecorToolbar public void h() { this.a.d(); } @Override // androidx.appcompat.widget.DecorToolbar public boolean i() { return this.a.f(); } @Override // androidx.appcompat.widget.DecorToolbar public Menu j() { return this.a.getMenu(); } @Override // androidx.appcompat.widget.DecorToolbar public int k() { return this.o; } @Override // androidx.appcompat.widget.DecorToolbar public ViewGroup l() { return this.a; } @Override // androidx.appcompat.widget.DecorToolbar public int m() { return this.b; } @Override // androidx.appcompat.widget.DecorToolbar public void n() { Log.i("ToolbarWidgetWrapper", "Progress display unsupported"); } @Override // androidx.appcompat.widget.DecorToolbar public void o() { Log.i("ToolbarWidgetWrapper", "Progress display unsupported"); } @Override // androidx.appcompat.widget.DecorToolbar public void setIcon(int i) { setIcon(i != 0 ? AppCompatResources.c(b(), i) : null); } @Override // androidx.appcompat.widget.DecorToolbar public void setWindowCallback(Window.Callback callback) { this.l = callback; } @Override // androidx.appcompat.widget.DecorToolbar public void setWindowTitle(CharSequence charSequence) { if (this.h) { return; } d(charSequence); } public ToolbarWidgetWrapper(Toolbar toolbar, boolean z, int i, int i2) { Drawable drawable; this.o = 0; this.p = 0; this.a = toolbar; this.i = toolbar.getTitle(); this.j = toolbar.getSubtitle(); this.h = this.i != null; this.g = toolbar.getNavigationIcon(); TintTypedArray a = TintTypedArray.a(toolbar.getContext(), null, R$styleable.ActionBar, R$attr.actionBarStyle, 0); this.q = a.b(R$styleable.ActionBar_homeAsUpIndicator); if (z) { CharSequence e = a.e(R$styleable.ActionBar_title); if (!TextUtils.isEmpty(e)) { c(e); } CharSequence e2 = a.e(R$styleable.ActionBar_subtitle); if (!TextUtils.isEmpty(e2)) { b(e2); } Drawable b = a.b(R$styleable.ActionBar_logo); if (b != null) { a(b); } Drawable b2 = a.b(R$styleable.ActionBar_icon); if (b2 != null) { setIcon(b2); } if (this.g == null && (drawable = this.q) != null) { b(drawable); } a(a.d(R$styleable.ActionBar_displayOptions, 0)); int g = a.g(R$styleable.ActionBar_customNavigationLayout, 0); if (g != 0) { a(LayoutInflater.from(this.a.getContext()).inflate(g, (ViewGroup) this.a, false)); a(this.b | 16); } int f = a.f(R$styleable.ActionBar_height, 0); if (f > 0) { ViewGroup.LayoutParams layoutParams = this.a.getLayoutParams(); layoutParams.height = f; this.a.setLayoutParams(layoutParams); } int b3 = a.b(R$styleable.ActionBar_contentInsetStart, -1); int b4 = a.b(R$styleable.ActionBar_contentInsetEnd, -1); if (b3 >= 0 || b4 >= 0) { this.a.a(Math.max(b3, 0), Math.max(b4, 0)); } int g2 = a.g(R$styleable.ActionBar_titleTextStyle, 0); if (g2 != 0) { Toolbar toolbar2 = this.a; toolbar2.b(toolbar2.getContext(), g2); } int g3 = a.g(R$styleable.ActionBar_subtitleTextStyle, 0); if (g3 != 0) { Toolbar toolbar3 = this.a; toolbar3.a(toolbar3.getContext(), g3); } int g4 = a.g(R$styleable.ActionBar_popupTheme, 0); if (g4 != 0) { this.a.setPopupTheme(g4); } } else { this.b = p(); } a.a(); d(i); this.k = this.a.getNavigationContentDescription(); this.a.setNavigationOnClickListener(new View.OnClickListener() { // from class: androidx.appcompat.widget.ToolbarWidgetWrapper.1 final ActionMenuItem a; { this.a = new ActionMenuItem(ToolbarWidgetWrapper.this.a.getContext(), 0, R.id.home, 0, 0, ToolbarWidgetWrapper.this.i); } @Override // android.view.View.OnClickListener public void onClick(View view) { ToolbarWidgetWrapper toolbarWidgetWrapper = ToolbarWidgetWrapper.this; Window.Callback callback = toolbarWidgetWrapper.l; if (callback == null || !toolbarWidgetWrapper.m) { return; } callback.onMenuItemSelected(0, this.a); } }); } public void b(CharSequence charSequence) { this.j = charSequence; if ((this.b & 8) != 0) { this.a.setSubtitle(charSequence); } } public void e(int i) { a(i == 0 ? null : b().getString(i)); } @Override // androidx.appcompat.widget.DecorToolbar public void setIcon(Drawable drawable) { this.e = drawable; s(); } @Override // androidx.appcompat.widget.DecorToolbar public boolean a() { return this.a.i(); } @Override // androidx.appcompat.widget.DecorToolbar public void c() { this.m = true; } @Override // androidx.appcompat.widget.DecorToolbar public void a(Menu menu, MenuPresenter.Callback callback) { if (this.n == null) { this.n = new ActionMenuPresenter(this.a.getContext()); this.n.a(R$id.action_menu_presenter); } this.n.a(callback); this.a.a((MenuBuilder) menu, this.n); } @Override // androidx.appcompat.widget.DecorToolbar public void c(int i) { this.a.setVisibility(i); } private void d(CharSequence charSequence) { this.i = charSequence; if ((this.b & 8) != 0) { this.a.setTitle(charSequence); } } @Override // androidx.appcompat.widget.DecorToolbar public void b(int i) { a(i != 0 ? AppCompatResources.c(b(), i) : null); } @Override // androidx.appcompat.widget.DecorToolbar public void b(boolean z) { this.a.setCollapsible(z); } public void b(Drawable drawable) { this.g = drawable; r(); } @Override // androidx.appcompat.widget.DecorToolbar public boolean d() { return this.a.b(); } @Override // androidx.appcompat.widget.DecorToolbar public void a(int i) { View view; int i2 = this.b ^ i; this.b = i; if (i2 != 0) { if ((i2 & 4) != 0) { if ((i & 4) != 0) { q(); } r(); } if ((i2 & 3) != 0) { s(); } if ((i2 & 8) != 0) { if ((i & 8) != 0) { this.a.setTitle(this.i); this.a.setSubtitle(this.j); } else { this.a.setTitle((CharSequence) null); this.a.setSubtitle((CharSequence) null); } } if ((i2 & 16) == 0 || (view = this.d) == null) { return; } if ((i & 16) != 0) { this.a.addView(view); } else { this.a.removeView(view); } } } @Override // androidx.appcompat.widget.DecorToolbar public void a(ScrollingTabContainerView scrollingTabContainerView) { View view = this.c; if (view != null) { ViewParent parent = view.getParent(); Toolbar toolbar = this.a; if (parent == toolbar) { toolbar.removeView(this.c); } } this.c = scrollingTabContainerView; if (scrollingTabContainerView == null || this.o != 2) { return; } this.a.addView(this.c, 0); Toolbar.LayoutParams layoutParams = (Toolbar.LayoutParams) this.c.getLayoutParams(); ((ViewGroup.MarginLayoutParams) layoutParams).width = -2; ((ViewGroup.MarginLayoutParams) layoutParams).height = -2; layoutParams.a = 8388691; scrollingTabContainerView.setAllowCollapse(true); } public void a(View view) { View view2 = this.d; if (view2 != null && (this.b & 16) != 0) { this.a.removeView(view2); } this.d = view; if (view == null || (this.b & 16) == 0) { return; } this.a.addView(this.d); } @Override // androidx.appcompat.widget.DecorToolbar public ViewPropertyAnimatorCompat a(final int i, long j) { ViewPropertyAnimatorCompat a = ViewCompat.a(this.a); a.a(i == 0 ? 1.0f : 0.0f); a.a(j); a.a(new ViewPropertyAnimatorListenerAdapter() { // from class: androidx.appcompat.widget.ToolbarWidgetWrapper.2 private boolean a = false; @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener public void a(View view) { this.a = true; } @Override // androidx.core.view.ViewPropertyAnimatorListener public void b(View view) { if (this.a) { return; } ToolbarWidgetWrapper.this.a.setVisibility(i); } @Override // androidx.core.view.ViewPropertyAnimatorListenerAdapter, androidx.core.view.ViewPropertyAnimatorListener public void c(View view) { ToolbarWidgetWrapper.this.a.setVisibility(0); } }); return a; } public void a(CharSequence charSequence) { this.k = charSequence; q(); } @Override // androidx.appcompat.widget.DecorToolbar public void a(MenuPresenter.Callback callback, MenuBuilder.Callback callback2) { this.a.a(callback, callback2); } }