Skip to content

Commit c564f8b

Browse files
committed
fix night mode confusion in preloaded assets
1 parent 6c9919e commit c564f8b

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
All notable changes to this project will be documented in this file.
33

44
## [0.34.3]
5-
5+
66
### Fixed
7+
- Fixed night mode confusion in not preloaded assets
78
- Update CameraX to 1.0.0-rc04 to fix a camera initialization crash on Samsung Galaxy S20 Ultra 5G
89

910
## [0.34.2]

core/src/main/java/io/snabble/sdk/Assets.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,13 @@ private void downloadAssets(Project project, ApiManifest apiManifest, String non
230230
String hash = Utils.sha1Hex(url);
231231
hashes.add(hash);
232232

233-
String nightModeFileName = null;
234-
if (nonRootIncludedFileName != null) {
235-
nightModeFileName = getNightModeFileName(nonRootIncludedFileName);
236-
}
237-
boolean forceInclude = FilenameUtils.removeExtension(apiAsset.name).equals(nightModeFileName);
238233
String ext = FilenameUtils.getExtension(apiAsset.name);
239-
if (!ext.equals("svg") && !forceInclude) {
234+
if (!ext.equals("svg") && !ext.equals("jpg") && !ext.equals("webp")) {
240235
continue;
241236
}
242237

243238
// exclude assets that are not in the root when not explicitly requested
244-
if (apiAsset.name.contains("/") && !forceInclude) {
239+
if (apiAsset.name.contains("/") && !apiAsset.name.equals(nonRootIncludedFileName)) {
245240
continue;
246241
}
247242

@@ -362,11 +357,6 @@ public Bitmap getBitmap(String name, Type type) {
362357
}
363358
}
364359

365-
private String getNightModeFileName(String fileName) {
366-
boolean nightMode = isNightModeActive(Snabble.getInstance().getApplication());
367-
return FilenameUtils.removeExtension(fileName) + (nightMode ? "_dark" : "");
368-
}
369-
370360
private Asset getAsset(String name, Type type) {
371361
// currently a limitation due to asynchronous reads and saves,
372362
// could be solved with careful locking
@@ -378,7 +368,9 @@ private Asset getAsset(String name, Type type) {
378368
return null;
379369
}
380370

381-
String fileName = getNightModeFileName(name);
371+
boolean nightMode = isNightModeActive(Snabble.getInstance().getApplication());
372+
373+
String fileName = FilenameUtils.removeExtension(name) + (nightMode ? "_dark" : "");
382374

383375
switch (type) {
384376
case SVG:

0 commit comments

Comments
 (0)