Removed the callback
property from the print
interface
This commit is contained in:
@@ -340,15 +340,4 @@ public class Printer extends CordovaPlugin {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent);
|
||||
|
||||
if (resultCode == -1) {
|
||||
ctx.success(4);
|
||||
} else {
|
||||
ctx.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,23 @@
|
||||
/*
|
||||
Copyright 2013 appPlant UG
|
||||
Copyright 2013 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
|
@@ -1,41 +1,36 @@
|
||||
/*
|
||||
Copyright 2013 appPlant UG
|
||||
Copyright 2013 appPlant UG
|
||||
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import "APPPrinter.h"
|
||||
|
||||
#define APP_PRINT_CANCELLED 0 // Printing cancelled (cancel button pressed)
|
||||
#define APP_PRINT_SENT 2 // Page printed
|
||||
#define APP_PRINT_FAILED 3 // Printing failed
|
||||
#define APP_PRINT_NOTSENT 4 // Page not printed (something wrong happened)
|
||||
|
||||
@interface APPPrinter (Private)
|
||||
|
||||
// Erstellt den PrintController
|
||||
- (UIPrintInteractionController *) getPrintController;
|
||||
- (UIPrintInteractionController*) getPrintController;
|
||||
// Stellt die Eigenschaften des Druckers ein.
|
||||
- (UIPrintInteractionController *) adjustSettingsForPrintController:(UIPrintInteractionController *)controller;
|
||||
- (UIPrintInteractionController*) adjustSettingsForPrintController:(UIPrintInteractionController*)controller;
|
||||
// Lädt den zu druckenden Content in ein WebView, welcher vom Drucker ausgedruckt werden soll.
|
||||
- (void) loadContent:(NSString *)content intoPrintController:(UIPrintInteractionController *)controller;
|
||||
- (void) loadContent:(NSString*)content intoPrintController:(UIPrintInteractionController*)controller;
|
||||
// Ruft den Callback auf und informiert diesen über den das Ergebnis des Druckvorgangs.
|
||||
- (void) informAboutResult:(int)code callbackId:(NSString *)callbackId;
|
||||
- (void) informAboutResult:(int)code callbackId:(NSString*)callbackId;
|
||||
// Überprüft, ob der Drucker-Dienst verfügbar ist
|
||||
- (BOOL) isPrintServiceAvailable;
|
||||
|
||||
@@ -47,7 +42,7 @@
|
||||
/*
|
||||
* Is printing available.
|
||||
*/
|
||||
- (void) isServiceAvailable:(CDVInvokedUrlCommand *)command
|
||||
- (void) isServiceAvailable:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
CDVPluginResult* pluginResult;
|
||||
|
||||
@@ -61,11 +56,10 @@
|
||||
* Öffnet den Drucker-Kontroller zur Auswahl des Druckers.
|
||||
* Callback gibt Meta-Informationen an.
|
||||
*/
|
||||
- (void) print:(CDVInvokedUrlCommand *)command
|
||||
- (void) print:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
if (![self isPrintServiceAvailable])
|
||||
{
|
||||
[self informAboutResult:APP_PRINT_FAILED callbackId:command.callbackId];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,20 +72,16 @@
|
||||
[self loadContent:content intoPrintController:controller];
|
||||
|
||||
[controller presentAnimated:YES completionHandler:^(UIPrintInteractionController* printController, BOOL completed, NSError* error) {
|
||||
if (completed) {
|
||||
[self informAboutResult:APP_PRINT_SENT callbackId:command.callbackId];
|
||||
} else if (error) {
|
||||
[self informAboutResult:APP_PRINT_FAILED callbackId:command.callbackId];
|
||||
} else {
|
||||
[self informAboutResult:APP_PRINT_CANCELLED callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
}];
|
||||
|
||||
[self commandDelegate];
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt den PrintController.
|
||||
*/
|
||||
- (UIPrintInteractionController *) getPrintController
|
||||
- (UIPrintInteractionController*) getPrintController
|
||||
{
|
||||
return [UIPrintInteractionController sharedPrintController];
|
||||
}
|
||||
@@ -99,7 +89,7 @@
|
||||
/**
|
||||
* Stellt die Eigenschaften des Druckers ein.
|
||||
*/
|
||||
- (UIPrintInteractionController *) adjustSettingsForPrintController:(UIPrintInteractionController *)controller
|
||||
- (UIPrintInteractionController*) adjustSettingsForPrintController:(UIPrintInteractionController*)controller
|
||||
{
|
||||
UIPrintInfo* printInfo = [UIPrintInfo printInfo];
|
||||
printInfo.outputType = UIPrintInfoOutputGeneral;
|
||||
@@ -112,7 +102,7 @@
|
||||
/**
|
||||
* Lädt den zu druckenden Content in ein WebView, welcher vom Drucker ausgedruckt werden soll.
|
||||
*/
|
||||
- (void) loadContent:(NSString *)content intoPrintController:(UIPrintInteractionController *)controller
|
||||
- (void) loadContent:(NSString*)content intoPrintController:(UIPrintInteractionController*)controller
|
||||
{
|
||||
// Set the base URL to be the www directory.
|
||||
NSString* wwwFilePath = [[NSBundle mainBundle] pathForResource:@"www" ofType:nil];
|
||||
@@ -129,17 +119,6 @@
|
||||
controller.showsPageRange = YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruft den Callback auf und informiert diesen über den das Ergebnis des Druckvorgangs.
|
||||
*/
|
||||
- (void) informAboutResult:(int)code callbackId:(NSString *)callbackId
|
||||
{
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsInt:code];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
|
||||
}
|
||||
|
||||
/**
|
||||
* Überprüft, ob der Drucker-Dienst verfügbar ist.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user