|
@@ -1,9 +1,14 @@
|
1
|
1
|
package com.fusi24.rfid.ui.home;
|
2
|
2
|
|
|
3
|
+import android.Manifest;
|
3
|
4
|
import android.annotation.SuppressLint;
|
|
5
|
+import android.content.Context;
|
4
|
6
|
import android.content.Intent;
|
|
7
|
+import android.content.pm.PackageManager;
|
5
|
8
|
import android.os.Build;
|
6
|
9
|
import android.os.Bundle;
|
|
10
|
+import android.provider.Settings;
|
|
11
|
+import android.telephony.TelephonyManager;
|
7
|
12
|
import android.view.Menu;
|
8
|
13
|
import android.view.MenuItem;
|
9
|
14
|
import android.view.View;
|
|
@@ -46,7 +51,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
46
|
51
|
private StatusScanAdapter scanAdapter;
|
47
|
52
|
private SiteAdapter siteAdapter;
|
48
|
53
|
private Integer idCheckType = null;
|
49
|
|
- private String idDevice, checkTypeName;
|
|
54
|
+ private String idDevice, checkTypeName, uniqueId;
|
50
|
55
|
|
51
|
56
|
@Override
|
52
|
57
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -58,12 +63,12 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
58
|
63
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
59
|
64
|
TextView toolbarTitle = findViewById(R.id.toolbar_text);
|
60
|
65
|
|
61
|
|
- if(toolbarTitle !=null && toolbar !=null) {
|
|
66
|
+ if (toolbarTitle != null && toolbar != null) {
|
62
|
67
|
toolbarTitle.setText(getString(R.string.app_name));
|
63
|
68
|
setSupportActionBar(toolbar);
|
64
|
69
|
}
|
65
|
70
|
|
66
|
|
- if (getSupportActionBar() != null){
|
|
71
|
+ if (getSupportActionBar() != null) {
|
67
|
72
|
getSupportActionBar().setDisplayShowTitleEnabled(false);
|
68
|
73
|
}
|
69
|
74
|
|
|
@@ -71,6 +76,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
71
|
76
|
presenter.attachView(this);
|
72
|
77
|
|
73
|
78
|
initView();
|
|
79
|
+ getDataDeviceId();
|
74
|
80
|
loadingData();
|
75
|
81
|
}
|
76
|
82
|
|
|
@@ -106,7 +112,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
106
|
112
|
initEvent();
|
107
|
113
|
}
|
108
|
114
|
|
109
|
|
- private void initView(){
|
|
115
|
+ private void initView() {
|
110
|
116
|
binding.refresh.setRefreshing(false);
|
111
|
117
|
ActivityCompat.requestPermissions(this, Constant.PERMISSIONS_RFID, 1000);
|
112
|
118
|
|
|
@@ -125,8 +131,9 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
125
|
131
|
}
|
126
|
132
|
|
127
|
133
|
@SuppressLint("SetTextI18n")
|
128
|
|
- private void loadingData(){
|
129
|
|
- idDevice = "RFID" + Build.ID + Build.DEVICE;
|
|
134
|
+ private void loadingData() {
|
|
135
|
+ // Build.DISPLAY is different
|
|
136
|
+ idDevice = "RFID" + "-" + Build.ID + "-" + Build.DEVICE + "-" + uniqueId;
|
130
|
137
|
binding.tvRfidGunId.setText(idDevice);
|
131
|
138
|
binding.tvRfidCardNumber.setText(getSessionManager().getUserRfidNumber());
|
132
|
139
|
binding.tvEmployeeName.setText(getSessionManager().getEmployeeName());
|
|
@@ -194,6 +201,7 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
194
|
201
|
statusScanList.addAll(dataStatusScanList);
|
195
|
202
|
scanAdapter.updateDetailList(statusScanList);
|
196
|
203
|
scanAdapter.notifyDataSetChanged();
|
|
204
|
+ setDataStatusScan(dataStatusScanList.size());
|
197
|
205
|
}
|
198
|
206
|
|
199
|
207
|
@Override
|
|
@@ -208,6 +216,61 @@ public class HomeActivity extends BaseActivity implements HomeView, StatusScanAd
|
208
|
216
|
binding.spinnerPermit.setAdapter(adapter);
|
209
|
217
|
}
|
210
|
218
|
|
|
219
|
+ private void setDataStatusScan(Integer size){
|
|
220
|
+ if (size <= 2){
|
|
221
|
+ binding.swStatusScan.setVisibility(View.VISIBLE);
|
|
222
|
+ binding.rvStatusScan.setVisibility(View.GONE);
|
|
223
|
+ } else {
|
|
224
|
+ binding.swStatusScan.setVisibility(View.GONE);
|
|
225
|
+ binding.rvStatusScan.setVisibility(View.VISIBLE);
|
|
226
|
+ }
|
|
227
|
+
|
|
228
|
+ binding.swStatusScan.setLabelOn(statusScanList.get(0).getName());
|
|
229
|
+ binding.swStatusScan.setLabelOff(statusScanList.get(1).getName());
|
|
230
|
+
|
|
231
|
+ binding.swStatusScan.setOnToggledListener((toggleableView, isOn) -> {
|
|
232
|
+ if (isOn){
|
|
233
|
+ idCheckType = statusScanList.get(0).getId();
|
|
234
|
+ checkTypeName = statusScanList.get(0).getName();
|
|
235
|
+ } else {
|
|
236
|
+ idCheckType = statusScanList.get(1).getId();
|
|
237
|
+ checkTypeName = statusScanList.get(1).getName();
|
|
238
|
+ }
|
|
239
|
+ });
|
|
240
|
+ }
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+ @SuppressLint("HardwareIds")
|
|
244
|
+ private void getDataDeviceId(){
|
|
245
|
+ if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
|
|
246
|
+ ActivityCompat.requestPermissions(this, Constant.PERMISSIONS_RFID, 1000);
|
|
247
|
+ return;
|
|
248
|
+ }
|
|
249
|
+ TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
|
|
250
|
+ String imsi = "";
|
|
251
|
+ String imei = "";
|
|
252
|
+ if (mTelephonyMgr != null) {
|
|
253
|
+ imsi = mTelephonyMgr.getSubscriberId();
|
|
254
|
+ imei = mTelephonyMgr.getDeviceId();
|
|
255
|
+ }
|
|
256
|
+ String uniqueId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
|
|
257
|
+ System.out.println("DEVELOPER 1 : " + imsi);
|
|
258
|
+ System.out.println("DEVELOPER 2 : " + imei);
|
|
259
|
+ System.out.println("DEVELOPER 3 : " + uniqueId);
|
|
260
|
+
|
|
261
|
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
|
|
262
|
+ this.uniqueId = uniqueId;
|
|
263
|
+ } else {
|
|
264
|
+ if (mTelephonyMgr != null) {
|
|
265
|
+ if (mTelephonyMgr.getDeviceId() != null){
|
|
266
|
+ this.uniqueId = imei;
|
|
267
|
+ } else {
|
|
268
|
+ this.uniqueId = uniqueId;
|
|
269
|
+ }
|
|
270
|
+ }
|
|
271
|
+ }
|
|
272
|
+ }
|
|
273
|
+
|
211
|
274
|
@Override
|
212
|
275
|
public void showError(Throwable e) {
|
213
|
276
|
binding.refresh.setRefreshing(false);
|