84
-    public void onBluetoothEnabled() {
85
-        btSwitchToggle.setChecked(true);
86
-        bluetoothStatusText.setText(R.string.bt_is_enabled);
87
-    }
88
-
89
-    @Override
90
-    public void onBluetoothDisabled() {
91
-        btSwitchToggle.setChecked(false);
92
-        bluetoothStatusText.setText(R.string.bt_is_disabled);
93
-    }
94
-
95
-
96
-    @Override
97
-    public void onPrinterStatusFetched(String msg) {
98
-        printerStatusText.setText(msg);
99
-        deviceAdapter.notifyDataSetChanged();
100
-    }
101
-
102
-
103
-    @Override
104
-    public void onNewDeviceDiscovered(BluetoothDevice device) {
105
-        deviceAdapter.addDevice(device);
106
-    }
107
-
108
-
109
-    @Override
110
-    public void onPairedDeviceDiscovered(List<BluetoothDevice> devices) {
111
-        if(devices==null|| devices.size()==0){
112
-            return;
113
-        }
114
-        deviceAdapter.setDeviceList((ArrayList<BluetoothDevice>)devices);
115
-    }
116
-
117
-
118
-    @Override
119
-    public void showToast(String msg) {
120
-        Toast.makeText(this,msg,Toast.LENGTH_SHORT).show();
121
-    }
122
-
123
-    @OnClick(R.id.tv_printer_status)
124
-    void checkStatus(){
125
-        showToast(getString(R.string.query_processing));
126
-        presenter.queryPrinterStatus();
127
-    }
128
-
129
-    @OnClick(R.id.btn_print_qr)
130
-    void printerQR(){
131
-        presenter.printQR("http://xfoto.com.cn/s/"+qrcode);
132
-    }
133
-
134
-    @OnClick(R.id.title_bar_back_layout)
135
-    void back(){
136
-        finish();
137
-    }
138
-
139
-    @OnCheckedChanged(R.id.tb_bluetooth_switch)
140
-    void switchBluetooth(){
141
-        if(!presenter.queryBluetoothStatus()){
142
-            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
143
-            startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
144
-        }else{
145
-            BluetoothAdapter.getDefaultAdapter().disable();
146
-            onBluetoothDisabled();
147
-        }
148
-    }
149
-
150
-    @Override
151
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
152
-        super.onActivityResult(requestCode, resultCode, data);
153
-        if(resultCode == Activity.RESULT_OK){
154
-            if(requestCode == REQUEST_ENABLE_BT){
155
-                onBluetoothEnabled();
156
-                onPairedDeviceDiscovered(presenter.queryPairedDevices());
157
-                presenter.discoverNewDevices();
158
-                presenter.queryPrinterStatus();
159
-            }else if(requestCode == REQUEST_CONNECT_DEVICE){
160
-
161
-            }
162
-        }
163
-    }
164
-
165
-    @Override
166
-    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
167
-        presenter.connectPrinter(deviceAdapter.getDeviceList().get(i));
168
-    }
169
-
170
-}

+ 0 - 33
app/src/main/java/ai/pai/lensman/printer/PrinterSettingContract.java

@@ -1,33 +0,0 @@
1
-package ai.pai.lensman.printer;
2
-
3
-import android.bluetooth.BluetoothDevice;
4
-
5
-import java.util.List;
6
-
7
-/**
8
- * Created by chengzhenyu on 2016/9/1.
9
- */
10
-
11
-public class PrinterSettingContract {
12
-
13
-    public interface Presenter{
14
-        void start();
15
-        void stop();
16
-        void queryPrinterStatus();
17
-        void printQR(String qrCodeStr);
18
-        boolean queryBluetoothStatus();
19
-        List<BluetoothDevice> queryPairedDevices();
20
-        void discoverNewDevices();
21
-        void connectPrinter(BluetoothDevice device);
22
-        void cancelDiscovery();
23
-    }
24
-
25
-    public interface View{
26
-        void onBluetoothEnabled();
27
-        void onBluetoothDisabled();
28
-        void onPrinterStatusFetched(String status);
29
-        void onNewDeviceDiscovered(BluetoothDevice device);
30
-        void onPairedDeviceDiscovered(List<BluetoothDevice> devices);
31
-        void showToast(String msg);
32
-    }
33
-}

+ 0 - 223
app/src/main/java/ai/pai/lensman/printer/PrinterSettingPresenter.java

