130
+        esc.addPrintQRCode();//打印QRCode
131
+        esc.addPrintAndLineFeed();
132
+
133
+        Vector<Byte> datas = esc.getCommand(); //发送数据
134
+        Byte[] Bytes = datas.toArray(new Byte[datas.size()]);
135
+        byte[] bytes = ArrayUtils.toPrimitive(Bytes);
136
+        String str = Base64.encodeToString(bytes, Base64.DEFAULT);
137
+        int rel;
138
+        try {
139
+            rel = mGpService.sendEscCommand(mPrinterId, str);
140
+            GpCom.ERROR_CODE r = GpCom.ERROR_CODE.values()[rel];
141
+            if (r != GpCom.ERROR_CODE.SUCCESS) {
142
+                sessionView.showToast( GpCom.getErrorText(r));
143
+            }
144
+        } catch (RemoteException e) {
145
+            e.printStackTrace();
146
+        }
147
+    }
148
+
149
+    private void startAndBindPrintService() {
150
+        Intent intent = new Intent(App.getAppContext(), GpPrintService.class);
151
+        App.getAppContext().startService(intent);
101 152
         conn = new PrinterServiceConnection();
102
-        Intent intent = new Intent("com.gprinter.aidl.GpPrintService");
103 153
         App.getAppContext().bindService(intent, conn, Context.BIND_AUTO_CREATE);
104 154
     }
105 155
 
@@ -115,4 +165,5 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
115 165
             mGpService = GpService.Stub.asInterface(service);
116 166
         }
117 167
     }
168
+
118 169
 }

+ 14 - 2
app/src/main/java/ai/pai/lensman/session/SessionQRPopup.java

@@ -5,8 +5,10 @@ import android.content.Context;
5 5
 import android.view.LayoutInflater;
6 6
 import android.view.View;
7 7
 import android.view.animation.Animation;
8
+import android.widget.Button;
8 9
 import android.widget.ImageView;
9 10
 import android.widget.LinearLayout;
11
+import android.widget.TextView;
10 12
 
11 13
 import com.android.common.utils.DeviceUtils;
12 14
 import com.android.views.popup.BasePopupWindow;
