Java Code Examples for com.dd.plist.NSString#getContent()

The following examples show how to use com.dd.plist.NSString#getContent() . 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: IpaLoader.java    From unidbg with Apache License 2.0 5 votes vote down vote up
private static String parseExecutable(File ipa, String appDir) throws IOException {
    try {
        byte[] data = loadZip(ipa, appDir + "Info.plist");
        if (data == null) {
            throw new IllegalStateException("Find Info.plist failed");
        }
        NSDictionary info = (NSDictionary) PropertyListParser.parse(data);
        NSString bundleExecutable = (NSString) info.get("CFBundleExecutable");
        return bundleExecutable.getContent();
    } catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("load ipa failed", e);
    }
}
 
Example 2
Source File: IpaLoader.java    From unidbg with Apache License 2.0 5 votes vote down vote up
private static String parseVersion(File ipa, String appDir) throws IOException {
    try {
        byte[] data = loadZip(ipa, appDir + "Info.plist");
        if (data == null) {
            throw new IllegalStateException("Find Info.plist failed");
        }
        NSDictionary info = (NSDictionary) PropertyListParser.parse(data);
        NSString bundleVersion = (NSString) info.get("CFBundleVersion");
        return bundleVersion.getContent();
    } catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("load ipa failed", e);
    }
}
 
Example 3
Source File: IpaLoader.java    From unidbg with Apache License 2.0 5 votes vote down vote up
private static String parseCFBundleIdentifier(File ipa, String appDir) throws IOException {
    try {
        byte[] data = loadZip(ipa, appDir + "Info.plist");
        if (data == null) {
            throw new IllegalStateException("Find Info.plist failed");
        }
        NSDictionary info = (NSDictionary) PropertyListParser.parse(data);
        NSString bundleIdentifier = (NSString) info.get("CFBundleIdentifier");
        return bundleIdentifier.getContent();
    } catch (PropertyListFormatException | ParseException | ParserConfigurationException | SAXException e) {
        throw new IllegalStateException("load ipa failed", e);
    }
}
 
Example 4
Source File: ColorParser.java    From Alite with GNU General Public License v3.0 4 votes vote down vote up
private static long getColorFromOXPString(NSString colorString) {
	String color = colorString.getContent();
	String [] colorValues = color.split(" ");
	if (colorValues.length == 1) {
		// Check for color names
		String c = color.toLowerCase(Locale.getDefault()).trim();
		if (c.endsWith("color")) {
			if ("blackcolor".equals(c)) return AliteColors.convertRgba(0, 0, 0, 1);
			if ("darkgraycolor".equals(c)) return AliteColors.convertRgba(0.33f, 0.33f, 0.33f, 1);
			if ("lightgraycolor".equals(c)) return AliteColors.convertRgba(0.66f, 0.66f, 0.66f, 1);
			if ("whitecolor".equals(c)) return AliteColors.convertRgba(1, 1, 1, 1);
			if ("graycolor".equals(c)) return AliteColors.convertRgba(0.5f, 0.5f, 0.5f, 1);
			if ("redcolor".equals(c)) return AliteColors.convertRgba(1, 0, 0, 1);
			if ("greencolor".equals(c)) return AliteColors.convertRgba(0, 1, 0, 1);
			if ("bluecolor".equals(c)) return AliteColors.convertRgba(0, 0, 1, 1);
			if ("cyancolor".equals(c)) return AliteColors.convertRgba(0, 1, 1, 1);
			if ("yellowcolor".equals(c)) return AliteColors.convertRgba(1, 1, 0, 1);
			if ("magentacolor".equals(c)) return AliteColors.convertRgba(1, 0, 1, 1);
			if ("orangecolor".equals(c)) return AliteColors.convertRgba(1, 0.5f, 0, 1);
			if ("purplecolor".equals(c)) return AliteColors.convertRgba(0.5f, 0, 0.5f, 1);
			if ("browncolor".equals(c)) return AliteColors.convertRgba(0.6f, 0.4f, 0.2f, 1);
			if ("clearcolor".equals(c)) return AliteColors.convertRgba(0, 0, 0, 0);
		}
		float r = parseStringColor(colorValues[0]);
		if (r > 1) {
			r /= 255.0f;
		}
		return AliteColors.convertRgba(r, 0, 0, 1);
	}
	float r = 0, g = 0, b = 0, a = 1;
	if (colorValues.length > 0) {
		r = parseStringColor(colorValues[0]);
	}
	if (colorValues.length > 1) {
		g = parseStringColor(colorValues[1]);
	}

	if (colorValues.length > 2) {
		b = parseStringColor(colorValues[2]);
	}

	if (colorValues.length > 3) {
		a = parseStringColor(colorValues[3]);
	}
	if (r <= 1.0f && g <= 1.0f && b <= 1.0f && a <= 1.0f) {
		return AliteColors.convertRgba(r, g, b, a);
	} 
	if (colorValues.length <= 3) {
		a = 255.0f;
	}
	return AliteColors.convertRgba(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
}