react-native-mytatva-rn-sdk 1.2.46 → 1.2.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +128 -58
- package/android/src/main/java/com/mytatvarnsdk/activity/BtManageActivity.java +345 -345
- package/android/src/main/java/com/mytatvarnsdk/activity/ConnectSensorActivity.kt +17 -38
- package/android/src/main/java/com/mytatvarnsdk/activity/ExitJourneyBottomSheet.kt +51 -51
- package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +10 -5
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceSensorActivity.kt +4 -5
- package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +4 -5
- package/android/src/main/java/com/mytatvarnsdk/activity/QRActivity.kt +96 -92
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +2 -2
- package/android/src/main/java/com/mytatvarnsdk/activity/SensorConnectSuccessActivity.kt +1 -1
- package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +4 -2
- package/android/src/main/java/com/mytatvarnsdk/activity/VideoActivity.kt +12 -7
- package/android/src/main/java/com/mytatvarnsdk/utils/TatvaEncryptionConfig.kt +0 -5
- package/android/src/main/res/layout/activity_video.xml +13 -2
- package/ios/Database/KLTBluetoothManager.m +9 -4
- package/ios/Database/KLTDatabaseHandler.m +53 -6
- package/ios/MyReactNativeBridge.h +4 -1
- package/ios/MyReactNativeBridge.m +433 -191
- package/ios/Support/API.swift +0 -1
- package/ios/Support/Global.swift +12 -0
- package/ios/ViewControllers/AttachTransmitterViewController.swift +33 -2
- package/ios/ViewControllers/ChatWithExpertViewController.swift +33 -3
- package/ios/ViewControllers/ConnectToSensorViewController.swift +101 -12
- package/ios/ViewControllers/ConnectToTransmitterViewController.swift +121 -5
- package/ios/ViewControllers/ProvidePermissionViewController.swift +37 -5
- package/ios/ViewControllers/PutOnTheSensorViewController.swift +22 -2
- package/ios/ViewControllers/StartConnectionViewController.swift +31 -3
- package/ios/ViewModel/FinalViewModel.swift +155 -48
- package/package.json +1 -1
|
@@ -45,383 +45,383 @@ import cgmblelib.utils.Tool;
|
|
|
45
45
|
* @author minyuchun
|
|
46
46
|
*/
|
|
47
47
|
public class BtManageActivity extends BaseBleActivity implements View.OnClickListener {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
/**
|
|
49
|
+
* 开启蓝牙 - requestCode
|
|
50
|
+
*/
|
|
51
|
+
public static final int REQUEST_BLUETOOTH_ON = 114;
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
public static final int REQUEST_LOCATION_ON = 116;
|
|
54
|
+
/**
|
|
55
|
+
* 进入扫描界面 - requestCode
|
|
56
|
+
*/
|
|
57
|
+
public static final int REQUEST_QR = 115;
|
|
58
|
+
/**
|
|
59
|
+
* 发射器列表
|
|
60
|
+
*/
|
|
61
|
+
private TransmitterState mBluetoothState;
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
private TextView permissionState;
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
private SpannableString openBluetoothInfo;
|
|
66
|
+
private SpannableString openLocationInfo;
|
|
67
|
+
private ConstraintLayout group;
|
|
68
|
+
private TextView qrNext;
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
private PocDevice connectDevice;
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
private TextView title;
|
|
73
73
|
|
|
74
74
|
// private String deviceType = "CT3";
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
private LinearLayout ll;
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
@Override
|
|
79
|
+
protected int setView() {
|
|
80
|
+
return R.layout.activity_bt_manage;
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
83
|
+
@Override
|
|
84
|
+
protected void onResume() {
|
|
85
|
+
super.onResume();
|
|
86
|
+
checkBTGPS();
|
|
87
|
+
}
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
@Override
|
|
90
|
+
protected void initViews() {
|
|
91
91
|
// deviceType = getIntent().getStringExtra("deviceType");
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
openLocationInfo = new SpannableString(openLocationNote);
|
|
121
|
-
openLocationInfo.setSpan(
|
|
122
|
-
new ForegroundColorSpan(Color.parseColor("#89C602")),
|
|
123
|
-
openLocationNote.length() - 11,
|
|
124
|
-
openLocationNote.length(),
|
|
125
|
-
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
126
|
-
|
|
127
|
-
//连接发射器
|
|
128
|
-
mBluetoothState.setActivity(this).setOnDeviceConnectionListener(new TransmitterState.OnDeviceConnectionListener() {
|
|
129
|
-
|
|
130
|
-
@Override
|
|
131
|
-
public void onDeviceConnect(PocDevice pocDevice, int position) {
|
|
132
|
-
if (pocDevice != null) {
|
|
133
|
-
Log.d("onDeviceConnect--->", "onDeviceConnect: " + pocDevice.toString());
|
|
92
|
+
ll = findViewById(R.id.rl_pop_bottom);
|
|
93
|
+
permissionState = findViewById(R.id.bt_manage_close_state);
|
|
94
|
+
permissionState.setOnClickListener(this);
|
|
95
|
+
mBluetoothState = findViewById(R.id.transmitter_state);
|
|
96
|
+
ImageView btnLeft = findViewById(R.id.btnLeft);
|
|
97
|
+
btnLeft.setOnClickListener(this);
|
|
98
|
+
findViewById(R.id.btnRight).setVisibility(View.GONE);
|
|
99
|
+
findViewById(R.id.iv_alert_type).setVisibility(View.GONE);
|
|
100
|
+
title = findViewById(R.id.tvTitle);
|
|
101
|
+
title.setText(getString(R.string.title_bt_step1));
|
|
102
|
+
group = findViewById(R.id.qr_group);
|
|
103
|
+
findViewById(R.id.qr_video_enter).setOnClickListener(this);
|
|
104
|
+
|
|
105
|
+
qrNext = findViewById(R.id.qr_next);
|
|
106
|
+
qrNext.setOnClickListener(this);
|
|
107
|
+
|
|
108
|
+
String blueClosedNote = getResources().getString(R.string.bluetooth_closed);
|
|
109
|
+
openBluetoothInfo = new SpannableString(blueClosedNote);
|
|
110
|
+
openBluetoothInfo.setSpan(
|
|
111
|
+
new ForegroundColorSpan(Color.parseColor("#89C602")),
|
|
112
|
+
blueClosedNote.length() - 11,
|
|
113
|
+
blueClosedNote.length(),
|
|
114
|
+
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
115
|
+
|
|
116
|
+
String openLocationNote = getResources().getString(R.string.location_permission);
|
|
117
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
118
|
+
openLocationNote = getResources().getString(R.string.bluetooth_permission);
|
|
134
119
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
120
|
+
openLocationInfo = new SpannableString(openLocationNote);
|
|
121
|
+
openLocationInfo.setSpan(
|
|
122
|
+
new ForegroundColorSpan(Color.parseColor("#89C602")),
|
|
123
|
+
openLocationNote.length() - 11,
|
|
124
|
+
openLocationNote.length(),
|
|
125
|
+
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
126
|
+
|
|
127
|
+
//连接发射器
|
|
128
|
+
mBluetoothState.setActivity(this).setOnDeviceConnectionListener(new TransmitterState.OnDeviceConnectionListener() {
|
|
129
|
+
|
|
130
|
+
@Override
|
|
131
|
+
public void onDeviceConnect(PocDevice pocDevice, int position) {
|
|
132
|
+
if (pocDevice != null) {
|
|
133
|
+
Log.d("onDeviceConnect--->", "onDeviceConnect: " + pocDevice.toString());
|
|
134
|
+
}
|
|
135
|
+
connectDevice = pocDevice;
|
|
136
|
+
if (enumDevice.getEnumDevice(pocDevice.getName()).isAbleScanQRCode()) {
|
|
137
|
+
group.setVisibility(View.VISIBLE);
|
|
138
|
+
title.setText(getString(R.string.title_bt_step2));
|
|
139
|
+
mBluetoothState.hind(true);
|
|
140
|
+
PopupWindowManagement.getInstance().dismiss();
|
|
141
|
+
} else {
|
|
142
|
+
bind(pocDevice);
|
|
143
|
+
mPocDevice = pocDevice;
|
|
144
|
+
PopupWindowManagement.getInstance().dismiss();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@Override
|
|
149
|
+
public void onQRResult(int type, PocDevice pocDevice, int position) {
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
requestPermission();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@Override
|
|
156
|
+
protected void init() {
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
public void checkBTGPS() {
|
|
161
|
+
if ((group == null || group.getVisibility() == View.GONE) && permissionState != null) {
|
|
162
|
+
if (getDeniedPermissions() == null) {
|
|
163
|
+
if (Tool.getBluetoothAdapter(getApplicationContext()).getState() == BluetoothAdapter.STATE_ON && Tool.isGPSEnable_S(this)) {
|
|
164
|
+
permissionState.setVisibility(View.GONE);
|
|
165
|
+
mBluetoothState.setVisibility(View.VISIBLE);
|
|
166
|
+
scanDeviceAgain();
|
|
167
|
+
} else {
|
|
168
|
+
permissionState.setVisibility(View.VISIBLE);
|
|
169
|
+
mBluetoothState.setVisibility(View.GONE);
|
|
170
|
+
if (Tool.getBluetoothAdapter(getApplicationContext()).getState() == BluetoothAdapter.STATE_OFF) {
|
|
171
|
+
permissionState.setText(openBluetoothInfo);
|
|
172
|
+
WarnDialogUtils.getInstance().showWarnDialog(this, DialogType.POP_BT_OPEN, getResources().getString(R.string.bluetooth_closed), null, new WarnDialog.OnSelectListener() {
|
|
173
|
+
@Override
|
|
174
|
+
public void confirm(DialogInterface dialog) {
|
|
175
|
+
Tool.ableBluetooth(BtManageActivity.this, REQUEST_BLUETOOTH_ON);
|
|
176
|
+
dialog.dismiss();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
@Override
|
|
180
|
+
public void cancel(DialogInterface dialog) {
|
|
181
|
+
dialog.dismiss();
|
|
182
|
+
}
|
|
183
|
+
}, null);
|
|
184
|
+
} else if (!Tool.isGPSEnable_S(this)) {
|
|
185
|
+
permissionState.setText(openLocationInfo);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
permissionState.setVisibility(View.VISIBLE);
|
|
190
|
+
mBluetoothState.setVisibility(View.GONE);
|
|
191
|
+
permissionState.setText(openLocationInfo);
|
|
192
|
+
}
|
|
145
193
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
@Override
|
|
156
|
-
protected void init() {
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
public void checkBTGPS() {
|
|
161
|
-
if ((group == null || group.getVisibility() == View.GONE) && permissionState != null) {
|
|
162
|
-
if (getDeniedPermissions() == null) {
|
|
163
|
-
if (Tool.getBluetoothAdapter(getApplicationContext()).getState() == BluetoothAdapter.STATE_ON && Tool.isGPSEnable_S(this)) {
|
|
164
|
-
permissionState.setVisibility(View.GONE);
|
|
165
|
-
mBluetoothState.setVisibility(View.VISIBLE);
|
|
166
|
-
scanDeviceAgain();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@Override
|
|
197
|
+
public void onPermissionRequestSuccess() {
|
|
198
|
+
permissions = null;
|
|
199
|
+
if (group.getVisibility() == View.GONE) {
|
|
200
|
+
checkBTGPS();
|
|
167
201
|
} else {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
permissionState.setText(openBluetoothInfo);
|
|
172
|
-
WarnDialogUtils.getInstance().showWarnDialog(this, DialogType.POP_BT_OPEN, getResources().getString(R.string.bluetooth_closed), null, new WarnDialog.OnSelectListener() {
|
|
173
|
-
@Override
|
|
174
|
-
public void confirm(DialogInterface dialog) {
|
|
175
|
-
Tool.ableBluetooth(BtManageActivity.this, REQUEST_BLUETOOTH_ON);
|
|
176
|
-
dialog.dismiss();
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
@Override
|
|
180
|
-
public void cancel(DialogInterface dialog) {
|
|
181
|
-
dialog.dismiss();
|
|
182
|
-
}
|
|
183
|
-
}, null);
|
|
184
|
-
} else if (!Tool.isGPSEnable_S(this)) {
|
|
185
|
-
permissionState.setText(openLocationInfo);
|
|
186
|
-
}
|
|
202
|
+
if (connectDevice != null) {
|
|
203
|
+
//todo Ankit - review this code
|
|
204
|
+
}
|
|
187
205
|
}
|
|
188
|
-
} else {
|
|
189
|
-
permissionState.setVisibility(View.VISIBLE);
|
|
190
|
-
mBluetoothState.setVisibility(View.GONE);
|
|
191
|
-
permissionState.setText(openLocationInfo);
|
|
192
|
-
}
|
|
193
206
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
207
|
+
|
|
208
|
+
@Override
|
|
209
|
+
public void scanStart() {
|
|
210
|
+
mBluetoothState.refresh(null, null);
|
|
211
|
+
mBluetoothState.transmitterImg.startAnimation(Tool.getRotate());
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
@Override
|
|
216
|
+
public void scanIn(PocDeviceAndRssi device) {
|
|
217
|
+
MyLog.i("scanIn " + device.toString());
|
|
218
|
+
mBluetoothState.setVisibility(View.VISIBLE);
|
|
219
|
+
mBluetoothState.refresh(device, null);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@Override
|
|
223
|
+
public void scanEnd() {
|
|
224
|
+
mBluetoothState.transmitterImg.clearAnimation();
|
|
225
|
+
mBluetoothState.transmitterImg.setVisibility(View.GONE);
|
|
226
|
+
mBluetoothState.loadSuccess();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@Override
|
|
230
|
+
public void bluetoothStateOFF() {
|
|
231
|
+
checkBTGPS();
|
|
232
|
+
showShortToast(R.string.please_open_bluetooth);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@Override
|
|
236
|
+
public void bluetoothStateON() {
|
|
237
|
+
checkBTGPS();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@Override
|
|
241
|
+
public void failGPS() {
|
|
242
|
+
checkBTGPS();
|
|
243
|
+
warn_gpsFail();
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@Override
|
|
247
|
+
public void failLocal() {
|
|
248
|
+
checkBTGPS();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@Override
|
|
252
|
+
public void bindFail() {
|
|
253
|
+
mBluetoothState.notifyItem();
|
|
254
|
+
ProgressManagement.getInstance().dismissWait(this);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
@Override
|
|
258
|
+
public void bindSuccess() {
|
|
203
259
|
//todo Ankit - review this code
|
|
204
|
-
|
|
260
|
+
ProgressManagement.getInstance().dismissWait(this);
|
|
261
|
+
finish();
|
|
205
262
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
@Override
|
|
216
|
-
public void scanIn(PocDeviceAndRssi device) {
|
|
217
|
-
MyLog.i("scanIn " + device.toString());
|
|
218
|
-
mBluetoothState.setVisibility(View.VISIBLE);
|
|
219
|
-
mBluetoothState.refresh(device, null);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
@Override
|
|
223
|
-
public void scanEnd() {
|
|
224
|
-
mBluetoothState.transmitterImg.clearAnimation();
|
|
225
|
-
mBluetoothState.transmitterImg.setVisibility(View.GONE);
|
|
226
|
-
mBluetoothState.loadSuccess();
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
@Override
|
|
230
|
-
public void bluetoothStateOFF() {
|
|
231
|
-
checkBTGPS();
|
|
232
|
-
showShortToast(R.string.please_open_bluetooth);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
@Override
|
|
236
|
-
public void bluetoothStateON() {
|
|
237
|
-
checkBTGPS();
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@Override
|
|
241
|
-
public void failGPS() {
|
|
242
|
-
checkBTGPS();
|
|
243
|
-
warn_gpsFail();
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
@Override
|
|
247
|
-
public void failLocal() {
|
|
248
|
-
checkBTGPS();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
@Override
|
|
252
|
-
public void bindFail() {
|
|
253
|
-
mBluetoothState.notifyItem();
|
|
254
|
-
ProgressManagement.getInstance().dismissWait(this);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
@Override
|
|
258
|
-
public void bindSuccess() {
|
|
259
|
-
//todo Ankit - review this code
|
|
260
|
-
ProgressManagement.getInstance().dismissWait(this);
|
|
261
|
-
finish();
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
@Override
|
|
266
|
-
public void disconnect() {
|
|
267
|
-
mBluetoothState.notifyItem();
|
|
268
|
-
ProgressManagement.getInstance().dismissWait(this);
|
|
269
|
-
showShortToast(R.string.bt_connect_fail);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
@Override
|
|
273
|
-
public void disconnectForTimeout() {
|
|
274
|
-
mBluetoothState.notifyItem();
|
|
275
|
-
ProgressManagement.getInstance().dismissWait(this);
|
|
276
|
-
showShortToast(R.string.bt_connect_fail);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
@Override
|
|
280
|
-
public void checkFailForLowPower() {
|
|
281
|
-
mBluetoothState.notifyItem();
|
|
282
|
-
ProgressManagement.getInstance().dismissWait(this);
|
|
283
|
-
WarnDialogUtils.getInstance().showWarnDialog(this, DialogType.TYPE_LOW_POWER);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
@Override
|
|
287
|
-
public void checkFailErrorTemperature() {
|
|
288
|
-
mBluetoothState.notifyItem();
|
|
289
|
-
ProgressManagement.getInstance().dismissWait(this);
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
@Override
|
|
293
|
-
public void onlineLost() {
|
|
294
|
-
showShortToast(R.string.online_lost);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* 搜索发射器,点击搜索按钮
|
|
299
|
-
*/
|
|
300
|
-
public void scanDeviceAgain() {
|
|
301
|
-
if (mPocDevice == null || !mPocDevice.isBound()) {
|
|
302
|
-
WarnDialogUtils.getInstance().dismissWarnDialog();
|
|
303
|
-
ReconnectManagement.getInstance().reconnect(ReconnectManagement.ReconnectState.STATE_SCAN_AGAIN);
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
@Override
|
|
266
|
+
public void disconnect() {
|
|
267
|
+
mBluetoothState.notifyItem();
|
|
268
|
+
ProgressManagement.getInstance().dismissWait(this);
|
|
269
|
+
showShortToast(R.string.bt_connect_fail);
|
|
304
270
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
finish();
|
|
312
|
-
} else if (id == R.id.bt_manage_close_state) {
|
|
313
|
-
permissionOpen();
|
|
314
|
-
} else if (id == R.id.qr_next) {
|
|
315
|
-
requestPermission();
|
|
271
|
+
|
|
272
|
+
@Override
|
|
273
|
+
public void disconnectForTimeout() {
|
|
274
|
+
mBluetoothState.notifyItem();
|
|
275
|
+
ProgressManagement.getInstance().dismissWait(this);
|
|
276
|
+
showShortToast(R.string.bt_connect_fail);
|
|
316
277
|
}
|
|
317
|
-
}
|
|
318
278
|
|
|
279
|
+
@Override
|
|
280
|
+
public void checkFailForLowPower() {
|
|
281
|
+
mBluetoothState.notifyItem();
|
|
282
|
+
ProgressManagement.getInstance().dismissWait(this);
|
|
283
|
+
WarnDialogUtils.getInstance().showWarnDialog(this, DialogType.TYPE_LOW_POWER);
|
|
284
|
+
}
|
|
319
285
|
|
|
320
|
-
|
|
286
|
+
@Override
|
|
287
|
+
public void checkFailErrorTemperature() {
|
|
288
|
+
mBluetoothState.notifyItem();
|
|
289
|
+
ProgressManagement.getInstance().dismissWait(this);
|
|
290
|
+
}
|
|
321
291
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
downY = e.getRawY();
|
|
292
|
+
@Override
|
|
293
|
+
public void onlineLost() {
|
|
294
|
+
showShortToast(R.string.online_lost);
|
|
326
295
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (!mBluetoothState.recyclerView.canScrollVertically(-1)) {
|
|
336
|
-
mBluetoothState.clearUpAnimation();
|
|
337
|
-
mBluetoothState.setUpHeightVisible(gap);
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* 搜索发射器,点击搜索按钮
|
|
299
|
+
*/
|
|
300
|
+
public void scanDeviceAgain() {
|
|
301
|
+
if (mPocDevice == null || !mPocDevice.isBound()) {
|
|
302
|
+
WarnDialogUtils.getInstance().dismissWarnDialog();
|
|
303
|
+
ReconnectManagement.getInstance().reconnect(ReconnectManagement.ReconnectState.STATE_SCAN_AGAIN);
|
|
338
304
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@Override
|
|
308
|
+
public void onClick(View v) {
|
|
309
|
+
int id = v.getId();//关闭发射器
|
|
310
|
+
if (id == R.id.btnLeft) {
|
|
311
|
+
finish();
|
|
312
|
+
} else if (id == R.id.bt_manage_close_state) {
|
|
313
|
+
permissionOpen();
|
|
314
|
+
} else if (id == R.id.qr_next) {
|
|
315
|
+
requestPermission();
|
|
345
316
|
}
|
|
346
|
-
break;
|
|
347
317
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
private float downY = -1;
|
|
321
|
+
|
|
322
|
+
@Override
|
|
323
|
+
public boolean onTouchEvent(MotionEvent e) {
|
|
324
|
+
if (downY == -1) {
|
|
325
|
+
downY = e.getRawY();
|
|
326
|
+
}
|
|
327
|
+
switch (e.getAction()) {
|
|
328
|
+
case MotionEvent.ACTION_DOWN:
|
|
329
|
+
downY = e.getRawY();
|
|
330
|
+
break;
|
|
331
|
+
case MotionEvent.ACTION_MOVE:
|
|
332
|
+
float gap = (e.getRawY() - downY) / 2;
|
|
333
|
+
downY = e.getRawY();
|
|
334
|
+
mBluetoothState.isNoTouch = false;
|
|
335
|
+
if (!mBluetoothState.recyclerView.canScrollVertically(-1)) {
|
|
336
|
+
mBluetoothState.clearUpAnimation();
|
|
337
|
+
mBluetoothState.setUpHeightVisible(gap);
|
|
338
|
+
}
|
|
339
|
+
break;
|
|
340
|
+
default:
|
|
341
|
+
downY = -1;
|
|
342
|
+
mBluetoothState.isNoTouch = true;
|
|
343
|
+
if (!mBluetoothState.recyclerView.canScrollVertically(-1)) {
|
|
344
|
+
mBluetoothState.startUpAnimation(mBluetoothState.upstate);
|
|
345
|
+
}
|
|
346
|
+
break;
|
|
347
|
+
}
|
|
348
|
+
return super.onTouchEvent(e);
|
|
365
349
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
350
|
+
|
|
351
|
+
private void permissionOpen() {
|
|
352
|
+
if (permissions != null) {
|
|
353
|
+
requestPermissions(permissions);
|
|
354
|
+
} else {
|
|
355
|
+
BluetoothAdapter adapter = Tool.getBluetoothAdapter(this);
|
|
356
|
+
if (adapter != null && !adapter.isEnabled()) {
|
|
357
|
+
Tool.ableBluetooth(this, REQUEST_BLUETOOTH_ON);
|
|
358
|
+
} else if (!Tool.isGPSEnable_S(this)) {
|
|
359
|
+
Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
|
360
|
+
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
361
|
+
startActivity(settingsIntent);
|
|
362
|
+
} else {
|
|
363
|
+
checkBTGPS();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
377
366
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
mPocDevice = data.getParcelableExtra("device");
|
|
389
|
-
if (mPocDevice != null) {
|
|
390
|
-
bind(mPocDevice);
|
|
391
|
-
}
|
|
367
|
+
|
|
368
|
+
@Override
|
|
369
|
+
public String[][] getPermission() {
|
|
370
|
+
MyLog.i("获取版本 " + Build.VERSION.SDK_INT);
|
|
371
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
372
|
+
return new String[][]{ConstantsLibrary.BLUETOOTH_S, ConstantsLibrary.CAMERA_PERMISSION};
|
|
373
|
+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
|
374
|
+
return new String[][]{ConstantsLibrary.LOCAL_PERMISSION, ConstantsLibrary.BACKGROUND_LOCATION_Q, ConstantsLibrary.CAMERA_PERMISSION};
|
|
375
|
+
} else {
|
|
376
|
+
return new String[][]{ConstantsLibrary.LOCAL_PERMISSION, ConstantsLibrary.CAMERA_PERMISSION};
|
|
392
377
|
}
|
|
393
|
-
} else {
|
|
394
|
-
mBluetoothState.isConnecting = false;
|
|
395
|
-
MyLog.e("扫描失败");
|
|
396
|
-
}
|
|
397
|
-
} else if (requestCode == REQUEST_BLUETOOTH_ON) {
|
|
398
|
-
if (resultCode == RESULT_OK) {
|
|
399
|
-
scanDeviceAgain();
|
|
400
|
-
}
|
|
401
|
-
} else if (requestCode == REQUEST_LOCATION_ON) {
|
|
402
|
-
if (resultCode == RESULT_OK) {
|
|
403
|
-
scanDeviceAgain();
|
|
404
|
-
}
|
|
405
378
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
@SuppressLint("BatteryLife")
|
|
382
|
+
@Override
|
|
383
|
+
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
384
|
+
super.onActivityResult(requestCode, resultCode, data);
|
|
385
|
+
if (requestCode == REQUEST_QR) {
|
|
386
|
+
if (resultCode == RESULT_OK) {
|
|
387
|
+
if (data != null) {
|
|
388
|
+
mPocDevice = data.getParcelableExtra("device");
|
|
389
|
+
if (mPocDevice != null) {
|
|
390
|
+
bind(mPocDevice);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
} else {
|
|
394
|
+
mBluetoothState.isConnecting = false;
|
|
395
|
+
MyLog.e("扫描失败");
|
|
396
|
+
}
|
|
397
|
+
} else if (requestCode == REQUEST_BLUETOOTH_ON) {
|
|
398
|
+
if (resultCode == RESULT_OK) {
|
|
399
|
+
scanDeviceAgain();
|
|
400
|
+
}
|
|
401
|
+
} else if (requestCode == REQUEST_LOCATION_ON) {
|
|
402
|
+
if (resultCode == RESULT_OK) {
|
|
403
|
+
scanDeviceAgain();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
420
406
|
}
|
|
421
|
-
}
|
|
422
407
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
408
|
+
/**
|
|
409
|
+
* 进行设备绑定
|
|
410
|
+
*
|
|
411
|
+
* @param device 需要绑定的发射器
|
|
412
|
+
*/
|
|
413
|
+
private void bind(PocDevice device) {
|
|
414
|
+
MyLog.setLocalLog(device.getId(), device.getName());
|
|
415
|
+
MyLog.iLog("bind result");
|
|
416
|
+
if (device.getAddress() != null) {
|
|
417
|
+
ManageGattCallback.getInstance().ConnectViaAddress(device.getAddress());
|
|
418
|
+
ManageScanCallback.getInstance().stopLeScan();
|
|
419
|
+
ProgressManagement.getInstance().showWait(this, ProgressType.PROGRESSDIALOG_CONNECT, null);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
@Override
|
|
424
|
+
protected void onDestroy() {
|
|
425
|
+
super.onDestroy();
|
|
426
|
+
}
|
|
427
427
|
}
|