android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java | 22 +++++++--- 1 file changed, 16 insertions(+), 6 deletions(-)
New commits: commit 56632cc1c9bce65787608f60d454cd016b9e1eee Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Mon Mar 16 17:35:37 2020 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Mar 16 19:40:09 2020 +0100 android: Cosmetic improvements to the content Uri download / upload. Change-Id: I290211e0024dfc86c1f57314bbef00f7117928bd Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90584 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Michael Meeks <michael.me...@collabora.com> diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java index e02ce5382..8e5c3c7fe 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/LOActivity.java @@ -484,11 +484,13 @@ public class LOActivity extends AppCompatActivity { byte[] buffer = new byte[1024]; int length; - while ((length = inputStream.read(buffer)) > 0) { + long bytes = 0; + while ((length = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, length); + bytes += length; } - Log.e(TAG, "Success copying from " + uri + " to " + mTempFile); - return true; + + Log.i(TAG, "Success copying " + bytes + " bytes from " + uri + " to " + mTempFile); } finally { if (inputStream != null) inputStream.close(); @@ -496,10 +498,14 @@ public class LOActivity extends AppCompatActivity { outputStream.close(); } } catch (FileNotFoundException e) { + Log.e(TAG, "file not found: " + e.getMessage()); return false; } catch (IOException e) { + Log.e(TAG, "exception: " + e.getMessage()); return false; } + + return true; } /** Check that we have created a temp file, and if yes, copy it back to the content: URI. */ @@ -513,16 +519,20 @@ public class LOActivity extends AppCompatActivity { try { try { + inputStream = new FileInputStream(mTempFile); + Uri uri = getIntent().getData(); outputStream = contentResolver.openOutputStream(uri); - inputStream = new FileInputStream(mTempFile); byte[] buffer = new byte[1024]; int length; - while ((length = inputStream.read(buffer)) > 0) { + long bytes = 0; + while ((length = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, length); + bytes += length; } - Log.e(TAG, "Success copying from " + mTempFile + " to " + uri); + + Log.i(TAG, "Success copying " + bytes + " bytes from " + mTempFile + " to " + uri); } finally { if (inputStream != null) inputStream.close(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits