mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-30 13:47:41 +00:00
Fixed sending files, we were closing the stream before it was sent
This commit is contained in:
@@ -305,11 +305,10 @@ public class SharePlugin extends Plugin {
|
|||||||
|
|
||||||
|
|
||||||
static void queuedSendUriList(final Context context, final Device device, final ArrayList<Uri> uriList) {
|
static void queuedSendUriList(final Context context, final Device device, final ArrayList<Uri> uriList) {
|
||||||
InputStream inputStream = null;
|
|
||||||
try {
|
try {
|
||||||
Uri uri = uriList.remove(0);
|
Uri uri = uriList.remove(0);
|
||||||
ContentResolver cr = context.getContentResolver();
|
ContentResolver cr = context.getContentResolver();
|
||||||
inputStream = cr.openInputStream(uri);
|
InputStream inputStream = cr.openInputStream(uri);
|
||||||
|
|
||||||
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_SHARE_REQUEST);
|
NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_SHARE_REQUEST);
|
||||||
long size = -1;
|
long size = -1;
|
||||||
@@ -347,8 +346,6 @@ public class SharePlugin extends Plugin {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
np.setPayload(inputStream, size);
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// Probably a content:// uri, so we query the Media content provider
|
// Probably a content:// uri, so we query the Media content provider
|
||||||
|
|
||||||
@@ -385,13 +382,13 @@ public class SharePlugin extends Plugin {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
cursor.close();
|
try { cursor.close(); } catch (Exception e) { }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
np.setPayload(inputStream, size);
|
np.setPayload(inputStream, size);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
final String filename = np.getString("filename");
|
final String filename = np.getString("filename");
|
||||||
|
|
||||||
builder.setContentText(res.getString(R.string.outgoing_file_text,filename));
|
builder.setContentText(res.getString(R.string.outgoing_file_text,filename));
|
||||||
@@ -490,8 +487,6 @@ public class SharePlugin extends Plugin {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("SendFileActivity", "Exception sending files");
|
Log.e("SendFileActivity", "Exception sending files");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
|
||||||
try { inputStream.close(); } catch(Exception e) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user