@@ -1,223 +0,0 @@
1
-package ai.pai.lensman.printer;
2
-
3
-import android.bluetooth.BluetoothAdapter;
4
-import android.bluetooth.BluetoothDevice;
5
-import android.content.BroadcastReceiver;
6
-import android.content.ComponentName;
7
-import android.content.Context;
8
-import android.content.Intent;
9
-import android.content.IntentFilter;
10
-import android.content.ServiceConnection;
11
-import android.os.IBinder;
12
-import android.text.TextUtils;
13
-import android.util.Log;
14
-
15
-import com.gprinter.command.GpCom;
16
-import com.gprinter.io.GpDevice;
17
-import com.gprinter.service.GpPrintService;
18
-
19
-import java.util.ArrayList;
20
-import java.util.List;
21
-import java.util.Set;
22
-
23
-import ai.pai.lensman.App;
24
-import ai.pai.lensman.R;
25
-import ai.pai.lensman.db.Preferences;
26
-
27
-
28
-public class PrinterSettingPresenter implements PrinterSettingContract.Presenter {
29
-
30
-    private Context context;
31
-    private PrinterService printerService;
32
-    private PrinterSettingContract.View view;
33
-    private PrinterServiceConnection connection;
34
-    private  BluetoothAdapter bluetoothAdapter;
35
-
36
-    private static final String TAG = "PrinterSettingPresenter";
37
-
38
-    private class PrinterServiceConnection implements ServiceConnection{
39
-
40
-        @Override
41
-        public void onServiceConnected(ComponentName name, IBinder service) {
42
-            printerService = ((PrinterService.PrintServiceBinder)service).getService();
43
-        }
44
-
45
-        @Override
46
-        public void onServiceDisconnected(ComponentName name) {
47
-            printerService = null;
48
-        }
49
-    }
50
-
51
-    public PrinterSettingPresenter(Context context, PrinterSettingContract.View view){
52
-        this.view = view;
53
-        this.context = context;
54
-        connection = new PrinterServiceConnection();
55
-        bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
56
-    }
57
-
58
-    @Override
59
-    public void start() {
60
-        registerPrinterBroadcast();
61
-        context.startService(new Intent(context,PrinterService.class));
62
-        context.bindService(new Intent(context,PrinterService.class),connection,Context.BIND_AUTO_CREATE);
63
-        if(queryBluetoothStatus()){
64
-            view.onBluetoothEnabled();
65
-            view.onPairedDeviceDiscovered(queryPairedDevices());
66
-            discoverNewDevices();
67
-            if(Preferences.getInstance().isPrinterConnected()){
68
-                view.onPrinterStatusFetched(context.getString(R.string.printer_is_connected));
69
-            }else{
70
-                view.onPrinterStatusFetched(context.getString(R.string.click_to_query));
71
-            }
72
-        }else{
73
-            view.onBluetoothDisabled();
74
-            view.showToast(context.getString(R.string.bt_is_disabled));
75
-        }
76
-    }
77
-
78
-    @Override
79
-    public void stop() {
80
-        cancelDiscovery();
81
-        context.unregisterReceiver(PrinterStatusBroadcastReceiver);
82
-        if(connection!=null){
83
-            context.unbindService(connection);
84
-        }
85
-    }
86
-
87
-    @Override
88
-    public void queryPrinterStatus() {
89
-        if(printerService==null){
90
-            view.showToast(context.getString(R.string.printer_status_query_fail));
91
-            return;
92
-        }
93
-        view.onPrinterStatusFetched(printerService.queryPrinterStatus());
94
-    }
95
-
96
-
97
-    @Override
98
-    public void printQR(String qrCodeStr) {
99
-        if(printerService==null){
100
-            view.showToast(context.getString(R.string.printer_service_boot_fail));
101
-            return;
102
-        }
103
-        if(TextUtils.isEmpty(Preferences.getInstance().getPrinterMac())){
104
-            view.showToast(App.getAppContext().getString(R.string.not_set_printer_yet));
105
-            return;
106
-        }
107
-        int code = printerService.printQR(qrCodeStr);
108
-        if(code == PrinterService.ERROR_CODE_PRINTER_SERVICE_EXCEPTION){
109
-            view.showToast(context.getString(R.string.go_check_printer));
110
-        }else if(code == PrinterService.ERROR_CODE_PRINTER_SERVICE_OFF){
111
-            view.showToast(context.getString(R.string.go_check_printer));
112
-        }else if( GpCom.ERROR_CODE.values()[code]!= GpCom.ERROR_CODE.SUCCESS){
113
-            view.showToast( GpCom.getErrorText(GpCom.ERROR_CODE.values()[code]));
114
-        }
115
-    }
116
-
117
-    @Override
118
-    public boolean queryBluetoothStatus() {
119
-        if(bluetoothAdapter==null){
120
-            return false;
121
-        }
122
-        return bluetoothAdapter.isEnabled();
123
-    }
124
-
125
-    @Override
126
-    public List<BluetoothDevice> queryPairedDevices() {
127
-        ArrayList<BluetoothDevice> pairedDevices = new ArrayList<>();
128
-        Set<BluetoothDevice> deviceSet = bluetoothAdapter.getBondedDevices();
129
-        for(BluetoothDevice device: deviceSet){
130
-            pairedDevices.add(device);
131
-        }
132
-        return pairedDevices;
133
-
134
-    }
135
-
136
-    @Override
137
-    public void discoverNewDevices() {
138
-        // Register for broadcasts when a device is discovered
139
-        IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
140
-        context.registerReceiver(mFindBlueToothReceiver, filter);
141
-        // Register for broadcasts when discovery has finished
142
-        filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
143
-        context.registerReceiver(mFindBlueToothReceiver, filter);
144
-        bluetoothAdapter.startDiscovery();
145
-    }
146
-
147
-    @Override
148
-    public void connectPrinter(BluetoothDevice device) {
149
-        if(printerService==null){
150
-            view.showToast(context.getString(R.string.printer_service_boot_fail));
151
-            return;
152
-        }
153
-        int code = printerService.connectPrinter(device);
154
-        if(code==0){
155
-            Preferences.getInstance().setPrinterMac(device.getAddress());
156
-            Preferences.getInstance().setPrinterConnected(true);
157
-        }else{
158
-            view.showToast(context.getString(R.string.printer_port_open_fail));
159
-            Preferences.getInstance().setPrinterConnected(false);
160
-        }
161
-
162
-    }
163
-
164
-    @Override
165
-    public void cancelDiscovery() {
166
-        try{
167
-            bluetoothAdapter.cancelDiscovery();
168
-            context.unregisterReceiver(mFindBlueToothReceiver);
169
-        }catch (Exception e){
170
-            e.printStackTrace();
171
-        }
172
-    }
173
-
174
-
175
-    // changes the title when discovery is finished
176
-    private final BroadcastReceiver mFindBlueToothReceiver = new BroadcastReceiver() {
177
-        @Override
178
-        public void onReceive(Context context, Intent intent) {
179
-            String action = intent.getAction();
180
-            // When discovery finds a device
181
-            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
182
-                // Get the BluetoothDevice object from the Intent
183
-                BluetoothDevice device = intent
184
-                        .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
185
-                // If it's already paired, skip it, because it's been listed
186
-                // already
187
-                if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
188
-                    view.onNewDeviceDiscovered(device);
189
-                }
190
-                // When discovery is finished, change the Activity title
191
-            } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED
192
-                    .equals(action)) {
193
-                view.showToast(context.getString(R.string.bt_discover_complete));
194
-            }
195
-        }
196
-    };
197
-
198
-    private void registerPrinterBroadcast() {
199
-        IntentFilter filter = new IntentFilter();
200
-        filter.addAction(GpCom.ACTION_CONNECT_STATUS);
201
-        context.registerReceiver(PrinterStatusBroadcastReceiver, filter);
202
-    }
203
-
204
-    private BroadcastReceiver PrinterStatusBroadcastReceiver = new BroadcastReceiver() {
205
-        @Override
206
-        public void onReceive(Context context, Intent intent) {
207
-            if (GpCom.ACTION_CONNECT_STATUS.equals(intent.getAction())) {
208
-                int type = intent.getIntExtra(GpPrintService.CONNECT_STATUS, 0);
209
-                Log.d(TAG, "connect status " + type);
210
-                if (type == GpDevice.STATE_CONNECTING) {
211
-                    view.onPrinterStatusFetched(context.getString(R.string.connecting));
212
-                } else if (type == GpDevice.STATE_NONE) {
213
-                    view.onPrinterStatusFetched(context.getString(R.string.connecting));
214
-                } else if (type == GpDevice.STATE_VALID_PRINTER) {
215
-                    view.onPrinterStatusFetched(context.getString(R.string.printer_is_connected));
216
-                } else if (type == GpDevice.STATE_INVALID_PRINTER) {
217
-                    view.onPrinterStatusFetched(context.getString(R.string.printer_is_disconnected));
218
-                }
219
-            }
220
-        }
221
-    };
222
-
223
-}

