增加 永久锁定epc

master
wanghao 3 days ago
parent 9b5f8cd6da
commit 0da5681b87

@ -48,10 +48,12 @@ dependencies {
implementation files('libs\\reader(1).jar')
implementation files('libs\\UHF67_v3.6.jar')
implementation 'androidx.preference:preference:1.2.0'
implementation files('libs\\jxl-2.6.12.jar')
// implementation files('libs\\uhfr_v1.8.jar')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'org.litepal.android:java:3.0.0'
implementation 'com.tonystark.android:socket:4.1.0'
//使 OkSocketServer Java,Server.
implementation 'com.tonystark.android:socket-server:4.1.0'

Binary file not shown.

Binary file not shown.

@ -4,6 +4,9 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<application
android:name=".base.MyApplication"
@ -17,10 +20,16 @@
android:theme="@style/Theme.WriteEpc"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".UserXuanchuanActivity"
android:exported="true"
android:label="宣传">
</activity>
<activity
android:name=".WriteUserActivity"
android:exported="true"
android:label="读写user">
android:label="读写EPC区">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -44,18 +53,16 @@
<activity
android:name=".HomeActivity"
android:exported="true">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>
<activity
android:name=".HomeActivity2"
android:exported="true"
android:label="轮胎信息追溯">
</activity>
android:label="轮胎信息追溯"></activity>
<activity
android:name=".ShuangqianActivity"
android:exported="true" />
@ -82,12 +89,12 @@
</activity>
<activity
android:name=".MoreActivity"
android:exported="true">
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
android:exported="true"
android:label="扫描EPC">
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
</activity>
<activity
android:name=".MainActivity"
@ -95,8 +102,6 @@
<!-- <intent-filter> -->
<!-- <action android:name="android.intent.action.MAIN" /> -->
<!-- <category android:name="android.intent.category.LAUNCHER" /> -->
<!-- </intent-filter> -->
</activity>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<litepal>
<dbname value="write_tag_info" />
<version value="1" />
<list>
<mapping class="com.example.writeepc.been.WriteInfo"></mapping>
</list>
</litepal>

@ -10,12 +10,12 @@ import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.example.writeepc.been.InfoData;
import com.example.writeepc.databinding.ActivityMainBinding;
import com.example.writeepc.utils.ASCIIUtil;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.util.List;
import cn.pda.serialport.Tools;
public class MainActivity extends AppCompatActivity {
@ -67,6 +67,13 @@ public class MainActivity extends AppCompatActivity {
public void readTid(View view) {
byte[] rdata = new byte[12];
Reader.READER_ERR readerErr = uhfrManager.getTagData(2, 0, 6, rdata, accesspwd, timeOut);
uhfrManager.setGen2session(0);
//taget
uhfrManager.setTarget(0);
//q value
uhfrManager.setQvaule(0);
//FastId
uhfrManager.setFastID(false);
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
infoData.setReadTId(Tools.Bytes2HexString(rdata, 12));

@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
@ -11,6 +12,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.databinding.ActivityMoreBinding;
import com.example.writeepc.utils.ASCIIUtil;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
@ -26,6 +28,7 @@ public class MoreActivity extends AppCompatActivity {
private boolean aBoolean;
private ActivityMoreBinding binding;
private MyAdapter adapter;
public MediaPlayer music;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -35,6 +38,7 @@ public class MoreActivity extends AppCompatActivity {
adapter = new MyAdapter(this);
binding.setAdapter(adapter);
uhfrManager = UHFRManager.getInstance();
music = MediaPlayer.create(this, com.example.writeepc.R.raw.msg);
registerReceiver();
}
@ -88,7 +92,7 @@ public class MoreActivity extends AppCompatActivity {
if (strings == null || strings.isEmpty()) {
return;
}
music.start();
List<String> list = new ArrayList<>(strings.size());
strings.forEach(taginfo -> {

@ -0,0 +1,108 @@
package com.example.writeepc;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.databinding.ActivityUserXuanchuanBinding;
import com.example.writeepc.utils.ASCIIUtil;
import java.util.Locale;
public class UserXuanchuanActivity extends BaseActivity {
private ActivityUserXuanchuanBinding binding;
private int flag = 0;
private byte[] rdata;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_user_xuanchuan);
Locale locale = new Locale("es");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
initReceiver();
initUHFRManager(33);
}
public void readTid(View view) {
flag = 1;
readTid();
}
public void writeUser(View view) {
String trim = binding.writeInfo.getText().toString().trim();
if (rdata == null) {
Toast.makeText(this, "请先读取TID", Toast.LENGTH_SHORT).show();
return;
}
if (trim.isEmpty()) {
Toast.makeText(this, "请输入要写入的用户信息", Toast.LENGTH_SHORT).show();
return;
}
int length = trim.length();
// 32,128
if (length > 32 ) {
Toast.makeText(this, "长度不能超过32个字符", Toast.LENGTH_SHORT).show();
return;
}
String writeData = ASCIIUtil.str4Hex(trim);
int writeLenth = writeData.length();
Log.e("TAG", "数据长度:" + length + " ," + writeLenth);
if (writeLenth < 128) {
writeData = writeData+String.format("%0"+(128-writeLenth)+"d", 0);
}
Log.e("TAG", "写入数据:" + writeData+" ,长度:" + writeData.length());
writeUserDataByTid(writeData, rdata);
}
public void readUser(View view) {
flag = 2;
readUser(64);
}
@Override
public void receiverSan() {
super.receiverSan();
readUser(null);
}
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
super.readTidReault(readState, result, rdata);
if (readState) {
if (flag == 1) {
binding.tidCode.setText(result);
this.rdata = rdata;
} else {
Log.e("TAG", "readTidReault:" + result);
String text = ASCIIUtil.hexTo4ZN(result);
binding.readInfo.setText(text);
}
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (uhfrManager != null) {
uhfrManager.close();
uhfrManager = null;
}
if (myReceiver != null) {
unregisterReceiver(myReceiver);
myReceiver = null;
}
}
}

@ -1,5 +1,9 @@
package com.example.writeepc;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
@ -8,55 +12,93 @@ import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import com.example.writeepc.base.BaseActivity;
import com.example.writeepc.been.InfoData;
import com.example.writeepc.been.WriteInfo;
import com.example.writeepc.databinding.ActivityWriteUserBinding;
import com.example.writeepc.utils.SharedPreferencesUtils;
import com.example.writeepc.utils.WriteExportExcelUtil;
import com.uhf.api.cls.Reader;
import org.litepal.LitePal;
import java.io.File;
import java.util.Date;
public class WriteUserActivity extends BaseActivity {
private ActivityWriteUserBinding binding;
private InfoData infoData;
private boolean isReadUser = false;
private WriteExportExcelUtil writeExportExcelUtil;
private MyKeyReceiver keyReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user);
infoData = new InfoData();
binding.setData(infoData);
initUHFRManager(5);
initReceiver();
int power = SharedPreferencesUtils.getInt("power", 30);
binding.selectPower.setSelection(power-5);
initUHFRManager(power);
writeExportExcelUtil = new WriteExportExcelUtil(this);
keyReceiver = new MyKeyReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction("android.rfid.FUN_KEY");
registerReceiver(keyReceiver, intentFilter);
}
@Override
protected void readTidReault(boolean readState, String result, byte[] rdata) {
Log.e("TAG", "readTidReault:" + result);
infoData.setReadUser(ASCIIUtil.hex2Str(result));
if (isReadUser) {
infoData.setTidBytes(rdata);
infoData.setReadTId(result);
return;
}
infoData.setReadUser(result);
}
public void writeUser(View view) {
String readTId = infoData.getReadTId();
if (readTId == null || readTId.isEmpty()) {
Toast.makeText(this, "请先读取TID", Toast.LENGTH_SHORT).show();
return;
}
String writeData = infoData.getWriteUser();
if (writeData == null || writeData.isEmpty()) {
Toast.makeText(this, "请输入要写入的数据", Toast.LENGTH_SHORT).show();
return;
}
int length = writeData.length();
String tag="";
if (writeData.length() % 4 != 0) {
tag=String.format("%0" + (length % 4)*2 + "d", 0);
try {
WriteInfo writeInfo = new WriteInfo(readTId, writeData, sdf.format(new Date()));
// boolean b = writeUserDataByTid(writeData + "0000000000", infoData.getTidBytes());
boolean b = writeEPCDataByTid("00"+writeData , infoData.getTidBytes());
if (b) {
writeInfo.save();
}
String s = ASCIIUtil.str2Hex(writeData)+tag;
Log.e("TAG", "writeUser:" + s);
Log.e("TAG", "writeUser:" + s.length());
writeUserData(s);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(this, "写入用户数据失败,请检查胎号是否正确", Toast.LENGTH_SHORT).show();
}
}
public void readUser(View view) {
int lenth = Integer.parseInt(binding.userReadLenth.getSelectedItem().toString());
readUser(lenth);
isReadUser = false;
// readUser(6);
readEPC(6);
}
public void userClearView(View view) {
infoData.setWriteUser(null);
infoData.setReadUser(null);
// infoData.setWriteUser(null);
// infoData.setReadUser(null);
infoData.clear();
}
public void writeUserReadTid(View view) {
isReadUser = true;
readTid();
}
@Override
public void receiverSan() {
@ -70,9 +112,71 @@ public class WriteUserActivity extends BaseActivity {
uhfrManager.close();
uhfrManager = null;
}
if (myReceiver != null) {
unregisterReceiver(myReceiver);
// if (myReceiver != null) {
// unregisterReceiver(myReceiver);
// }
if (keyReceiver != null) {
unregisterReceiver(keyReceiver);
}
}
@Override
protected void onResume() {
super.onResume();
exportExcel(null);
}
public void exportExcel(View view) {
// File file= writeExportExcelUtil.getFilePath("RFID写入记录.xls");
// if (file.exists()) {
// file.delete();
// }
// writeExportExcelUtil.export(LitePal.findAll(WriteInfo.class), "RFID写入记录.xls");
}
// 点击两次返回结束程序
private long exitTime = 0;
@Override
public void onBackPressed() {
if (System.currentTimeMillis() - exitTime > 2000) {
Toast.makeText(this, "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
} else {
finish();
}
}
public class MyKeyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
var keydown = intent.getBooleanExtra("keydown", false);
var keyCode = intent.getIntExtra("keyCode", 0);
Log.e("TAG", "onReceive:" + keyCode);
if (!keydown) {
if (keyCode == 135) {
writeUserReadTid(null);
}else if (keyCode ==136){
writeUser(null);
}
}
}
}
public void setPower(View view) {
String powerString = binding.selectPower.getSelectedItem().toString();
int power = Integer.parseInt(powerString);
SharedPreferencesUtils.putInt("power", power);
Reader.READER_ERR readerErr = uhfrManager.setPower(power, power);
Log.e("TAG", "setPower:" + readerErr.toString());
}
}

@ -19,6 +19,8 @@ import com.google.gson.Gson;
import com.handheld.uhfr.UHFRManager;
import com.uhf.api.cls.Reader;
import java.text.SimpleDateFormat;
import cn.pda.serialport.Tools;
import okhttp3.MediaType;
@ -32,6 +34,8 @@ public class BaseActivity extends AppCompatActivity {
public MediaType mediaType = MediaType.parse("text/xml; charset=utf-8");
public Gson gson;
public MyReceiver myReceiver;
public SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 格式化时间
public SimpleDateFormat fileNameDate = new SimpleDateFormat("yyyy-MM-dd HH_mm_ss");// 格式化时间
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@ -100,7 +104,7 @@ public class BaseActivity extends AppCompatActivity {
public void readEPC(int lenth) {
byte[] rdata = new byte[lenth];
Reader.READER_ERR readerErr =
uhfrManager.getTagData(1, 2, lenth / 2, rdata, accesspwd, timeOut);
uhfrManager.getTagData(1, 5, lenth / 2, rdata, accesspwd, timeOut);
Log.e("TAG", "readTid:" + readerErr.name());
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
music.start();
@ -141,6 +145,73 @@ public class BaseActivity extends AppCompatActivity {
}
}
public boolean writeUserDataByTid(String writeData, byte[] rdata) {
byte[] bytes = Tools.HexString2Bytes(writeData);
Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter
((char) 3, 0,
bytes, bytes.length, accesspwd, timeOut,
rdata, 2, 0, true);
Log.e("TAG", "写入状态:" + readerErr.name());
boolean b = readerErr == Reader.READER_ERR.MT_OK_ERR;
if (b) {
music.start();
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
}
return b;
}
public boolean writeEPCDataByTid(String writeData, byte[] rdata) {
byte[] bytes = Tools.HexString2Bytes(writeData);
Reader.READER_ERR readerErr = uhfrManager.writeTagDataByFilter
((char) 1, 5,
bytes, bytes.length, accesspwd, timeOut,
rdata, 2, 0, true);
Log.e("TAG", "写入状态:" + readerErr.name());
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Log.e("TAG", "Sleep interrupted", e);
}
Reader.READER_ERR readerErr2 = Reader.READER_ERR.MT_CMD_FAILED_ERR;
if (readerErr == Reader.READER_ERR.MT_OK_ERR) {
// 写入成功
byte[] suessTagEpc = new byte[12];
Reader.READER_ERR readerErrReed =
uhfrManager.getTagData(1, 2, 6, suessTagEpc, accesspwd, timeOut);
Log.e("TAG", "read读取全部EPC:" + readerErrReed.name());
if ( readerErrReed == Reader.READER_ERR.MT_OK_ERR) {
readerErr2 = uhfrManager.lockTagByFilter(
Reader.Lock_Obj.LOCK_OBJECT_BANK1,
Reader.Lock_Type.BANK1_PERM_LOCK,
// Reader.Lock_Type.BANK1_LOCK,
accesspwd,
timeOut,
suessTagEpc, 1, 2, true);
}
}
Log.e("TAG", "锁定状态:" + readerErr2.name());
boolean b = readerErr2 == Reader.READER_ERR.MT_OK_ERR;
if (b) {
music.start();
Toast.makeText(this, "写入成功", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(this, "写入失败", Toast.LENGTH_SHORT).show();
}
return b;
}
protected void readTidReault(boolean readState, String result, byte[] rdata) {
}

@ -13,6 +13,8 @@ import com.lzy.okgo.https.HttpsUtils;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders;
import org.litepal.LitePal;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
@ -48,6 +50,7 @@ public class MyApplication extends Application {
application = this;
SharedPreferencesUtils.init(getApplicationContext(), "myapp");
okGoBase();
LitePal.initialize(this);
}
// OKGO 初始化

@ -1,7 +1,9 @@
package com.example.writeepc;
package com.example.writeepc.been;
import androidx.databinding.BaseObservable;
import java.util.Arrays;
public class InfoData extends BaseObservable {
private int power;
private String epc;
@ -113,4 +115,18 @@ public class InfoData extends BaseObservable {
this.state = state;
notifyChange();
}
public void clear() {
epc = null;
writeEpc = null;
readEpc = null;
readAscii = null;
readTId = null;
tidBytes = null;
writeUser = null;
readUser = null;
notifyChange();
}
}

@ -0,0 +1,51 @@
package com.example.writeepc.been;
import org.litepal.crud.LitePalSupport;
public class WriteInfo extends LitePalSupport {
private int id;
private String tid;
private String writeInfo;
private String dateTime;
public WriteInfo() {
}
public WriteInfo(String tid, String writeInfo, String dateTime) {
this.tid = tid;
this.writeInfo = writeInfo;
this.dateTime = dateTime;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTid() {
return tid;
}
public void setTid(String tid) {
this.tid = tid;
}
public String getWriteInfo() {
return writeInfo;
}
public void setWriteInfo(String writeInfo) {
this.writeInfo = writeInfo;
}
public String getDateTime() {
return dateTime;
}
public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}
}

@ -1,4 +1,6 @@
package com.example.writeepc;
package com.example.writeepc.utils;
import android.util.Log;
/**
* @author: wangh
@ -31,13 +33,16 @@ public class ASCIIUtil {
return sb.toString();
}
public static String hexTo4ZN(String hex) throws Exception {
public static String hexTo4ZN(String hex) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hex.length() - 1; i += 4) {
String h = hex.substring(i, (i + 4));
Log.e("TAG", "hexTo4ZN:" + h);
if (!h.equals("0000")) {
sb.append((char) Integer.parseInt(h, 16));
}
}
return sb.toString();
}

@ -0,0 +1,98 @@
package com.example.writeepc.utils;
import android.content.Context;
import android.os.Environment;
import android.widget.Toast;
import com.example.writeepc.been.WriteInfo;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
/**
* 使 jxl-2.6.12 Excel Android 5.1
*/
public class WriteExportExcelUtil {
private Context mContext;
public WriteExportExcelUtil(Context context) {
this.mContext = context;
}
/**
* RFID .xls
*/
public void export(List<WriteInfo> dataList, String fileName) {
// 确保文件名以 .xls 结尾
if (!fileName.endsWith(".xls")) {
fileName += ".xls";
}
WritableWorkbook workbook = null;
try {
File file = getFilePath(fileName);
FileOutputStream fos = new FileOutputStream(file);
workbook = Workbook.createWorkbook(fos);
WritableSheet sheet = workbook.createSheet("RFID写入记录", 0); // 索引0表示第一个表
sheet.setColumnView(0, 10);
sheet.setColumnView(1, 20);
sheet.setColumnView(2, 20);
sheet.setColumnView(3, 20);
// 4. 写入表头(第一行)
String[] headers = {"序号", "TID", "写入胎号", "写入时间"};
for (int i = 0; i < headers.length; i++) {
// Label(列索引, 行索引, 内容)
Label headerLabel = new Label(i, 0, headers[i]);
sheet.addCell(headerLabel);
}
// 5. 写入数据从第二行开始行索引1
for (int i = 0; i < dataList.size(); i++) {
WriteInfo data = dataList.get(i);
int rowIndex = i + 1;
// 序号id
sheet.addCell(new Label(0, rowIndex, String.valueOf(data.getId())));
sheet.addCell(new Label(1, rowIndex, data.getTid() == null ? "" : data.getTid()));
sheet.addCell(new Label(2, rowIndex, data.getWriteInfo() == null ? "" : data.getWriteInfo()));
sheet.addCell(new Label(3, rowIndex, data.getDateTime() == null ? "" : data.getDateTime()));
}
// 6. 写入文件并关闭工作簿
workbook.write();
// Toast.makeText(mContext, "导出成功:" + file.getAbsolutePath(), Toast.LENGTH_LONG).show();
} catch (IOException | WriteException e) {
e.printStackTrace();
// Toast.makeText(mContext, "导出失败:" + e.getMessage(), Toast.LENGTH_SHORT).show();
} finally {
// 7. 释放资源
if (workbook != null) {
try {
workbook.close();
} catch (IOException | WriteException e) {
e.printStackTrace();
}
}
}
}
/**
* Android 5.1
*/
public File getFilePath(String fileName) {
File downloadDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
if (!downloadDir.exists()) {
downloadDir.mkdirs();
}
return new File(downloadDir, fileName);
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp"/>
<solid android:color="@color/white"/>
</shape>

@ -7,7 +7,7 @@
<variable
name="data"
type="com.example.writeepc.InfoData" />
type="com.example.writeepc.been.InfoData" />
</data>
<LinearLayout

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@mipmap/test1"
tools:context=".UserXuanchuanActivity">
<TextView
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_gravity="center"
android:background="@color/blue2"
android:letterSpacing="0.2"
android:text="RFID Tag writing"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="San TID:" />
<TextView
android:id="@+id/tid_code"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="readTid"
android:backgroundTint="@color/blue2"
android:text="Query TID" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="Input data:" />
<EditText
android:id="@+id/write_info"
style="@style/info_text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:minHeight="45dp" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/blue2"
android:onClick="writeUser"
android:text="Write data" />
<TextView
android:id="@+id/read_info"
style="@style/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="8dp"
android:layout_weight="1" />
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/blue2"
android:onClick="readUser"
android:text="Scan RFID" />
</LinearLayout>
</layout>

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="data"
type="com.example.writeepc.InfoData" />
type="com.example.writeepc.been.InfoData" />
</data>
<LinearLayout
@ -23,15 +23,17 @@
android:layout_gravity="center"
android:background="#6750A4"
android:letterSpacing="0.2"
android:text="User区读写"
android:text="EPC区读写"
android:textColor="@color/white"
android:textSize="22sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="30dp"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
style="@style/info_text"
@ -44,10 +46,70 @@
android:id="@+id/user_read_lenth"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/read_lenth"
android:textAlignment="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="设置功率:" />
<Spinner
android:id="@+id/select_power"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:entries="@array/power"
android:textAlignment="center"
android:entries="@array/read_lenth"/>
/>
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="setPower"
android:text="设置功率" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
style="@style/info_text"
android:layout_width="110dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="扫描TID:" />
<TextView
android:id="@+id/tid_code"
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_gravity="center"
android:text="@{data.readTId}" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:backgroundTint="@color/blue2"
android:onClick="writeUserReadTid"
android:text="1-查询TID" />
<LinearLayout
android:layout_width="match_parent"
@ -71,13 +133,12 @@
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:onClick="writeUser"
android:layout_marginTop="12dp"
android:onClick="writeUser"
android:text="写入数据" />
<LinearLayout
@ -91,20 +152,19 @@
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:text="user:" />
android:text="EPC:" />
<TextView
style="@style/san_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="5dp"
android:minHeight="55dp"
android:padding="5dp"
android:text="@={data.readUser}" />
</LinearLayout>
<Button
style="@style/button_style"
android:layout_width="match_parent"
@ -112,14 +172,30 @@
android:layout_marginTop="12dp"
android:onClick="readUser"
android:text="扫描验证" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp">
<Button
style="@style/button_style"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginTop="12dp"
android:onClick="userClearView"
android:layout_weight="1"
android:backgroundTint="#FFD600"
android:onClick="userClearView"
android:text="清空操作" />
<!-- <Button-->
<!-- style="@style/button_style"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="55dp"-->
<!-- android:backgroundTint="@color/blue"-->
<!-- android:onClick="exportExcel"-->
<!-- android:text="设置功率" />-->
</LinearLayout>
</LinearLayout>
</layout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

@ -3,4 +3,5 @@
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="blue">#304FFE</color>
<color name="blue2">#034580</color>
</resources>

@ -44,6 +44,16 @@
<item name="android:background">@drawable/san_text_bg</item>
<item name="android:layout_marginEnd">8dp</item>
</style>
<style name="info_text2">
<item name="android:textColor">@color/black</item>
<item name="android:textSize">18sp</item>
<item name="android:gravity">center</item>
<item name="android:background">@drawable/info_text_bg</item>
<item name="android:layout_marginEnd">8dp</item>
</style>
<style name="button_style">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>

Loading…
Cancel
Save