From 6e538f44b5e9b1c7f260ec60c9d8c271fc80b07b Mon Sep 17 00:00:00 2001 From: gdlbo <41114720+gdlbo@users.noreply.github.com> Date: Sat, 20 Aug 2022 12:17:22 +0300 Subject: [PATCH] some pix fixes --- .../main/java/com/vk/core/util/DownloadUtils.java | 14 ++++++++++++-- .../vtosters/lite/downloaders/StoryDownloader.java | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) 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 25ef4c0af..da49f43b2 100644 --- a/app/src/main/java/com/vk/core/util/DownloadUtils.java +++ b/app/src/main/java/com/vk/core/util/DownloadUtils.java @@ -1,5 +1,6 @@ package com.vk.core.util; +import static ru.vtosters.lite.utils.AndroidUtils.getGlobalContext; import static ru.vtosters.lite.utils.Preferences.getDownloadsDir; import static ru.vtosters.lite.utils.Preferences.getMusicDir; import static ru.vtosters.lite.utils.Preferences.getPhotosDir; @@ -12,6 +13,7 @@ import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteException; +import android.media.MediaScannerConnection; import android.net.Uri; import android.text.TextUtils; import android.util.Log; @@ -22,6 +24,7 @@ import com.vk.core.concurrent.VkExecutors; import com.vk.imageloader.VKImageLoader; import com.vk.log.L; import com.vk.metrics.eventtracking.VkTracker; +import com.vtosters.lite.MainActivity; import com.vtosters.lite.R; import java.io.File; @@ -51,7 +54,7 @@ public class DownloadUtils { ToastUtils.a(context.getString(R.string.error) + " [" + e2.getMessage() + "]"); } } - + private static void b(final Context context, String str, String str2, boolean z) { if (TextUtils.isEmpty(str2)) { return; @@ -59,10 +62,12 @@ public class DownloadUtils { String file = a(str, str2); File b2; + boolean pic = false; boolean c2 = MediaUtils.c(MediaUtils.b(str2)); if (file.endsWith(".jpg") || file.endsWith(".png") || file.endsWith(".jpeg")) { b2 = new File(getPhotosDir(), file); + pic = true; } 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 (file.endsWith(".mp4") || file.endsWith(".mkv") || file.endsWith(".avi") || file.endsWith(".flv") || file.endsWith(".wmv") || file.endsWith(".mov") || file.endsWith(".3gp")) { @@ -83,14 +88,16 @@ public class DownloadUtils { if (b2.exists()) { VkExecutors.x.a().execute(() -> ToastUtils.a(context.getString(R.string.file_saved, b2.getAbsoluteFile()))); } + } catch (Exception e2) { L.a(e2); } + CameraUtils.a(context, b2, null); return; } } - + DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str2)); request.setDestinationUri(Uri.fromFile(b2)); request.setMimeType(FileUtils.f(new File(str))); @@ -103,6 +110,9 @@ public class DownloadUtils { } try { long enqueue = a2.enqueue(request); + if (pic) { + CameraUtils.a(context, b2, null); + } if (!z) { return; } diff --git a/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java b/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java index a764711f3..3fbebe2f6 100644 --- a/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java +++ b/app/src/main/java/ru/vtosters/lite/downloaders/StoryDownloader.java @@ -24,7 +24,7 @@ public class StoryDownloader { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setTitle("photo" + story.E.a); - request.setDestinationInExternalPublicDir(getPhotosDir().getAbsolutePath(), "/Stories/photo" + story.E.a + ".jpg"); + request.setDestinationInExternalPublicDir(getPhotosDir().getAbsolutePath(), "/Stories/" + story.E.a + ".jpg"); ((DownloadManager) getGlobalContext().getSystemService(Context.DOWNLOAD_SERVICE)).enqueue(request); return; }