Skip to content

Commit 0c4ece0

Browse files
committed
Fix trigger media scan
1 parent 45193e1 commit 0c4ece0

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

owncloudApp/src/main/java/com/owncloud/android/datamodel/FileDataStorageManager.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,18 +1713,23 @@ public ArrayList<OCShare> getPublicSharesForAFile(String filePath, String accoun
17131713
public void triggerMediaScan(String path) {
17141714
if (path != null) {
17151715
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
1716+
intent.setData(Uri.fromFile(new File(path)));
1717+
MainApp.getAppContext().sendBroadcast(intent);
1718+
1719+
// For making uploads and downloads work in wrapped apps
1720+
Intent wrappedAppintent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
17161721
try {
1717-
intent.setData(
1718-
FileProvider.getUriForFile(
1719-
mContext.getApplicationContext(),
1720-
mContext.getResources().getString(R.string.file_provider_authority),
1721-
new File(path)
1722-
)
1722+
Uri uri = FileProvider.getUriForFile(
1723+
mContext.getApplicationContext(),
1724+
mContext.getResources().getString(R.string.file_provider_authority),
1725+
new File(path)
17231726
);
1727+
wrappedAppintent.setData(uri);
17241728
} catch (IllegalArgumentException illegalArgumentException) {
1725-
intent.setData(Uri.fromFile(new File(path)));
1729+
wrappedAppintent.setData(Uri.fromFile(new File(path)));
17261730
}
1727-
MainApp.getAppContext().sendBroadcast(intent);
1731+
1732+
MainApp.getAppContext().sendBroadcast(wrappedAppintent);
17281733
}
17291734
}
17301735

0 commit comments

Comments
 (0)