101
+        startActivity(intent);
98 102
     }
99 103
 
100 104
     @OnClick(R.id.title_bar_back_layout)
@@ -143,7 +147,9 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
143 147
     @Override
144 148
     public void onClick(View view) {
145 149
         if(view.getId()==R.id.btn_print_qr){
146
-            presenter.printQR();
150
+            Intent intent = new Intent(this,PrinterSettingActivity.class);
151
+            intent.putExtra("qrcode",sessionBean.sessionId);
152
+            startActivity(intent);
147 153
         }else if(view.getId()==R.id.tv_printer_set){
148 154
             startActivity(new Intent(this, PrinterSettingActivity.class));
149 155
         }

+ 0 - 1
app/src/main/java/ai/pai/lensman/session/SessionContract.java

@@ -18,6 +18,5 @@ public class SessionContract {
18 18
 
19 19
     interface Presenter extends BasePresenter{
20 20
         void swipeToDeletePhoto(int index);
21
-        void printQR();
22 21
     }
23 22
 }

+ 1 - 127
app/src/main/java/ai/pai/lensman/session/SessionPresenter.java

@@ -1,34 +1,13 @@
1 1
 package ai.pai.lensman.session;
2 2
 
3
-import android.content.ComponentName;
4
-import android.content.Context;
5 3
 import android.content.Intent;
6
-import android.content.ServiceConnection;
7
-import android.os.IBinder;
8
-import android.text.TextUtils;
9
-import android.util.Base64;
10
-import android.util.Log;
11
-
12
-import com.android.common.utils.LogHelper;
13
-import com.gprinter.aidl.GpService;
14
-import com.gprinter.command.EscCommand;
15
-import com.gprinter.command.GpCom;
16
-import com.gprinter.io.PortParameters;
17
-import com.gprinter.service.GpPrintService;
18
-
19
-import org.apache.commons.lang.ArrayUtils;
20
-
21
-import java.text.SimpleDateFormat;
4
+
22 5
 import java.util.ArrayList;
23
-import java.util.Date;
24
-import java.util.Vector;
25 6
 
26 7
 import ai.pai.lensman.App;
27
-import ai.pai.lensman.R;
28 8
 import ai.pai.lensman.bean.PhotoBean;
29 9
 import ai.pai.lensman.bean.SessionBean;
30 10
 import ai.pai.lensman.db.DBService;
31
-import ai.pai.lensman.db.Preferences;
32 11
 import ai.pai.lensman.service.UploadService;
33 12
 
34 13
 
@@ -40,9 +19,6 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
40 19
     private SessionBean sessionBean;
41 20
     private boolean isWorking;
42 21
 
43
-    private GpService mGpService = null;
44
-    private PrinterServiceConnection conn = null;
45
-    private int mPrinterId = 0;
46 22
 
47 23
 
48 24
     public SessionPresenter(SessionBean sessionBean, SessionContract.View view) {
@@ -63,16 +39,12 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
63 39
             }
64 40
         }
65 41
         interactor.startSession();
66
-        startAndBindPrintService();
67 42
     }
68 43
 
69 44
     @Override
70 45
     public void stop() {
71 46
         interactor.endSession();
72 47
         isWorking = false;
73
-        if (conn != null) {
74
-            App.getAppContext().unbindService(conn);
75
-        }
76 48
     }
77 49
 
78 50
     @Override
@@ -111,102 +83,4 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
111 83
         interactor.deletePhoto(photoBean);
112 84
     }
113 85
 
