mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 21:55:10 +00:00
Use StringUtils.containsAny().
This commit is contained in:
committed by
Nicolas Fella
parent
29c6d28569
commit
84ca679d84
@@ -42,6 +42,8 @@ import java.util.Scanner;
|
|||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.stream.Collectors;
|
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
|
//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
|
//modified to work on Lollipop and other devices
|
||||||
public class StorageHelper {
|
public class StorageHelper {
|
||||||
@@ -109,7 +111,7 @@ public class StorageHelper {
|
|||||||
}
|
}
|
||||||
if (!path.startsWith("/storage/emulated") || dirs.length == 1) {
|
if (!path.startsWith("/storage/emulated") || dirs.length == 1) {
|
||||||
if (!paths.contains(path) && !paths.contains(path2)) {
|
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++));
|
list.add(0, new StorageInfo(path, dir.canWrite(), true, cur_removable_number++));
|
||||||
paths.add(path);
|
paths.add(path);
|
||||||
}
|
}
|
||||||
@@ -123,8 +125,7 @@ public class StorageHelper {
|
|||||||
try (FileReader fileReader = new FileReader("/proc/mounts")) {
|
try (FileReader fileReader = new FileReader("/proc/mounts")) {
|
||||||
// The reader is buffered internally, so buffering it separately is unnecessary.
|
// The reader is buffered internally, so buffering it separately is unnecessary.
|
||||||
final List<String> lines = IOUtils.readLines(fileReader).stream()
|
final List<String> lines = IOUtils.readLines(fileReader).stream()
|
||||||
.filter(line -> line.contains("vfat") || line.contains("exfat") ||
|
.filter(line -> StringUtils.containsAny(line, "vfat", "exfat", "ntfs", "/mnt"))
|
||||||
line.contains("ntfs") || line.contains("/mnt"))
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
if (line.contains("/storage/sdcard"))
|
if (line.contains("/storage/sdcard"))
|
||||||
@@ -147,18 +148,12 @@ public class StorageHelper {
|
|||||||
List<String> flags = Arrays.asList(tokens.nextToken().split(",")); //flags
|
List<String> flags = Arrays.asList(tokens.nextToken().split(",")); //flags
|
||||||
boolean readonly = flags.contains("ro");
|
boolean readonly = flags.contains("ro");
|
||||||
|
|
||||||
if (line.contains("/dev/block/vold")) {
|
if (line.contains("/dev/block/vold") && !StringUtils.containsAny(line, "/mnt/secure",
|
||||||
if (!line.contains("/mnt/secure")
|
"/mnt/asec", "/mnt/obb", "/dev/mapper", "tmpfs")) {
|
||||||
&& !line.contains("/mnt/asec")
|
paths.add(mount_point);
|
||||||
&& !line.contains("/mnt/obb")
|
list.add(new StorageInfo(mount_point, readonly, true, cur_removable_number++));
|
||||||
&& !line.contains("/dev/mapper")
|
|
||||||
&& !line.contains("tmpfs")) {
|
|
||||||
paths.add(mount_point);
|
|
||||||
list.add(new StorageInfo(mount_point, readonly, true, cur_removable_number++));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package org.kde.kdeconnect.Helpers;
|
package org.kde.kdeconnect.Helpers;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -29,9 +31,7 @@ public class VideoUrlsHelper {
|
|||||||
boolean seekUrl = false;
|
boolean seekUrl = false;
|
||||||
|
|
||||||
// Override defaults if necessary
|
// Override defaults if necessary
|
||||||
if (host.contains("youtube.com")
|
if (StringUtils.containsAny(host, "youtube.com", "youtu.be", "pornhub.com")) {
|
||||||
|| host.contains("youtu.be")
|
|
||||||
|| host.contains("pornhub.com")) {
|
|
||||||
seekUrl = true;
|
seekUrl = true;
|
||||||
url = stripTimestampS(url, parameter, trailer, inQuery);
|
url = stripTimestampS(url, parameter, trailer, inQuery);
|
||||||
} else if (host.contains("vimeo.com")) {
|
} else if (host.contains("vimeo.com")) {
|
||||||
|
Reference in New Issue
Block a user