Skip to content

Commit 7ea2b18

Browse files
committed
Fix retrieving external color resources for icons
1 parent 1dbaa4a commit 7ea2b18

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/android/reader_apk.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ class ApkReader extends IsolateRunner<String, APK_READER_FLAGS> {
9292
/// Returns the gradient as an aapt xml element
9393
static Future<String> getGradient(String gradientId) async {
9494
Resource? gradientRes = await getResources(gradientId);
95-
if (gradientRes == null || !gradientRes.values.first.endsWith(".xml")) return "";
95+
if (gradientRes == null) return "";
96+
String resValue = gradientRes.values.first;
97+
// TODO this is a dirty hack because I did not foresee the 'type1' resource to refer to plain color resources and not just gradients
98+
if (!resValue.endsWith(".xml")) return gradientRes.type == ResType.COLOR ?
99+
'<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>' : '';
96100
Archive apkFile = await _apkArchive;
97101
ArchiveFile? gradientFile = apkFile.findFile(gradientRes.values.first);
98102
if (gradientFile == null) return "";
@@ -185,7 +189,7 @@ class ApkReader extends IsolateRunner<String, APK_READER_FLAGS> {
185189

186190
String backXmlData = isBackXml && backXml != null ? await backXml : "";
187191
String foreXmlData = isForeXml ? await foreXml! : "";
188-
192+
189193
if (isBackColor) {
190194
final color = Color(int.parse(background!.values.first, radix: 16));
191195
updateState(()=>GState.apkBackgroundColor, color);

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class Constants {
200200

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

206206

0 commit comments

Comments
 (0)