ActionBarDrawerToggleHoneycombpublic class ActionBarDrawerToggleHoneycomb extends Object This class encapsulates some awful hacks.
Before JB-MR2 (API 18) it was not possible to change the home-as-up indicator glyph
in an action bar without some really gross hacks. Since the MR2 SDK is not published as of
this writing, the new API is accessed via reflection here if available. |
Fields Summary |
---|
private static final String | TAG | private static final int[] | THEME_ATTRS |
Methods Summary |
---|
public static android.graphics.drawable.Drawable | getThemeUpIndicator(android.app.Activity activity)
final TypedArray a = activity.obtainStyledAttributes(THEME_ATTRS);
final Drawable result = a.getDrawable(0);
a.recycle();
return result;
| public static java.lang.Object | setActionBarDescription(java.lang.Object info, android.app.Activity activity, int contentDescRes)
if (info == null) {
info = new SetIndicatorInfo(activity);
}
final SetIndicatorInfo sii = (SetIndicatorInfo) info;
if (sii.setHomeAsUpIndicator != null) {
try {
final ActionBar actionBar = activity.getActionBar();
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
if (Build.VERSION.SDK_INT <= 19) {
// For API 19 and earlier, we need to manually force the
// action bar to generate a new content description.
actionBar.setSubtitle(actionBar.getSubtitle());
}
} catch (Exception e) {
Log.w(TAG, "Couldn't set content description via JB-MR2 API", e);
}
}
return info;
| public static java.lang.Object | setActionBarUpIndicator(java.lang.Object info, android.app.Activity activity, android.graphics.drawable.Drawable drawable, int contentDescRes)
if (info == null) {
info = new SetIndicatorInfo(activity);
}
final SetIndicatorInfo sii = (SetIndicatorInfo) info;
if (sii.setHomeAsUpIndicator != null) {
try {
final ActionBar actionBar = activity.getActionBar();
sii.setHomeAsUpIndicator.invoke(actionBar, drawable);
sii.setHomeActionContentDescription.invoke(actionBar, contentDescRes);
} catch (Exception e) {
Log.w(TAG, "Couldn't set home-as-up indicator via JB-MR2 API", e);
}
} else if (sii.upIndicatorView != null) {
sii.upIndicatorView.setImageDrawable(drawable);
} else {
Log.w(TAG, "Couldn't set home-as-up indicator");
}
return info;
|
|