2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 13:47:41 +00:00

Use StringUtils.containsAny().

This commit is contained in:
Isira Seneviratne 2020-07-09 15:15:05 +05:30 committed by Nicolas Fella
parent 29c6d28569
commit 84ca679d84
2 changed files with 11 additions and 16 deletions

View File

@ -42,6 +42,8 @@ import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
//Code from http://stackoverflow.com/questions/9340332/how-can-i-get-the-list-of-mounted-external-storage-of-android-device/19982338#19982338
//modified to work on Lollipop and other devices
public class StorageHelper {
@ -109,7 +111,7 @@ public class StorageHelper {
}
if (!path.startsWith("/storage/emulated") || dirs.length == 1) {
if (!paths.contains(path) && !paths.contains(path2)) {
if (mounts == null || mounts.contains(path) || mounts.contains(path2)) {
if (mounts == null || StringUtils.containsAny(mounts, path, path2)) {
list.add(0, new StorageInfo(path, dir.canWrite(), true, cur_removable_number++));
paths.add(path);
}
@ -123,8 +125,7 @@ public class StorageHelper {
try (FileReader fileReader = new FileReader("/proc/mounts")) {
// The reader is buffered internally, so buffering it separately is unnecessary.
final List<String> lines = IOUtils.readLines(fileReader).stream()
.filter(line -> line.contains("vfat") || line.contains("exfat") ||
line.contains("ntfs") || line.contains("/mnt"))
.filter(line -> StringUtils.containsAny(line, "vfat", "exfat", "ntfs", "/mnt"))
.collect(Collectors.toList());
for (String line : lines) {
if (line.contains("/storage/sdcard"))
@ -147,18 +148,12 @@ public class StorageHelper {
List<String> flags = Arrays.asList(tokens.nextToken().split(",")); //flags
boolean readonly = flags.contains("ro");
if (line.contains("/dev/block/vold")) {
if (!line.contains("/mnt/secure")
&& !line.contains("/mnt/asec")
&& !line.contains("/mnt/obb")
&& !line.contains("/dev/mapper")
&& !line.contains("tmpfs")) {
paths.add(mount_point);
list.add(new StorageInfo(mount_point, readonly, true, cur_removable_number++));
}
if (line.contains("/dev/block/vold") && !StringUtils.containsAny(line, "/mnt/secure",
"/mnt/asec", "/mnt/obb", "/dev/mapper", "tmpfs")) {
paths.add(mount_point);
list.add(new StorageInfo(mount_point, readonly, true, cur_removable_number++));
}
}
}
return list;

View File

@ -1,5 +1,7 @@
package org.kde.kdeconnect.Helpers;
import org.apache.commons.lang3.StringUtils;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Locale;
@ -29,9 +31,7 @@ public class VideoUrlsHelper {
boolean seekUrl = false;
// Override defaults if necessary
if (host.contains("youtube.com")
|| host.contains("youtu.be")
|| host.contains("pornhub.com")) {
if (StringUtils.containsAny(host, "youtube.com", "youtu.be", "pornhub.com")) {
seekUrl = true;
url = stripTimestampS(url, parameter, trailer, inQuery);
} else if (host.contains("vimeo.com")) {