AppId kann als PlatformConfig unter Android beim Drucken angegeben werden

This commit is contained in:
Sebastián Katzer 2013-08-24 19:49:06 +02:00
parent 797a1d5bfc
commit c6b60b73d4

View File

@ -113,7 +113,8 @@ public class Printer extends CordovaPlugin {
cordova.getActivity().runOnUiThread( new Runnable() { cordova.getActivity().runOnUiThread( new Runnable() {
public void run() { public void run() {
String appId = self.getFirstInstalledAppId(); JSONObject platformConfig = args.optJSONObject(1);
String appId = self.getPrintAppId(platformConfig);
if (appId == null) { if (appId == null) {
self.ctx.success(4); 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. * Erstellt den Print-View.
*/ */
@ -207,10 +221,10 @@ public class Printer extends CordovaPlugin {
public void run() { public void run() {
Bitmap screenshot = self.takeScreenshot(page); Bitmap screenshot = self.takeScreenshot(page);
File tmpFile = self.saveScreenshotToTmpFile(screenshot); File tmpFile = self.saveScreenshotToTmpFile(screenshot);
ViewGroup vg = (ViewGroup)(page.getParent());
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tmpFile)); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(tmpFile));
ViewGroup vg = (ViewGroup)(page.getParent());
vg.removeView(page); vg.removeView(page);
} }
}, 1000); }, 1000);