diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-04-15 13:47:23 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-04-16 08:48:52 +0200 |
commit | 40f30020b9e91d15c4d90e53b1d2e41770fbc58c (patch) | |
tree | b52661fc54428e656b20be8ff727b54fbe4e82cd /android | |
parent | 9ebcb80e2e4335fca1e137d015fe4d84631e282a (diff) |
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@posteo.de>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/LOKitTileProvider.java | 25 |
1 files changed, 11 insertions, 14 deletions
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(); } } |