Skip to content

Commit

Permalink
Fix retrieving external color resources for icons
Browse files Browse the repository at this point in the history
  • Loading branch information
alesimula committed Jan 28, 2023
1 parent 1dbaa4a commit 7ea2b18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/android/reader_apk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ class ApkReader extends IsolateRunner<String, APK_READER_FLAGS> {
/// Returns the gradient as an aapt xml element
static Future<String> getGradient(String gradientId) async {
Resource? gradientRes = await getResources(gradientId);
if (gradientRes == null || !gradientRes.values.first.endsWith(".xml")) return "";
if (gradientRes == null) return "";
String resValue = gradientRes.values.first;
// TODO this is a dirty hack because I did not foresee the 'type1' resource to refer to plain color resources and not just gradients
if (!resValue.endsWith(".xml")) return gradientRes.type == ResType.COLOR ?
'<aapt:attr name="android:fillColor"><gradient android:type="linear" android:startX="0" android:startY="0" android:endX="1" android:endY="1"><item android:color="#$resValue" android:offset="0"/></gradient></aapt:attr>' : '';
Archive apkFile = await _apkArchive;
ArchiveFile? gradientFile = apkFile.findFile(gradientRes.values.first);
if (gradientFile == null) return "";
Expand Down Expand Up @@ -185,7 +189,7 @@ class ApkReader extends IsolateRunner<String, APK_READER_FLAGS> {

String backXmlData = isBackXml && backXml != null ? await backXml : "";
String foreXmlData = isForeXml ? await foreXml! : "";

if (isBackColor) {
final color = Color(int.parse(background!.values.first, radix: 16));
updateState(()=>GState.apkBackgroundColor, color);
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class Constants {

void main(List<String> arguments) async {
//int prevTime = DateTime.now().millisecondsSinceEpoch;
//arguments = [r'C:\Users\Alex\Downloads\AuroraStore_4.1.1.apk'];
//arguments = [r'C:\Users\Alex\Downloads\caab_585.apk'];
//arguments = [r'C:\Users\Alex\Downloads\Chrome.xapk'];


Expand Down

0 comments on commit 7ea2b18

Please sign in to comment.