Skip to content

Commit 839210a

Browse files
committed
style(android): java code format by the ide
1 parent 265a932 commit 839210a

File tree

7 files changed

+54
-53
lines changed

7 files changed

+54
-53
lines changed

src/android/ContentFilesystem.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Licensed to the Apache Software Foundation (ASF) under one
2525
import android.provider.DocumentsContract;
2626
import android.provider.MediaStore;
2727
import android.provider.OpenableColumns;
28+
2829
import java.io.File;
2930
import java.io.FileNotFoundException;
3031
import java.io.IOException;
@@ -78,14 +79,14 @@ public LocalFilesystemURL toLocalUri(Uri inputURL) {
7879
b.appendEncodedPath(subPath);
7980
}
8081
Uri localUri = b.encodedQuery(inputURL.getEncodedQuery())
81-
.encodedFragment(inputURL.getEncodedFragment())
82-
.build();
82+
.encodedFragment(inputURL.getEncodedFragment())
83+
.build();
8384
return LocalFilesystemURL.parse(localUri);
8485
}
8586

8687
@Override
8788
public JSONObject getFileForLocalURL(LocalFilesystemURL inputURL,
88-
String fileName, JSONObject options, boolean directory) throws IOException, TypeMismatchException, JSONException {
89+
String fileName, JSONObject options, boolean directory) throws IOException, TypeMismatchException, JSONException {
8990
throw new UnsupportedOperationException("getFile() not supported for content:. Use resolveLocalFileSystemURL instead.");
9091
}
9192

@@ -162,9 +163,10 @@ public JSONObject getFileMetadataForLocalURL(LocalFilesystemURL inputURL) throws
162163

