diff --git a/app/release/20240527.apk b/app/release/20240527.apk new file mode 100644 index 0000000..863136b Binary files /dev/null and b/app/release/20240527.apk differ diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4a921bf..145d662 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,10 @@ + + + + + + - - - - - - + + + + + - - - - + + + + + - - - - + + + + + diff --git a/app/src/main/java/com/example/jinyu_rfid/MainActivity.java b/app/src/main/java/com/example/jinyu_rfid/MainActivity.java index 3906535..7aa224b 100644 --- a/app/src/main/java/com/example/jinyu_rfid/MainActivity.java +++ b/app/src/main/java/com/example/jinyu_rfid/MainActivity.java @@ -49,7 +49,7 @@ public class MainActivity extends BaseActivity { resources.updateConfiguration(config, resources.getDisplayMetrics()); binding = DataBindingUtil.setContentView(this, R.layout.activity_main); binding.mainLanguage.setSelection(index); - loginVm = new LoginVm(); + loginVm = new LoginVm(); boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false); if (isRemember) { loginVm.setUsername(SharedPreferencesUtils.getstring("user", "")); @@ -60,6 +60,9 @@ public class MainActivity extends BaseActivity { } + + + private void getLocaleStringXML(String languageString){ if (languageString.equals("中文")){ config.locale = Locale.CHINA; @@ -87,6 +90,7 @@ public class MainActivity extends BaseActivity { map.put("UserID", name); map.put("UserPass", pass); map.put("token", "123456"); + map.put("Language", index+""); if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return; OkGo.post(url + "/login") .upRequestBody(RequestBody.create(JSON, gson.toJson(map))) @@ -105,6 +109,7 @@ public class MainActivity extends BaseActivity { SharedPreferencesUtils.putstring("pass", pass); } SharedPreferencesUtils.putstring("language", selectLanguage); + SharedPreferencesUtils.putstring("languageIndex", index+""); resources.updateConfiguration(config, resources.getDisplayMetrics()); List list = LitePal.findAll(ConfigurationTable.class); Intent intent; diff --git a/app/src/main/java/com/example/jinyu_rfid/MyBluetoothService.java b/app/src/main/java/com/example/jinyu_rfid/MyBluetoothService.java new file mode 100644 index 0000000..e4d69cd --- /dev/null +++ b/app/src/main/java/com/example/jinyu_rfid/MyBluetoothService.java @@ -0,0 +1,16 @@ +package com.example.jinyu_rfid; + +import android.app.Service; +import android.content.Intent; +import android.os.IBinder; + +public class MyBluetoothService extends Service { + public MyBluetoothService() { + } + + @Override + public IBinder onBind(Intent intent) { + // TODO: Return the communication channel to the service. + throw new UnsupportedOperationException("Not yet implemented"); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java index e084d88..90da8e8 100644 --- a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java +++ b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java @@ -18,6 +18,7 @@ import com.example.jinyu_rfid.databinding.ActivityReadBinding; import com.example.jinyu_rfid.rfid.C5106Device; import com.example.jinyu_rfid.rfid.RFIDModel; import com.example.jinyu_rfid.uitls.ASCIIUtil; +import com.example.jinyu_rfid.uitls.SharedPreferencesUtils; import com.google.gson.reflect.TypeToken; import com.lzy.okgo.OkGo; import com.lzy.okgo.model.Response; @@ -39,7 +40,6 @@ public class ReadActivity extends BaseActivity implements DataReturnCall { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - binding = DataBindingUtil.setContentView(this, R.layout.activity_read); binding.setTitle(getString(R.string.go_read)); adapter = new ResultAdapter(this); @@ -48,8 +48,6 @@ public class ReadActivity extends BaseActivity implements DataReturnCall { binding.setAdapter(adapter); var workmode = getIntent().getIntExtra("work", 0); binding.setType(workmode == 1); - - // 名称 stringArray = getResources().getStringArray(R.array.project_list); rfidModel = new C5106Device(this); @@ -73,9 +71,9 @@ public class ReadActivity extends BaseActivity implements DataReturnCall { Map map = new HashMap<>(); map.put("EpcCode", info); map.put("token", "123456"); + map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0")); OkGo.post(url + "/readEPCCode") .upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) { - @Override public void onSuccess(Response response) { super.onSuccess(response); @@ -115,9 +113,4 @@ public class ReadActivity extends BaseActivity implements DataReturnCall { adapter.notifyDataSetChanged(); } - @Override - protected void onDestroy() { - super.onDestroy(); - rfidModel.close(); - } } \ No newline at end of file diff --git a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java index 11e0795..158dcca 100644 --- a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java +++ b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java @@ -24,6 +24,7 @@ import com.example.jinyu_rfid.databinding.ActivityWriteUserBinding; import com.example.jinyu_rfid.rfid.C5106Device; import com.example.jinyu_rfid.rfid.RFIDModel; import com.example.jinyu_rfid.uitls.ASCIIUtil; +import com.example.jinyu_rfid.uitls.SharedPreferencesUtils; import com.google.gson.reflect.TypeToken; import com.lzy.okgo.OkGo; import com.lzy.okgo.model.Response; @@ -46,11 +47,11 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P private List list; private PopupMenu popupMenu; + @SuppressLint("UnspecifiedRegisterReceiverFlag") @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user); - rfidModel = new C5106Device(this); intent1 = new Intent(this, ReadActivity.class); intent1.putExtra("work", 1); intent2 = new Intent(this, ConfigurationTableActivity.class); @@ -61,6 +62,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P popupMenu = new PopupMenu(this, binding.writeMenu); popupMenu.setOnMenuItemClickListener(this); getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu()); + rfidModel = new C5106Device(this); } @@ -68,6 +70,12 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P rfidModel.sanEpc(6); } + @Override + protected void onDestroy() { + super.onDestroy(); + rfidModel.close(); + } + private boolean writeUserState = false; // 写入 @@ -104,6 +112,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P map.put("EpcCode", epcStr); map.put("TyreNo", list.get(0).getPropertyContent()); map.put("token", "123456"); + map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0")); Log.e("TAG", "writeUser:" + 2); OkGo.post(url + "/write").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) { @SuppressLint("NotifyDataSetChanged") @@ -171,6 +180,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P Map map = new HashMap<>(); map.put("TyreNo", erCode); map.put("token", "123456"); + map.put("Language", SharedPreferencesUtils.getstring("languageIndex","0")); OkGo.post(url + "/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) { @SuppressLint("NotifyDataSetChanged") @Override diff --git a/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java b/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java index e1bc3b0..1872c55 100644 --- a/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java +++ b/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java @@ -27,6 +27,7 @@ public class C5106Device implements RFIDModel { @Override public void sanEpc(int len) { + byte[] rdata = new byte[len * 2]; Reader.READER_ERR readerErr = uhfrManager.getTagData(1, 2, len, rdata, accessBytes, (short) 200); call.readEpcCodeInfo(Tools.Bytes2HexString(rdata, rdata.length), readerErr == Reader.READER_ERR.MT_OK_ERR, readerErr.toString()); @@ -52,6 +53,7 @@ public class C5106Device implements RFIDModel { */ @Override public boolean writeUser(String writeStr, String tagEpc) { + var bytes = Tools.HexString2Bytes(writeStr); var bytesF = Tools.HexString2Bytes(tagEpc); Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter( @@ -67,6 +69,7 @@ public class C5106Device implements RFIDModel { @Override public void sanUser(int len) { + byte[] rdata = new byte[len * 2]; Reader.READER_ERR readerErr = uhfrManager.getTagData(3, 0, len, rdata, accessBytes, (short) 200); call.readUserInfo(Tools.Bytes2HexString(rdata, rdata.length), readerErr == Reader.READER_ERR.MT_OK_ERR, readerErr.toString());