Fix videos cannot be downloaded

This commit is contained in:
Thomas 2023-01-11 17:07:47 +01:00
parent f966874550
commit 39f248e0a6
2 changed files with 11 additions and 17 deletions

View File

@ -94,30 +94,14 @@ public class MediaHelper {
try {
request = new DownloadManager.Request(Uri.parse(url.trim()));
} catch (Exception e) {
e.printStackTrace();
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
return -1;
}
try {
String mime = getMimeType(url);
final String fileName = URLUtil.guessFileName(url, null, null);
request.allowScanningByMediaScanner();
String myDir;
if (mime.toLowerCase().startsWith("video")) {
myDir = Environment.DIRECTORY_MOVIES + "/" + context.getString(R.string.app_name);
} else if (mime.toLowerCase().startsWith("audio")) {
myDir = Environment.DIRECTORY_MUSIC + "/" + context.getString(R.string.app_name);
} else {
myDir = Environment.DIRECTORY_DOWNLOADS;
}
if (!new File(myDir).exists()) {
boolean created = new File(myDir).mkdir();
if (!created) {
Toasty.error(context, context.getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
return -1;
}
}
if (mime.toLowerCase().startsWith("video")) {
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_MOVIES, context.getString(R.string.app_name) + "/" + fileName);
} else if (mime.toLowerCase().startsWith("audio")) {

View File

@ -0,0 +1,10 @@
Added:
- Search bar display suggestions
Changed:
- Preload media in timelines
Fixed:
- Fix fetch more jumps
- Fix videos cannot be saved
- Fix crashes