mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(android): log reject failures, handle trailing slashes in path, remove unused attr param
This commit is contained in:
@@ -113,7 +113,8 @@ public class FileUploaderPlugin extends Plugin {
|
|||||||
Log.e(TAG, "Upload failed", e);
|
Log.e(TAG, "Upload failed", e);
|
||||||
try {
|
try {
|
||||||
call.reject("Upload failed: " + e.getMessage());
|
call.reject("Upload failed: " + e.getMessage());
|
||||||
} catch (Exception ignored) {
|
} catch (Exception rejectEx) {
|
||||||
|
Log.e(TAG, "Failed to reject call", rejectEx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,8 +51,12 @@ public class FileUtils {
|
|||||||
if (result == null) {
|
if (result == null) {
|
||||||
String path = uri.getPath();
|
String path = uri.getPath();
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
|
path = path.replaceAll("/+$", "");
|
||||||
int cut = path.lastIndexOf('/');
|
int cut = path.lastIndexOf('/');
|
||||||
result = (cut != -1) ? path.substring(cut + 1) : path;
|
result = (cut != -1) ? path.substring(cut + 1) : path;
|
||||||
|
if (result.isEmpty()) {
|
||||||
|
result = "unknown";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result = "unknown";
|
result = "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,6 @@ public final class MediaUploadRecipes {
|
|||||||
*/
|
*/
|
||||||
public static String getSuccessJs(String provider) {
|
public static String getSuccessJs(String provider) {
|
||||||
String[] selectorCandidates;
|
String[] selectorCandidates;
|
||||||
String attribute;
|
|
||||||
if (PROVIDER_IMGUR.equals(provider)) {
|
if (PROVIDER_IMGUR.equals(provider)) {
|
||||||
selectorCandidates =
|
selectorCandidates =
|
||||||
new String[] {
|
new String[] {
|
||||||
@@ -143,7 +142,6 @@ public final class MediaUploadRecipes {
|
|||||||
"[class*=\"copy-link\"] input",
|
"[class*=\"copy-link\"] input",
|
||||||
"[data-link]",
|
"[data-link]",
|
||||||
};
|
};
|
||||||
attribute = "href";
|
|
||||||
} else if (PROVIDER_POSTIMAGES.equals(provider)) {
|
} else if (PROVIDER_POSTIMAGES.equals(provider)) {
|
||||||
selectorCandidates =
|
selectorCandidates =
|
||||||
new String[] {
|
new String[] {
|
||||||
@@ -152,14 +150,13 @@ public final class MediaUploadRecipes {
|
|||||||
"[class*=\"direct-link\"]",
|
"[class*=\"direct-link\"]",
|
||||||
"textarea",
|
"textarea",
|
||||||
};
|
};
|
||||||
attribute = "value";
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return buildSuccessJs(selectorCandidates, attribute);
|
return buildSuccessJs(selectorCandidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildSuccessJs(String[] selectors, String attr) {
|
private static String buildSuccessJs(String[] selectors) {
|
||||||
StringBuilder sb = new StringBuilder("(function(){var s=[");
|
StringBuilder sb = new StringBuilder("(function(){var s=[");
|
||||||
for (int i = 0; i < selectors.length; i++) {
|
for (int i = 0; i < selectors.length; i++) {
|
||||||
if (i > 0) sb.append(",");
|
if (i > 0) sb.append(",");
|
||||||
|
|||||||
Reference in New Issue
Block a user