Showing
5 changed files
with
13 additions
and
19 deletions
@@ -25,7 +25,7 @@ android { | @@ -25,7 +25,7 @@ android { | ||
25 | compileSdkVersion 28 | 25 | compileSdkVersion 28 |
26 | 26 | ||
27 | defaultConfig { | 27 | defaultConfig { |
28 | - minSdkVersion 19 | 28 | + minSdkVersion 16 |
29 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | 29 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
30 | } | 30 | } |
31 | lintOptions { | 31 | lintOptions { |
@@ -14,7 +14,7 @@ public class PrintingHandler implements MethodChannel.MethodCallHandler { | @@ -14,7 +14,7 @@ public class PrintingHandler implements MethodChannel.MethodCallHandler { | ||
14 | private final Activity activity; | 14 | private final Activity activity; |
15 | private final MethodChannel channel; | 15 | private final MethodChannel channel; |
16 | 16 | ||
17 | - public PrintingHandler(@NonNull Activity activity, @NonNull MethodChannel channel) { | 17 | + PrintingHandler(@NonNull Activity activity, @NonNull MethodChannel channel) { |
18 | this.activity = activity; | 18 | this.activity = activity; |
19 | this.channel = channel; | 19 | this.channel = channel; |
20 | } | 20 | } |
@@ -34,8 +34,7 @@ public class PrintingHandler implements MethodChannel.MethodCallHandler { | @@ -34,8 +34,7 @@ public class PrintingHandler implements MethodChannel.MethodCallHandler { | ||
34 | final PrintingJob printJob = | 34 | final PrintingJob printJob = |
35 | new PrintingJob(activity, this, (int) call.argument("job")); | 35 | new PrintingJob(activity, this, (int) call.argument("job")); |
36 | assert name != null; | 36 | assert name != null; |
37 | - printJob.printPdf( | ||
38 | - name, width, height, marginLeft, marginTop, marginRight, marginBottom); | 37 | + printJob.printPdf(name); |
39 | 38 | ||
40 | result.success(1); | 39 | result.success(1); |
41 | break; | 40 | break; |
@@ -73,13 +73,16 @@ public class PrintingJob extends PrintDocumentAdapter { | @@ -73,13 +73,16 @@ public class PrintingJob extends PrintDocumentAdapter { | ||
73 | } | 73 | } |
74 | 74 | ||
75 | static HashMap<String, Object> printingInfo() { | 75 | static HashMap<String, Object> printingInfo() { |
76 | + final boolean canPrint = android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; | ||
77 | + final boolean canRaster = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; | ||
78 | + | ||
76 | HashMap<String, Object> result = new HashMap<>(); | 79 | HashMap<String, Object> result = new HashMap<>(); |
77 | result.put("directPrint", false); | 80 | result.put("directPrint", false); |
78 | - result.put("dynamicLayout", true); | ||
79 | - result.put("canPrint", true); | ||
80 | - result.put("canConvertHtml", true); | 81 | + result.put("dynamicLayout", canPrint); |
82 | + result.put("canPrint", canPrint); | ||
83 | + result.put("canConvertHtml", canRaster); | ||
81 | result.put("canShare", true); | 84 | result.put("canShare", true); |
82 | - result.put("canRaster", true); | 85 | + result.put("canRaster", canRaster); |
83 | return result; | 86 | return result; |
84 | } | 87 | } |
85 | 88 | ||
@@ -181,8 +184,7 @@ public class PrintingJob extends PrintDocumentAdapter { | @@ -181,8 +184,7 @@ public class PrintingJob extends PrintDocumentAdapter { | ||
181 | thread.start(); | 184 | thread.start(); |
182 | } | 185 | } |
183 | 186 | ||
184 | - void printPdf(@NonNull String name, Double width, Double height, Double marginLeft, | ||
185 | - Double marginTop, Double marginRight, Double marginBottom) { | 187 | + void printPdf(@NonNull String name) { |
186 | jobName = name; | 188 | jobName = name; |
187 | printJob = printManager.print(name, this, null); | 189 | printJob = printManager.print(name, this, null); |
188 | } | 190 | } |
@@ -17,22 +17,14 @@ | @@ -17,22 +17,14 @@ | ||
17 | package net.nfet.flutter.printing; | 17 | package net.nfet.flutter.printing; |
18 | 18 | ||
19 | import android.app.Activity; | 19 | import android.app.Activity; |
20 | -import android.content.Context; | ||
21 | -import android.print.PrintAttributes; | ||
22 | 20 | ||
23 | import androidx.annotation.NonNull; | 21 | import androidx.annotation.NonNull; |
24 | 22 | ||
25 | -import java.util.HashMap; | ||
26 | - | ||
27 | import io.flutter.embedding.engine.plugins.FlutterPlugin; | 23 | import io.flutter.embedding.engine.plugins.FlutterPlugin; |
28 | import io.flutter.embedding.engine.plugins.activity.ActivityAware; | 24 | import io.flutter.embedding.engine.plugins.activity.ActivityAware; |
29 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; | 25 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; |
30 | import io.flutter.plugin.common.BinaryMessenger; | 26 | import io.flutter.plugin.common.BinaryMessenger; |
31 | -import io.flutter.plugin.common.EventChannel; | ||
32 | -import io.flutter.plugin.common.MethodCall; | ||
33 | import io.flutter.plugin.common.MethodChannel; | 27 | import io.flutter.plugin.common.MethodChannel; |
34 | -import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | ||
35 | -import io.flutter.plugin.common.MethodChannel.Result; | ||
36 | import io.flutter.plugin.common.PluginRegistry.Registrar; | 28 | import io.flutter.plugin.common.PluginRegistry.Registrar; |
37 | 29 | ||
38 | /** | 30 | /** |
@@ -73,7 +65,7 @@ public class PrintingPlugin implements FlutterPlugin, ActivityAware { | @@ -73,7 +65,7 @@ public class PrintingPlugin implements FlutterPlugin, ActivityAware { | ||
73 | } | 65 | } |
74 | 66 | ||
75 | @Override | 67 | @Override |
76 | - public void onDetachedFromEngine(FlutterPluginBinding binding) { | 68 | + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) { |
77 | channel.setMethodCallHandler(null); | 69 | channel.setMethodCallHandler(null); |
78 | channel = null; | 70 | channel = null; |
79 | handler = null; | 71 | handler = null; |
-
Please register or login to post a comment