Skip to content

Commit 2b5b8b6

Browse files
committed
fix: crash when deleting widgets if stored widget images cannot be listed
1 parent c96e6a0 commit 2b5b8b6

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
## Fixed
10+
### Fixed
1111

12+
- Fix crash when deleting widgets if stored widget images cannot be listed
1213
- Match clickable view ripple corners to uniform `borderRadius` on Android 12+.
1314
- Use expedited WorkManager requests for widget background tasks on Android 12+ to reduce delays when the app is in the background, with fallback to regular work when expedited quota is exhausted.
1415

1516
## [0.20.3] - 2026-05-02
1617

17-
## Fixed
18+
### Fixed
1819

1920
- Added missing app.plugin.js
2021

2122
## [0.20.2] - 2026-05-02
2223

23-
## Fixed
24+
### Fixed
2425

2526
- renderWidget from WidgetConfigurationScreenProps does not update the widget
2627

2728
## [0.20.1] - 2026-01-15
2829

29-
## Fixed
30+
### Fixed
3031

3132
- Compatibility with older react native versions
3233

3334
## [0.20.0] - 2026-01-13
3435

35-
## Added
36+
### Added
3637

3738
- Accessibility (TalkBack) support
3839

3940
## [0.19.0] - 2026-01-11
4041

41-
## Added
42+
### Added
4243

4344
- Added support for dark mode widgets
4445

4546
## [0.18.0] - 2026-01-04
4647

47-
## Added
48+
### Added
4849

4950
- Support for React Native 0.83
5051

@@ -55,7 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5556

5657
## [0.17.3] - 2026-01-03
5758

58-
## Fixed
59+
### Fixed
5960

6061
- Add a error message about using React Compiler and how to avoid "Invalid hook call" error
6162

android/src/main/java/com/reactnativeandroidwidget/RNWidgetImageProvider.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.io.FileNotFoundException;
1515
import java.io.FileOutputStream;
1616
import java.io.IOException;
17-
import java.util.Objects;
1817

1918
public class RNWidgetImageProvider extends ContentProvider {
2019
public static final String AUTHORITY_SUFFIX = ".rnwidget.imageprovider";
@@ -67,18 +66,22 @@ public ParcelFileDescriptor openFile(@NonNull Uri uri, @NonNull String mode) thr
6766
public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs) { return 0; }
6867

6968
static void deleteWidgetImages(Context context, int widgetId) {
70-
deleteImages(context, "widget_" + widgetId);
69+
deleteImages(context, "widget_" + widgetId + "_");
7170
}
7271

7372
static void deleteCollectionImages(Context context, int widgetId, int collectionId, String mode) {
74-
deleteImages(context, "widget_" + widgetId + "_mode_" + mode + "_collection_" + collectionId);
73+
deleteImages(context, "widget_" + widgetId + "_mode_" + mode + "_collection_" + collectionId + "_");
7574
}
7675

7776
private static void deleteImages(Context context, String prefix) {
7877
File folder = getFolderWithImages(context);
7978
File[] files = folder.listFiles(pathname -> pathname.getName().startsWith(prefix));
8079

81-
for (File f : Objects.requireNonNull(files)) {
80+
if (files == null) {
81+
return;
82+
}
83+
84+
for (File f : files) {
8285
f.delete();
8386
}
8487
}

0 commit comments

Comments
 (0)