use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method loadThemeAttributeValue.
@HiddenApi
@Implementation(minSdk = LOLLIPOP)
protected static int loadThemeAttributeValue(long themeHandle, int ident, TypedValue outValue, boolean resolve) {
ResTableTheme theme = Preconditions.checkNotNull(Registries.NATIVE_THEME_REGISTRY.getNativeObject(themeHandle));
ResTable res = theme.getResTable();
final Ref<Res_value> value = new Ref<>(null);
// XXX value could be different in different configs!
final Ref<Integer> typeSpecFlags = new Ref<>(0);
int block = theme.GetAttribute(ident, value, typeSpecFlags);
final Ref<Integer> ref = new Ref<>(0);
if (resolve) {
block = res.resolveReference(value, block, ref, typeSpecFlags);
if (kThrowOnBadId) {
if (block == BAD_INDEX) {
throw new IllegalStateException("Bad resource!");
}
}
}
return block >= 0 ? copyValue(outValue, res, value.get(), ref.get(), block, typeSpecFlags.get(), null) : block;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowArscAssetManager method newTheme.
@HiddenApi
@Implementation
protected final Number newTheme() {
CppAssetManager am = assetManagerForJavaObject();
if (am == null) {
return RuntimeEnvironment.castNativePtr(0);
}
ResTableTheme theme = new ResTableTheme(am.getResources());
return RuntimeEnvironment.castNativePtr(Registries.NATIVE_THEME_REGISTRY.register(theme));
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowLegacyAssetManager method setConfiguration.
@HiddenApi
@Implementation(minSdk = VERSION_CODES.O)
public void setConfiguration(int mcc, int mnc, String locale, int orientation, int touchscreen, int density, int keyboard, int keyboardHidden, int navigation, int screenWidth, int screenHeight, int smallestScreenWidthDp, int screenWidthDp, int screenHeightDp, int screenLayout, int uiMode, int colorMode, int majorVersion) {
// AssetManager* am = assetManagerForJavaObject(env, clazz);
ResTable_config config = new ResTable_config();
// Constants duplicated from Java class android.content.res.Configuration.
final int kScreenLayoutRoundMask = 0x300;
final int kScreenLayoutRoundShift = 8;
config.mcc = mcc;
config.mnc = mnc;
config.orientation = orientation;
config.touchscreen = touchscreen;
config.density = density;
config.keyboard = keyboard;
config.inputFlags = keyboardHidden;
config.navigation = navigation;
config.screenWidth = screenWidth;
config.screenHeight = screenHeight;
config.smallestScreenWidthDp = smallestScreenWidthDp;
config.screenWidthDp = screenWidthDp;
config.screenHeightDp = screenHeightDp;
config.screenLayout = screenLayout;
config.uiMode = uiMode;
// config.colorMode = colorMode; // todo
config.sdkVersion = majorVersion;
config.minorVersion = 0;
// In Java, we use a 32bit integer for screenLayout, while we only use an 8bit integer
// in C++. We must extract the round qualifier out of the Java screenLayout and put it
// into screenLayout2.
config.screenLayout2 = (byte) ((screenLayout & kScreenLayoutRoundMask) >> kScreenLayoutRoundShift);
if (locale != null) {
config.setBcp47Locale(locale);
}
// am->setConfiguration(config, locale8);
this.config = config;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowLegacyAssetManager method getArrayIntResource.
@HiddenApi
@Implementation(maxSdk = O_MR1)
public int[] getArrayIntResource(int resId) {
TypedResource value = getAndResolve(resId, config, true);
if (value == null)
return null;
List<TypedResource> items = getConverter(value).getItems(value);
int[] ints = new int[items.size()];
for (int i = 0; i < items.size(); i++) {
TypedResource typedResource = resolve(items.get(i), config, resId);
ints[i] = getConverter(typedResource).asInt(typedResource);
}
return ints;
}
use of org.robolectric.annotation.HiddenApi in project robolectric by robolectric.
the class ShadowLegacyAssetManager method applyThemeStyle.
@HiddenApi
@Implementation(minSdk = LOLLIPOP, maxSdk = O_MR1)
public static void applyThemeStyle(long themePtr, int styleRes, boolean force) {
NativeTheme nativeTheme = getNativeTheme(themePtr);
Style style = nativeTheme.getShadowAssetManager().resolveStyle(styleRes, null);
nativeTheme.themeStyleSet.apply(style, force);
}
Aggregations