package androidx.appcompat.app; import android.app.ActionBar; import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import android.content.res.TypedArray; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.MenuItem; import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.appcompat.app.ActionBarDrawerToggleHoneycomb; import androidx.appcompat.graphics.drawable.DrawerArrowDrawable; import androidx.appcompat.widget.Toolbar; import androidx.core.view.GravityCompat; import androidx.drawerlayout.widget.DrawerLayout; public class ActionBarDrawerToggle implements DrawerLayout.DrawerListener { private final Delegate mActivityImpl; private final int mCloseDrawerContentDescRes; public boolean mDrawerIndicatorEnabled; private final DrawerLayout mDrawerLayout; private boolean mDrawerSlideAnimationEnabled; private boolean mHasCustomUpIndicator; private Drawable mHomeAsUpIndicator; private final int mOpenDrawerContentDescRes; private DrawerArrowDrawable mSlider; public View.OnClickListener mToolbarNavigationClickListener; private boolean mWarnedForDisplayHomeAsUp; /* renamed from: androidx.appcompat.app.ActionBarDrawerToggle$1 reason: invalid class name */ public class AnonymousClass1 implements View.OnClickListener { public AnonymousClass1() { } @Override // android.view.View.OnClickListener public void onClick(View view) { ActionBarDrawerToggle actionBarDrawerToggle = ActionBarDrawerToggle.this; if (actionBarDrawerToggle.mDrawerIndicatorEnabled) { actionBarDrawerToggle.toggle(); return; } View.OnClickListener onClickListener = actionBarDrawerToggle.mToolbarNavigationClickListener; if (onClickListener != null) { onClickListener.onClick(view); } } } public interface Delegate { Context getActionBarThemedContext(); Drawable getThemeUpIndicator(); boolean isNavigationVisible(); void setActionBarDescription(@StringRes int i); void setActionBarUpIndicator(Drawable drawable, @StringRes int i); } public interface DelegateProvider { @Nullable Delegate getDrawerToggleDelegate(); } public static class FrameworkActionBarDelegate implements Delegate { private final Activity mActivity; private ActionBarDrawerToggleHoneycomb.SetIndicatorInfo mSetIndicatorInfo; public FrameworkActionBarDelegate(Activity activity) { this.mActivity = activity; } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public Context getActionBarThemedContext() { ActionBar actionBar = this.mActivity.getActionBar(); return actionBar != null ? actionBar.getThemedContext() : this.mActivity; } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public Drawable getThemeUpIndicator() { TypedArray obtainStyledAttributes = getActionBarThemedContext().obtainStyledAttributes(null, new int[]{16843531}, 16843470, 0); Drawable drawable = obtainStyledAttributes.getDrawable(0); obtainStyledAttributes.recycle(); return drawable; } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public boolean isNavigationVisible() { ActionBar actionBar = this.mActivity.getActionBar(); return (actionBar == null || (actionBar.getDisplayOptions() & 4) == 0) ? false : true; } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public void setActionBarDescription(int i) { ActionBar actionBar = this.mActivity.getActionBar(); if (actionBar != null) { actionBar.setHomeActionContentDescription(i); } } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public void setActionBarUpIndicator(Drawable drawable, int i) { ActionBar actionBar = this.mActivity.getActionBar(); if (actionBar != null) { actionBar.setHomeAsUpIndicator(drawable); actionBar.setHomeActionContentDescription(i); } } } public static class ToolbarCompatDelegate implements Delegate { public final CharSequence mDefaultContentDescription; public final Drawable mDefaultUpIndicator; public final Toolbar mToolbar; public ToolbarCompatDelegate(Toolbar toolbar) { this.mToolbar = toolbar; this.mDefaultUpIndicator = toolbar.getNavigationIcon(); this.mDefaultContentDescription = toolbar.getNavigationContentDescription(); } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public Context getActionBarThemedContext() { return this.mToolbar.getContext(); } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public Drawable getThemeUpIndicator() { return this.mDefaultUpIndicator; } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public boolean isNavigationVisible() { return true; } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public void setActionBarDescription(@StringRes int i) { if (i == 0) { this.mToolbar.setNavigationContentDescription(this.mDefaultContentDescription); } else { this.mToolbar.setNavigationContentDescription(i); } } @Override // androidx.appcompat.app.ActionBarDrawerToggle.Delegate public void setActionBarUpIndicator(Drawable drawable, @StringRes int i) { this.mToolbar.setNavigationIcon(drawable); setActionBarDescription(i); } } public ActionBarDrawerToggle(Activity activity, Toolbar toolbar, DrawerLayout drawerLayout, DrawerArrowDrawable drawerArrowDrawable, @StringRes int i, @StringRes int i2) { this.mDrawerSlideAnimationEnabled = true; this.mDrawerIndicatorEnabled = true; this.mWarnedForDisplayHomeAsUp = false; if (toolbar != null) { this.mActivityImpl = new ToolbarCompatDelegate(toolbar); toolbar.setNavigationOnClickListener(new AnonymousClass1()); } else if (activity instanceof DelegateProvider) { this.mActivityImpl = ((DelegateProvider) activity).getDrawerToggleDelegate(); } else { this.mActivityImpl = new FrameworkActionBarDelegate(activity); } this.mDrawerLayout = drawerLayout; this.mOpenDrawerContentDescRes = i; this.mCloseDrawerContentDescRes = i2; if (drawerArrowDrawable == null) { this.mSlider = new DrawerArrowDrawable(this.mActivityImpl.getActionBarThemedContext()); } else { this.mSlider = drawerArrowDrawable; } this.mHomeAsUpIndicator = getThemeUpIndicator(); } public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, @StringRes int i, @StringRes int i2) { this(activity, null, drawerLayout, null, i, i2); } public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, @StringRes int i, @StringRes int i2) { this(activity, toolbar, drawerLayout, null, i, i2); } private void setPosition(float f) { if (f == 1.0f) { this.mSlider.setVerticalMirror(true); } else if (f == 0.0f) { this.mSlider.setVerticalMirror(false); } this.mSlider.setProgress(f); } @NonNull public DrawerArrowDrawable getDrawerArrowDrawable() { return this.mSlider; } public Drawable getThemeUpIndicator() { return this.mActivityImpl.getThemeUpIndicator(); } public View.OnClickListener getToolbarNavigationClickListener() { return this.mToolbarNavigationClickListener; } public boolean isDrawerIndicatorEnabled() { return this.mDrawerIndicatorEnabled; } public boolean isDrawerSlideAnimationEnabled() { return this.mDrawerSlideAnimationEnabled; } public void onConfigurationChanged(Configuration configuration) { if (!this.mHasCustomUpIndicator) { this.mHomeAsUpIndicator = getThemeUpIndicator(); } syncState(); } @Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener public void onDrawerClosed(View view) { setPosition(0.0f); if (this.mDrawerIndicatorEnabled) { setActionBarDescription(this.mOpenDrawerContentDescRes); } } @Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener public void onDrawerOpened(View view) { setPosition(1.0f); if (this.mDrawerIndicatorEnabled) { setActionBarDescription(this.mCloseDrawerContentDescRes); } } @Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener public void onDrawerSlide(View view, float f) { if (this.mDrawerSlideAnimationEnabled) { setPosition(Math.min(1.0f, Math.max(0.0f, f))); } else { setPosition(0.0f); } } @Override // androidx.drawerlayout.widget.DrawerLayout.DrawerListener public void onDrawerStateChanged(int i) { } public boolean onOptionsItemSelected(MenuItem menuItem) { if (menuItem == null || menuItem.getItemId() != 16908332 || !this.mDrawerIndicatorEnabled) { return false; } toggle(); return true; } public void setActionBarDescription(int i) { this.mActivityImpl.setActionBarDescription(i); } public void setActionBarUpIndicator(Drawable drawable, int i) { if (!this.mWarnedForDisplayHomeAsUp && !this.mActivityImpl.isNavigationVisible()) { Log.w("ActionBarDrawerToggle", "DrawerToggle may not show up because NavigationIcon is not visible. You may need to call actionbar.setDisplayHomeAsUpEnabled(true);"); this.mWarnedForDisplayHomeAsUp = true; } this.mActivityImpl.setActionBarUpIndicator(drawable, i); } public void setDrawerArrowDrawable(@NonNull DrawerArrowDrawable drawerArrowDrawable) { this.mSlider = drawerArrowDrawable; syncState(); } public void setDrawerIndicatorEnabled(boolean z2) { if (z2 != this.mDrawerIndicatorEnabled) { if (z2) { setActionBarUpIndicator(this.mSlider, this.mDrawerLayout.isDrawerOpen(GravityCompat.START) ? this.mCloseDrawerContentDescRes : this.mOpenDrawerContentDescRes); } else { setActionBarUpIndicator(this.mHomeAsUpIndicator, 0); } this.mDrawerIndicatorEnabled = z2; } } public void setDrawerSlideAnimationEnabled(boolean z2) { this.mDrawerSlideAnimationEnabled = z2; if (!z2) { setPosition(0.0f); } } public void setHomeAsUpIndicator(int i) { setHomeAsUpIndicator(i != 0 ? this.mDrawerLayout.getResources().getDrawable(i) : null); } public void setHomeAsUpIndicator(Drawable drawable) { if (drawable == null) { this.mHomeAsUpIndicator = getThemeUpIndicator(); this.mHasCustomUpIndicator = false; } else { this.mHomeAsUpIndicator = drawable; this.mHasCustomUpIndicator = true; } if (!this.mDrawerIndicatorEnabled) { setActionBarUpIndicator(this.mHomeAsUpIndicator, 0); } } public void setToolbarNavigationClickListener(View.OnClickListener onClickListener) { this.mToolbarNavigationClickListener = onClickListener; } public void syncState() { if (this.mDrawerLayout.isDrawerOpen(GravityCompat.START)) { setPosition(1.0f); } else { setPosition(0.0f); } if (this.mDrawerIndicatorEnabled) { setActionBarUpIndicator(this.mSlider, this.mDrawerLayout.isDrawerOpen(GravityCompat.START) ? this.mCloseDrawerContentDescRes : this.mOpenDrawerContentDescRes); } } public void toggle() { int drawerLockMode = this.mDrawerLayout.getDrawerLockMode(GravityCompat.START); if (this.mDrawerLayout.isDrawerVisible(GravityCompat.START) && drawerLockMode != 2) { this.mDrawerLayout.closeDrawer(GravityCompat.START); } else if (drawerLockMode != 1) { this.mDrawerLayout.openDrawer(GravityCompat.START); } } }