From c6b60b73d4d6315b3e3c631899b2784fbafc9112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Katzer?= Date: Sat, 24 Aug 2013 19:49:06 +0200 Subject: [PATCH] AppId kann als PlatformConfig unter Android beim Drucken angegeben werden --- src/android/Printer.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/android/Printer.java b/src/android/Printer.java index 0484050..1b19d14 100644 --- a/src/android/Printer.java +++ b/src/android/Printer.java @@ -113,7 +113,8 @@ public class Printer extends CordovaPlugin { cordova.getActivity().runOnUiThread( new Runnable() { public void run() { - String appId = self.getFirstInstalledAppId(); + JSONObject platformConfig = args.optJSONObject(1); + String appId = self.getPrintAppId(platformConfig); if (appId == null) { self.ctx.success(4); @@ -131,6 +132,19 @@ public class Printer extends CordovaPlugin { }); } + /** + * Gibt die zu verwendende App-ID an. + */ + private String getPrintAppId (JSONObject platformConfig) { + String appId = platformConfig.optString("appId", null); + + if (appId != null) { + return (this.isAppInstalled(appId)) ? appId : null; + } else { + return this.getFirstInstalledAppId(); + } + } + /** * Erstellt den Print-View. */ @@ -207,10 +221,10 @@ public class Printer extends CordovaPlugin { public void run() { Bitmap screenshot = self.takeScreenshot(page); File tmpFile = self.saveScreenshotToTmpFile(screenshot); + ViewGroup vg = (ViewGroup)(page.getParent()); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tmpFile)); - ViewGroup vg = (ViewGroup)(page.getParent()); vg.removeView(page); } }, 1000);