@@ -41,6 +41,14 @@ class FileAccessModule(reactContext: ReactApplicationContext) :
41
41
)
42
42
}
43
43
44
+ // https://github.com/facebook/react-native/blob/v0.65.1/Libraries/EventEmitter/NativeEventEmitter.js#L22
45
+ @ReactMethod
46
+ fun addListener (eventType : String ) = Unit
47
+
48
+ // https://github.com/facebook/react-native/blob/v0.65.1/Libraries/EventEmitter/NativeEventEmitter.js#L23
49
+ @ReactMethod
50
+ fun removeListeners (count : Int ) = Unit
51
+
44
52
@ReactMethod
45
53
fun appendFile (path : String , data : String , encoding : String , promise : Promise ) {
46
54
ioScope.launch {
@@ -113,7 +121,12 @@ class FileAccessModule(reactContext: ReactApplicationContext) :
113
121
if (android.os.Build .VERSION .SDK_INT >= android.os.Build .VERSION_CODES .Q ) {
114
122
reactApplicationContext.contentResolver.insert(
115
123
MediaStore .Downloads .EXTERNAL_CONTENT_URI ,
116
- ContentValues ().apply { put(MediaStore .Downloads .DISPLAY_NAME , targetName) }
124
+ ContentValues ().apply {
125
+ put(
126
+ MediaStore .Downloads .DISPLAY_NAME ,
127
+ targetName
128
+ )
129
+ }
117
130
)?.let { reactApplicationContext.contentResolver.openOutputStream(it) }
118
131
} else {
119
132
@Suppress(" DEPRECATION" )
@@ -136,7 +149,9 @@ class FileAccessModule(reactContext: ReactApplicationContext) :
136
149
put(
137
150
MediaStore .Audio .AudioColumns .DATA ,
138
151
File (
139
- Environment .getExternalStoragePublicDirectory(Environment .DIRECTORY_MUSIC ),
152
+ Environment .getExternalStoragePublicDirectory(
153
+ Environment .DIRECTORY_MUSIC
154
+ ),
140
155
targetName
141
156
).absolutePath
142
157
)
@@ -147,13 +162,23 @@ class FileAccessModule(reactContext: ReactApplicationContext) :
147
162
" images" -> {
148
163
reactApplicationContext.contentResolver.insert(
149
164
MediaStore .Images .Media .EXTERNAL_CONTENT_URI ,
150
- ContentValues ().apply { put(MediaStore .Images .Media .DISPLAY_NAME , targetName) }
165
+ ContentValues ().apply {
166
+ put(
167
+ MediaStore .Images .Media .DISPLAY_NAME ,
168
+ targetName
169
+ )
170
+ }
151
171
)
152
172
}
153
173
" video" -> {
154
174
reactApplicationContext.contentResolver.insert(
155
175
MediaStore .Video .Media .EXTERNAL_CONTENT_URI ,
156
- ContentValues ().apply { put(MediaStore .Video .Media .DISPLAY_NAME , targetName) }
176
+ ContentValues ().apply {
177
+ put(
178
+ MediaStore .Video .Media .DISPLAY_NAME ,
179
+ targetName
180
+ )
181
+ }
157
182
)
158
183
}
159
184
else -> null
@@ -286,7 +311,12 @@ class FileAccessModule(reactContext: ReactApplicationContext) :
286
311
ioScope.launch {
287
312
try {
288
313
if (! parsePathToFile(source).renameTo(parsePathToFile(target))) {
289
- parsePathToFile(source).also { it.copyTo(parsePathToFile(target), overwrite = true ) }
314
+ parsePathToFile(source).also {
315
+ it.copyTo(
316
+ parsePathToFile(target),
317
+ overwrite = true
318
+ )
319
+ }
290
320
.delete()
291
321
}
292
322
promise.resolve(null )
0 commit comments