diff --git a/app/src/main/java/com/vk/core/util/DownloadUtils.java b/app/src/main/java/com/vk/core/util/DownloadUtils.java
index ec9022056..21d339553 100644
--- a/app/src/main/java/com/vk/core/util/DownloadUtils.java
+++ b/app/src/main/java/com/vk/core/util/DownloadUtils.java
@@ -61,11 +61,11 @@ public class DownloadUtils {
File b2;
boolean c2 = MediaUtils.c(MediaUtils.b(str2));
- if (str.endsWith("png") || str.endsWith("jpg") || str.endsWith("jpeg")) {
+ if (file.endsWith(".jpg") || file.endsWith(".png") || file.endsWith(".jpeg")) {
b2 = new File(getPhotosDir(), file);
- } else if (str.endsWith("mp3") || str.endsWith("wav") || str.endsWith("ogg") || str.endsWith("aac") || str.endsWith("flac") || str.endsWith("m4a")) {
+ } else if (file.endsWith(".mp3") || file.endsWith(".wav") || file.endsWith(".ogg") || file.endsWith(".aac") || file.endsWith(".flac") || file.endsWith(".m4a")) {
b2 = new File(getMusicDir(), file);
- } else if (str.endsWith("mp4") || str.endsWith("mkv") || str.endsWith("avi") || str.endsWith("flv") || str.endsWith("wmv") || str.endsWith("mov") || str.endsWith("3gp")) {
+ } else if (file.endsWith(".mp4") || file.endsWith(".mkv") || file.endsWith(".avi") || file.endsWith(".flv") || file.endsWith(".wmv") || file.endsWith(".mov") || file.endsWith(".3gp")) {
b2 = new File(getVideosDir(), file);
} else {
b2 = new File(getDownloadsDir(), file);
@@ -76,7 +76,11 @@ public class DownloadUtils {
final InputStream h = c3 == null ? null : c3.h();
if (h != null) {
try {
- if (b2.exists() || FileUtils.b(b2)) {
+ if (b2.getParentFile() != null) {
+ b2.createNewFile();
+ }
+
+ if (b2.exists()) {
VkExecutors.x.a().execute(() -> ToastUtils.a(context.getString(R.string.file_saved, b2.getAbsoluteFile())));
}
} catch (Exception e2) {
@@ -86,6 +90,7 @@ public class DownloadUtils {
return;
}
}
+
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str2));
request.setDestinationUri(Uri.fromFile(b2));
request.setMimeType(FileUtils.f(new File(str)));
diff --git a/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java b/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java
index d70befaeb..ad23fc5b6 100644
--- a/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java
+++ b/app/src/main/java/ru/vtosters/lite/ui/fragments/OtherFragment.java
@@ -9,6 +9,7 @@ import static ru.vtosters.lite.ui.components.BackupManager.deletePrefs;
import static ru.vtosters.lite.ui.components.BackupManager.restoreBackup;
import static ru.vtosters.lite.utils.AccountManagerUtils.getUserToken;
import static ru.vtosters.lite.utils.AndroidUtils.dp2px;
+import static ru.vtosters.lite.utils.AndroidUtils.edit;
import static ru.vtosters.lite.utils.AndroidUtils.getDefaultPrefs;
import static ru.vtosters.lite.utils.AndroidUtils.getIdentifier;
import static ru.vtosters.lite.utils.CacheUtils.deleteCache;
@@ -95,6 +96,12 @@ public class OtherFragment extends MaterialPreferenceToolbarFragment {
return true;
});
+ findPreference("resetfolders").setOnPreferenceClickListener(preference -> {
+ edit().remove("photos_directory").remove("videos_directory").remove("audios_directory").remove("downloads_directory").apply();
+ Toast.makeText(getContext(), "Папки успешно сброшены", LENGTH_SHORT).show();
+ return true;
+ });
+
var pref = getDefaultPrefs().getString("autoclearcache", "Default");
switch (pref) {
case "Default":
diff --git a/smali/res/xml/preferences_other.xml b/smali/res/xml/preferences_other.xml
index eab05dfdb..bea708e5c 100644
--- a/smali/res/xml/preferences_other.xml
+++ b/smali/res/xml/preferences_other.xml
@@ -19,6 +19,9 @@
+