feat: support for apk

This commit is contained in:
relikd
2025-11-28 13:21:58 +01:00
parent cde957b01f
commit 591a75dabc
15 changed files with 480 additions and 15 deletions

View File

@@ -42,4 +42,81 @@ extension PreviewGenerator {
"AppMinOS": minVersion,
])
}
/// Process info stored in `Info.plist`
mutating func procAppInfoAndroid(_ appPlist: PlistDict) {
let featuresRequired = appPlist["featuresRequired"] as! [String]
let featuresOptional = appPlist["featuresOptional"] as! [String]
let permissions = appPlist["permissions"] as! [String]
func asList(_ list: [String]) -> String {
"<pre>\(list.joined(separator: "\n"))</pre>"
}
func resolveSDK(_ sdk: String?) -> String {
sdk == nil ? "" : "\(sdk!) (Android \(ANDROID_SDK_MAP[sdk!] ?? "?"))"
}
self.apply([
"AppInfoHidden": CLASS_VISIBLE,
"AppName": appPlist["appName"] as? String ?? "",
"AppVersion": appPlist["versionName"] as? String ?? "",
"AppBuildVer": appPlist["versionCode"] as? String ?? "",
"AppId": appPlist["packageId"] as? String ?? "",
"ApkFeaturesRequiredHidden": featuresRequired.isEmpty ? CLASS_HIDDEN : CLASS_VISIBLE,
"ApkFeaturesRequiredList": asList(featuresRequired),
"ApkFeaturesOptionalHidden": featuresOptional.isEmpty ? CLASS_HIDDEN : CLASS_VISIBLE,
"ApkFeaturesOptionalList": asList(featuresOptional),
"ApkPermissionsHidden": permissions.isEmpty ? CLASS_HIDDEN : CLASS_VISIBLE,
"ApkPermissionsList": asList(permissions),
"AppDeviceFamily": "Android",
"AppSDK": resolveSDK(appPlist["sdkVerTarget"] as? String),
"AppMinOS": resolveSDK(appPlist["sdkVerMin"] as? String),
])
}
}
private let ANDROID_SDK_MAP: [String: String] = [
"1": "1.0",
"2": "1.1",
"3": "1.5",
"4": "1.6",
"5": "2.0",
"6": "2.0.1",
"7": "2.1.x",
"8": "2.2.x",
"9": "2.3, 2.3.1, 2.3.2",
"10": "2.3.3, 2.3.4",
"11": "3.0.x",
"12": "3.1.x",
"13": "3.2",
"14": "4.0, 4.0.1, 4.0.2",
"15": "4.0.3, 4.0.4",
"16": "4.1, 4.1.1",
"17": "4.2, 4.2.2",
"18": "4.3",
"19": "4.4",
"20": "4.4W",
"21": "5.0",
"22": "5.1",
"23": "6.0",
"24": "7.0",
"25": "7.1, 7.1.1",
"26": "8.0",
"27": "8.1",
"28": "9",
"29": "10",
"30": "11",
"31": "12",
"32": "12",
"33": "13",
"34": "14",
"35": "15",
"36": "16",
// can we assume new versions will stick to this scheme?
"37": "17",
"38": "18",
"39": "19",
"40": "20",
]