147 161
         }
148 162
     }
149 163
 
164
+    private void checkPrinter(){
165
+        sessionView.showToast(App.getAppContext().getString(R.string.connecting));
166
+        try{
167
+            int status = mGpService.queryPrinterStatus(0, 10000);
168
+            if (status != GpCom.STATE_NO_ERR) {
169
+                connectPrinter();
170
+            }
171
+        }catch (Exception e){
172
+            sessionView.showToast(App.getAppContext().getString(R.string.go_check_printer));
173
+            return;
174
+        }
175
+        printQR();
176
+    }
177
+
178
+    public void connectPrinter() {
179
+        if(mGpService==null){
180
+            sessionView.showToast(App.getAppContext().getString(R.string.printer_service_boot_fail));
181
+            return;
182
+        }
183
+        try {
184
+            int code = mGpService.openPort(0, PortParameters.BLUETOOTH, Preferences.getInstance().getPrinterMac(), 0);
185
+            LogHelper.d("czy111","open port return code ="+code);
186
+        } catch (Exception e) {
187
+            sessionView.showToast(App.getAppContext().getString(R.string.printer_port_open_fail));
188
+        }
189
+
190
+    }
191
+
150 192
     private void startAndBindPrintService() {
151 193
         Intent intent = new Intent(App.getAppContext(), GpPrintService.class);
152 194
         App.getAppContext().startService(intent);

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -110,4 +110,6 @@
110 110
     <string name="printer_status_query_fail">打印机状态查询失败</string>
111 111
 
112 112
     <string name="printer_service_boot_fail">打印机服务连接失败,请退出应用重试</string>
113
+
114
+    <string name="not_set_printer_yet">尚未设置打印机,去设置</string>
113 115
 </resources>

+ 1 - 1
build.gradle

@@ -5,7 +5,7 @@ buildscript {
5 5
         jcenter()
6 6
     }
7 7
     dependencies {
8
-        classpath 'com.android.tools.build:gradle:2.1.3'
8
+        classpath 'com.android.tools.build:gradle:2.2.0-rc1'
9 9
         classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
10 10
         // NOTE: Do not place your application dependencies here; they belong
11 11
         // in the individual module build.gradle files

kodo - Gogs: Go Git Service

説明なし

tests.py 61B

    from django.test import TestCase # Create your tests here.