114
-    @Override
115
-    public void printQR() {
116
-        if(TextUtils.isEmpty(Preferences.getInstance().getPrinterMac())){
117
-            sessionView.showToast(App.getAppContext().getString(R.string.not_set_printer_yet));
118
-            return;
119
-        }
120
-        checkPrinter();
121
-        EscCommand esc = new EscCommand();
122
-        esc.addPrintAndFeedLines((byte) 3);
123
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.CENTER);//设置打印居中
124
-        esc.addSelectPrintModes(EscCommand.FONT.FONTA, EscCommand.ENABLE.OFF, EscCommand.ENABLE.ON, EscCommand.ENABLE.ON, EscCommand.ENABLE.OFF);//设置为倍高倍宽
125
-        esc.addText("拍爱\n");   //  打印文字
126
-        esc.addPrintAndLineFeed();
127
-
128
-		/*打印文字*/
129
-        esc.addSelectPrintModes(EscCommand.FONT.FONTA, EscCommand.ENABLE.OFF, EscCommand.ENABLE.OFF, EscCommand.ENABLE.OFF, EscCommand.ENABLE.OFF);//取消倍高倍宽
130
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.LEFT);//设置打印左对齐
131
-        esc.addText("欢迎使用拍爱!\n");   //  打印文字
132
-
133
-		/*QRCode命令打印
134
-			此命令只在支持QRCode命令打印的机型才能使用。
135
-			在不支持二维码指令打印的机型上,则需要发送二维条码图片
136
-		*/
137
-        esc.addText("Print QRCode\n");   //  打印文字
138
-        esc.addPrintAndFeedLines((byte) 3);
139
-        esc.addSelectErrorCorrectionLevelForQRCode((byte) 0x31); //设置纠错等级
140
-        esc.addSelectSizeOfModuleForQRCode((byte)10);//设置qrcode模块大小
141
-        esc.addStoreQRCodeData(sessionBean.sessionId);//设置qrcode内容
142
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.CENTER);//设置打印中心对齐
143
-        esc.addPrintQRCode();//打印QRCode
144
-        esc.addSelectJustification(EscCommand.JUSTIFICATION.LEFT);//设置打印左对齐
145
-        esc.addText("拍摄日期 "+new SimpleDateFormat("yy/MM/dd HH:mm").format(new Date()));
146
-        esc.addPrintAndFeedLines((byte) 3);
147
-
148
-        Vector<Byte> datas = esc.getCommand(); //发送数据
149
-        Byte[] Bytes = datas.toArray(new Byte[datas.size()]);
150
-        byte[] bytes = ArrayUtils.toPrimitive(Bytes);
151
-        String str = Base64.encodeToString(bytes, Base64.DEFAULT);
152
-        int rel;
153
-        try {
154
-            rel = mGpService.sendEscCommand(mPrinterId, str);
155
-            GpCom.ERROR_CODE r = GpCom.ERROR_CODE.values()[rel];
156
-            if (r != GpCom.ERROR_CODE.SUCCESS) {
157
-                sessionView.showToast( GpCom.getErrorText(r));
158
-            }
159
-        } catch (Exception e) {
160
-            sessionView.showToast(App.getAppContext().getString(R.string.go_check_printer));
161
-        }
162
-    }
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
-
192
-    private void startAndBindPrintService() {
193
-        Intent intent = new Intent(App.getAppContext(), GpPrintService.class);
194
-        App.getAppContext().startService(intent);
195
-        conn = new PrinterServiceConnection();
196
-        App.getAppContext().bindService(intent, conn, Context.BIND_AUTO_CREATE);
197
-    }
198
-
199
-    class PrinterServiceConnection implements ServiceConnection {
200
-        @Override
201
-        public void onServiceDisconnected(ComponentName name) {
202
-            Log.i("ServiceConnection", "onServiceDisconnected() called");
203
-            mGpService = null;
204
-        }
205
-
206
-        @Override
207
-        public void onServiceConnected(ComponentName name, IBinder service) {
208
-            mGpService = GpService.Stub.asInterface(service);
209
-        }
210
-    }
211
-
212 86
 }

+ 8 - 1
app/src/main/res/layout/activity_printer_setting.xml

@@ -65,6 +65,13 @@
65 65
         android:layout_below="@id/title_bar_with_back_btn"
66 66
         android:orientation="vertical">
67 67
 
68
+        <ImageView
69
+            android:id="@+id/iv_qrcode"
70
+            android:layout_width="240dp"
71
+            android:layout_height="240dp"
72
+            android:layout_gravity="center_horizontal"
73
+            android:layout_margin="8dp"/>
74
+
68 75
         <LinearLayout
69 76
             android:layout_width="match_parent"
