@@ -533,15 +533,15 @@ private OutputStream destinationStreamForFile(Attachment att) throws IOException
533
533
ContentValues values =new ContentValues ();
534
534
// values.put(MediaStore.Downloads.DOWNLOAD_URI, att.url);
535
535
values .put (MediaStore .MediaColumns .DISPLAY_NAME , fileName );
536
- values .put (MediaStore .MediaColumns .RELATIVE_PATH , Environment .DIRECTORY_DOWNLOADS );
536
+ values .put (MediaStore .MediaColumns .RELATIVE_PATH , Environment .DIRECTORY_DOWNLOADS + "/" + activity . getApplicationInfo (). loadLabel ( activity . getPackageManager ()) );
537
537
String mime =mimeTypeForFileName (fileName );
538
538
if (mime !=null )
539
539
values .put (MediaStore .MediaColumns .MIME_TYPE , mime );
540
540
ContentResolver cr =activity .getContentResolver ();
541
541
Uri itemUri =cr .insert (MediaStore .Files .getContentUri (MediaStore .VOLUME_EXTERNAL_PRIMARY ), values );
542
542
return cr .openOutputStream (itemUri );
543
543
}else {
544
- return new FileOutputStream (new File (Environment .getExternalStoragePublicDirectory (Environment .DIRECTORY_DOWNLOADS ), fileName ));
544
+ return new FileOutputStream (new File (Environment .getExternalStoragePublicDirectory (Environment .DIRECTORY_DOWNLOADS ), activity . getApplicationInfo (). loadLabel ( activity . getPackageManager ()) + "/" + fileName ));
545
545
}
546
546
}
547
547
@@ -568,7 +568,7 @@ private void doSaveCurrentFile(){
568
568
});
569
569
if (Build .VERSION .SDK_INT <29 ){
570
570
String fileName =Uri .parse (att .url ).getLastPathSegment ();
571
- File dstFile =new File (Environment .getExternalStoragePublicDirectory (Environment .DIRECTORY_DOWNLOADS ), fileName );
571
+ File dstFile =new File (Environment .getExternalStoragePublicDirectory (Environment .DIRECTORY_DOWNLOADS ), activity . getApplicationInfo (). loadLabel ( activity . getPackageManager ()) + "/" + fileName );
572
572
MediaScannerConnection .scanFile (activity , new String []{dstFile .getAbsolutePath ()}, new String []{mimeTypeForFileName (fileName )}, null );
573
573
}
574
574
}catch (IOException x ){
@@ -596,7 +596,7 @@ private void saveViaDownloadManager(Attachment att){
596
596
DownloadManager .Request req =new DownloadManager .Request (uri );
597
597
req .allowScanningByMediaScanner ();
598
598
req .setNotificationVisibility (DownloadManager .Request .VISIBILITY_VISIBLE_NOTIFY_COMPLETED );
599
- req .setDestinationInExternalPublicDir (Environment .DIRECTORY_DOWNLOADS , uri .getLastPathSegment ());
599
+ req .setDestinationInExternalPublicDir (Environment .DIRECTORY_DOWNLOADS , activity . getApplicationInfo (). loadLabel ( activity . getPackageManager ()) + "/" + uri .getLastPathSegment ());
600
600
if (Build .VERSION .SDK_INT >=Build .VERSION_CODES .TIRAMISU )
601
601
activity .registerReceiver (downloadCompletedReceiver , new IntentFilter (DownloadManager .ACTION_DOWNLOAD_COMPLETE ), Context .RECEIVER_EXPORTED );
602
602
else
@@ -1108,4 +1108,4 @@ public void onCompletion(MediaPlayer mp){
1108
1108
windowView .removeCallbacks (uiAutoHider );
1109
1109
}
1110
1110
}
1111
- }
1111
+ }
0 commit comments