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