+ 0 - 3
app/src/main/java/ai/pai/lensman/session/SessionActivity.java

@@ -24,7 +24,6 @@ import ai.pai.lensman.activities.SessionQRCodeActivity;
24 24
 import ai.pai.lensman.base.BaseActivity;
25 25
 import ai.pai.lensman.bean.PhotoBean;
26 26
 import ai.pai.lensman.bean.SessionBean;
27
-import ai.pai.lensman.printer.PrinterSettingActivity;
28 27
 import ai.pai.lensman.qrcode.QRCaptureActivity;
29 28
 import ai.pai.lensman.utils.UmengEvent;
30 29
 import ai.pai.lensman.views.ExitSessionConfirmPopup;
@@ -231,8 +230,6 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie
231 230
             Intent intent = new Intent(this,SessionQRCodeActivity.class);
232 231
             intent.putExtra("qrcode",sessionBean.sessionId);
233 232
             startActivity(intent);
234
-        }else if(view.getId()==R.id.tv_printer_set){
235
-            startActivity(new Intent(this, PrinterSettingActivity.class));
236 233
         }else if(view.getId()==R.id.btn_exit_session_confirm){
237 234
             presenter.stop();
238 235
             finish();

+ 0 - 11
app/src/main/java/com/gprinter/aidl/GpService.aidl

@@ -1,11 +0,0 @@
1
-package com.gprinter.aidl;
2
-interface GpService{  
3
-	int openPort(int PrinterId,int PortType,String DeviceName,int PortNumber);
4
-	void closePort(int PrinterId);
5
-	int getPrinterConnectStatus(int PrinterId);
6
-	int printeTestPage(int PrinterId);   
7
-  	int queryPrinterStatus(int PrinterId,int Timesout);
8
-  	int getPrinterCommandType(int PrinterId);
9
-	int sendEscCommand(int PrinterId, String b64);
10
-  	int sendTscCommand(int PrinterId, String  b64); 
11
-}       

kodo - Gogs: Go Git Service

No Description

FFIB: b1998d68a0 记录后台管理员登录日志 4 years ago
..
0001_initial.py 5fdb5b42fd Logfile Upload 8 years ago
0002_auto_20180530_1122.py 5fdb5b42fd Logfile Upload 8 years ago
0003_mchinfoencryptloginfo.py 15e0f2277f MchInfoEncryptLogInfo 8 years ago
0004_mchinfoencryptloginfo_distributor_pk.py 15e0f2277f MchInfoEncryptLogInfo 8 years ago
0005_mchinfodecryptloginfo.py 6e7c94e744 MchInfoDecryptLogInfo 8 years ago
0006_auto_20200113_1832.py 212f24c882 MarketCode 6 years ago
0007_auto_20200114_1229.py f17ee852fd decrypt2 6 years ago
0008_mchsearchmodelandcameraloginfo.py 9619c195e6 :art: Makemigrations 6 years ago
0009_mchsearchmodelandcameraloginfo_is_selected_model.py 9619c195e6 :art: Makemigrations 6 years ago
0010_mchinfoencryptloginfo_version.py 7dc0b7fc6b :art: Makemigrations 6 years ago
0011_auto_20200309_1735.py 7dc0b7fc6b :art: Makemigrations 6 years ago
0012_auto_20201130_0131.py 96c4bec605 :art: Add api activity_group_share 6 years ago
0013_complementcodeloginfo.py e7da55aaf2 :art: Add complement_code 5 years ago
0014_complementcodeloginfo_audit_status.py df5a5d54a7 :art: Add complement_code 5 years ago
0015_complementcodeloginfo_is_contacted.py 52b3fd6549 :art: Add complement_code 5 years ago
0016_auto_20210107_1438.py 3183256275 Return ciphertext for complement_code_audit 5 years ago
0017_complementcodeloginfo_is_upload_qiniu.py 5f51d36155 :art: ComplementCodeLogInfo image upload qiniu 5 years ago
0018_administratorloginloginfo.py b1998d68a0 记录后台管理员登录日志 4 years ago
__init__.py 5fdb5b42fd Logfile Upload 8 years ago