Renamed isAvailable to check
This commit is contained in:
parent
a1dc163ccc
commit
7d38b4e354
@ -117,8 +117,8 @@ public class Printer extends CordovaPlugin {
|
||||
|
||||
command = callback;
|
||||
|
||||
if (action.equalsIgnoreCase("isAvailable")) {
|
||||
isAvailable();
|
||||
if (action.equalsIgnoreCase("check")) {
|
||||
check();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ public class Printer extends CordovaPlugin {
|
||||
* Informs if the device is able to print documents.
|
||||
* A Internet connection is required to load the cloud print dialog.
|
||||
*/
|
||||
private void isAvailable () {
|
||||
private void check () {
|
||||
cordova.getThreadPool().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -25,11 +25,11 @@
|
||||
|
||||
@interface APPPrinter : CDVPlugin <UIWebViewDelegate>
|
||||
|
||||
// Prints the content
|
||||
- (void) print:(CDVInvokedUrlCommand*)command;
|
||||
// Find out whether printing is supported on this platform
|
||||
- (void) isAvailable:(CDVInvokedUrlCommand*)command;
|
||||
- (void) check:(CDVInvokedUrlCommand*)command;
|
||||
// Displays system interface for selecting a printer
|
||||
- (void) pick:(CDVInvokedUrlCommand*)command;
|
||||
// Prints the content
|
||||
- (void) print:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|
||||
|
@ -41,7 +41,7 @@
|
||||
* @param {Function} callback
|
||||
* A callback function to be called with the result
|
||||
*/
|
||||
- (void) isAvailable:(CDVInvokedUrlCommand*)command
|
||||
- (void) check:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
[self.commandDelegate runInBackground:^{
|
||||
CDVPluginResult* pluginResult;
|
||||
@ -94,13 +94,13 @@
|
||||
return;
|
||||
}
|
||||
_callbackId = command.callbackId;
|
||||
|
||||
|
||||
NSArray* arguments = [command arguments];
|
||||
NSMutableDictionary* settings = [arguments objectAtIndex:0];
|
||||
|
||||
|
||||
NSArray* bounds = [settings objectForKey:@"bounds"];
|
||||
CGRect rect = [self convertIntoRect:bounds];
|
||||
|
||||
|
||||
[self presentPrinterPicker:rect];
|
||||
}
|
||||
|
||||
@ -140,11 +140,11 @@
|
||||
- (BOOL) isPrintingAvailable
|
||||
{
|
||||
Class controllerCls = NSClassFromString(@"UIPrintInteractionController");
|
||||
|
||||
|
||||
if (!controllerCls) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
return [self printController] && [UIPrintInteractionController
|
||||
isPrintingAvailable];
|
||||
}
|
||||
@ -165,7 +165,7 @@
|
||||
CDVPluginResult* pluginResult =
|
||||
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsBool:ok];
|
||||
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult
|
||||
callbackId:_callbackId];
|
||||
}];
|
||||
@ -176,7 +176,7 @@
|
||||
CDVPluginResult* pluginResult =
|
||||
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsBool:ok];
|
||||
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult
|
||||
callbackId:_callbackId];
|
||||
}];
|
||||
@ -196,13 +196,13 @@
|
||||
{
|
||||
NSURL* url = [NSURL URLWithString:printerId];
|
||||
UIPrinter* printer = [UIPrinter printerWithURL:url];
|
||||
|
||||
|
||||
[controller printToPrinter:printer completionHandler:
|
||||
^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
|
||||
CDVPluginResult* pluginResult =
|
||||
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsBool:ok];
|
||||
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult
|
||||
callbackId:_callbackId];
|
||||
}];
|
||||
@ -218,7 +218,7 @@
|
||||
{
|
||||
UIPrinterPickerController* controller =
|
||||
[UIPrinterPickerController printerPickerControllerWithInitiallySelectedPrinter:nil];
|
||||
|
||||
|
||||
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
|
||||
[controller presentFromRect:rect inView:self.webView animated:YES completionHandler:
|
||||
^(UIPrinterPickerController *ctrl, BOOL userDidSelect, NSError *e) {
|
||||
@ -248,18 +248,18 @@
|
||||
{
|
||||
CDVPluginResult* pluginResult =
|
||||
[CDVPluginResult resultWithStatus:CDVCommandStatus_NO_RESULT];
|
||||
|
||||
|
||||
if (userDidSelect) {
|
||||
UIPrinter* printer = ctrl.selectedPrinter;
|
||||
|
||||
|
||||
[UIPrinterPickerController
|
||||
printerPickerControllerWithInitiallySelectedPrinter:printer];
|
||||
|
||||
|
||||
pluginResult = [CDVPluginResult
|
||||
resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsString:printer.URL.absoluteString];
|
||||
}
|
||||
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult
|
||||
callbackId:_callbackId];
|
||||
}
|
||||
@ -301,9 +301,9 @@
|
||||
if ([[settings objectForKey:@"graystyle"] boolValue]) {
|
||||
outputType = UIPrintInfoOutputGrayscale;
|
||||
}
|
||||
|
||||
|
||||
outputType += [[settings objectForKey:@"border"] boolValue] ? 0 : 1;
|
||||
|
||||
|
||||
if ([[settings objectForKey:@"duplex"] isEqualToString:@"long"]) {
|
||||
duplexMode = UIPrintInfoDuplexLongEdge;
|
||||
} else
|
||||
@ -340,7 +340,7 @@
|
||||
UIViewPrintFormatter* formatter = [page viewPrintFormatter];
|
||||
|
||||
[renderer addPrintFormatter:formatter startingAtPageAtIndex:0];
|
||||
|
||||
|
||||
page.delegate = self;
|
||||
|
||||
if ([NSURL URLWithString:content]) {
|
||||
|
@ -34,7 +34,7 @@ var Printing = Windows.Graphics.Printing,
|
||||
* @param {Array} args
|
||||
* Interface arguments
|
||||
*/
|
||||
exports.isAvailable = function (success, fail, args) {
|
||||
exports.check = function (success, fail, args) {
|
||||
success(MSApp.hasOwnProperty('getHtmlPrintDocumentSourceAsync'), 0);
|
||||
};
|
||||
|
||||
|
@ -54,10 +54,17 @@ exports.getDefaults = function () {
|
||||
*
|
||||
* @return {Boolean}
|
||||
*/
|
||||
exports.isAvailable = function (callback, scope) {
|
||||
exports.check = function (callback, scope) {
|
||||
var fn = this._createCallbackFn(callback);
|
||||
|
||||
exec(fn, null, 'Printer', 'isAvailable', []);
|
||||
exec(fn, null, 'Printer', 'check', []);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated API call. Use `check` instead!
|
||||
*/
|
||||
exports.isAvailable = function () {
|
||||
exports.check.apply(exports, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user