[Libreoffice-commits] core.git: android/source

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 16 06:49:41 UTC 2021


 android/source/src/java/org/libreoffice/LOKitTileProvider.java |   25 ++++------
 1 file changed, 11 insertions(+), 14 deletions(-)

New commits:
commit 40f30020b9e91d15c4d90e53b1d2e41770fbc58c
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Thu Apr 15 13:47:23 2021 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Fri Apr 16 08:48:52 2021 +0200

    android: Merge 2 'LOKitTileProvider#printDocument' methods
    
    ... and move the check for a new enough SDK version to
    the beginning.
    
    Change-Id: I7f5528985b8c43e218b88899409fdd22b640f72e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114145
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index 5d8d2e557d0f..a5222f7e46ea 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -340,25 +340,22 @@ class LOKitTileProvider implements TileProvider {
     }
 
     public void printDocument() {
+        if (Build.VERSION.SDK_INT < 19) {
+            mContext.showCustomStatusMessage(mContext.getString(R.string.printing_not_supported));
+            return;
+        }
+
         String mInputFileName = (new File(mInputFile)).getName();
         String file = mInputFileName.substring(0,(mInputFileName.length()-3))+"pdf";
         String cacheFile = mContext.getExternalCacheDir().getAbsolutePath() + "/" + file;
         mDocument.saveAs("file://"+cacheFile,"pdf","");
-        printDocument(cacheFile);
-    }
-
-    private void printDocument(String cacheFile) {
-        if (Build.VERSION.SDK_INT >= 19) {
-            try {
-                PrintManager printManager = (PrintManager) mContext.getSystemService(Context.PRINT_SERVICE);
-                PrintDocumentAdapter printAdapter = new PDFDocumentAdapter(mContext, cacheFile);
-                printManager.print("Document", printAdapter, new PrintAttributes.Builder().build());
+        try {
+            PrintManager printManager = (PrintManager) mContext.getSystemService(Context.PRINT_SERVICE);
+            PrintDocumentAdapter printAdapter = new PDFDocumentAdapter(mContext, cacheFile);
+            printManager.print("Document", printAdapter, new PrintAttributes.Builder().build());
 
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        } else {
-            mContext.showCustomStatusMessage(mContext.getString(R.string.printing_not_supported));
+        } catch (Exception e) {
+            e.printStackTrace();
         }
     }
 


More information about the Libreoffice-commits mailing list