use of com.android.ide.common.rendering.api.RenderResources in project android_frameworks_base by ResurrectionRemix.
the class CustomBar method getResourceValue.
private ResourceValue getResourceValue(String reference) {
RenderResources res = getContext().getRenderResources();
// find the resource
ResourceValue value = res.findResValue(reference, false);
// resolve it if needed
return res.resolveResValue(value);
}
use of com.android.ide.common.rendering.api.RenderResources in project android_frameworks_base by ResurrectionRemix.
the class AppCompatActionBar method getInflater.
@Override
protected LayoutInflater getInflater(BridgeContext context) {
// Other than the resource resolution part, the code has been taken from the support
// library. see code from line 269 onwards in
// https://android.googlesource.com/platform/frameworks/support/+/android-5.1.0_r1/v7/appcompat/src/android/support/v7/app/ActionBarActivityDelegateBase.java
Context themedContext = context;
RenderResources resources = context.getRenderResources();
ResourceValue actionBarTheme = resources.findItemInTheme("actionBarTheme", false);
if (actionBarTheme != null) {
// resolve it, if needed.
actionBarTheme = resources.resolveResValue(actionBarTheme);
}
if (actionBarTheme instanceof StyleResourceValue) {
int styleId = context.getDynamicIdByStyle(((StyleResourceValue) actionBarTheme));
if (styleId != 0) {
themedContext = new ContextThemeWrapper(context, styleId);
}
}
return LayoutInflater.from(themedContext);
}
use of com.android.ide.common.rendering.api.RenderResources in project android_frameworks_base by ResurrectionRemix.
the class AppCompatActionBar method getDrawable.
// TODO: this is duplicated from FrameworkActionBarWrapper$WindowActionBarWrapper
@Nullable
private Drawable getDrawable(@NonNull String name, boolean isFramework) {
RenderResources res = mBridgeContext.getRenderResources();
ResourceValue value = res.findResValue(name, isFramework);
value = res.resolveResValue(value);
if (value != null) {
return ResourceHelper.getDrawable(value, mBridgeContext);
}
return null;
}
use of com.android.ide.common.rendering.api.RenderResources in project android_frameworks_base by ResurrectionRemix.
the class BridgeActionBar method setTitle.
private void setTitle() {
RenderResources res = mBridgeContext.getRenderResources();
String title = mParams.getAppLabel();
ResourceValue titleValue = res.findResValue(title, false);
if (titleValue != null && titleValue.getValue() != null) {
setTitle(titleValue.getValue());
} else {
setTitle(title);
}
}
use of com.android.ide.common.rendering.api.RenderResources in project android_frameworks_base by ResurrectionRemix.
the class CustomBar method getBarColor.
/**
* Find the background color for this bar from the theme attributes. Only relevant to StatusBar
* and NavigationBar.
* <p/>
* Returns 0 if not found.
*
* @param colorAttrName the attribute name for the background color
* @param translucentAttrName the attribute name for the translucency property of the bar.
*
* @throws NumberFormatException if color resolved to an invalid string.
*/
protected int getBarColor(@NonNull String colorAttrName, @NonNull String translucentAttrName) {
if (!Config.isGreaterOrEqual(mSimulatedPlatformVersion, LOLLIPOP)) {
return 0;
}
RenderResources renderResources = getContext().getRenderResources();
// First check if the bar is translucent.
boolean translucent = ResourceHelper.getBooleanThemeValue(renderResources, translucentAttrName, true, false);
if (translucent) {
// 40% black.
return 0x66000000;
}
boolean transparent = ResourceHelper.getBooleanThemeValue(renderResources, "windowDrawsSystemBarBackgrounds", true, false);
if (transparent) {
return getColor(renderResources, colorAttrName);
}
return 0;
}
Aggregations