70 77
             android:layout_height="38dp"
@@ -111,7 +118,7 @@
111 118
                 android:id="@+id/tv_print_test"
112 119
                 android:layout_width="wrap_content"
113 120
                 android:layout_height="wrap_content"
114
-                android:text="@string/print_test"
121
+                android:text="@string/print_qr"
115 122
                 android:textColor="@color/dark_grey"
116 123
                 android:textSize="16sp" />
117 124
         </LinearLayout>

kodo - Gogs: Go Git Service

説明なし

FFIB: b2220dd77c MemberActivityInfo default 6 年 前
account 6a9e324f6f :art: Re Makemigrations 6 年 前
api e2d620ee89 增加 会员活动接口(增、删、改、查) 6 年 前
box 018d52f61d Update package django_xxx 8 年 前
commands 3e9628d0c9 iSort & Pycodestyle 6 年 前
coupon 6a9e324f6f :art: Re Makemigrations 6 年 前
docs 212e3994d1 MP verify file 9 年 前
geo 018d52f61d Update package django_xxx 8 年 前
group 6a9e324f6f :art: Re Makemigrations 6 年 前
guideline 91c6ab8593 :art: Remove unicode 6 年 前
integral 6a9e324f6f :art: Re Makemigrations 6 年 前
kodo 44c0a03bdc :art: Remove db_index=True for BooleanField 6 年 前
logs 91c6ab8593 :art: Remove unicode 6 年 前
marketcode 6a9e324f6f :art: Re Makemigrations 6 年 前
mch 6a9e324f6f :art: Re Makemigrations 6 年 前
member b2220dd77c MemberActivityInfo default 6 年 前
message 6a9e324f6f :art: Re Makemigrations 6 年 前
miniapp 3e9628d0c9 iSort & Pycodestyle 6 年 前
operation 96c4bec605 :art: Add api activity_group_share 6 年 前
page b4b69326ce :art: Remove unused imports 6 年 前
pay 6a9e324f6f :art: Re Makemigrations 6 年 前
photo 96c4bec605 :art: Add api activity_group_share 6 年 前
pre e812ec3fb2 switch gis to tencent 6 年 前
sales 6a9e324f6f :art: Re Makemigrations 6 年 前
server 018d52f61d Update package django_xxx 8 年 前
shells 57be08ef32 :art: Codes Format 6 年 前
simditor 3e9628d0c9 iSort & Pycodestyle 6 年 前
staff 91c6ab8593 :art: Remove unicode 6 年 前
statistic 91c6ab8593 :art: Remove unicode 6 年 前
utils 3e9628d0c9 iSort & Pycodestyle 6 年 前
website 597ee33ba6 Pai2 => Kodo 8 年 前
.editorconfig 4defb80fdc gogs first init 11 年 前
.gitignore 4ce7f5c87b :art: Member Relative APIs 7 年 前
.isort.cfg afcdf74a49 add api group_data_api 10 年 前
TODO.md d31ffaa118 Update TODO 10 年 前
check.sh 95c1d32792 put isort and pep8 in check.sh 10 年 前
isort.sh 3e9628d0c9 iSort & Pycodestyle 6 年 前
manage.py 597ee33ba6 Pai2 => Kodo 8 年 前
pep8.sh 511533855d Change oauth to use http 9 年 前
requirements.txt 2839c5059d :art: Update requirement_xxx.txt 6 年 前
requirements_deploy.txt 873b42cb2f :art: TimeConvert local_string utc_dt 6 年 前
requirements_dev.txt 926f0ef06a Update requirements_xxx.txt 8 年 前
requirements_dj.txt 6a9e324f6f :art: Re Makemigrations 6 年 前
requirements_pywe.txt 6a9e324f6f :art: Re Makemigrations 6 年 前
requirements_redis.txt 2839c5059d :art: Update requirement_xxx.txt 6 年 前
sysctl.sh 34c6774438 Opt 8 年 前
kodo - Gogs: Go Git Service

Brak opisu

apps.py 146B

    # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.apps import AppConfig class PreConfig(AppConfig): name = 'pre'