163164
@Override
164165
public long writeToFileAtURL(LocalFilesystemURL inputURL, String data,
165-
int offset, boolean isBinary) throws NoModificationAllowedException {
166+
int offset, boolean isBinary) throws NoModificationAllowedException {
166167
throw new NoModificationAllowedException("Couldn't write to file given its content URI");
167168
}
169+
168170
@Override
169171
public long truncateFileAtURL(LocalFilesystemURL inputURL, long size)
170172
throws NoModificationAllowedException {

src/android/DirectoryManager.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Licensed to the Apache Software Foundation (ASF) under one
2626
/**
2727
* This class provides file directory utilities.
2828
* All file operations are performed on the SD card.
29-
*
29+
* <p>
3030
* It is used by the FileUtils class.
3131
*/
3232
public class DirectoryManager {
@@ -36,8 +36,9 @@ public class DirectoryManager {
3636

3737
/**
3838
* Determine if a file or directory exists.
39-
* @param name The name of the file to check.
40-
* @return T=exists, F=not found
39+
*
40+
* @param name The name of the file to check.
41+
* @return T=exists, F=not found
4142
*/
4243
public static boolean testFileExists(String name) {
4344
boolean status;
@@ -58,7 +59,7 @@ public static boolean testFileExists(String name) {
5859
/**
5960
* Get the free space in external storage
6061
*
61-
* @return Size in KB or -1 if not available
62+
* @return Size in KB or -1 if not available
6263
*/
6364
public static long getFreeExternalStorageSpace() {
6465
String status = Environment.getExternalStorageState();
@@ -96,7 +97,7 @@ public static long getFreeSpaceInBytes(String path) {
9697
/**
9798
* Determine if SD card exists.
9899
*
99-
* @return T=exists, F=not found
100+
* @return T=exists, F=not found
100101
*/
101102
public static boolean testSaveLocationExists() {
102103
String sDCardStatus = Environment.getExternalStorageState();
@@ -117,16 +118,15 @@ public static boolean testSaveLocationExists() {
117118
/**
118119
* Create a new file object from two file paths.
119120
*
120-
* @param file1 Base file path
121-
* @param file2 Remaining file path
122-
* @return File object
121+
* @param file1 Base file path
122+
* @param file2 Remaining file path
123+
* @return File object
123124
*/
124-
private static File constructFilePaths (String file1, String file2) {
125+
private static File constructFilePaths(String file1, String file2) {
125126
File newPath;
126127
if (file2.startsWith(file1)) {
127128
newPath = new File(file2);
128-
}
129-
else {
129+
} else {
130130
newPath = new File(file1 + "/" + file2);
131131
}
132132
return newPath;

src/android/FileUtils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ private void getWritePermission(String rawArgs, int action, CallbackContext call
553553
* If your app targets Android 13 (SDK 33) or higher and needs to access media files that other apps have created,
554554
* you must request one or more of the following granular media permissions READ_MEDIA_*
555555
* instead of the READ_EXTERNAL_STORAGE permission:
556-
*
556+
* <p>
557557
* Refer to: https://developer.android.com/about/versions/13/behavior-changes-13
558558
*
559559
* @return
@@ -659,7 +659,6 @@ public LocalFilesystemURL filesystemURLforLocalPath(String localPath) {
659659
return localURL;
660660
}
661661

662-
663662
/* helper to execute functions async and handle the result codes
664663
*
665664
*/
@@ -834,7 +833,6 @@ private boolean removeRecursively(String baseURLstr) throws FileExistsException,
834833
}
835834
}
836835

837-
838836
/**
839837
* Deletes a file or directory. It is an error to attempt to delete a directory that is not empty.
840838
* It is an error to attempt to delete the root directory of a filesystem.
@@ -1123,7 +1121,6 @@ public void handleData(InputStream inputStream, String contentType) {
11231121
}
11241122
}
11251123

1126-
11271124
/**
11281125
* Write contents of file.
11291126
*
@@ -1168,7 +1165,6 @@ private long truncateFile(String srcURLstr, long size) throws FileNotFoundExcept
11681165
}
11691166
}
11701167

1171-
11721168
/*
11731169
* Handle the response
11741170
*/

src/android/Filesystem.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public JSONObject makeEntryForFile(File file) {
106106
}
107107

108108
abstract JSONObject getFileForLocalURL(LocalFilesystemURL inputURL, String path,
109-
JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException;
109+
JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException;
110110

111111
abstract boolean removeFileAtLocalURL(LocalFilesystemURL inputURL) throws InvalidModificationException, NoModificationAllowedException;
112112

@@ -174,13 +174,13 @@ protected static String normalizePath(String rawPath) {
174174
if (components.get(index).equals("..")) {
175175
components.remove(index);
176176
if (index > 0) {
177-
components.remove(index-1);
177+
components.remove(index - 1);
178178
--index;
179179
}
180180
}
181181
}
182182
StringBuilder normalizedPath = new StringBuilder();
183-
for(String component: components) {
183+
for (String component : components) {
184184
normalizedPath.append("/");
185185
normalizedPath.append(component);
186186
}
@@ -200,6 +200,7 @@ public long getFreeSpaceInBytes() {
200200
}
201201

202202
public abstract Uri toNativeUri(LocalFilesystemURL inputURL);
203+
203204
public abstract LocalFilesystemURL toLocalUri(Uri inputURL);
204205

205206
public JSONObject getRootEntry() {
@@ -221,7 +222,7 @@ public JSONObject getParentForLocalURL(LocalFilesystemURL inputURL) throws IOExc
221222
protected LocalFilesystemURL makeDestinationURL(String newName, LocalFilesystemURL srcURL, LocalFilesystemURL destURL, boolean isDirectory) {
222223
// I know this looks weird but it is to work around a JSON bug.
223224
if ("null".equals(newName) || "".equals(newName)) {
224-
newName = srcURL.uri.getLastPathSegment();;
225+
newName = srcURL.uri.getLastPathSegment();
225226
}
226227

227228
String newDest = destURL.uri.toString();
@@ -242,7 +243,7 @@ protected LocalFilesystemURL makeDestinationURL(String newName, LocalFilesystemU
242243
* or remove the source file when finished.
243244
*/
244245
public JSONObject copyFileToURL(LocalFilesystemURL destURL, String newName,
245-
Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
246+
Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
246247
// First, check to see that we can do it
247248
if (move && !srcFs.canRemoveFileAtLocalURL(srcURL)) {
248249
throw new NoModificationAllowedException("Cannot move file at source URL");
@@ -294,7 +295,7 @@ public void readFileAtURL(LocalFilesystemURL inputURL, long start, long end,
294295
}
295296

296297
abstract long writeToFileAtURL(LocalFilesystemURL inputURL, String data, int offset,
297-
boolean isBinary) throws NoModificationAllowedException, IOException;
298+
boolean isBinary) throws NoModificationAllowedException, IOException;
298299

299300
abstract long truncateFileAtURL(LocalFilesystemURL inputURL, long size)
300301
throws IOException, NoModificationAllowedException;
@@ -308,10 +309,12 @@ abstract long truncateFileAtURL(LocalFilesystemURL inputURL, long size)
308309

309310
protected class LimitedInputStream extends FilterInputStream {
310311
long numBytesToRead;
312+
311313
public LimitedInputStream(InputStream in, long numBytesToRead) {
312314
super(in);
313315
this.numBytesToRead = numBytesToRead;
314316
}
317+
315318
@Override
316319
public int read() throws IOException {
317320
if (numBytesToRead <= 0) {
@@ -320,14 +323,15 @@ public int read() throws IOException {
320323
numBytesToRead--;
321324
return in.read();
322325
}
326+
323327
@Override
324328
public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
325329
if (numBytesToRead <= 0) {
326330
return -1;
327331
}
328332
int bytesToRead = byteCount;
329333
if (byteCount > numBytesToRead) {
330-
bytesToRead = (int)numBytesToRead; // Cast okay; long is less than int here.
334+
bytesToRead = (int) numBytesToRead; // Cast okay; long is less than int here.
331335
}
332336
int numBytesRead = in.read(buffer, byteOffset, bytesToRead);
333337
numBytesToRead -= numBytesRead;
@@ -341,8 +345,8 @@ protected Uri.Builder createLocalUriBuilder() {
341345
String path = LocalFilesystemURL.fsNameToCdvKeyword(name);
342346

343347
return new Uri.Builder()
344-
.scheme(scheme)
345-
.authority(hostname)
346-
.path(path);
348+
.scheme(scheme)
349+
.authority(hostname)
350+
.path(path);
347351
}
348352
}

src/android/LocalFilesystem.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public LocalFilesystemURL URLforFilesystemPath(String path) {
106106

107107
@Override
108108
public JSONObject getFileForLocalURL(LocalFilesystemURL inputURL,
109-
String path, JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
109+
String path, JSONObject options, boolean directory) throws FileExistsException, IOException, TypeMismatchException, EncodingException, JSONException {
110110
boolean create = false;
111111
boolean exclusive = false;
112112

@@ -148,8 +148,7 @@ public JSONObject getFileForLocalURL(LocalFilesystemURL inputURL,
148148
if (!fp.exists()) {
149149
throw new FileExistsException("create fails");
150150
}
151-
}
152-
else {
151+
} else {
153152
if (!fp.exists()) {
154153
throw new FileNotFoundException("path does not exist");
155154
}
@@ -324,7 +323,7 @@ private void copyDirectory(Filesystem srcFs, LocalFilesystemURL srcURL, File dst
324323

325324
@Override
326325
public JSONObject copyFileToURL(LocalFilesystemURL destURL, String newName,
327-
Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
326+
Filesystem srcFs, LocalFilesystemURL srcURL, boolean move) throws IOException, InvalidModificationException, JSONException, NoModificationAllowedException, FileExistsException {
328327

329328
// Check to see if the destination directory exists
330329
String newParent = this.filesystemPathForURL(destURL);
@@ -371,7 +370,7 @@ public JSONObject copyFileToURL(LocalFilesystemURL destURL, String newName,
371370

372371
@Override
373372
public long writeToFileAtURL(LocalFilesystemURL inputURL, String data,
374-
int offset, boolean isBinary) throws IOException, NoModificationAllowedException {
373+
int offset, boolean isBinary) throws IOException, NoModificationAllowedException {
375374

376375
boolean append = false;
377376
if (offset > 0) {
@@ -386,8 +385,7 @@ public long writeToFileAtURL(LocalFilesystemURL inputURL, String data,
386385
rawData = data.getBytes(Charset.defaultCharset());
387386
}
388387
ByteArrayInputStream in = new ByteArrayInputStream(rawData);
389-
try
390-
{
388+
try {
391389
byte buff[] = new byte[rawData.length];
392390
String absolutePath = filesystemPathForURL(inputURL);
393391
FileOutputStream out = new FileOutputStream(absolutePath, append);
@@ -402,9 +400,7 @@ public long writeToFileAtURL(LocalFilesystemURL inputURL, String data,
402400
if (isPublicDirectory(absolutePath)) {
403401
broadcastNewFile(Uri.fromFile(new File(absolutePath)));
404402
}
405-
}
406-
catch (NullPointerException e)
407-
{
403+
} catch (NullPointerException e) {
408404
// This is a bug in the Android implementation of the Java Stack
409405
NoModificationAllowedException realException = new NoModificationAllowedException(inputURL.toString());
410406
realException.initCause(e);
@@ -419,7 +415,7 @@ private boolean isPublicDirectory(String absolutePath) {
419415
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
420416
// Lollipop has a bug where SD cards are null.
421417
for (File f : context.getExternalMediaDirs()) {
422-
if(f != null && absolutePath.startsWith(f.getAbsolutePath())) {
418+
if (f != null && absolutePath.startsWith(f.getAbsolutePath())) {
423419
return true;
424420
}
425421
}
@@ -429,7 +425,7 @@ private boolean isPublicDirectory(String absolutePath) {
429425
return absolutePath.startsWith(extPath);
430426
}
431427

432-
/**
428+
/**
433429
* Send broadcast of new file so files appear over MTP
434430
*/
435431
private void broadcastNewFile(Uri nativeUri) {

src/android/LocalFilesystemURL.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private LocalFilesystemURL(Uri uri, String fsName, String fsPath, boolean isDire
3838
}
3939

4040
public static LocalFilesystemURL parse(Uri uri) {
41-
if(!uri.toString().contains(CDVFILE_KEYWORD)) {
41+
if (!uri.toString().contains(CDVFILE_KEYWORD)) {
4242
return null;
4343
}
4444

@@ -66,7 +66,9 @@ public static LocalFilesystemURL parse(String uri) {
6666
return parse(Uri.parse(uri));
6767
}
6868

69-
public static String fsNameToCdvKeyword(String fsName) { return CDVFILE_KEYWORD + fsName + "__"; }
69+
public static String fsNameToCdvKeyword(String fsName) {
70+
return CDVFILE_KEYWORD + fsName + "__";
71+
}
7072

7173
public String toString() {
7274
return uri.toString();

src/android/PendingRequests.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,23 @@ class PendingRequests {
3232
/**
3333
* Creates a request and adds it to the array of pending requests. Each created request gets a
3434
* unique result code for use with requestPermission()
35-
* @param rawArgs The raw arguments passed to the plugin
36-
* @param action The action this request corresponds to (get file, etc.)
37-
* @param callbackContext The CallbackContext for this plugin call
38-
* @return The request code that can be used to retrieve the Request object
35+
*
36+
* @param rawArgs The raw arguments passed to the plugin
37+
* @param action The action this request corresponds to (get file, etc.)
38+
* @param callbackContext The CallbackContext for this plugin call
39+
* @return The request code that can be used to retrieve the Request object
3940
*/
40-
public synchronized int createRequest(String rawArgs, int action, CallbackContext callbackContext) {
41+
public synchronized int createRequest(String rawArgs, int action, CallbackContext callbackContext) {
4142
Request req = new Request(rawArgs, action, callbackContext);
4243
requests.put(req.requestCode, req);
4344
return req.requestCode;
4445
}
4546

4647
/**
4748
* Gets the request corresponding to this request code and removes it from the pending requests
48-
* @param requestCode The request code for the desired request
49-
* @return The request corresponding to the given request code or null if such a
50-
* request is not found
49+
*
50+
* @param requestCode The request code for the desired request
51+
* @return The request corresponding to the given request code or null if such a request is not found
5152
*/
5253
public synchronized Request getAndRemove(int requestCode) {
5354
Request result = requests.get(requestCode);
@@ -76,7 +77,7 @@ private Request(String rawArgs, int action, CallbackContext callbackContext) {
7677
this.rawArgs = rawArgs;
7778
this.action = action;
7879
this.callbackContext = callbackContext;
79-
this.requestCode = currentReqId ++;
80+
this.requestCode = currentReqId++;
8081
}
8182

8283
public int getAction() {

0 commit comments

Comments
 (0)