Rabbit-R1/switch port/java/sources/androidx/appcompat/app/ActionBarDrawerToggleHoneycomb.java
2024-05-21 17:08:36 -04:00

87 lines
3.6 KiB
Java

package androidx.appcompat.app;
import android.R;
import android.app.Activity;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
class ActionBarDrawerToggleHoneycomb {
private static final String TAG = "ActionBarDrawerToggleHC";
private static final int[] THEME_ATTRS = {R.attr.homeAsUpIndicator};
public static SetIndicatorInfo setActionBarUpIndicator(Activity activity, Drawable drawable, int i) {
SetIndicatorInfo setIndicatorInfo = new SetIndicatorInfo(activity);
if (setIndicatorInfo.setHomeAsUpIndicator != null) {
try {
android.app.ActionBar actionBar = activity.getActionBar();
setIndicatorInfo.setHomeAsUpIndicator.invoke(actionBar, drawable);
setIndicatorInfo.setHomeActionContentDescription.invoke(actionBar, Integer.valueOf(i));
} catch (Exception e) {
Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
}
} else if (setIndicatorInfo.upIndicatorView != null) {
setIndicatorInfo.upIndicatorView.setImageDrawable(drawable);
} else {
Log.w(TAG, "Couldn't set home-as-up indicator");
}
return setIndicatorInfo;
}
public static SetIndicatorInfo setActionBarDescription(SetIndicatorInfo setIndicatorInfo, Activity activity, int i) {
if (setIndicatorInfo == null) {
setIndicatorInfo = new SetIndicatorInfo(activity);
}
if (setIndicatorInfo.setHomeAsUpIndicator != null) {
try {
setIndicatorInfo.setHomeActionContentDescription.invoke(activity.getActionBar(), Integer.valueOf(i));
} catch (Exception e) {
Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
}
}
return setIndicatorInfo;
}
public static Drawable getThemeUpIndicator(Activity activity) {
TypedArray obtainStyledAttributes = activity.obtainStyledAttributes(THEME_ATTRS);
Drawable drawable = obtainStyledAttributes.getDrawable(0);
obtainStyledAttributes.recycle();
return drawable;
}
/* loaded from: classes.dex */
static class SetIndicatorInfo {
public Method setHomeActionContentDescription;
public Method setHomeAsUpIndicator;
public ImageView upIndicatorView;
SetIndicatorInfo(Activity activity) {
try {
this.setHomeAsUpIndicator = android.app.ActionBar.class.getDeclaredMethod("setHomeAsUpIndicator", Drawable.class);
this.setHomeActionContentDescription = android.app.ActionBar.class.getDeclaredMethod("setHomeActionContentDescription", Integer.TYPE);
} catch (NoSuchMethodException unused) {
View findViewById = activity.findViewById(R.id.home);
if (findViewById == null) {
return;
}
ViewGroup viewGroup = (ViewGroup) findViewById.getParent();
if (viewGroup.getChildCount() != 2) {
return;
}
View childAt = viewGroup.getChildAt(0);
childAt = childAt.getId() == 16908332 ? viewGroup.getChildAt(1) : childAt;
if (childAt instanceof ImageView) {
this.upIndicatorView = (ImageView) childAt;
}
}
}
}
private ActionBarDrawerToggleHoneycomb() {
}
}