Java Code Examples for android.util.typedvalue#TYPE_INT_BOOLEAN
The following examples show how to use
android.util.typedvalue#TYPE_INT_BOOLEAN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThemeEnforcement.java From material-components-android with Apache License 2.0 | 6 votes |
private static void checkCompatibleTheme( @NonNull Context context, AttributeSet set, @AttrRes int defStyleAttr, @StyleRes int defStyleRes) { TypedArray a = context.obtainStyledAttributes( set, R.styleable.ThemeEnforcement, defStyleAttr, defStyleRes); boolean enforceMaterialTheme = a.getBoolean(R.styleable.ThemeEnforcement_enforceMaterialTheme, false); a.recycle(); if (enforceMaterialTheme) { TypedValue isMaterialTheme = new TypedValue(); boolean resolvedValue = context.getTheme().resolveAttribute(R.attr.isMaterialTheme, isMaterialTheme, true); if (!resolvedValue || (isMaterialTheme.type == TypedValue.TYPE_INT_BOOLEAN && isMaterialTheme.data == 0)) { // If we were unable to resolve isMaterialTheme boolean attribute, or isMaterialTheme is // false, check for Material Theme color attributes checkMaterialTheme(context); } } checkAppCompatTheme(context); }
Example 2
Source File: AndroidXmlConvertor.java From ghidra with Apache License 2.0 | 5 votes |
private static String getAttributeValue(AXmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data == 0 ? "false" : "true"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>", data, type); }
Example 3
Source File: UIUtils.java From DoraemonKit with Apache License 2.0 | 5 votes |
public static boolean checkFullScreenByTheme(Context context) { Resources.Theme theme = context.getTheme(); if (theme != null) { TypedValue typedValue = new TypedValue(); boolean result = theme.resolveAttribute(android.R.attr.windowFullscreen, typedValue, false); if (result) { typedValue.coerceToString(); if (typedValue.type == TypedValue.TYPE_INT_BOOLEAN) { return typedValue.data != 0; } } } return false; }
Example 4
Source File: ScreenInfo.java From MobileInfo with Apache License 2.0 | 5 votes |
private static boolean checkFullScreenByTheme(Context context) { Resources.Theme theme = context.getTheme(); if (theme != null) { TypedValue typedValue = new TypedValue(); boolean result = theme.resolveAttribute(android.R.attr.windowFullscreen, typedValue, false); if (result) { typedValue.coerceToString(); if (typedValue.type == TypedValue.TYPE_INT_BOOLEAN) { return typedValue.data != 0; } } } return false; }
Example 5
Source File: ResValueFactory.java From ratel with Apache License 2.0 | 5 votes |
public ResScalarValue factory(int type, int value, String rawValue) throws AndrolibException { switch (type) { case TypedValue.TYPE_NULL: if (value == TypedValue.DATA_NULL_UNDEFINED) { // Special case $empty as explicitly defined empty value return new ResStringValue(null, value); } else if (value == TypedValue.DATA_NULL_EMPTY) { return new ResEmptyValue(value, rawValue, type); } return new ResReferenceValue(mPackage, 0, null); case TypedValue.TYPE_REFERENCE: return newReference(value, rawValue); case TypedValue.TYPE_ATTRIBUTE: return newReference(value, rawValue, true); case TypedValue.TYPE_STRING: return new ResStringValue(rawValue, value); case TypedValue.TYPE_FLOAT: return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue); case TypedValue.TYPE_DIMENSION: return new ResDimenValue(value, rawValue); case TypedValue.TYPE_FRACTION: return new ResFractionValue(value, rawValue); case TypedValue.TYPE_INT_BOOLEAN: return new ResBoolValue(value != 0, value, rawValue); case TypedValue.TYPE_DYNAMIC_REFERENCE: return newReference(value, rawValue); case TypedValue.TYPE_DYNAMIC_ATTRIBUTE: return newReference(value, rawValue, true); } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return new ResColorValue(value, rawValue); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return new ResIntValue(value, rawValue, type); } throw new AndrolibException("Invalid value type: " + type); }
Example 6
Source File: ResValueFactory.java From ArscEditor with Apache License 2.0 | 5 votes |
public ResScalarValue factory(int type, int value, String rawValue) throws IOException { switch (type) { case TypedValue.TYPE_NULL: return new ResReferenceValue(mPackage, 0, null); case TypedValue.TYPE_REFERENCE: return newReference(value, rawValue); case TypedValue.TYPE_ATTRIBUTE: return newReference(value, rawValue, true); case TypedValue.TYPE_STRING: return new ResStringValue(rawValue, value); case TypedValue.TYPE_FLOAT: return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue); case TypedValue.TYPE_DIMENSION: return new ResDimenValue(value, rawValue); case TypedValue.TYPE_FRACTION: return new ResFractionValue(value, rawValue); case TypedValue.TYPE_INT_BOOLEAN: return new ResBoolValue(value != 0, value, rawValue); case 0x07: return newReference(value, rawValue); } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return new ResColorValue(value, rawValue); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return new ResIntValue(value, rawValue, type); } throw new IOException("Invalid value type: " + type); }
Example 7
Source File: ResValueFactory.java From Auto.js-ApkBuilder with Apache License 2.0 | 5 votes |
public ResScalarValue factory(int type, int value, String rawValue) throws IOException { switch (type) { case TypedValue.TYPE_NULL: return new ResReferenceValue(mPackage, 0, null); case TypedValue.TYPE_REFERENCE: return newReference(value, rawValue); case TypedValue.TYPE_ATTRIBUTE: return newReference(value, rawValue, true); case TypedValue.TYPE_STRING: return new ResStringValue(rawValue, value); case TypedValue.TYPE_FLOAT: return new ResFloatValue(Float.intBitsToFloat(value), value, rawValue); case TypedValue.TYPE_DIMENSION: return new ResDimenValue(value, rawValue); case TypedValue.TYPE_FRACTION: return new ResFractionValue(value, rawValue); case TypedValue.TYPE_INT_BOOLEAN: return new ResBoolValue(value != 0, value, rawValue); case 0x07: return newReference(value, rawValue); } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return new ResColorValue(value, rawValue); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return new ResIntValue(value, rawValue, type); } throw new IOException("Invalid value type: " + type); }
Example 8
Source File: AXMLPrinter.java From LibScout with Apache License 2.0 | 5 votes |
public static String getAttributeValue(AXmlResourceParser parser,int index) { int type=parser.getAttributeValueType(index); int data=parser.getAttributeValueData(index); if (type==TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type==TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X",getPackage(data),data); } if (type==TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X",getPackage(data),data); } if (type==TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type==TypedValue.TYPE_INT_HEX) { return String.format("0x%08X",data); } if (type==TypedValue.TYPE_INT_BOOLEAN) { return data!=0?"true":"false"; } if (type==TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data))+ DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type==TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data))+ FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type>=TypedValue.TYPE_FIRST_COLOR_INT && type<=TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X",data); } if (type>=TypedValue.TYPE_FIRST_INT && type<=TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>",data,type); }
Example 9
Source File: ManifestReader.java From PluginLoader with Apache License 2.0 | 5 votes |
private static String getAttributeValue(XmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data != 0 ? "true" : "false"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>", data, type); }
Example 10
Source File: MaterialAttributes.java From material-components-android with Apache License 2.0 | 5 votes |
/** * Returns the boolean value for the provided {@code attributeResId} or {@code defaultValue} if * the attribute is not a boolean or not present in the current theme. */ public static boolean resolveBoolean( @NonNull Context context, @AttrRes int attributeResId, boolean defaultValue) { TypedValue typedValue = resolve(context, attributeResId); return (typedValue != null && typedValue.type == TypedValue.TYPE_INT_BOOLEAN) ? typedValue.data != 0 : defaultValue; }
Example 11
Source File: ResignerLogic.java From apkReSign with Apache License 2.0 | 5 votes |
private static String getAttributeValue(AXmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data != 0 ? "true" : "false"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>", data, type); }
Example 12
Source File: AXMLPrinter.java From Android-Applications-Info with Apache License 2.0 | 5 votes |
private static String getAttributeValue(AXmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data != 0 ? "true" : "false"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>", data, type); }
Example 13
Source File: ManifestReader.java From Android-Plugin-Framework with MIT License | 5 votes |
private static String getAttributeValue(XmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data != 0 ? "true" : "false"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } if (type == 0x07) { return String.format("@%s%08X", getPackage(data), data); } return String.format("<0x%X, type 0x%02X>", data, type); }
Example 14
Source File: XmlManifestReader.java From AndroidPlugin with MIT License | 5 votes |
private static String getAttributeValue(XmlResourceParser parser, int index) { int type = parser.getAttributeValueType(index); int data = parser.getAttributeValueData(index); if (type == TypedValue.TYPE_STRING) { return parser.getAttributeValue(index); } if (type == TypedValue.TYPE_ATTRIBUTE) { return String.format("?%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_REFERENCE) { return String.format("@%s%08X", getPackage(data), data); } if (type == TypedValue.TYPE_FLOAT) { return String.valueOf(Float.intBitsToFloat(data)); } if (type == TypedValue.TYPE_INT_HEX) { return String.format("0x%08X", data); } if (type == TypedValue.TYPE_INT_BOOLEAN) { return data != 0 ? "true" : "false"; } if (type == TypedValue.TYPE_DIMENSION) { return Float.toString(complexToFloat(data)) + DIMENSION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type == TypedValue.TYPE_FRACTION) { return Float.toString(complexToFloat(data)) + FRACTION_UNITS[data & TypedValue.COMPLEX_UNIT_MASK]; } if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) { return String.format("#%08X", data); } if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return String.valueOf(data); } return String.format("<0x%X, type 0x%02X>", data, type); }
Example 15
Source File: Resources.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
/** * Parse a name/value pair out of an XML tag holding that data. The * AttributeSet must be holding the data defined by * {@link android.R.styleable#Extra}. The following value types are supported: * <ul> * <li> {@link TypedValue#TYPE_STRING}: * {@link Bundle#putCharSequence Bundle.putCharSequence()} * <li> {@link TypedValue#TYPE_INT_BOOLEAN}: * {@link Bundle#putCharSequence Bundle.putBoolean()} * <li> {@link TypedValue#TYPE_FIRST_INT}-{@link TypedValue#TYPE_LAST_INT}: * {@link Bundle#putCharSequence Bundle.putBoolean()} * <li> {@link TypedValue#TYPE_FLOAT}: * {@link Bundle#putCharSequence Bundle.putFloat()} * </ul> * * @param tagName The name of the tag these attributes come from; this is * only used for reporting error messages. * @param attrs The attributes from which to retrieve the name/value pair. * @param outBundle The Bundle in which to place the parsed value. * @throws XmlPullParserException If the attributes are not valid. */ public void parseBundleExtra(String tagName, AttributeSet attrs, Bundle outBundle) throws XmlPullParserException { TypedArray sa = obtainAttributes(attrs, com.android.internal.R.styleable.Extra); String name = sa.getString( com.android.internal.R.styleable.Extra_name); if (name == null) { sa.recycle(); throw new XmlPullParserException("<" + tagName + "> requires an android:name attribute at " + attrs.getPositionDescription()); } TypedValue v = sa.peekValue( com.android.internal.R.styleable.Extra_value); if (v != null) { if (v.type == TypedValue.TYPE_STRING) { CharSequence cs = v.coerceToString(); outBundle.putCharSequence(name, cs); } else if (v.type == TypedValue.TYPE_INT_BOOLEAN) { outBundle.putBoolean(name, v.data != 0); } else if (v.type >= TypedValue.TYPE_FIRST_INT && v.type <= TypedValue.TYPE_LAST_INT) { outBundle.putInt(name, v.data); } else if (v.type == TypedValue.TYPE_FLOAT) { outBundle.putFloat(name, v.getFloat()); } else { sa.recycle(); throw new XmlPullParserException("<" + tagName + "> only supports string, integer, float, color, and boolean at " + attrs.getPositionDescription()); } } else { sa.recycle(); throw new XmlPullParserException("<" + tagName + "> requires an android:value or android:resource attribute at " + attrs.getPositionDescription()); } sa.recycle(); }