@@ -19,15 +21,18 @@ import butterknife.ButterKnife;
19 21
 public class SessionQRPopup extends BasePopupWindow {
20 22
 
21 23
     private View popupView;
24
+    private Button printQRBtn;
22 25
     private ImageView groupQRImg;
26
+    private TextView printerSetText;
23 27
     private String groupId;
24 28
     private Context context;
29
+    private View.OnClickListener listener;
25 30
 
26
-
27
-    public SessionQRPopup(Activity context, String groupId) {
31
+    public SessionQRPopup(Activity context, String groupId,View.OnClickListener listener) {
28 32
         super(context);
29 33
         this.groupId = groupId;
30 34
         this.context = context;
35
+        this.listener = listener;
31 36
         init();
32 37
     }
33 38
 
@@ -45,10 +50,16 @@ public class SessionQRPopup extends BasePopupWindow {
45 50
     public View getPopupView() {
46 51
         popupView = LayoutInflater.from(mContext).inflate(R.layout.pop_session_qr, null);
47 52
         groupQRImg = ButterKnife.findById(popupView,R.id.iv_group_qrcode);
53
+        printQRBtn = ButterKnife.findById(popupView,R.id.btn_print_qr);
54
+        printerSetText = ButterKnife.findById(popupView,R.id.tv_printer_set);
55
+
48 56
         return popupView;
49 57
     }
50 58
 
51 59
     private void init(){
60
+        printQRBtn.setOnClickListener(listener);
61
+        printerSetText.setOnClickListener(listener);
62
+
52 63
         try{
53 64
             initQRImageSize();
54 65
             groupQRImg.setImageBitmap(QRCreateUtils.Create2DCode(UrlContainer.HOST_URL+groupId, DeviceUtils.dip2px(context,200)));
@@ -56,6 +67,7 @@ public class SessionQRPopup extends BasePopupWindow {
56 67
         }catch (Exception e){
57 68
             e.printStackTrace();
58 69
         }
70
+
59 71
     }
60 72
 
61 73
     @Override

BIN
app/src/main/res/drawable-hdpi/toggle_butt_close.png


BIN
app/src/main/res/drawable-hdpi/toggle_butt_on.png


+ 7 - 0
app/src/main/res/drawable/toggle_button_selector.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+    <item android:drawable="@drawable/toggle_butt_on" android:state_checked="true"/>
5
+    <item android:drawable="@drawable/toggle_butt_close" android:state_checked="false"/>
6
+
7
+</selector>

+ 191 - 0
app/src/main/res/layout/activity_printer_setting.xml

@@ -0,0 +1,191 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:layout_width="match_parent"
4
+    android:layout_height="match_parent"
5
+    android:background="@color/background_light_grey_color">
6
+
7
+    <LinearLayout
8
+        android:id="@+id/title_bar_with_back_btn"
9
+        android:layout_width="match_parent"
10
+        android:layout_height="@dimen/action_bar_height"
11
+        android:background="@color/colorPrimary"
12
+        android:orientation="horizontal">
13
+
14
+        <LinearLayout
15
+            android:id="@+id/title_bar_back_layout"
16
+            android:layout_width="70dp"
17
+            android:layout_height="match_parent"
18
+            android:gravity="center_vertical"
19
+            android:orientation="horizontal"
20
+            android:paddingLeft="12dp">
21
+
22
+            <ImageView
23
+                android:layout_width="32dp"
24
+                android:layout_height="32dp"
25
+                android:src="@drawable/back_selector" />
26
+
27
+        </LinearLayout>
28
+
29
+        <TextView
30
+            android:id="@+id/title_bar_middle_txt"
31
+            android:layout_width="0dp"
32
+            android:layout_height="match_parent"
33
+            android:layout_weight="1"
34
+            android:gravity="center"
35
+            android:paddingLeft="10dp"
36
+            android:paddingRight="10dp"
37
+            android:text="@string/printer_settings"
38
+            android:textColor="@color/text_white"
39
+            android:textSize="@dimen/action_bar_title_medium_text_size" />
40
+
41
+        <LinearLayout
42
+            android:id="@+id/title_bar_option_layout"
43
+            android:layout_width="70dp"
44
+            android:layout_height="match_parent"
45
+            android:gravity="center_vertical|right"
46
+            android:orientation="horizontal"
47
+            android:paddingRight="9dp"
48
+            android:visibility="invisible">
49
+
50
+
51
+            <ImageView
52
+                android:id="@+id/iv_options"
53
+                android:layout_width="32dp"
54
+                android:layout_height="32dp"
55
+                android:layout_marginLeft="6dp"
56
+                android:src="@drawable/option" />
57
+
58
+        </LinearLayout>
59
+
60
+    </LinearLayout>
61
+
62
+    <ScrollView
63
+        android:layout_width="match_parent"
64
+        android:layout_height="match_parent"
65
+        android:layout_below="@id/title_bar_with_back_btn">
66
+
67
+        <LinearLayout
68
+            android:layout_width="match_parent"
69
+            android:layout_height="wrap_content"
70
+            android:orientation="vertical">
71
+
72
+            <LinearLayout
73
+                android:layout_width="match_parent"
74
+                android:layout_height="38dp"
75
+                android:gravity="center_vertical"
76
+                android:orientation="horizontal"
77
+                android:paddingLeft="12dp">
78
+
79
+                <TextView
80
+                    android:layout_width="wrap_content"
81
+                    android:layout_height="wrap_content"
82
+                    android:text="@string/printer_status"
83
+                    android:textColor="@color/grey"
84
+                    android:textSize="14sp" />
85
+            </LinearLayout>
86
+
87
+
88
+            <LinearLayout
89
+                android:layout_width="match_parent"
90
+                android:layout_height="42dp"
91
+                android:background="@color/white"
92
+                android:gravity="center_vertical"
93
+                android:orientation="horizontal"
94
+                android:paddingLeft="12dp">
95
+
96
+                <TextView
97
+                    android:id="@+id/tv_printer_status"
98
+                    android:layout_width="wrap_content"
99
+                    android:layout_height="wrap_content"
100
+                    android:text="@string/query_processing"
101
+                    android:textColor="@color/dark_grey"
102
+                    android:textSize="16sp" />
103
+            </LinearLayout>
104
+
105
+            <LinearLayout
106
+                android:layout_width="match_parent"
107
+                android:layout_height="42dp"
108
+                android:layout_marginTop="1dp"
109
+                android:background="@color/white"
110
+                android:gravity="center_vertical"
111
+                android:orientation="horizontal"
112
+                android:paddingLeft="12dp">
113
+
114
+                <TextView
115
+                    android:id="@+id/tv_print_test"
116
+                    android:layout_width="wrap_content"
117
+                    android:layout_height="wrap_content"
118
+                    android:text="@string/print_test"
119
+                    android:textColor="@color/dark_grey"
120
+                    android:textSize="16sp" />
121
+            </LinearLayout>
122
+
123
+            <LinearLayout
124
+                android:layout_width="match_parent"
125
+                android:layout_height="38dp"
126
+                android:gravity="center_vertical"
127
+                android:orientation="horizontal"
128
+                android:paddingLeft="12dp">
129
+
130
+                <TextView
131
+                    android:layout_width="wrap_content"
132
+                    android:layout_height="wrap_content"
133
+                    android:text="@string/bluetooth_status"
134
+                    android:textColor="@color/grey"
135
+                    android:textSize="14sp" />
136
+            </LinearLayout>
137
+
138
+
139
+            <LinearLayout
140
+                android:layout_width="match_parent"
141
+                android:layout_height="42dp"
142
+                android:background="@color/white"
143
+                android:gravity="center_vertical"
144
+                android:orientation="horizontal"
145
+                android:paddingLeft="12dp">
146
+
147
+                <TextView
148
+                    android:id="@+id/tv_bluetooth_status"
149
+                    android:layout_width="0dp"
150
+                    android:layout_height="wrap_content"
151
+                    android:layout_weight="1"
152
+                    android:text="@string/bt_is_enabled"
153
+                    android:textColor="@color/dark_grey"
154
+                    android:textSize="16sp" />
155
+
156
+
157
+                <ToggleButton
158
+                    android:id="@+id/tb_bluetooth_switch"
159
+                    android:layout_width="56dp"
160
+                    android:layout_height="19dp"
161
+                    android:layout_marginRight="12dp"
162
+                    android:background="@drawable/toggle_button_selector"
163
+                    android:checked="true"
164
+                    android:gravity="center"
165
+                    android:textColor="@color/white"
166
+                    android:textOff="@null"
167
+                    android:textOn="@null" />
168
+
169
+            </LinearLayout>
170
+
171
+
172
+            <LinearLayout
173
+                android:layout_width="match_parent"
174
+                android:layout_height="38dp"
175
+                android:gravity="center_vertical"
176
+                android:orientation="horizontal"
177
+                android:paddingLeft="12dp">
178
+
179
+                <TextView
180
+                    android:layout_width="wrap_content"
181
+                    android:layout_height="wrap_content"
182
+                    android:text="@string/paired_devices"
183
+                    android:textColor="@color/grey"
184
+                    android:textSize="14sp" />
185
+            </LinearLayout>
186
+
187
+        </LinearLayout>
188
+    </ScrollView>
189
+
190
+
191
+</RelativeLayout>

+ 25 - 2
app/src/main/res/layout/pop_session_qr.xml

@@ -11,8 +11,8 @@
11 11
 
12 12
         <LinearLayout
13 13
             android:id="@+id/popup_anima"
14
-            android:layout_width="270dp"
15
-            android:layout_height="270dp"
14
+            android:layout_width="300dp"
15
+            android:layout_height="360dp"
16 16
             android:layout_centerInParent="true"
17 17
             android:gravity="center"
18 18
             android:background="@color/pop_bg_color"
@@ -34,6 +34,29 @@
34 34
                 android:textColor="@color/grey"
35 35
                 android:textSize="12sp" />
36 36
 
37
+            <Button
38
+                android:id="@+id/btn_print_qr"
39
+                android:layout_width="wrap_content"
40
+                android:layout_height="wrap_content"
41
+                android:paddingLeft="8dp"
42
+                android:paddingRight="8dp"
43
+                android:paddingBottom="5dp"
44
+                android:paddingTop="5dp"
45
+                android:textSize="14sp"
46
+                android:textColor="@color/dark_grey"
47
+                android:layout_marginTop="10dp"
48
+                android:text="@string/print_qr"/>
49
+
50
+            <TextView
51
+                android:id="@+id/tv_printer_set"
52
+                android:layout_marginTop="16dp"
53
+                android:padding="5dp"
54
+                android:layout_width="wrap_content"
55
+                android:layout_height="wrap_content"
56
+                android:text="@string/check_printer"
57
+                android:textColor="@color/light_blue"
58
+                android:textSize="12sp" />
59
+
37 60
         </LinearLayout>
38 61
 
39 62
     </RelativeLayout>

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

@@ -58,4 +58,32 @@
58 58
     <string name="no_system_msg">暂无新系统消息</string>
59 59
 
60 60
     <string name="no_order_msg">暂无新购买消息</string>
61
+
62
+    <string name="print_qr">打印二维码</string>
63
+
64
+    <string name="check_bluetooth">请检查手机蓝牙是否开启</string>
65
+
66
+    <string name="check_printer">打印遇到问题了?去设置</string>
67
+
68
+    <string name="printer_settings">打印机设置</string>
69
+
70
+    <string name="printer_status">打印机状态</string>
71
+
72
+    <string name="query_processing">正在查询</string>
73
+
74
+    <string name="print_test">打印测试页</string>
75
+
76
+    <string name="bluetooth_status">蓝牙状态</string>
77
+
78
+    <string name="bt_is_enabled">蓝牙已打开</string>
79
+
80
+    <string name="bt_is_disabled">蓝牙已关闭</string>
81
+
82
+    <string name="connected_device">已连接设备</string>
83
+
84
+    <string name="discover_device">搜索设备</string>
85
+
86
+    <string name="paired_devices">已配对设备</string>
87
+
88
+    <string name="new_usable_devices">新可用设备</string>
61 89
 </resources>

Войти - Gogs: Go Git Service

Войти