Commit f7c16ce3 by liulei

初始化

parent 2d0cc45d
apply plugin: 'com.android.application'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
applicationId "com.stm.asset"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation "androidx.room:room-runtime:2.2.3"
annotationProcessor "androidx.room:room-compiler:2.2.3"
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.squareup.okhttp3:okhttp:3.14.2'
implementation 'com.squareup.okio:okio:1.17.4'
implementation 'com.tencent.bugly:crashreport:3.4.4'
implementation 'me.jessyan:autosize:1.1.2'
implementation (name: 'BaseLib', ext: 'aar')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// compile project(path: ':u8')
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontwarn com.tencent.bugly.**
-keep public class com.tencent.bugly.**{*;}
\ No newline at end of file
package com.stm.asset;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.stm.asset", appContext.getPackageName());
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stm.asset">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:name=".base.StmApplication"
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:roundIcon="@drawable/logo"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
<!-- 480 * 640 -->
<meta-data android:name="design_width_in_dp" android:value="337"/>
<meta-data android:name="design_height_in_dp" android:value="449"/>
<activity android:name=".page.WelcomeActivity" android:screenOrientation="portrait">
<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.VIEW" />
</intent-filter>
</activity>
<activity android:name=".page.MainActivity" android:screenOrientation="portrait" />
<activity android:name=".page.CheckTaskActivity" android:screenOrientation="portrait" />
<activity android:name=".page.TaskInfoActivity" android:screenOrientation="portrait" />
<activity android:name=".page.SetAndSaveActivity" android:screenOrientation="portrait" />
<activity android:name=".page.InventoryActivity" android:screenOrientation="portrait" />
<activity android:name=".page.LoginActivity" android:screenOrientation="portrait" />
<activity android:name=".page.DeviceSetActivity" android:screenOrientation="portrait" />
<activity android:name=".page.SelectIPActivity" android:screenOrientation="portrait" />
</application>
</manifest>
\ No newline at end of file
package com.fn.useries.model;
public interface IResponseHandler {
/**
* 成功
* msg 成功时返回的消息
* data 成功时返回的数据,已转换为字符串
* parameters 成功时返回的响应帧中的Parameters域的数据
*/
public void onSuccess(String msg, Object data, byte[] parameters);
/**
* 失败
* msg 失败的消息
*/
public void onFailure(String msg);
}
package com.fn.useries.model;
public class Message {
private int code; // 0 Successful, 1 Failure
private String message; //额外信息
private String result; // 结果
public Message(){
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
public void setCode(int code) {
this.code = code;
}
public void setMessage(String message) {
this.message = message;
}
public void setResult(String result) {
this.result = result;
}
public String getResult() {
return result;
}
}
package com.fn.useries.model;
public class ReceiveDataHandler {
private static final ReceiveDataHandler mReceiverHolder = new ReceiveDataHandler();
private int code; // 0 Successful, 1 Failure
private String message; //额外信息
private String result; // 返回结果
private ReceiveDataHandler(){}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public static ReceiveDataHandler getInstance(){
return mReceiverHolder;
}
}
package com.fn.useries.model;
public abstract class ResponseHandler implements IResponseHandler {
private static final String TAG = "ResponseHandler";
/*
* (non-Javadoc)
* @see com.fn.useries.model.IResponseHandler#onSuccess(java.lang.String, java.lang.Object, byte[])
*/
@Override
public void onSuccess(String msg, Object data, byte[] parameters) {
}
/*
* (non-Javadoc)
* @see com.fn.useries.model.IResponseHandler#onFailure(java.lang.String)
*/
@Override
public void onFailure(String msg) {
System.out.println("onFailure---msg:" + msg);
}
}
package com.fn.useries.model;
/**
* 保存读到的设置参数,各个模块不同可加参数
*
* @author 07
*
*/
public class SettingParams {
private int TXPower;
private int detectionTemperature;// 模块温度
private byte btMode;// 蜂鸣器状态
public int getTXPower() {
return TXPower;
}
public void setTXPower(int tXPower) {
TXPower = tXPower;
}
public int getDetectionTemperature() {
return detectionTemperature;
}
public void setDetectionTemperature(int detectionTemperature) {
this.detectionTemperature = detectionTemperature;
}
public byte getBtMode() {
return btMode;
}
public void setBtMode(byte btMode) {
this.btMode = btMode;
}
}
package com.fn.useries.operation;
import com.fn.useries.model.IResponseHandler;
import com.fn.useries.model.Message;
public interface IUSeries {
/**
* 打开串口
* @param moduleName 模块名
* @return true_ 打开串口成功,false_ 打开串口失败
*/
Message openSerialPort(String moduleName);
/**
* 关闭串口
*
* @return true_ 关闭串口成功,false_ 关闭串口失败
*/
Message closeSerialPort();
/**
* 模块上电
* @param moduleName 模块名
* @return true_ 上电成功,false_ 上电失败
*/
Message modulePowerOn(String moduleName);
/**
* 模块下电
* @param moduleName 模块名
* @return true_ 下电成功,false_ 下电失败
*/
Message modulePowerOff(String moduleName);
/**
* 开始盘询
* @param responseHandler 盘询结果回调
* @return true_ 开始盘询成功成功,false_ 开始盘询失败
*/
boolean startInventory(IResponseHandler responseHandler);
/**
* 停止盘询
* @return true_ 停止盘询成功,false_ 停止盘询失败
*/
boolean stopInventory();
/**
* 单次盘询
* @return 盘询结果
*/
Message Inventory();
/**
* 读标签
*
* @param block 读取区域
* @param w_count 读取长度
* @param w_offset 偏移
* @param acs_pwd 访问密码
* @return 读取标签数据
*/
Message readTagMemory(byte[] EPC, byte block, byte w_count, byte w_offset, byte[] acs_pwd);
/**
* 写标签
*
* @param block 写入区域
* @param w_count 写入长度
* @param w_offset 偏移
* @param data 写入数据
* @param acs_pwd 访问密码
* @return 是否写入成功
*/
Message writeTagMemory(byte[] EPC, byte block, byte w_count, byte w_offset, byte[] data, byte[] acs_pwd);
/**
* 锁标签
*
* @param block 锁定区域
* @param operation 操作类型
* @param acs_pwd 访问密码
* @return 返回错误代码
*/
Message lockTagMemory(byte[] EPC, byte block, Enum operation, byte[] acs_pwd);
/**
* 销毁标签
*
* @param kill_pwd 销毁密码
* @return 返回错误代码
*/
Message killTag(byte[] EPC, byte[] kill_pwd);
/**
* 设置参数
*
* @param paraName 参数名(详见SDK)
* @return
*/
String getParams(String paraName);
/**
* 设置参数
*
* @param paraName 参数名(详见SDK)
* @param paraValue 参数值(详见SDK)
* @return
*/
boolean setParams(String paraName, String paraValue);
}
package com.fn.useries.operation;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.AndroidVersions;
import com.fn.useries.model.IResponseHandler;
import com.fn.useries.model.Message;
import com.fn.useries.reader.CMD;
import com.fn.useries.reader.ERROR;
import com.fn.useries.reader.model.InventoryBuffer;
import com.fn.useries.reader.model.InventoryBuffer.InventoryTagMap;
import com.fn.useries.reader.model.OperateTagBuffer;
import com.fn.useries.reader.model.ReaderSetting;
import com.fn.useries.reader.server.ReaderBase;
import com.fn.useries.reader.server.ReaderHelper;
import com.fn.useries.utils.Tools;
import com.fn.useries.utils.U8Property;
import com.fntech.Loger;
import com.stm.asset.R;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.List;
import android_serialport_api.SerialPort;
import cn.fuen.xmldemo.activity.SetAndSaveActivity;
import cn.fuen.xmldemo.entity.Device;
import cn.fuen.xmldemo.model.DeviceModel;
public class U8Series implements IUSeries {
private static final String TAG = "USeries";
private Tools tools = new Tools();
private static Context mContext;
public static final Object object = new Object();// 设置参数锁
public static final Object readObject = new Object();// read Tag线程锁对象
/**
* notify标识,防止出现接收线程已经收到串口返回并notify,而发送线程并未开始sleep造成异常;
* 此标志位在每次使用前必须恢复初始值false
*/
public static boolean havenotify;
private final int SUCCEED = 0;
private final int FAILED = 1;
public static final String REFRESHTEXT = "REFRESHTEXT";
public static final String REFRESHLIST = "REFRESHLIST";
/**
* 射频功率
*/
public static final String PARA_POWER = "PARA_POWER";
/**
* 软件提示音模式
*/
public static final String BEER_STATE = "BEER_STATE";
/**
* 软件提示音开关 0-打开;1-关闭
*/
public static final String SOFT_SOUND = "SOFT_SOUND";
/**
* 模块温度
*/
public static final String TEMPERATURE = "TEMPERATURE";
/**
* session
*/
public static final String SESSIONSTATE = "SESSIONSTATE";
/**
* flag state
*/
public static final String FLAGSTATE = "FLAGSTATE";
private SerialPort mSerialPort = null;
// 以下三个字符串供上下电配置使用,不可更改
private String model = "U8";
private String packageName = "com.fn.useries";
private String activityName = "com.fn.useries.activity.MainActivity";
private ReaderBase mReader;
private ReaderHelper mReaderHelper;
private ReaderSetting m_curReaderSetting;
private InventoryBuffer m_curInventoryBuffer;
private OperateTagBuffer m_curOperateTagBuffer;
private static U8Series mUSeries;
private List<InventoryTagMap> mTagMaps;
/**
* 读标签结果,若读取成功在@link ReaderHelper.processReadTag(MessageTran)中被赋值
*/
public String readDataString = "";
/**
* 写/锁/杀标签结果标志位,成功:0,失败:1; 注意操作前复位为1
*/
public static int operationTagResult;
/**
* 错误信息,当解析到错误代码时被赋值
*/
public static String errorData = "";
/**
*
*/
public static String temperature;
private IResponseHandler mResponseHandler;
private boolean enableSaveDataWhenGoOnInventory = true;// 重新盘存保存上一次数据
private boolean firstInventoryFlag = true;
private int timeout = 3 * 1000;
/**
* 锁标签操作类型
*
* LOCK_FREE 解锁
* LOCK_FREE_EVER 永久解锁
* LOCK_LOCK 锁
* LOCK_LOCK_EVER 永久锁定
*/
public static enum lockOperation {
LOCK_FREE, LOCK_FREE_EVER, LOCK_LOCK, LOCK_LOCK_EVER
}
private U8Series() {
}
public static void setContext(Context context) {
mContext = context;
}
public static U8Series getInstance() {
if (mUSeries == null) {
mUSeries = new U8Series();
registerReceiver();
return mUSeries;
}
return mUSeries;
}
@Override
public boolean startInventory(IResponseHandler responseHandler) {
this.mResponseHandler = responseHandler;
try {
initInventoryParam(); //初始化,开启数据接收线程
} catch (Exception e) {
Loger.disk_log("Exception", "initInventoryParamException,info = " + e.toString(), "M10_U8");
return false;
}
m_curInventoryBuffer.clearInventoryPar();
m_curInventoryBuffer.bLoopCustomizedSession = true;
m_curInventoryBuffer.btSession = (byte) (U8Property.getSessionState() & 0xFF);
m_curInventoryBuffer.btTarget = (byte) (U8Property.getFlagState() & 0xFF);
m_curInventoryBuffer.lAntenna.add((byte) 0x01);
m_curInventoryBuffer.bLoopInventoryReal = true;
m_curInventoryBuffer.btRepeat = (byte) 1;
if (enableSaveDataWhenGoOnInventory) {
if (firstInventoryFlag)// add by lyz
m_curInventoryBuffer.clearInventoryRealResult();
} else {
m_curInventoryBuffer.clearInventoryRealResult();
}
mReaderHelper.setInventoryFlag(true);
if (enableSaveDataWhenGoOnInventory) {
if (firstInventoryFlag)// add by lyz
mReaderHelper.clearInventoryTotal();
} else {
mReaderHelper.clearInventoryTotal();
}
byte btWorkAntenna = m_curInventoryBuffer.lAntenna.get(m_curInventoryBuffer.nIndexAntenna);
if (btWorkAntenna < 0)
btWorkAntenna = 0;
mReader.setWorkAntenna(m_curReaderSetting.btReadId, btWorkAntenna);//设置工作天线
//mReader.getFirmwareVersion(m_curReaderSetting.btReadId);
return true;
}
@Override
public boolean stopInventory() {
try {
mReaderHelper.setInventoryFlag(false);
m_curInventoryBuffer.bLoopInventory = false;
m_curInventoryBuffer.bLoopInventoryReal = false;
// if (enableSaveDataWhenGoOnInventory)
// mReader.resetRecevice();
Log.i("toolsdebug", " stopInventory() ");
Loger.disk_log("stopInventory", " stopInventory ", "U8");
} catch (Exception e) {
Loger.disk_log("Exception", "stopInventoryException" + getExceptionAllinformation(e), "M10_U8");
return false;
}
return true;
}
@Override
public Message readTagMemory(byte[] EPC, byte block, byte w_count, byte w_offset, byte[] acs_pwd) {
Message message = new Message();
if(setEpcMatch(EPC)==FAILED){
message.setCode(FAILED);
message.setMessage(mContext.getString(R.string.str_set_epc_match_failed));
return message;
}
flagReset();
m_curOperateTagBuffer.clearBuffer();
mReader.readTag(m_curReaderSetting.btReadId, block, w_offset, w_count, acs_pwd);
// 发送指令后线程挂起 等待数据返回
synchronized (readObject) {
try {
readObject.wait(timeout);
} catch (InterruptedException e) {
readObject.notify();
}
}
// 未读到标签数据
if (readDataString == null) {
mReader.resetRecevice();
message.setCode(FAILED);
message.setMessage(TextUtils.isEmpty(errorData) ? receviceIncompleteError() : errorData);
return message;
}
// notify后返回数据
message.setCode(SUCCEED);
message.setResult(readDataString);
return message;
}
@Override
public Message writeTagMemory(byte[] EPC, byte block, byte w_count, byte w_offset, byte[] data, byte[] acs_pwd) {
Message message = new Message();
if(setEpcMatch(EPC)==FAILED){
message.setCode(FAILED);
message.setMessage(mContext.getString(R.string.str_set_epc_match_failed));
return message;
}
flagReset();
m_curOperateTagBuffer.clearBuffer();
mReader.writeTag(m_curReaderSetting.btReadId, acs_pwd, block, w_offset, w_count, data);
// 发送指令后线程挂起 等待数据返回
synchronized (mReaderHelper) {
try {
mReaderHelper.wait(timeout);
} catch (InterruptedException e) {
Loger.disk_log("Exception", "writeTagMemoryWaitException" + getExceptionAllinformation(e), "M10_U8");
mReaderHelper.notify();
}
}
message.setCode(operationTagResult);
message.setMessage(TextUtils.isEmpty(errorData) ? receviceIncompleteError() : errorData);
return message;
}
@Override
public Message lockTagMemory(byte[] EPC, byte block, Enum operation, byte[] acs_pwd) {
Message message = new Message();
if(setEpcMatch(EPC)==FAILED){
message.setCode(FAILED);
message.setMessage(mContext.getString(R.string.str_set_epc_match_failed));
return message;
}
flagReset();
m_curOperateTagBuffer.clearBuffer();
byte operat = 0x04;
if (operation.name().equals(lockOperation.LOCK_FREE.name())) {
operat = 0x00;
} else if (operation.name().equals(lockOperation.LOCK_FREE_EVER.name())) {
operat = 0x02;
} else if (operation.name().equals(lockOperation.LOCK_LOCK.name())) {
operat = 0x01;
} else if (operation.name().equals(lockOperation.LOCK_LOCK_EVER.name())) {
operat = 0x03;
}
mReader.lockTag(m_curReaderSetting.btReadId, acs_pwd, block, operat);
// 发送指令后线程挂起 等待数据返回
synchronized (mReaderHelper) {
try {
mReaderHelper.wait(timeout);
} catch (InterruptedException e) {
Loger.disk_log("Exception", "lockTagMemoryException" + getExceptionAllinformation(e), "M10_U8");
mReaderHelper.notify();
}
}
message.setCode(operationTagResult);
message.setMessage(TextUtils.isEmpty(errorData) ? receviceIncompleteError() : errorData);
return message;
}
@Override
public Message killTag(byte[] EPC, byte[] kill_pwd) {
Message message = new Message();
if(setEpcMatch(EPC)==FAILED){
message.setCode(FAILED);
message.setMessage(mContext.getString(R.string.str_set_epc_match_failed));
return message;
}
flagReset();
m_curOperateTagBuffer.clearBuffer();
mReader.killTag(m_curReaderSetting.btReadId, kill_pwd);
// 发送指令后线程挂起 等待数据返回
synchronized (mReaderHelper) {
try {
mReaderHelper.wait(timeout);
} catch (InterruptedException e) {
Loger.disk_log("Exception", "writeTagMemoryException" + getExceptionAllinformation(e), "M10_U8");
mReaderHelper.notify();
}
}
message.setCode(operationTagResult);
message.setMessage(TextUtils.isEmpty(errorData) ? receviceIncompleteError() : errorData);
return message;
}
/**
* 设置
* @param paraName
* 参数名(详见SDK)
* @param paraValue
* 参数值(详见SDK)
* @return
*/
@Override
public boolean setParams(String paraName, String paraValue) {
flagReset();
byte paramsValue = 0;
try {
paramsValue = Byte.parseByte(paraValue);
} catch (NumberFormatException e) {
e.printStackTrace();
Loger.disk_log("Exception", "setParamsException" + getExceptionAllinformation(e), "M10_U8");
return false;
}
if (paraName.equals(PARA_POWER)) {
m_curReaderSetting.btAryOutputPower = new byte[] { paramsValue };
mReader.setOutputPower(m_curReaderSetting.btReadId, paramsValue);
synchronized (object) {
try {
if (!havenotify)
object.wait(timeout);
} catch (InterruptedException e) {
object.notify();
}
}
return m_curReaderSetting.blnSetResult;
} else if (paraName.equals(BEER_STATE)) {
mReader.setBeeperMode(m_curReaderSetting.btReadId, paramsValue);
synchronized (object) {
try {
if (!havenotify)
object.wait(timeout);
} catch (InterruptedException e) {
object.notify();
}
}
if (m_curReaderSetting.blnSetResult) {
m_curReaderSetting.btBeeperMode = paramsValue;
U8Property.saveBeeperState((paramsValue & 0xFF));
}
return m_curReaderSetting.blnSetResult;
} else if (paraName.equals(SOFT_SOUND)) {
U8Property.saveSoftSound(paramsValue);
return true;
} else if (paraName.equals(TEMPERATURE)) {
// 温度只能获取无法设置
} else if (paraName.equals(SESSIONSTATE)) {
try {
U8Property.saveSessionState(paramsValue);
} catch (Exception e) {
e.printStackTrace();
Loger.disk_log("Exception", "set_SESSIONSTATE_Exception:" + e.toString(), "M10_U8");
return false;
}
return true;
} else if (paraName.equals(FLAGSTATE)) {
try {
U8Property.saveFlagState(paramsValue);
} catch (Exception e) {
e.printStackTrace();
Loger.disk_log("Exception", "set_FLAGSTATE_Exception:" + e.toString(), "M10_U8");
return false;
}
return true;
}
return false;
}
@Override
public String getParams(String paraName) {
flagReset();
try {
mReaderHelper = ReaderHelper.getDefaultHelper();
mReader = mReaderHelper.getReader();
} catch (Exception e) {
e.printStackTrace();
}
m_curReaderSetting = mReaderHelper.getCurReaderSetting();
if (paraName.equals(PARA_POWER)) {
// 获取
mReader.getOutputPower(m_curReaderSetting.btReadId);
// 发送指令后线程挂起 等待数据返回
synchronized (object) {
try {
if (!havenotify)
object.wait(timeout);
} catch (InterruptedException e) {
object.notify();
}
}
if (m_curReaderSetting.btAryOutputPower != null) {
int powerValue = m_curReaderSetting.btAryOutputPower[0] & 0xFF;
return Integer.toString(powerValue);
} else {
return receviceIncompleteError();
}
} else if (paraName.equals(BEER_STATE)) {
m_curReaderSetting.btBeeperMode = (byte) U8Property.getVeeperState();
if (m_curReaderSetting.btBeeperMode == 0) {
return "0";
} else if (m_curReaderSetting.btBeeperMode == 1) {
return "1";
} else if (m_curReaderSetting.btBeeperMode == 2) {
return "2";
}
} else if (paraName.equals(TEMPERATURE)) {
// 这里暂时将符号位作为是否正确返回标志,协议中规定符号位只能为0x00,0x01,这里赋值为0x02
m_curReaderSetting.btPlusMinus = 0x02;
int result = mReader.getReaderTemperature(m_curReaderSetting.btReadId);
if (result == 0) {
synchronized (object) {
try {
if (!havenotify)
object.wait(timeout);
} catch (InterruptedException e) {
object.notify();
}
}
}
String strTemperature = "";
if (m_curReaderSetting.btPlusMinus == 0x00) {
strTemperature = "-" + String.valueOf(m_curReaderSetting.btTemperature & 0xFF) + "℃";
} else if (m_curReaderSetting.btPlusMinus == 0x01) {
strTemperature = String.valueOf(m_curReaderSetting.btTemperature & 0xFF) + "℃";
} else {// 接收异常
return receviceIncompleteError();
}
// 标志位复位
return strTemperature;
} else if (paraName.equals(SESSIONSTATE)) {
return U8Property.getSessionState() + "";
} else if (paraName.equals(FLAGSTATE)) {
return U8Property.getFlagState() + "";
}
return null;
}
/********************************************************/
private final BroadcastReceiver mRecv = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, Intent intent) {
if (intent.getAction().equals(ReaderHelper.BROADCAST_REFRESH_INVENTORY_REAL)) {
byte btCmd = intent.getByteExtra("cmd", (byte) 0x00);
switch (btCmd) {
case CMD.REAL_TIME_INVENTORY:
case CMD.CUSTOMIZED_SESSION_TARGET_INVENTORY:
try {
mResponseHandler.onSuccess(REFRESHTEXT, null, null);
} catch (Exception e) {
System.out.println(e.toString());
}
break;
case ReaderHelper.INVENTORY_END:
mTagMaps = m_curInventoryBuffer.lsTagList;
//mTagMaps = tools.bubbleSort(mTagMaps);
mResponseHandler.onSuccess(REFRESHLIST, mTagMaps, null);
break;
}
} else if (intent.getAction().equals(ReaderHelper.BROADCAST_WRITE_LOG)) {
}
// 读写锁杀页面
if (intent.getAction().equals(ReaderHelper.BROADCAST_REFRESH_OPERATE_TAG)) {
byte btCmd = intent.getByteExtra("cmd", (byte) 0x00);
byte type = intent.getByteExtra("type", (byte) 0x00);
final String msg = intent.getStringExtra("msg");
switch (btCmd) {
case CMD.GET_ACCESS_EPC_MATCH:
break;
case CMD.READ_TAG:
break;
case CMD.WRITE_TAG:
break;
case CMD.LOCK_TAG:
break;
case CMD.KILL_TAG:
break;
}
}
// 设置功率
if (intent.getAction().equals(ReaderHelper.BROADCAST_REFRESH_READER_SETTING)) {
byte btCmd = intent.getByteExtra("cmd", (byte) 0x00);
if (btCmd == CMD.GET_OUTPUT_POWER || btCmd == CMD.SET_OUTPUT_POWER) {
}
// 温度
if (btCmd == CMD.GET_READER_TEMPERATURE) {
}
}
}
};
@Override
public Message Inventory() {
startInventory(new IResponseHandler() {
@Override
public void onSuccess(String msg, Object data, byte[] parameters) {
if (msg.equalsIgnoreCase(REFRESHLIST)) {
List<InventoryTagMap> InventoryOnceResult = (List<InventoryTagMap>) data;
stopInventory();
synchronized (object) {
object.notifyAll();
}
}
}
@Override
public void onFailure(String msg) {
stopInventory();
synchronized (object) {
object.notifyAll();
}
}
});
synchronized (object) {
try {
object.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 打开串口
* @param moduleName 模块名
* @return
*/
@Override
public Message openSerialPort(String moduleName) {
DeviceModel deviceModel = new DeviceModel(mContext);
Device device = deviceModel.getDeviceFromModel(moduleName);
Message msg = new Message();
if (device == null) {
msg.setCode(1);
msg.setMessage(mContext.getResources().getString(R.string.lose_configurationfile));
return msg;
}
String serialPortPath = device.getSerialPort();
int baudRate = device.getBaudRate();
try {
if (android.os.Build.VERSION.RELEASE.equals(AndroidVersions.V_4_0_3)) {
try {
mSerialPort = new SerialPort(new File(serialPortPath), baudRate, 0);
} catch (SecurityException e1) {
e1.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e1.toString()));
return msg;
} catch (IOException e1) {
e1.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e1.toString()));
return msg;
}
} else if (android.os.Build.VERSION.RELEASE.equals(AndroidVersions.V_5_1_1)) {
try {
mSerialPort = new SerialPort(new File(serialPortPath), baudRate, 0);
} catch (SecurityException e1) {
e1.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e1.toString()));
return msg;
} catch (IOException e1) {
e1.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e1.toString()));
return msg;
}
} else {
Toast.makeText(mContext, "程序版本有误,请联系技术支持人员!", Toast.LENGTH_SHORT).show();
msg.setCode(1);
msg.setMessage(mContext.getResources().getString(R.string.version_exception));
return msg;
}
mReaderHelper = ReaderHelper.getDefaultHelper();
mReaderHelper.setReader(mSerialPort.getInputStream(), mSerialPort.getOutputStream());
mReader = mReaderHelper.getReader();
m_curReaderSetting = mReaderHelper.getCurReaderSetting();
m_curOperateTagBuffer = mReaderHelper.getCurOperateTagBuffer();
} catch (Exception e) {
e.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e.toString()));
return msg;
}
msg.setCode(0);
msg.setMessage(mContext.getResources().getString(R.string.u8_success));
return msg;
}
/**
* 关闭串口
* @return
*/
@Override
public Message closeSerialPort() {
Message msg = new Message();
if (mSerialPort != null) {
try {
mSerialPort.close();
msg.setCode(0);
msg.setMessage(mContext.getResources().getString(R.string.u8_success));
return msg;
} catch (Exception e) {
e.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e.toString()));
return msg;
}
}
msg.setCode(1);
msg.setMessage(mContext.getResources().getString(R.string.serialPort_not_open));
return msg;
}
/**
* 模块上电
* @param moduleName 模块名
* @return
*/
@Override
public Message modulePowerOn(String moduleName) {
Message msg = new Message();
DeviceModel deviceModel = new DeviceModel(mContext);
Device device = deviceModel.getDeviceFromModel(moduleName);
if (device != null) {
try {
device.powerOn();
msg.setCode(0);
msg.setMessage(mContext.getResources().getString(R.string.u8_success));
return msg;
} catch (Exception e) {
e.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e.toString()));
return msg;
}
} else {
}
msg.setCode(1);
msg.setMessage(mContext.getResources().getString(R.string.lose_configurationfile));
return msg;
}
/**
* 模块下电
* @param moduleName 模块名
* @return
*/
@Override
public Message modulePowerOff(String moduleName) {
Message msg = new Message();
DeviceModel deviceModel = new DeviceModel(mContext);
Device device = deviceModel.getDeviceFromModel(moduleName);
if (device != null) {
try {
device.powerOff();
msg.setCode(0);
msg.setMessage(mContext.getResources().getString(R.string.u8_success));
return msg;
} catch (Exception e) {
e.printStackTrace();
msg.setCode(1);
msg.setMessage(String.format(mContext.getResources().getString(R.string.exception_occurred), e.toString()));
return msg;
}
}
msg.setCode(1);
msg.setMessage(mContext.getResources().getString(R.string.lose_configurationfile));
return msg;
}
/**
* 标志位复位,包括:</br> havenotify :notify标志位</br> errorData :错误信息标志位</br>
* readDataString :读标签数据标志位</br> operationTagResult :写/锁/杀标签结果标志位</br>
* m_curReaderSetting.blnSetResult :设置结果标志位</br>
*/
private void flagReset() {
havenotify = false;
errorData = null;
readDataString = null;
operationTagResult = FAILED;
m_curReaderSetting.blnSetResult = false;
m_curReaderSetting.btAryOutputPower = null;
}
/**
* 设置匹配标签
*
* @param EPC
* 要绑定的EPC号(需要完整EPC,只绑定部分EPC时读写操作会返回无可操作标签错误),
* 需要解绑标签时此方法传进"Cancel".getBytes()即可
*
* @return 绑定/解绑结果:成功 :0, 失败:-1
*/
private int setEpcMatch(byte[] EPC) {
flagReset();
if (new String(EPC).equalsIgnoreCase("Cancel")) {
mReader.cancelAccessEpcMatch(m_curReaderSetting.btReadId);
// 发送指令后线程挂起 等待数据返回
synchronized (object) {
try {
object.wait(timeout);
} catch (InterruptedException e) {
Loger.disk_log("Exception", "setEpcMatchWaitException" + getExceptionAllinformation(e), "M10_U8");
mReaderHelper.notify();
}
}
Log.e("see", "m_curReaderSetting.blnSetResult ==>"+m_curReaderSetting.blnSetResult);
if(m_curReaderSetting.blnSetResult)
return SUCCEED;
else {
return FAILED;
}
} else {
byte[] btAryEpc = EPC;
mReader.setAccessEpcMatch(m_curReaderSetting.btReadId, (byte) (btAryEpc.length & 0xFF), btAryEpc);
// 发送指令后线程挂起 等待数据返回
synchronized (object) {
try {
object.wait(timeout);
} catch (InterruptedException e) {
Loger.disk_log("Exception", "setEpcMatchWaitException" + getExceptionAllinformation(e), "M10_U8");
mReaderHelper.notify();
}
}
if(m_curReaderSetting.blnSetResult)
return SUCCEED;
else {
return FAILED;
}
}
}
/**
* 初始化盘询所需资源
*
* @throws Exception
*/
private void initInventoryParam() throws Exception {
mReaderHelper = ReaderHelper.getDefaultHelper();
mReader = mReaderHelper.getReader();
m_curInventoryBuffer = mReaderHelper.getCurInventoryBuffer();
m_curOperateTagBuffer = mReaderHelper.getCurOperateTagBuffer();
if (mReader != null) {
if (!mReader.IsAlive())
mReader.StartWait();
}
}
/**
* 若配置文件丟失,跳转到配置工具
*/
private void jumpToConfigurationTool() {
Intent intent = new Intent();
intent.putExtra("modelName", model);
intent.putExtra("packageName", packageName);
intent.putExtra("activityName", activityName);
intent.setClass(mContext, SetAndSaveActivity.class);
mContext.startActivity(intent);
}
/**
* 注册广播接收器
*/
private static void registerReceiver() {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(mContext);
IntentFilter itent = new IntentFilter();
itent.addAction(ReaderHelper.BROADCAST_REFRESH_INVENTORY_REAL);
lbm.registerReceiver(mUSeries.mRecv, itent);
}
/**
* 获取全部异常信息.
*
* @param ex
* 异常
* @return
*/
private static String getExceptionAllinformation(Exception ex) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(out);
ex.printStackTrace(pout);
String ret = new String(out.toByteArray());
pout.close();
try {
out.close();
} catch (Exception e) {
e.printStackTrace();
}
return ret;
}
private String receviceIncompleteError() {
mReader.resetRecevice();
return ERROR.RECEVICE_INCOMPLETE;
}
}
package com.fn.useries.reader;
public class CMD {
public final static byte RESET = 0x70;
public final static byte SET_UART_BAUDRATE = 0x71;
public final static byte GET_FIRMWARE_VERSION = 0x72;
public final static byte SET_READER_ADDRESS = 0x73;
public final static byte SET_WORK_ANTENNA = 0x74;
public final static byte GET_WORK_ANTENNA = 0x75;
public final static byte SET_OUTPUT_POWER = 0x76;
public final static byte GET_OUTPUT_POWER = 0x77;
public final static byte SET_FREQUENCY_REGION = 0x78;
public final static byte GET_FREQUENCY_REGION = 0x79;
public final static byte SET_BEEPER_MODE = 0x7A;
public final static byte GET_READER_TEMPERATURE = 0x7B;
public final static byte READ_GPIO_VALUE = 0x60;
public final static byte WRITE_GPIO_VALUE = 0x61;
public final static byte SET_ANT_CONNECTION_DETECTOR = 0x62;
public final static byte GET_ANT_CONNECTION_DETECTOR = 0x63;
public final static byte SET_TEMPORARY_OUTPUT_POWER = 0x66;
public final static byte SET_READER_IDENTIFIER = 0x67;
public final static byte GET_READER_IDENTIFIER = 0x68;
public final static byte SET_RF_LINK_PROFILE = 0x69;
public final static byte GET_RF_LINK_PROFILE = 0x6A;
public final static byte GET_RF_PORT_RETURN_LOSS = 0x7E;
public final static byte INVENTORY = (byte) 0x80;
public final static byte READ_TAG = (byte) 0x81;
public final static byte WRITE_TAG = (byte) 0x82;
public final static byte LOCK_TAG = (byte) 0x83;
public final static byte KILL_TAG = (byte) 0x84;
public final static byte SET_ACCESS_EPC_MATCH = (byte) 0x85;
public final static byte GET_ACCESS_EPC_MATCH = (byte) 0x86;
public final static byte REAL_TIME_INVENTORY = (byte) 0x89;
public final static byte FAST_SWITCH_ANT_INVENTORY = (byte) 0x8A;
public final static byte CUSTOMIZED_SESSION_TARGET_INVENTORY = (byte) 0x8B;
public final static byte SET_IMPINJ_FAST_TID = (byte) 0x8C;
public final static byte SET_AND_SAVE_IMPINJ_FAST_TID = (byte) 0x8D;
public final static byte GET_IMPINJ_FAST_TID = (byte) 0x8E;
public final static byte ISO18000_6B_INVENTORY = (byte) 0xB0;
public final static byte ISO18000_6B_READ_TAG = (byte) 0xB1;
public final static byte ISO18000_6B_WRITE_TAG = (byte) 0xB2;
public final static byte ISO18000_6B_LOCK_TAG = (byte) 0xB3;
public final static byte ISO18000_6B_QUERY_LOCK_TAG = (byte) 0xB4;
public final static byte GET_INVENTORY_BUFFER = (byte) 0x90;
public final static byte GET_AND_RESET_INVENTORY_BUFFER = (byte) 0x91;
public final static byte GET_INVENTORY_BUFFER_TAG_COUNT = (byte) 0x92;
public final static byte RESET_INVENTORY_BUFFER = (byte) 0x93;
public static String format(byte btCmd)
{
String strCmd = "";
switch (btCmd)
{
case RESET:
strCmd = "复位读写器";
break;
case SET_UART_BAUDRATE:
strCmd = "设置串口通讯波特率";
break;
case GET_FIRMWARE_VERSION:
strCmd = "读取读写器固件版本";
break;
case SET_READER_ADDRESS:
strCmd = "设置读写器地址";
break;
case SET_WORK_ANTENNA:
strCmd = "设置读写器工作天线";
break;
case GET_WORK_ANTENNA:
strCmd = "查询当前天线工作天线";
break;
case SET_OUTPUT_POWER:
strCmd = "设置读写器射频输出功率";
break;
case GET_OUTPUT_POWER:
strCmd = "查询读写器当前输出功率";
break;
case SET_FREQUENCY_REGION:
strCmd = "设置读写器工作频率范围";
break;
case GET_FREQUENCY_REGION:
strCmd = "查询读写器工作频率范围";
break;
case SET_BEEPER_MODE:
strCmd = "设置蜂鸣器状态";
break;
case GET_READER_TEMPERATURE:
strCmd = "查询当前设备的工作温度";
break;
case READ_GPIO_VALUE:
strCmd = "读取GPIO电平";
break;
case WRITE_GPIO_VALUE:
strCmd = "设置GPIO电平";
break;
case SET_ANT_CONNECTION_DETECTOR:
strCmd = "设置天线连接检测器状态";
break;
case GET_ANT_CONNECTION_DETECTOR:
strCmd = "读取天线连接检测器状态";
break;
case SET_TEMPORARY_OUTPUT_POWER:
strCmd = "设置读写器临时射频输出功率";
break;
case SET_READER_IDENTIFIER:
strCmd = "设置读写器识别码";
break;
case GET_READER_IDENTIFIER:
strCmd = "读取读写器识别码";
break;
case SET_RF_LINK_PROFILE:
strCmd = "设置射频链路的通讯速率";
break;
case GET_RF_LINK_PROFILE:
strCmd = "读取射频链路的通讯速率";
break;
case GET_RF_PORT_RETURN_LOSS:
strCmd = "测量天线端口的回波损耗";
break;
case INVENTORY:
strCmd = "盘存标签";
break;
case READ_TAG:
strCmd = "读标签";
break;
case WRITE_TAG:
strCmd = "写标签";
break;
case LOCK_TAG:
strCmd = "锁定标签";
break;
case KILL_TAG:
strCmd = "灭活标签";
break;
case SET_ACCESS_EPC_MATCH:
strCmd = "匹配ACCESS操作的EPC号";
break;
case GET_ACCESS_EPC_MATCH:
strCmd = "查询匹配的EPC状态";
break;
case REAL_TIME_INVENTORY:
strCmd = "盘存标签(实时上传标签数据)";
break;
case FAST_SWITCH_ANT_INVENTORY:
strCmd = "快速轮询多个天线盘存标签";
break;
case CUSTOMIZED_SESSION_TARGET_INVENTORY:
strCmd = "自定义session和target盘存";
break;
case SET_IMPINJ_FAST_TID:
strCmd = "设置Monza标签快速读TID(不保存)";
break;
case SET_AND_SAVE_IMPINJ_FAST_TID:
strCmd = "设置Monza标签快速读TID(保存)";
break;
case GET_IMPINJ_FAST_TID:
strCmd = "查询当前的快速TID设置";
break;
case ISO18000_6B_INVENTORY:
strCmd = "盘询18000-6B标签";
break;
case ISO18000_6B_READ_TAG:
strCmd = "读18000-6B标签";
break;
case ISO18000_6B_WRITE_TAG:
strCmd = "写18000-6B标签";
break;
case ISO18000_6B_LOCK_TAG:
strCmd = "锁18000-6B标签";
break;
case ISO18000_6B_QUERY_LOCK_TAG:
strCmd = "匹配18000-6B标签";
break;
case GET_INVENTORY_BUFFER:
strCmd = "提取标签数据保留缓存备份";
break;
case GET_AND_RESET_INVENTORY_BUFFER:
strCmd = "提取标签数据并删除缓存";
break;
case GET_INVENTORY_BUFFER_TAG_COUNT:
strCmd = "查询缓存中已读标签个数";
break;
case RESET_INVENTORY_BUFFER:
strCmd = "清空标签数据缓存";
break;
default:
strCmd = "未知操作";
break;
}
return strCmd;
}
}
package com.fn.useries.reader;
public class Converter {
public static final int LITTLE_ENDIAN = 0;
public static final int BIG_ENDIAN = 1;
public static byte[] getBytes(int number, int order) {
int temp = number;
byte[] b = new byte[4];
if (order == LITTLE_ENDIAN) {
for (int i = b.length - 1; i >= 0; i--) {
b[i] = new Long(temp & 0xff).byteValue();
temp = temp >> 8;
}
} else {
for (int i = 0; i < b.length; i++) {
b[i] = new Long(temp & 0xff).byteValue();
temp = temp >> 8;
}
}
return b;
}
public static byte[] getBytes(long number, int order) {
long temp = number;
byte[] b = new byte[8];
if (order == LITTLE_ENDIAN) {
for (int i = b.length - 1; i >= 0; i--) {
b[i] = new Long(temp & 0xff).byteValue();
temp = temp >> 8;
}
} else {
for (int i = 0; i < b.length; i++) {
b[i] = new Long(temp & 0xff).byteValue();
temp = temp >> 8;
}
}
return b;
}
public static byte[] getBytes(short number, int order) {
int temp = number;
byte[] b = new byte[8];
if (order == LITTLE_ENDIAN) {
for (int i = b.length - 1; i >= 0; i--) {
b[i] = new Long(temp & 0xff).byteValue();
temp = temp >> 8;
}
} else {
for (int i = 0; i < b.length; i++) {
b[i] = new Long(temp & 0xff).byteValue();
temp = temp >> 8;
}
}
return b;
}
public static long byteToLong(byte[] b, int order) {
long s = 0;
long s0 = b[0] & 0xff;// 最低位
long s1 = b[1] & 0xff;
long s2 = b[2] & 0xff;
long s3 = b[3] & 0xff;
long s4 = b[4] & 0xff;// 最低位
long s5 = b[5] & 0xff;
long s6 = b[6] & 0xff;
long s7 = b[7] & 0xff;
if (order == LITTLE_ENDIAN) {
s1 <<= 8 * 1;
s2 <<= 8 * 2;
s3 <<= 8 * 3;
s4 <<= 8 * 4;
s5 <<= 8 * 5;
s6 <<= 8 * 6;
s7 <<= 8 * 7;
} else {
s0 <<= 8 * 7;
s1 <<= 8 * 6;
s2 <<= 8 * 5;
s3 <<= 8 * 4;
s4 <<= 8 * 3;
s5 <<= 8 * 2;
s6 <<= 8 * 1;
}
s = s0 | s1 | s2 | s3 | s4 | s5 | s6 | s7;
return s;
}
public static int byteToInt(byte[] b, int order) {
int s = 0;
int s0 = b[0] & 0xff;// 最低位
int s1 = b[1] & 0xff;
int s2 = b[2] & 0xff;
int s3 = b[3] & 0xff;
if (order == LITTLE_ENDIAN) {
s2 <<= 8;
s1 <<= 16;
s0 <<= 24;
} else {
s3 <<= 24;
s2 <<= 16;
s1 <<= 8;
}
s = s0 | s1 | s2 | s3;
return s;
}
public static short byteToShort(byte[] b, int order) {
short s = 0;
short s0 = (short) (b[0] & 0xff);// 最低位
short s1 = (short) (b[1] & 0xff);
if (order == LITTLE_ENDIAN) {
s0 <<= 8;
s = (short) (s0 | s1);
} else {
s1 <<= 8;
s = (short) (s0 | s1);
}
return s;
}
}
package com.fn.useries.reader;
public class ERROR {
public final static byte SUCCESS = 0x10;
public final static byte FAIL = 0x11;
public final static byte MCU_RESET_ERROR = 0x20;
public final static byte CW_ON_ERROR = 0x21;
public final static byte ANTENNA_MISSING_ERROR = 0x22;
public final static byte WRITE_FLASH_ERROR = 0x23;
public final static byte READ_FLASH_ERROR = 0x24;
public final static byte SET_OUTPUT_POWER_ERROR = 0x25;
public final static byte TAG_INVENTORY_ERROR = 0x31;
public final static byte TAG_READ_ERROR = 0x32;
public final static byte TAG_WRITE_ERROR = 0x33;
public final static byte TAG_LOCK_ERROR = 0x34;
public final static byte TAG_KILL_ERROR = 0x35;
public final static byte NO_TAG_ERROR = 0x36;
public final static byte INVENTORY_OK_BUT_ACCESS_FAIL = 0x37;
public final static byte BUFFER_IS_EMPTY_ERROR = 0x38;
public final static byte ACCESS_OR_PASSWORD_ERROR = 0x40;
public final static byte PARAMETER_INVALID = 0x41;
public final static byte PARAMETER_INVALID_WORDCNT_TOO_LONG = 0x42;
public final static byte PARAMETER_INVALID_MEMBANK_OUT_OF_RANGE = 0x43;
public final static byte PARAMETER_INVALID_LOCK_REGION_OUT_OF_RANGE = 0x44;
public final static byte PARAMETER_INVALID_LOCK_ACTION_OUT_OF_RANGE = 0x45;
public final static byte PARAMETER_READER_ADDRESS_INVALID = 0x46;
public final static byte PARAMETER_INVALID_ANTENNA_ID_OUT_OF_RANGE = 0x47;
public final static byte PARAMETER_INVALID_OUTPUT_POWER_OUT_OF_RANGE = 0x48;
public final static byte PARAMETER_INVALID_FREQUENCY_REGION_OUT_OF_RANGE = 0x49;
public final static byte PARAMETER_INVALID_BAUDRATE_OUT_OF_RANGE = 0x4A;
public final static byte PARAMETER_BEEPER_MODE_OUT_OF_RANGE = 0x4B;
public final static byte PARAMETER_EPC_MATCH_LEN_TOO_LONG = 0x4C;
public final static byte PARAMETER_EPC_MATCH_LEN_ERROR = 0x4D;
public final static byte PARAMETER_INVALID_EPC_MATCH_MODE = 0x4E;
public final static byte PARAMETER_INVALID_FREQUENCY_RANGE = 0x4F;
public final static byte FAIL_TO_GET_RN16_FROM_TAG = 0x50;
public final static byte PARAMETER_INVALID_DRM_MODE = 0x51;
public final static byte PLL_LOCK_FAIL = 0x52;
public final static byte RF_CHIP_FAIL_TO_RESPONSE = 0x53;
public final static byte FAIL_TO_ACHIEVE_DESIRED_OUTPUT_POWER = 0x54;
public final static byte COPYRIGHT_AUTHENTICATION_FAIL = 0x55;
public final static byte SPECTRUM_REGULATION_ERROR = 0x56;
public final static byte OUTPUT_POWER_TOO_LOW = 0x57;
/**
* 自定义错误: 未接受完整错误
*/
public final static String RECEVICE_INCOMPLETE = "接收数据异常";
/**
* 自定义错误: EPC绑定/解绑失败
*/
public final static String EPC_MATCH_ERROR = "EPC绑定/解绑失败";
/**
* 根据错误代码获取错误类型
* @param btErrorCode 错误代码(1 byte)
* @return 错误类型说明
*/
public static String format(byte btErrorCode)
{
String strErrorCode = "";
switch (btErrorCode)
{
case SUCCESS:
strErrorCode = "命令成功完成";
break;
case FAIL:
strErrorCode = "命令执行失败";//
break;
case MCU_RESET_ERROR:
strErrorCode = "CPU 复位错误";//
break;
case CW_ON_ERROR:
strErrorCode = "打开CW 错误";//
break;
case ANTENNA_MISSING_ERROR:
strErrorCode = "天线未连接";//
break;
case WRITE_FLASH_ERROR:
strErrorCode = "写Flash 错误";//
break;
case READ_FLASH_ERROR:
strErrorCode = "读Flash 错误";//
break;
case SET_OUTPUT_POWER_ERROR:
strErrorCode = "设置发射功率错误";//
break;
case TAG_INVENTORY_ERROR:
strErrorCode = "盘存标签错误";//
break;
case TAG_READ_ERROR:
strErrorCode = "读标签错误";//
break;
case TAG_WRITE_ERROR:
strErrorCode = "写标签错误";//
break;
case TAG_LOCK_ERROR:
strErrorCode = "锁定标签错误";//
break;
case TAG_KILL_ERROR:
strErrorCode = "灭活标签错误";//
break;
case NO_TAG_ERROR:
strErrorCode = "无可操作标签错误";//
break;
case INVENTORY_OK_BUT_ACCESS_FAIL:
strErrorCode = "成功盘存但访问失败";//
break;
case BUFFER_IS_EMPTY_ERROR:
strErrorCode = "缓存为空";//
break;
case ACCESS_OR_PASSWORD_ERROR:
strErrorCode = "访问标签错误或访问密码错误";//
break;
case PARAMETER_INVALID:
strErrorCode = "无效的参数";//
break;
case PARAMETER_INVALID_WORDCNT_TOO_LONG:
strErrorCode = "wordCnt 参数超过规定长度";//
break;
case PARAMETER_INVALID_MEMBANK_OUT_OF_RANGE:
strErrorCode = "MemBank 参数超出范围";//
break;
case PARAMETER_INVALID_LOCK_REGION_OUT_OF_RANGE:
strErrorCode = "Lock 数据区参数超出范围";//
break;
case PARAMETER_INVALID_LOCK_ACTION_OUT_OF_RANGE:
strErrorCode = "LockType 参数超出范围";//
break;
case PARAMETER_READER_ADDRESS_INVALID:
strErrorCode = "读写器地址无效";//
break;
case PARAMETER_INVALID_ANTENNA_ID_OUT_OF_RANGE:
strErrorCode = "Antenna_id 超出范围";//
break;
case PARAMETER_INVALID_OUTPUT_POWER_OUT_OF_RANGE:
strErrorCode = "输出功率参数超出范围";//
break;
case PARAMETER_INVALID_FREQUENCY_REGION_OUT_OF_RANGE:
strErrorCode = "射频规范区域参数超出范围";//
break;
case PARAMETER_INVALID_BAUDRATE_OUT_OF_RANGE:
strErrorCode = "波特率参数超出范围";//
break;
case PARAMETER_BEEPER_MODE_OUT_OF_RANGE:
strErrorCode = "蜂鸣器设置参数超出范围";//
break;
case PARAMETER_EPC_MATCH_LEN_TOO_LONG:
strErrorCode = "EPC 匹配长度越界";//
break;
case PARAMETER_EPC_MATCH_LEN_ERROR:
strErrorCode = "EPC 匹配长度错误";//
break;
case PARAMETER_INVALID_EPC_MATCH_MODE:
strErrorCode = "EPC 匹配参数超出范围";//
break;
case PARAMETER_INVALID_FREQUENCY_RANGE:
strErrorCode = "频率范围设置参数错误";//
break;
case FAIL_TO_GET_RN16_FROM_TAG:
strErrorCode = "无法接收标签的RN16";//
break;
case PARAMETER_INVALID_DRM_MODE:
strErrorCode = "DRM 设置参数错误";//
break;
case PLL_LOCK_FAIL:
strErrorCode = "PLL 不能锁定";//
break;
case RF_CHIP_FAIL_TO_RESPONSE:
strErrorCode = "射频芯片无响应";//
break;
case FAIL_TO_ACHIEVE_DESIRED_OUTPUT_POWER:
strErrorCode = "输出达不到指定的输出功率";//
break;
case COPYRIGHT_AUTHENTICATION_FAIL:
strErrorCode = "版权认证未通过";//
break;
case SPECTRUM_REGULATION_ERROR:
strErrorCode = "频谱规范设置错误";//
break;
case OUTPUT_POWER_TOO_LOW:
strErrorCode = "输出功率过低";//
break;
default:
strErrorCode = "未知错误";//
break;
}
return strErrorCode;
}
}
package com.fn.useries.reader;
public class HEAD {
public final static byte HEAD = (byte) 0xA0;
}
package com.fn.useries.reader;
public class MessageTran {
private byte btPacketType; //数据包头,默认为0xA0
private byte btDataLen; //数据包长度,数据包从‘长度’字节后面开始的字节数,不包含‘长度’字节本身
private byte btReadId; //读写器地址
private byte btCmd; //数据包命令代码
private byte[] btAryData; //数据包命令参数,部分命令无参数
private byte btCheck; //校验和,除校验和本身外所有字节的校验和
private byte[] btAryTranData; //完整数据包
public MessageTran() {
}
public MessageTran(byte btReadId, byte btCmd, byte[] btAryData) {
int nLen = btAryData.length;
this.btPacketType = HEAD.HEAD;
this.btDataLen = (byte)(nLen + 3);
this.btReadId = btReadId;
this.btCmd = btCmd;
this.btAryData = new byte[nLen];
System.arraycopy(btAryData, 0, this.btAryData, 0, btAryData.length);
//btAryData.CopyTo(this.btAryData, 0);
this.btAryTranData = new byte[nLen + 5];
this.btAryTranData[0] = this.btPacketType;
this.btAryTranData[1] = this.btDataLen;
this.btAryTranData[2] = this.btReadId;
this.btAryTranData[3] = this.btCmd;
System.arraycopy(this.btAryData, 0, this.btAryTranData, 4, this.btAryData.length);
//this.btAryData.CopyTo(this.btAryTranData, 4);
this.btCheck = checkSum(this.btAryTranData, 0, nLen + 4);
this.btAryTranData[nLen + 4] = this.btCheck;
}
public MessageTran(byte btReadId, byte btCmd) {
this.btPacketType = HEAD.HEAD;
this.btDataLen = 0x03;
this.btReadId = btReadId;
this.btCmd = btCmd;
this.btAryTranData = new byte[5];
this.btAryTranData[0] = this.btPacketType;
this.btAryTranData[1] = this.btDataLen;
this.btAryTranData[2] = this.btReadId;
this.btAryTranData[3] = this.btCmd;
this.btCheck = checkSum(this.btAryTranData, 0, 4);
this.btAryTranData[4] = this.btCheck;
}
public MessageTran(byte[] btAryTranData) {
int nLen = btAryTranData.length;
this.btAryTranData = new byte[nLen];
System.arraycopy(btAryTranData, 0, this.btAryTranData, 0, btAryTranData.length);
//btAryTranData.CopyTo(this.btAryTranData, 0);
byte btCK = checkSum(this.btAryTranData, 0, this.btAryTranData.length - 1);
if (btCK != btAryTranData[nLen - 1]) {
return;
}
this.btPacketType = btAryTranData[0];
this.btDataLen = btAryTranData[1];
this.btReadId = btAryTranData[2];
this.btCmd = btAryTranData[3];
this.btCheck = btAryTranData[nLen - 1];
if (nLen > 5) {
this.btAryData = new byte[nLen - 5];
for (int nloop = 0; nloop < nLen - 5; nloop++ ) {
this.btAryData[nloop] = btAryTranData[4 + nloop];
}
}
}
//设置属性
/**
* 获取完整数据包。
* @return 数据包
*/
public byte[] getAryTranData() {
return this.btAryTranData;
}
/**
* 获取数据包命令参数,部分命令无参数。
* @return 命令参数
*/
public byte[] getAryData() {
return this.btAryData;
}
/**
* 获取读写器地址。
* @return 读写器地址
*/
public byte getReadId() {
return this.btReadId;
}
/**
* 获取数据包命令字。
* @return 命令字
*/
public byte getCmd() {
return this.btCmd;
}
/**
* 获取数据包头,默认为0xA0。
* @return 数据包头
*/
public byte getPacketType() {
return this.btPacketType;
}
/**
* 校验包头。
* @return 校验结果
*/
public boolean checkPacketType() {
return this.btPacketType == HEAD.HEAD;
}
/**
* 计算校验和
* @param btAryBuffer 数据
* @param nStartPos 起始位置
* @param nLen 校验长度
* @return 校验和
*/
public byte checkSum(byte[] btAryBuffer, int nStartPos, int nLen) {
byte btSum = 0x00;
for (int nloop = nStartPos; nloop < nStartPos + nLen; nloop++ ) {
btSum += btAryBuffer[nloop];
}
return (byte)(((~btSum) + 1) & 0xFF);
}
}
package com.fn.useries.reader.model;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class ISO180006BOperateTagBuffer {
public static class ISO180006BOperateTagMap {
public byte btAntId;
public String strUID;
public int nTotal;
public byte btStartAdd;
public int nLength;
public String strData;
public byte btStatus;
public ISO180006BOperateTagMap() {
btAntId = 0;
strUID = "";
nTotal = 0;
btStartAdd = 0;
nLength = 0;
strData = "";
btStatus = 0;
}
}
public Map<String, Integer> dtIndexMap;
public List<ISO180006BOperateTagMap> lsTagList;
public byte btAntId;
public int nTagCount;
public String strReadData;
public byte btWriteLength;
public byte btStatus;
public ISO180006BOperateTagBuffer() {
btAntId = (byte) 0xFF;
nTagCount = 0;
strReadData = "";
btWriteLength = 0x00;
btStatus = 0x00;
dtIndexMap = new LinkedHashMap<String, Integer>();
lsTagList = new ArrayList<ISO180006BOperateTagMap>();
}
public void clearBuffer() {
btAntId = (byte) 0xFF;
nTagCount = 0;
strReadData = "";
btWriteLength = 0x00;
btStatus = 0x00;
clearTagMap();
}
public final void clearTagMap() {
dtIndexMap.clear();
lsTagList.clear();
}
}
package com.fn.useries.reader.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
public class InventoryBuffer implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public static class InventoryTagMap {
public String strPC;
public String strCRC;
public String strEPC;
public byte btAntId;
public String strRSSI;
public int nReadCount;
public String strFreq;
public int nAnt1;
public int nAnt2;
public int nAnt3;
public int nAnt4;
public InventoryTagMap() {
strPC = "";
strCRC = "";
strEPC = "";
btAntId = 0;
strRSSI = "";
nReadCount = 0;
strFreq = "";
nAnt1 = 0;
nAnt2 = 0;
nAnt3 = 0;
nAnt4 = 0;
}
}
public byte btRepeat;
public byte btSession;
public byte btTarget;
public byte btA, btB, btC, btD;
public byte btStayA, btStayB, btStayC, btStayD;
public byte btInterval;
public byte btFastRepeat;
public ArrayList<Byte> lAntenna;
public boolean bLoopInventory;
public int nIndexAntenna;
public int nCommond;
public boolean bLoopInventoryReal;
public boolean bLoopCustomizedSession;
public int nTagCount;
public int nDataCount; //执行一次命令所返回的标签记录条数
public int nCommandDuration;
public int nReadRate;
public int nCurrentAnt;
public int nTotalRead;
public Date dtStartInventory;
public Date dtEndInventory;
public int nMaxRSSI;
public int nMinRSSI;
public Map<String, Integer> dtIndexMap;
public List<InventoryTagMap> lsTagList;
public InventoryBuffer() {
btRepeat = 0x00;
btFastRepeat = 0x00;
/** 大于3表示不轮询*/
btA = btB = btC = btD = (byte) 0xFF;
btStayA = btStayB = btStayC = btStayD = 0x01;
lAntenna = new ArrayList<Byte>();
bLoopInventory = false;
nIndexAntenna = 0;
nCommond = 0;
bLoopInventoryReal = false;
nTagCount = 0;
nReadRate = 0;
nTotalRead = 0;
dtStartInventory = new Date();
dtEndInventory = dtStartInventory;
nMaxRSSI = 0;
nMinRSSI = 0;
dtIndexMap = new LinkedHashMap<String, Integer>();
lsTagList = new ArrayList<InventoryTagMap>();
}
public final void clearInventoryPar() {
btRepeat = 0x00;
lAntenna.clear();
//bLoopInventory = false;
nIndexAntenna = 0;
nCommond = 0;
bLoopInventoryReal = false;
}
public final void clearInventoryResult() {
nTagCount = 0;
nReadRate = 0;
nTotalRead = 0;
dtStartInventory = new Date();
dtEndInventory = dtStartInventory;
nMaxRSSI = 0;
nMinRSSI = 0;
clearTagMap();
}
public final void clearInventoryRealResult() {
nTagCount = 0;
nReadRate = 0;
nTotalRead = 0;
dtStartInventory = new Date();
dtEndInventory = dtStartInventory;
nMaxRSSI = 0;
nMinRSSI = 0;
clearTagMap();
}
public final void clearTagMap() {
dtIndexMap.clear();
lsTagList.clear();
}
}
package com.fn.useries.reader.model;
import java.util.ArrayList;
import java.util.List;
public class OperateTagBuffer {
public static class OperateTagMap {
public String strPC;
public String strCRC;
public String strEPC;
public String strData;
public int nDataLen;
public byte btAntId;
public int nReadCount;
public OperateTagMap() {
strPC = "";
strCRC = "";
strEPC = "";
strData = "";
nDataLen = 0;
btAntId = 0;
nReadCount = 0;
}
}
public String strAccessEpcMatch;
public List<OperateTagMap> lsTagList;
public OperateTagBuffer() {
strAccessEpcMatch = "";
lsTagList = new ArrayList<OperateTagMap>();
}
public final void clearBuffer() {
lsTagList.clear();
}
}
package com.fn.useries.reader.model;
public class ReaderSetting {
public byte btReadId;
public byte btMajor;
public byte btMinor;
public byte btIndexBaudrate;
public byte btPlusMinus;
public byte btTemperature;
/**1-4字节*/
public byte []btAryOutputPower;
public byte btWorkAntenna;
public byte btDrmMode;
public byte btRegion;
public byte btFrequencyStart;
public byte btFrequencyEnd;
public byte btBeeperMode;
public byte btGpio1Value;
public byte btGpio2Value;
public byte btGpio3Value;
public byte btGpio4Value;
public byte btAntDetector;
public byte btMonzaStatus;
public boolean blnMonzaStore;
/**固定12字节*/
public byte []btAryReaderIdentifier;
public byte btReturnLoss;
public byte btImpedanceFrequency;
public int nUserDefineStartFrequency;
public byte btUserDefineFrequencyInterval;
public byte btUserDefineChannelQuantity;
public byte btRfLinkProfile;
public boolean blnSetResult;
public String strErrorCode;
public ReaderSetting() {
btReadId = (byte) 0xFF;
btMajor = 0x00;
btMinor = 0x00;
btIndexBaudrate = 0x00;
btPlusMinus = 0x00;
btTemperature = 0x00;
btAryOutputPower = null;
btWorkAntenna = 0x00;
btDrmMode = 0x00;
btRegion = 0x00;
btFrequencyStart = 0x00;
btFrequencyEnd = 0x00;
btBeeperMode = 0x00;
blnMonzaStore = false;
btGpio1Value = 0x00;
btGpio2Value = 0x00;
btGpio3Value = 0x00;
btGpio4Value = 0x00;
btAntDetector = 0x00;
btMonzaStatus = 0x00;
btAryReaderIdentifier = new byte[12];
btReturnLoss = 0x00;
btImpedanceFrequency = 0x00;
nUserDefineStartFrequency = 0x00;
btUserDefineFrequencyInterval = 0x00;
btUserDefineChannelQuantity = 0x00;
btRfLinkProfile = 0x00;
}
}
/**
* 文件名 :ReaderMethod.java
* CopyRright (c) 2008-xxxx:
* 文件编号:2014-03-12_001
* 创建人:Jie Zhu
* 日期:2014/03/12
* 修改人:Jie Zhu
* 日期:2014/03/12
* 描述:初始版本
* 版本:1.0.0
*/
package com.fn.useries.reader.server;
import android.util.Log;
import com.fn.useries.reader.CMD;
import com.fn.useries.reader.HEAD;
import com.fn.useries.reader.MessageTran;
import com.fn.useries.utils.StringTool;
import com.fn.useries.utils.Tools;
import com.fntech.Loger;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
public abstract class ReaderBase {
private WaitThread mWaitThread = null;
private InputStream mInStream = null;
private OutputStream mOutStream = null;
/**
* 连接丢失。
*/
public abstract void onLostConnect();
/**
* 可重写函数,解析到一包数据后会调用此函数。
*
* @param msgTran
* 解析到的包
*/
public abstract void analyData(MessageTran msgTran);
// 记录未处理的接收数据,主要考虑接收数据分段
private byte[] m_btAryBuffer = new byte[4096];
// 记录未处理数据的有效长度
private int m_nLength = 0;
/**
* 带参构造函数,构造一个带输入、输出流的Reader。
*
* @param in
* 输入流
* @param out
* 输出流
*/
public ReaderBase(InputStream in, OutputStream out) {
this.mInStream = in;
this.mOutStream = out;
StartWait();
}
public boolean IsAlive() {
return mWaitThread != null && mWaitThread.isAlive();
}
public void StartWait() {
mWaitThread = new WaitThread();
mWaitThread.start();
}
/**
* 循环接收数据线程
*
* @author Jie
*/
private class WaitThread extends Thread {
private boolean mShouldRunning = true;
private int len_have = 0;
public WaitThread() {
mShouldRunning = true;
}
@Override
public void run() {
byte[] btAryBuffer = new byte[4096];
//byte[] buff = new byte[512];
byte[] buff = new byte[4096];
while (mShouldRunning) {
try {
Log.i("yourTag", "start Read");
Loger.disk_log("Read", "start Read", "U8");
int nLenRead = mInStream.read(buff);
Loger.disk_log("Read Count", "nLenRead == "+nLenRead, "U8");
if (nLenRead <= 0) {
continue;
}
Log.i("yourTag", "串口原始返回 ===>" + Tools.Bytes2HexString(buff, nLenRead));
Loger.disk_log("Read", "串口原始返回 ===>" + Tools.Bytes2HexString(buff, nLenRead), "U8");
if (nLenRead > 0) {
System.arraycopy(buff, 0, btAryBuffer, len_have, nLenRead);
len_have += nLenRead;
while (true) {
if (len_have == 1) {
len_have = 0;
break;
} else if (len_have > 1 && btAryBuffer[0] == (byte) 0xA0) {
if (len_have - 2 == btAryBuffer[1]) {
byte[] btAryReceiveData = new byte[btAryBuffer[1] + 2];
System.arraycopy(btAryBuffer, 0, btAryReceiveData, 0, btAryBuffer[1] + 2);
runReceiveDataCallback(btAryReceiveData);
len_have = 0;
break;
} else if (len_have - 2 > btAryBuffer[1]) {
byte[] btAryReceiveData = new byte[btAryBuffer[1] + 2];
System.arraycopy(btAryBuffer, 0, btAryReceiveData, 0, btAryBuffer[1] + 2);
runReceiveDataCallback(btAryReceiveData);
len_have = len_have - (btAryBuffer[1] + 2);
System.arraycopy(btAryBuffer, btAryBuffer[1] + 2, btAryBuffer, 0, len_have);
continue;
} else if (len_have - 2 < btAryBuffer[1])// 不足
{
break;
}
} else {
Log.e("toolsdebug", "异常情况!协议头错误");
Loger.disk_log("Read", "异常情况!协议头错误", "M10_U8");
/*btAryBuffer = new byte[4096];
buff = new byte[512];*/
len_have = 0;
break;
}
}// while
// Loger.disk_log("Read",
// StringTool.byteArrayToString(buff, 0, nLenRead),
// "M10_U8");
}
} catch (Exception e) {
Log.e("toolsdebug", "读错误");
Loger.disk_log("读错误", "e=" + e.toString() + "\r\n" + e.getStackTrace(), "M10_U8");
onLostConnect();
return;
}
}// while
}
public void signOut() {
mShouldRunning = false;
interrupt();
}
public void reset() {
len_have = 0;
}
};
/**
* 退出接收线程。
*/
public final void signOut() {
mWaitThread.signOut();
try {
mInStream.close();
mOutStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 清空串口接收缓存中的数据,防止异常情况发生
*/
public void resetRecevice() {
mWaitThread.reset();
}
/**
* 从输入流读取数据后,会调用此函数。
*
* @param btAryReceiveData
* 接收到的数据
*/
private void runReceiveDataCallback(byte[] btAryReceiveData) {
// Loger.disk_log("Read", StringTool.byteArrayToString(btAryReceiveData,
// 0, btAryReceiveData.length), "M10_U8");
Log.e("toolsdebug", "runReceiveDataCallback = " + Tools.Bytes2HexString(btAryReceiveData, btAryReceiveData.length));
try {
reciveData(btAryReceiveData);
int nCount = btAryReceiveData.length;
byte[] btAryBuffer = new byte[nCount + m_nLength];
System.arraycopy(m_btAryBuffer, 0, btAryBuffer, 0, m_nLength);
System.arraycopy(btAryReceiveData, 0, btAryBuffer, m_nLength, btAryReceiveData.length);
// Array.Copy(m_btAryBuffer, btAryBuffer, m_nLenth);
// Array.Copy(btAryReceiveData, 0, btAryBuffer, m_nLenth,
// btAryReceiveData.Length);
// 分析接收数据,以0xA0为数据起点,以协议中数据长度为数据终止点
int nIndex = 0; // 当数据中存在A0时,记录数据的终止点
int nMarkIndex = 0; // 当数据中不存在A0时,nMarkIndex等于数据组最大索引
for (int nLoop = 0; nLoop < btAryBuffer.length; nLoop++) {
if (btAryBuffer.length > nLoop + 1) {
if (btAryBuffer[nLoop] == HEAD.HEAD) {
int nLen = btAryBuffer[nLoop + 1] & 0xFF;
if (nLoop + 1 + nLen < btAryBuffer.length) {
byte[] btAryAnaly = new byte[nLen + 2];
System.arraycopy(btAryBuffer, nLoop, btAryAnaly, 0, nLen + 2);
// Array.Copy(btAryBuffer, nLoop, btAryAnaly, 0,
// nLen + 2);
MessageTran msgTran = new MessageTran(btAryAnaly);
analyData(msgTran);
nLoop += 1 + nLen;
nIndex = nLoop + 1;
} else {
nLoop += 1 + nLen;
}
} else {
nMarkIndex = nLoop;
}
}
}
if (nIndex < nMarkIndex) {
nIndex = nMarkIndex + 1;
}
if (nIndex < btAryBuffer.length) {
m_nLength = btAryBuffer.length - nIndex;
Arrays.fill(m_btAryBuffer, 0, 4096, (byte) 0);
System.arraycopy(btAryBuffer, nIndex, m_btAryBuffer, 0, btAryBuffer.length - nIndex);
// Array.Clear(m_btAryBuffer, 0, 4096);
// Array.Copy(btAryBuffer, nIndex, m_btAryBuffer, 0,
// btAryBuffer.Length - nIndex);
} else {
m_nLength = 0;
}
} catch (Exception e) {
Log.e("toolsdebug", "数据错误");
}
}
/**
* 可重写函数,接收到数据时会调用此函数。
*
* @param btAryReceiveData
* 收到的数据
*/
public void reciveData(byte[] btAryReceiveData) {
};
/**
* 可重写函数,发送数据后会调用此函数。
*
* @param btArySendData
* 发送的数据
*/
public void sendData(byte[] btArySendData) {
};
/**
* 发送数据,使用synchronized()防止并发操作。
*
* @param btArySenderData
* 要发送的数据
* @return 成功 :0, 失败:-1
*/
private int sendMessage(byte[] btArySenderData) {
try {
synchronized (mOutStream) { // 防止并发
mOutStream.write(btArySenderData);
Log.e("yourTag", " 串口发送 ===> " + Tools.Bytes2HexString(btArySenderData, btArySenderData.length));
Loger.disk_log("Write",
StringTool.byteArrayToString(btArySenderData, 0,
btArySenderData.length), "U8");
}
} catch (IOException e) {
Loger.disk_log("写错误", "e=" + e.getMessage() + "\r\n" + e.getStackTrace(), "M10_U8");
onLostConnect();
return -1;
} catch (Exception e) {
Loger.disk_log("写错误", "e=" + e.getMessage() + "\r\n" + e.getStackTrace(), "M10_U8");
return -1;
}
sendData(btArySenderData);
return 0;
}
private int sendMessage(byte btReadId, byte btCmd) {
MessageTran msgTran = new MessageTran(btReadId, btCmd);
return sendMessage(msgTran.getAryTranData());
}
private int sendMessage(byte btReadId, byte btCmd, byte[] btAryData) {
MessageTran msgTran = new MessageTran(btReadId, btCmd, btAryData);
return sendMessage(msgTran.getAryTranData());
}
/**
* 复位指定地址的读写器。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int reset(byte btReadId) {
byte btCmd = CMD.RESET;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 设置串口通讯波特率。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param nIndexBaudrate
* 波特率(0x03: 38400bps, 0x04:115200 bps)
* @return 成功 :0, 失败:-1
*/
public final int setUartBaudrate(byte btReadId, byte nIndexBaudrate) {
byte btCmd = CMD.SET_UART_BAUDRATE;
byte[] btAryData = new byte[1];
btAryData[0] = nIndexBaudrate;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 读取读写器固件版本。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getFirmwareVersion(byte btReadId) {
byte btCmd = CMD.GET_FIRMWARE_VERSION;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 设置读写器地址。
*
* @param btReadId
* 原读写器地址(0xFF公用地址)
* @param btNewReadId
* 新读写器地址,取值范围0-254(0x00–0xFE)
* @return 成功 :0, 失败:-1
*/
public final int setReaderAddress(byte btReadId, byte btNewReadId) {
byte btCmd = CMD.SET_READER_ADDRESS;
byte[] btAryData = new byte[1];
btAryData[0] = btNewReadId;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 设置读写器工作天线。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btWorkAntenna
* 天线号(0x00:天线1, 0x01:天线2, 0x02:天线3, 0x03:天线4)
* @return 成功 :0, 失败:-1
*/
public final int setWorkAntenna(byte btReadId, byte btWorkAntenna) {
Log.i("ReaderBase", "setWorkAntenna指令");
byte btCmd = CMD.SET_WORK_ANTENNA;
byte[] btAryData = new byte[1];
btAryData[0] = btWorkAntenna;
int nResult = sendMessage(btReadId, btCmd, btAryData);//向串口发送指令
return nResult;
}
/**
* 查询当前天线工作天线。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getWorkAntenna(byte btReadId) {
byte btCmd = CMD.GET_WORK_ANTENNA;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 设置读写器射频输出功率(方式1)。 <br>
* ★此命令耗时将超过100mS。 <br>
* ★如果需要动态改变射频输出功率,请使用CmdCode_set_temporary_output_power命令,否则将会影响Flash的使用寿命。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btOutputPower
* RF输出功率,取值范围0-33(0x00–0x21), 单位dBm
* @return 成功 :0, 失败:-1
*/
public final int setOutputPower(byte btReadId, byte btOutputPower) {
byte btCmd = CMD.SET_OUTPUT_POWER;
byte[] btAryData = new byte[1];
btAryData[0] = btOutputPower;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 设置读写器射频输出功率(方式2)。 <br>
* ★此命令耗时将超过100mS。 <br>
* ★如果需要动态改变射频输出功率,请使用CmdCode_set_temporary_output_power命令,否则将会影响Flash的使用寿命。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btPower1
* RF天线1输出功率,取值范围0-33(0x00–0x21), 单位dBm
* @param btPower2
* RF天线2输出功率,取值范围0-33(0x00–0x21), 单位dBm
* @param btPower3
* RF天线3输出功率,取值范围0-33(0x00–0x21), 单位dBm
* @param btPower4
* RF天线4输出功率,取值范围0-33(0x00–0x21), 单位dBm
* @return 成功 :0, 失败:-1
*/
public final int setOutputPower(byte btReadId, byte btPower1, byte btPower2, byte btPower3, byte btPower4) {
byte btCmd = CMD.SET_OUTPUT_POWER;
byte[] btAryData = new byte[4];
btAryData[0] = btPower1;
btAryData[1] = btPower2;
btAryData[2] = btPower3;
btAryData[3] = btPower4;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 查询读写器当前输出功率。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getOutputPower(byte btReadId) {
byte btCmd = CMD.GET_OUTPUT_POWER;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 设置蜂鸣器状态。 <br>
* ★读到一张标签后蜂鸣器鸣响,会占用大量处理器时间,若此选项打开,将会明显影响到读多标签(防冲突算法)的性能,此选项应作为测试功能选用。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btMode
* 操作标签时蜂鸣器状态(0x00:安静, 0x01:每次盘存后鸣响, 0x02:每读到一张标签鸣响)
* @return 成功 :0, 失败:-1
*/
public final int setBeeperMode(byte btReadId, byte btMode) {
byte btCmd = CMD.SET_BEEPER_MODE;
byte[] btAryData = new byte[1];
btAryData[0] = btMode;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 查询当前设备的工作温度。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getReaderTemperature(byte btReadId) {
byte btCmd = CMD.GET_READER_TEMPERATURE;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 设置天线连接检测器状态。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btDetectorStatus
* 状态(0x00:关闭天线连接检测, 其他值:天线连接检测的灵敏度(端口回波损耗值),单位dB.
* 值越大对端口的阻抗匹配要求越高
* @return 成功 :0, 失败:-1
*/
public final int setAntConnectionDetector(byte btReadId, byte btDetectorStatus) {
byte btCmd = CMD.SET_ANT_CONNECTION_DETECTOR;
byte[] btAryData = new byte[1];
btAryData[0] = btDetectorStatus;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 读取天线连接检测器状态。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getAntConnectionDetector(byte btReadId) {
byte btCmd = CMD.GET_ANT_CONNECTION_DETECTOR;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 设置读写器临时射频输出功率。 <br>
* 操作成功后输出功率值将不会被保存在内部的Flash中,重新启动或断电后输出功率将恢复至内部Flash中保存的输出功率值。此命令的操作速度非常快,
* 并且不写Flash,从而不影响Flash的使用寿命,适合需要反复切换射频输出功率的应用。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btRfPower
* RF输出功率, 取值范围20-33(0x14–0x21), 单位dBm
* @return 成功 :0, 失败:-1
*/
public final int setTemporaryOutputPower(byte btReadId, byte btRfPower) {
byte btCmd = CMD.SET_TEMPORARY_OUTPUT_POWER;
byte[] btAryData = new byte[1];
btAryData[0] = btRfPower;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 盘存标签。 <br>
* 读写器收到此命令后,进行多标签识别操作。标签数据存入读写器缓存区。 <br>
* 注意: <br>
* ★将参数设置成255(0xFF)时,将启动专为读少量标签设计的算法。对于少量标的应用来说,效率更高,反应更灵敏,
* 但此参数不适合同时读取大量标签的应用。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btRepeat
* 盘存过程重复的次数, Repeat=0xFF则此轮盘存时间为最短时间.
* 如果射频区域内只有一张标签,则此轮的盘存约耗时为30-50mS. 一般在四通道机器上快速轮询多个天线时使用此参数值
* @return 成功 :0, 失败:-1
*/
public final int inventory(byte btReadId, byte btRepeat) {
Log.i("ReaderBase", "inventory指令");
byte btCmd = CMD.INVENTORY;
byte[] btAryData = new byte[1];
btAryData[0] = btRepeat;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 读标签。 <br>
* 注意: <br>
* ★相同EPC的标签,若读取的数据不相同,则被视为不同的标签。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btMemBank
* 标签存储区域(0x00:RESERVED, 0x01:EPC, 0x02:TID, 0x03:USER)
* @param btWordAdd
* 读取数据首地址,取值范围请参考标签规格
* @param btWordCnt
* 读取数据长度,字长,WORD(16 bits)长度. 取值范围请参考标签规格书
* @param btAryPassWord
* 标签访问密码,4字节
* @return 成功 :0, 失败:-1
*/
public final int readTag(byte btReadId, byte btMemBank, byte btWordAdd, byte btWordCnt, byte[] btAryPassWord) {
byte btCmd = CMD.READ_TAG;
byte[] btAryData = null;
if (btAryPassWord == null || btAryPassWord.length < 4) {
btAryPassWord = null;
btAryData = new byte[3];
} else {
btAryData = new byte[3 + 4];
}
btAryData[0] = btMemBank;
btAryData[1] = btWordAdd;
btAryData[2] = btWordCnt;
if (btAryPassWord != null) {
System.arraycopy(btAryPassWord, 0, btAryData, 3, btAryPassWord.length);
}
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 写标签。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btAryPassWord
* 标签访问密码,4字节
* @param btMemBank
* 标签存储区域(0x00:RESERVED, 0x01:EPC, 0x02:TID, 0x03:USER)
* @param btWordAdd
* 数据首地址,WORD(16 bits)地址. 写入EPC存储区域一般从0x02开始,该区域前四个字节存放PC+CRC
* @param btWordCnt
* WORD(16 bits)长度,数值请参考标签规格
* @param btAryData
* 写入的数据, btWordCnt*2 字节
* @return 成功 :0, 失败:-1
*/
public final int writeTag(byte btReadId, byte[] btAryPassWord, byte btMemBank, byte btWordAdd, byte btWordCnt, byte[] btAryData) {
byte btCmd = CMD.WRITE_TAG;
byte[] btAryBuffer = new byte[btAryData.length + 7];
System.arraycopy(btAryPassWord, 0, btAryBuffer, 0, btAryPassWord.length);
btAryBuffer[4] = btMemBank;
btAryBuffer[5] = btWordAdd;
btAryBuffer[6] = btWordCnt;
System.arraycopy(btAryData, 0, btAryBuffer, 7, btAryData.length);
int nResult = sendMessage(btReadId, btCmd, btAryBuffer);
return nResult;
}
/**
* 锁定标签。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btAryPassWord
* 标签访问密码,4字节
* @param btMembank
* 操作的数据区域(0x01:User Memory, 0x02:TID Memory, 0x03:EPC Memory,
* 0x04:Access Password, 0x05:Kill Password)
* @param btLockType
* 锁操作类型(0x00:开放, 0x01:锁定, 0x02:永久开放, 0x03:永久锁定)
* @return 成功 :0, 失败:-1
*/
public final int lockTag(byte btReadId, byte[] btAryPassWord, byte btMemBank, byte btLockType) {
byte btCmd = CMD.LOCK_TAG;
byte[] btAryData = new byte[6];
System.arraycopy(btAryPassWord, 0, btAryData, 0, btAryPassWord.length);
btAryData[4] = btMemBank;
btAryData[5] = btLockType;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 灭活标签。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btAryPassWord
* 标签销毁密码,4字节
* @return 成功 :0, 失败:-1
*/
public final int killTag(byte btReadId, byte[] btAryPassWord) {
byte btCmd = CMD.KILL_TAG;
byte[] btAryData = new byte[4];
System.arraycopy(btAryPassWord, 0, btAryData, 0, btAryPassWord.length);
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 匹配ACCESS操作的EPC号(匹配一直有效,直到下一次刷新)。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btEpcLen
* EPC长度
* @param btAryEpc
* EPC号, 由EpcLen个字节组成
* @return 成功 :0, 失败:-1
*/
public final int setAccessEpcMatch(byte btReadId, byte btEpcLen, byte[] btAryEpc) {
byte btCmd = CMD.SET_ACCESS_EPC_MATCH;
int nLen = (btEpcLen & 0xFF) + 2;
byte[] btAryData = new byte[nLen];
btAryData[0] = 0x00;
btAryData[1] = btEpcLen;
System.arraycopy(btAryEpc, 0, btAryData, 2, btAryEpc.length);
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 清除EPC匹配。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int cancelAccessEpcMatch(byte btReadId) {
byte btCmd = CMD.SET_ACCESS_EPC_MATCH;
byte[] btAryData = new byte[1];
btAryData[0] = 0x01;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 查询匹配的EPC状态。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getAccessEpcMatch(byte btReadId) {
byte btCmd = CMD.GET_ACCESS_EPC_MATCH;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 盘存标签(实时上传标签数据)。 <br>
* 注意: <br>
* ★由于硬件为双CPU架构,主CPU负责轮询标签,副CPU负责数据管理。轮询标签和发送数据并行,互不占用对方的时间,
* 因此串口的数据传输不影响读写器工作的效率。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btRepeat
* 盘存过程重复的次数,Repeat=0xFF则此轮盘存时间为最短时间.
* 如果射频区域内只有一张标签,则此轮的盘存约耗时为30-50mS. 一般在四通道机器上快速轮询多个天线时使用此参数值
* @return 成功 :0, 失败:-1
*/
public final int realTimeInventory(byte btReadId, byte btRepeat) {
Log.i("ReaderBase", "realTimeInventory指令");
byte btCmd = CMD.REAL_TIME_INVENTORY;
byte[] btAryData = new byte[1];
btAryData[0] = btRepeat;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 快速轮询多个天线盘存标签。 <br>
* 注意: <br>
* ★由于硬件为双CPU架构,主CPU负责轮询标签,副CPU负责数据管理。轮询标签和发送数据并行,互不占用对方的时间,
* 因此串口的数据传输不影响读写器工作的效率。 <br>
* ★此命令读取大量标签时,效率没有CmdCode_real_time_inventory命令高。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btA
* 首先轮询的天线(00–03), 天线号大于三则表示不轮询
* @param btStayA
* 天线重复轮询的次数
* @param btB
* 第二个轮询的天线(00–03), 天线号大于三则表示不轮询
* @param btStayB
* 天线重复轮询的次数
* @param btC
* 第三个轮询的天线(00–03), 天线号大于三则表示不轮询
* @param btStayC
* 天线重复轮询的次数
* @param btD
* 第四个轮询的天线(00–03), 天线号大于三则表示不轮询
* @param btStayD
* 天线重复轮询的次数
* @param btInterval
* 天线间的休息时间. 单位是mS. 休息时无射频输出,可降低功耗
* @param btRepeat
* 重复以上天线切换顺序次数
* @return 成功 :0, 失败:-1
*/
public final int fastSwitchAntInventory(byte btReadId, byte btA, byte btStayA, byte btB, byte btStayB, byte btC, byte btStayC, byte btD, byte btStayD, byte btInterval, byte btRepeat) {
byte btCmd = CMD.FAST_SWITCH_ANT_INVENTORY;
byte[] btAryData = new byte[10];
btAryData[0] = btA;
btAryData[1] = btStayA;
btAryData[2] = btB;
btAryData[3] = btStayB;
btAryData[4] = btC;
btAryData[5] = btStayC;
btAryData[6] = btD;
btAryData[7] = btStayD;
btAryData[8] = btInterval;
btAryData[9] = btRepeat;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 自定义session和target盘存。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @param btSession
* 指定盘存的session
* @param btTarget
* 指定盘存的Inventoried Flag(0x00:A, 0x01:B)
* @param btRepeat
* 盘存过程重复的次数
* @return 成功 :0, 失败:-1
*/
public final int customizedSessionTargetInventory(byte btReadId, byte btSession, byte btTarget, byte btRepeat) {
byte btCmd = CMD.CUSTOMIZED_SESSION_TARGET_INVENTORY;
byte[] btAryData = new byte[3];
btAryData[0] = btSession;
btAryData[1] = btTarget;
btAryData[2] = btRepeat;
int nResult = sendMessage(btReadId, btCmd, btAryData);
return nResult;
}
/**
* 提取标签数据并删除缓存。 <br>
* 注意: <br>
* ★命令完成后,缓存中的数据并不丢失,可以多次提取。 <br>
* ★若再次运行CmdCode_inventory 命令,则盘存到的标签将累计存入缓存。 <br>
* ★若再次运行其他的18000-6C命令,缓存中的数据将被清空。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getInventoryBuffer(byte btReadId) {
Log.i("ReaderBase", "getInventoryBuffer指令");
byte btCmd = CMD.GET_INVENTORY_BUFFER;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 提取标签数据保留缓存备份。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getAndResetInventoryBuffer(byte btReadId) {
byte btCmd = CMD.GET_AND_RESET_INVENTORY_BUFFER;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 查询缓存中已读标签个数。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int getInventoryBufferTagCount(byte btReadId) {
Log.i("ReaderBase", "getInventoryBufferTagCount指令");
byte btCmd = CMD.GET_INVENTORY_BUFFER_TAG_COUNT;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 清空标签数据缓存。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int resetInventoryBuffer(byte btReadId) {
byte btCmd = CMD.RESET_INVENTORY_BUFFER;
int nResult = sendMessage(btReadId, btCmd);
return nResult;
}
/**
* 发送裸数据。
*
* @param btReadId
* 读写器地址(0xFF公用地址)
* @return 成功 :0, 失败:-1
*/
public final int sendBuffer(byte[] btAryBuf) {
int nResult = sendMessage(btAryBuf);
return nResult;
}
}
package com.fn.useries.reader.server;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.fn.useries.operation.U8Series;
import com.fn.useries.reader.CMD;
import com.fn.useries.reader.ERROR;
import com.fn.useries.reader.HEAD;
import com.fn.useries.reader.MessageTran;
import com.fn.useries.reader.model.ISO180006BOperateTagBuffer;
import com.fn.useries.reader.model.InventoryBuffer;
import com.fn.useries.reader.model.InventoryBuffer.InventoryTagMap;
import com.fn.useries.reader.model.OperateTagBuffer;
import com.fn.useries.reader.model.OperateTagBuffer.OperateTagMap;
import com.fn.useries.reader.model.ReaderSetting;
import com.fn.useries.utils.MusicPlayer;
import com.fn.useries.utils.MusicPlayer.Type;
import com.fn.useries.utils.StringTool;
import com.fn.useries.utils.Tools;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.Date;
public class ReaderHelper {
public final static String BROADCAST_ON_LOST_CONNECT = "com.reader.helper.onLostConnect";
public final static String BROADCAST_WRITE_DATA = "com.reader.helper.writeData";
public final static String BROADCAST_WRITE_LOG = "com.reader.helper.writeLog";
public final static String BROADCAST_REFRESH_READER_SETTING = "com.reader.helper.refresh.readerSetting";
public final static String BROADCAST_REFRESH_INVENTORY = "com.reader.helper.refresh.inventory";
public final static String BROADCAST_REFRESH_INVENTORY_REAL = "com.reader.helper.refresh.inventoryReal";
public final static String BROADCAST_REFRESH_FAST_SWITCH = "com.reader.helper.refresh.fastSwitch";
public final static String BROADCAST_REFRESH_OPERATE_TAG = "com.reader.helper.refresh.operateTag";
public final static String BROADCAST_REFRESH_ISO18000_6B = "com.reader.helper.refresh.ISO180006B";
private static LocalBroadcastManager mLocalBroadcastManager = null;
public final static byte INVENTORY_ERR = 0x00;
public final static byte INVENTORY_ERR_END = 0x01;
public final static byte INVENTORY_END = 0x02;
public final static int WRITE_LOG = 0x10;
public final static int REFRESH_READER_SETTING = 0x11;
public final static int REFRESH_INVENTORY = 0x12;
public final static int REFRESH_INVENTORY_REAL = 0x13;
public final static int REFRESH_FAST_SWITCH = 0x14;
public final static int REFRESH_OPERATE_TAG = 0x15;
public final static int REFRESH_ISO18000_6B = 0x15;
public final static int LOST_CONNECT = 0x20;
private Tools tools = new Tools();
private static ReaderBase mReader;
private static Context mContext;
private static ReaderHelper mReaderHelper;
private static ReaderSetting m_curReaderSetting;
private static InventoryBuffer m_curInventoryBuffer;
private static OperateTagBuffer m_curOperateTagBuffer;
private static ISO180006BOperateTagBuffer m_curOperateTagISO18000Buffer;
// 盘存操作前,需要先设置工作天线,用于标识当前是否在执行盘存操作
private boolean m_bInventory = false;
private boolean m_bISO6BContinue = false;
// 实时盘存次数
private int m_nTotal = 0;
/**
* 构造函数
*/
public ReaderHelper() {
m_curReaderSetting = new ReaderSetting();
m_curInventoryBuffer = new InventoryBuffer();
m_curOperateTagBuffer = new OperateTagBuffer();
m_curOperateTagISO18000Buffer = new ISO180006BOperateTagBuffer();
}
/**
* 设置Context。
*
* @param context
* 设置Context
* @throws Exception
* 当Context为空时会抛出错误
*/
public static void setContext(Context context) throws Exception {
mContext = context;
mLocalBroadcastManager = LocalBroadcastManager.getInstance(mContext);
mReaderHelper = new ReaderHelper();
}
/**
* 返回helper中全局的读写器帮助类。
*
* @return 返回helper中全局的读写器帮助类
* @throws Exception
* 当helper中全局的读写器帮助类为空时会抛出错误
*/
public static ReaderHelper getDefaultHelper() throws Exception {
if (mReaderHelper == null || mContext == null)
throw new NullPointerException("mReaderHelper Or mContext is Null!");
return mReaderHelper;
}
/**
* 设置循环标志位。
*
* @param flag
* 标志
*/
public void setInventoryFlag(boolean flag) {
this.m_bInventory = flag;
}
/**
* 获取循环标志位。
*
* @return 标志
*/
public boolean getInventoryFlag() {
return this.m_bInventory;
}
/**
* 设置循环标志位。
*
* @param m_continue 标志
*/
public void setISO6BContinue(boolean m_continue) {
this.m_bISO6BContinue = m_continue;
}
/**
* 获取循环标志位。
*
* @return 标志
*/
public boolean getISO6BContinue() {
return this.m_bISO6BContinue;
}
public int getInventoryTotal() {
return this.m_nTotal;
}
public void setInventoryTotal(int num) {
this.m_nTotal = num;
}
public void clearInventoryTotal() {
this.m_nTotal = 0;
}
public ReaderSetting getCurReaderSetting() {
return m_curReaderSetting;
}
public InventoryBuffer getCurInventoryBuffer() {
return m_curInventoryBuffer;
}
public OperateTagBuffer getCurOperateTagBuffer() {
return m_curOperateTagBuffer;
}
public ISO180006BOperateTagBuffer getCurOperateTagISO18000Buffer() {
return m_curOperateTagISO18000Buffer;
}
/**
* 显示log。
*
* @param strLog
* log信息
* @param type
* log等级(0x10:正确, 0x11:错误) play
*/
private void writeLog(String strLog, int type) {
Intent itent = new Intent(BROADCAST_WRITE_LOG);
itent.putExtra("type", type);
itent.putExtra("log", strLog);
mLocalBroadcastManager.sendBroadcast(itent);
};
/**
* 读写器各参数刷新显示。
*
* @param btCmd
* 命令类型(用于指定类型的刷新)
* @param curSetting
* 当前读写器各参数
*/
int a = 1;
private void refreshReaderSetting(byte btCmd, ReaderSetting curReaderSetting) {
Intent itent = new Intent(BROADCAST_REFRESH_READER_SETTING);
itent.putExtra("cmd", btCmd);
settingNotify();
mLocalBroadcastManager.sendBroadcast(itent);
}
private void settingNotify() {
Object object = U8Series.object;
synchronized (object) {
U8Series.havenotify = true;
object.notifyAll();
}
};
/**
* 存盘标签(缓存模式),标签数据刷新。
*
* @param btCmd
* 命令类型(用于指定类型的刷新)
* @param curInventoryBuffer
* 当前标签数据
*/
private void refreshInventory(byte btCmd, InventoryBuffer curInventoryBuffer) {
Log.i("ReaderHelper", "refreshInventory指令");
Intent itent = new Intent(BROADCAST_REFRESH_INVENTORY);
itent.putExtra("cmd", btCmd);
mLocalBroadcastManager.sendBroadcast(itent);
// if(curInventoryBuffer.nDataCount > 0){
if (btCmd != INVENTORY_END && btCmd != INVENTORY_ERR_END)
MusicPlayer.getInstance().play(Type.OK);
// }
};
/**
* 存盘标签(实时模式),标签数据刷新。
*
* @param btCmd
* 命令类型(用于指定类型的刷新)
* @param curInventoryBuffer
* 当前标签数据
*/
private void refreshInventoryReal(byte btCmd, InventoryBuffer curInventoryBuffer) {
Log.i("ReaderHelper", "refreshInventoryReal指令");
Intent itent = new Intent(BROADCAST_REFRESH_INVENTORY_REAL);
itent.putExtra("cmd", btCmd);
mLocalBroadcastManager.sendBroadcast(itent);
// if (curInventoryBuffer.nDataCount > 0) {
if (btCmd != INVENTORY_END && btCmd != INVENTORY_ERR_END)
MusicPlayer.getInstance().play(Type.OK);
// }
};
/**
* 存盘标签(快速模式),标签数据刷新。
*
* @param btCmd
* 命令类型(用于指定类型的刷新)
* @param curInventoryBuffer
* 当前标签数据
*/
private void refreshFastSwitch(byte btCmd, InventoryBuffer curInventoryBuffer) {
Intent itent = new Intent(BROADCAST_REFRESH_FAST_SWITCH);
itent.putExtra("cmd", btCmd);
mLocalBroadcastManager.sendBroadcast(itent);
if (curInventoryBuffer.nDataCount > 0) {
MusicPlayer.getInstance().play(Type.OK);
// Tools.playMedia(mContext);
}
};
/**
* 存盘标签(快速模式),标签数据刷新。
*
* @param btCmd
* 命令类型(用于指定类型的刷新)
* @param curOperateTagBuffer
* 当前标签数据
*/
private void refreshOperateTag(byte btCmd, OperateTagBuffer curOperateTagBuffer) {
Log.i("ReaderHelper", "refreshOperateTag指令");
Intent itent = new Intent(BROADCAST_REFRESH_OPERATE_TAG);
itent.putExtra("cmd", btCmd);
mLocalBroadcastManager.sendBroadcast(itent);
// Tools.playMedia(mContext);
};
/**
* 设置并返回helper中全局的读写器基类。
*
* @param in
* 输入流
* @param out
* 输出流
* @return helper中全局的读写器基类
* @throws Exception
* 当in或out为空时会抛出错误
*/
public ReaderBase setReader(InputStream in, OutputStream out) throws Exception {
if (in == null || out == null)
throw new NullPointerException("in Or out is NULL!");
if (mReader == null) {
Log.i("toolsdebug", "new Reader");
mReader = new ReaderBase(in, out) {
@Override
public void onLostConnect() {
mLocalBroadcastManager.sendBroadcast(new Intent(BROADCAST_ON_LOST_CONNECT));
}
@Override
public void analyData(MessageTran msgTran) {
mReaderHelper.analyData(msgTran);
}
@Override
public void reciveData(byte[] btAryReceiveData) {
// String strLog =
// StringTool.byteArrayToString(btAryReceiveData, 0,
// btAryReceiveData.length);
/*
* Intent itent = new Intent(BROADCAST_WRITE_DATA); Integer
* type = ERROR.SUCCESS & 0xFF; itent.putExtra("type",
* type); itent.putExtra("log", strLog);
*/
// 接收的数据记录入磁盘
// Loger.disk_log("Read:", strLog, "M10_U8");
// mLocalBroadcastManager.sendBroadcast(itent);
}
@Override
public void sendData(byte[] btArySendData) {
// String strLog =
// StringTool.byteArrayToString(btArySendData, 0,
// btArySendData.length);
/*
* Intent itent = new Intent(BROADCAST_WRITE_DATA); Integer
* type = ERROR.SUCCESS & 0xFF; itent.putExtra("type",
* type); itent.putExtra("log", strLog);
*/
// 发送的数据记录入磁盘
// Loger.disk_log("Write:", strLog, "M10_U8");
// mLocalBroadcastManager.sendBroadcast(itent);
}
};
}
return mReader;
}
/**
* 返回helper中全局的读写器基类。
*
* @return helper中全局的读写器基类
* @throws Exception
* 当helper中全局的读写器基类为空时会抛出错误
*/
public ReaderBase getReader() throws Exception {
if (mReader == null) {
throw new NullPointerException("mReader is Null!");
}
return mReader;
}
/**
* 可重写函数,解析到一包数据后会调用此函数。
*
* @param msgTran
* 解析到的包
*/
private void analyData(MessageTran msgTran) {
Log.i("ReaderHelper", "analyData");
if (msgTran.getPacketType() != HEAD.HEAD) {
return;
}
switch (msgTran.getCmd()) {
case CMD.RESET:
processReset(msgTran);
break;
case CMD.SET_UART_BAUDRATE:
processSetUartBaudrate(msgTran);
break;
case CMD.GET_FIRMWARE_VERSION:
processGetFirmwareVersion(msgTran);
break;
case CMD.SET_READER_ADDRESS:
processSetReaderAddress(msgTran);
break;
case CMD.SET_WORK_ANTENNA:
processSetWorkAntenna(msgTran);
break;
case CMD.GET_WORK_ANTENNA:
processGetWorkAntenna(msgTran);
break;
case CMD.SET_OUTPUT_POWER:
processSetOutputPower(msgTran);
break;
case CMD.GET_OUTPUT_POWER:
processGetOutputPower(msgTran);
break;
case CMD.SET_FREQUENCY_REGION:
processSetFrequencyRegion(msgTran);
break;
case CMD.GET_FREQUENCY_REGION:
processGetFrequencyRegion(msgTran);
break;
case CMD.SET_BEEPER_MODE:
processSetBeeperMode(msgTran);
break;
case CMD.GET_READER_TEMPERATURE:
Log.i("toolsdebug", "GET_READER_TEMPERATURE");
processGetReaderTemperature(msgTran);
break;
case CMD.READ_GPIO_VALUE:
processReadGpioValue(msgTran);
break;
case CMD.WRITE_GPIO_VALUE:
processWriteGpioValue(msgTran);
break;
case CMD.SET_ANT_CONNECTION_DETECTOR:
processSetAntConnectionDetector(msgTran);
break;
case CMD.GET_ANT_CONNECTION_DETECTOR:
processGetAntConnectionDetector(msgTran);
break;
case CMD.SET_TEMPORARY_OUTPUT_POWER:
processSetTemporaryOutputPower(msgTran);
break;
case CMD.SET_READER_IDENTIFIER:
processSetReaderIdentifier(msgTran);
break;
case CMD.GET_READER_IDENTIFIER:
processGetReaderIdentifier(msgTran);
break;
case CMD.SET_RF_LINK_PROFILE:
processSetRfLinkProfile(msgTran);
break;
case CMD.GET_RF_LINK_PROFILE:
processGetRfLinkProfile(msgTran);
break;
case CMD.GET_RF_PORT_RETURN_LOSS:
processGetRfPortReturnLoss(msgTran);
break;
case CMD.INVENTORY:
processInventory(msgTran);
break;
case CMD.READ_TAG:
processReadTag(msgTran);
break;
case CMD.WRITE_TAG:
processWriteTag(msgTran);
break;
case CMD.LOCK_TAG:
processLockTag(msgTran);
break;
case CMD.KILL_TAG:
processKillTag(msgTran);
break;
case CMD.SET_ACCESS_EPC_MATCH:
processSetAccessEpcMatch(msgTran);
break;
case CMD.GET_ACCESS_EPC_MATCH:
processGetAccessEpcMatch(msgTran);
break;
case CMD.REAL_TIME_INVENTORY:
processRealTimeInventory(msgTran);
break;
case CMD.FAST_SWITCH_ANT_INVENTORY:
processFastSwitchInventory(msgTran);
break;
case CMD.CUSTOMIZED_SESSION_TARGET_INVENTORY:
processCustomizedSessionTargetInventory(msgTran);
break;
case CMD.SET_IMPINJ_FAST_TID:
processSetImpinjFastTid(msgTran);
break;
case CMD.SET_AND_SAVE_IMPINJ_FAST_TID:
processSetAndSaveImpinjFastTid(msgTran);
break;
case CMD.GET_IMPINJ_FAST_TID:
processGetImpinjFastTid(msgTran);
break;
case CMD.GET_INVENTORY_BUFFER:
processGetInventoryBuffer(msgTran);
break;
case CMD.GET_AND_RESET_INVENTORY_BUFFER:
processGetAndResetInventoryBuffer(msgTran);
break;
case CMD.GET_INVENTORY_BUFFER_TAG_COUNT:
processGetInventoryBufferTagCount(msgTran);
break;
case CMD.RESET_INVENTORY_BUFFER:
processResetInventoryBuffer(msgTran);
break;
default:
break;
}
}
/**
* 解析所有设置命令的反馈。
*
* @param msgTran
*/
private void processSet(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
if (btAryData[0] == ERROR.SUCCESS) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.blnSetResult = true;
writeLog(strCmd, ERROR.SUCCESS);
settingNotify();
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
m_curReaderSetting.blnSetResult = false;
m_curReaderSetting.strErrorCode = strErrorCode;
}
} else {
strErrorCode = "未知错误";
m_curReaderSetting.blnSetResult = false;
m_curReaderSetting.strErrorCode = strErrorCode;
}
settingNotify();
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processReset(MessageTran msgTran) {
processSet(msgTran);
}
private void processSetUartBaudrate(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetFirmwareVersion(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x02) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btMajor = btAryData[0];
m_curReaderSetting.btMinor = btAryData[1];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processSetReaderAddress(MessageTran msgTran) {
processSet(msgTran);
}
private void processSetWorkAntenna(MessageTran msgTran) {
// Loger.disk_log("AAAA", "processSetWorkAntenna", "M10_U8");
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strErrorCode = "";
String strCmd = "设置工作天线成功,当前工作天线: 天线" + (m_curReaderSetting.btWorkAntenna + 1);
if (btAryData.length == 0x01) {
if (btAryData[0] == ERROR.SUCCESS) {
m_curReaderSetting.btReadId = msgTran.getReadId();
writeLog(strCmd, ERROR.SUCCESS);
// 校验是否盘存操作
if (m_bInventory) {
runLoopInventroy();
}
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
}
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
if (m_bInventory) {
m_curInventoryBuffer.nCommond = 1;
m_curInventoryBuffer.dtEndInventory = new Date();
runLoopInventroy();
}
}
private void processGetWorkAntenna(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
if (btAryData[0] == 0x00 || btAryData[0] == 0x01 || btAryData[0] == 0x02 || btAryData[0] == 0x03) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btWorkAntenna = btAryData[0];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
}
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processSetOutputPower(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetOutputPower(MessageTran msgTran) {
Log.i("toolsdebug", "processGetOutputPower");
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x04 || btAryData.length == 0x01) {
Log.i("toolsdebug", "processGetOutputPower11111111111");
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btAryOutputPower = btAryData.clone();
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
Log.i("toolsdebug", "processGetOutputPower22222222222");
settingNotify();
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processSetFrequencyRegion(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetFrequencyRegion(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x03) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btRegion = btAryData[0];
m_curReaderSetting.btFrequencyStart = btAryData[1];
m_curReaderSetting.btFrequencyEnd = btAryData[2];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else if (btAryData.length == 0x06) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btRegion = btAryData[0];
m_curReaderSetting.btUserDefineFrequencyInterval = btAryData[1];
m_curReaderSetting.btUserDefineChannelQuantity = btAryData[2];
m_curReaderSetting.nUserDefineStartFrequency = (btAryData[3] & 0xFF) * 256 * 256 + (btAryData[4] & 0xFF) * 256 + (btAryData[5] & 0xFF);
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processSetBeeperMode(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetReaderTemperature(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x02) {
Log.i("toolsdebug", "processGetReaderTemperature11");
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btPlusMinus = btAryData[0];
m_curReaderSetting.btTemperature = btAryData[1];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
settingNotify();
return;
} else if (btAryData.length == 0x01) {
Log.i("toolsdebug", "processGetReaderTemperature22");
strErrorCode = ERROR.format(btAryData[0]);
settingNotify();
} else {
Log.i("toolsdebug", "processGetReaderTemperature33");
strErrorCode = "未知错误";
settingNotify();
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processReadGpioValue(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x02) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btGpio1Value = btAryData[0];
m_curReaderSetting.btGpio2Value = btAryData[1];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processWriteGpioValue(MessageTran msgTran) {
processSet(msgTran);
}
private void processSetAntConnectionDetector(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetAntConnectionDetector(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btAntDetector = btAryData[0];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processSetTemporaryOutputPower(MessageTran msgTran) {
processSet(msgTran);
}
private void processSetReaderIdentifier(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetReaderIdentifier(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x0C) {
m_curReaderSetting.btReadId = msgTran.getReadId();
Arrays.fill(m_curReaderSetting.btAryReaderIdentifier, (byte) 0x00);
System.arraycopy(btAryData, 0, m_curReaderSetting.btAryReaderIdentifier, 0, btAryData.length);
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processSetRfLinkProfile(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetRfLinkProfile(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
if ((btAryData[0] & 0xFF) >= 0xD0 && (btAryData[0] & 0xFF) <= 0xD3) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btRfLinkProfile = btAryData[0];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
}
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processGetRfPortReturnLoss(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btReturnLoss = btAryData[0];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processInventory(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x09) {
m_curInventoryBuffer.nCurrentAnt = btAryData[0];
m_curInventoryBuffer.nTagCount = (btAryData[1] & 0xFF) * 256 + (btAryData[2] & 0xFF);
m_curInventoryBuffer.nReadRate = (btAryData[3] & 0xFF) * 256 + (btAryData[4] & 0xFF);
int nTotalRead = (btAryData[5] & 0xFF) * 256 * 256 * 256 + (btAryData[6] & 0xFF) * 256 * 256 + (btAryData[7] & 0xFF) * 256 + (btAryData[8] & 0xFF);
m_curInventoryBuffer.nDataCount = nTotalRead;
m_curInventoryBuffer.nTotalRead += nTotalRead;
m_curInventoryBuffer.dtEndInventory = new Date();
refreshInventory(btCmd, m_curInventoryBuffer);
writeLog(strCmd, ERROR.SUCCESS);
runLoopInventroy();
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
refreshInventory(INVENTORY_ERR_END, m_curInventoryBuffer);
runLoopInventroy();
}
private void processReadTag(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
Object object = U8Series.readObject;
Intent itent = new Intent(BROADCAST_REFRESH_OPERATE_TAG);
if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
synchronized (object) {
U8Series.getInstance().readDataString = null;
U8Series.errorData = strLog;
object.notifyAll();
}
// BROADCAST_REFRESH_OPERATE_TAG
itent.putExtra("cmd", msgTran.getCmd());
itent.putExtra("type", ERROR.FAIL);
itent.putExtra("msg", strLog);
// 使用新接口后广播依然发送,但接收器内无逻辑
mLocalBroadcastManager.sendBroadcast(itent);
// writeLog(strLog, ERROR.FAIL);
} else {
int nLen = btAryData.length;
int nDataLen = (btAryData[nLen - 3] & 0xFF);
int nEpcLen = (btAryData[2] & 0xFF) - nDataLen - 4;
String strPC = StringTool.byteArrayToString(btAryData, 3, 2);
String strEPC = StringTool.byteArrayToString(btAryData, 5, nEpcLen);
String strCRC = StringTool.byteArrayToString(btAryData, 5 + nEpcLen, 2);
String strData = StringTool.byteArrayToString(btAryData, 7 + nEpcLen, nDataLen);
byte btTemp = btAryData[nLen - 2];
byte btAntId = (byte) ((btTemp & 0x03) + 1);
int nReadCount = btAryData[nLen - 1] & 0xFF;
OperateTagMap tag = new OperateTagMap();
tag.strPC = strPC;
tag.strCRC = strCRC;
tag.strEPC = strEPC;
tag.strData = strData;
tag.nDataLen = nDataLen;
tag.btAntId = btAntId;
tag.nReadCount = nReadCount;
m_curOperateTagBuffer.lsTagList.add(tag);
// refreshOperateTag(btCmd, m_curOperateTagBuffer);
synchronized (object) {
U8Series.getInstance().readDataString = strData;
Log.i("see", "notifyAll yes");
object.notifyAll();
}
itent.putExtra("cmd", msgTran.getCmd());
itent.putExtra("type", ERROR.SUCCESS);
itent.putExtra("msg", strData);
mLocalBroadcastManager.sendBroadcast(itent);
// writeLog(strCmd, ERROR.SUCCESS);
}
}
private void processWriteTag(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
Intent itent = new Intent(BROADCAST_REFRESH_OPERATE_TAG);
if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
String strLog = strCmd + "失败,失败原因:" + strErrorCode;
synchronized (this) {
U8Series.operationTagResult = 1;
U8Series.errorData = strLog;
this.notifyAll();
}
itent.putExtra("cmd", msgTran.getCmd());
itent.putExtra("type", ERROR.FAIL);
itent.putExtra("msg", strLog);
mLocalBroadcastManager.sendBroadcast(itent);
// writeLog(strLog, ERROR.FAIL);
} else {
int nLen = btAryData.length;
int nEpcLen = (btAryData[2] & 0xFF) - 4;
if (btAryData[nLen - 3] != ERROR.SUCCESS) {
strErrorCode = ERROR.format(btAryData[nLen - 3]);
String strLog = strCmd + "失败,失败原因:" + strErrorCode;
synchronized (this) {
U8Series.operationTagResult = 1;
U8Series.errorData = strLog;
this.notifyAll();
}
itent.putExtra("cmd", msgTran.getCmd());
itent.putExtra("type", ERROR.FAIL);
itent.putExtra("msg", strLog);
mLocalBroadcastManager.sendBroadcast(itent);
// writeLog(strLog, ERROR.FAIL);
return;
}
String strPC = StringTool.byteArrayToString(btAryData, 3, 2);
String strEPC = StringTool.byteArrayToString(btAryData, 5, nEpcLen);
String strCRC = StringTool.byteArrayToString(btAryData, 5 + nEpcLen, 2);
String strData = "";
byte btTemp = btAryData[nLen - 2];
byte btAntId = (byte) ((btTemp & 0x03) + 1);
int nReadCount = btAryData[nLen - 1] & 0xFF;
OperateTagMap tag = new OperateTagMap();
tag.strPC = strPC;
tag.strCRC = strCRC;
tag.strEPC = strEPC;
tag.strData = strData;
tag.nDataLen = 0;
tag.btAntId = btAntId;
tag.nReadCount = nReadCount;
m_curOperateTagBuffer.lsTagList.add(tag);
synchronized (this) {
U8Series.operationTagResult = 0;
U8Series.errorData="success";
Log.i("toolsdebug", "3333");
this.notifyAll();
}
itent.putExtra("cmd", msgTran.getCmd());
itent.putExtra("type", ERROR.SUCCESS);
if (msgTran.getCmd() == CMD.WRITE_TAG) {
itent.putExtra("msg", "Write label success");
} else if (msgTran.getCmd() == CMD.KILL_TAG) {
itent.putExtra("msg", "Destruction of label success");
} else if (msgTran.getCmd() == CMD.LOCK_TAG) {
itent.putExtra("msg", "Operation is successful!");
}
mLocalBroadcastManager.sendBroadcast(itent);
// refreshOperateTag(btCmd, m_curOperateTagBuffer);
// writeLog(strCmd, ERROR.SUCCESS);
}
}
/**
* processWriteTag 与 processLockTag 返回一致。
*
* @param msgTran
* 消息包
*/
private void processLockTag(MessageTran msgTran) {
processWriteTag(msgTran);
}
/**
* processKillTag 与 processLockTag 返回一致。
*
* @param msgTran
* 消息包
*/
private void processKillTag(MessageTran msgTran) {
processWriteTag(msgTran);
}
private void processSetAccessEpcMatch(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetAccessEpcMatch(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
if (btAryData[0] == 0x01) {
writeLog("无匹配标签", ERROR.FAIL);
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
}
} else {
if (btAryData[0] == 0x00) {
m_curOperateTagBuffer.strAccessEpcMatch = StringTool.byteArrayToString(btAryData, 2, btAryData[1] & 0xFF);
refreshOperateTag(btCmd, m_curOperateTagBuffer);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
strErrorCode = "未知错误";
}
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processRealTimeInventory(MessageTran msgTran) {
// Loger.disk_log("AAAA", "processRealTimeInventory===============",
// "M10_U8");
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) { // 本次获取因为错误结束
strErrorCode = ERROR.format(btAryData[0]);
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
refreshInventoryReal(INVENTORY_ERR_END, m_curInventoryBuffer);
// Loger.disk_log("AAAA",
// "processRealTimeInventory:1-runLoopInventroy", "M10_U8");
runLoopInventroy();
} else if (btAryData.length == 0x07) { // 本次获取正常结束
m_curInventoryBuffer.nReadRate = (btAryData[1] & 0xFF) * 256 + (btAryData[2] & 0xFF);
m_curInventoryBuffer.nDataCount = (btAryData[3] & 0xFF) * 256 * 256 * 256 + (btAryData[4] & 0xFF) * 256 * 256 + (btAryData[5] & 0xFF) * 256 + (btAryData[6] & 0xFF);
writeLog(strCmd, ERROR.SUCCESS);
refreshInventoryReal(INVENTORY_END, m_curInventoryBuffer);
// Loger.disk_log("AAAA",
// "processRealTimeInventory:2-runLoopInventroy", "M10_U8");
runLoopInventroy();
} else {
if (m_curInventoryBuffer.bLoopInventoryReal || m_curInventoryBuffer.bLoopInventory) {
// Loger.disk_log("AAAA", "processRealTimeInventory:else",
// "M10_U8");
m_nTotal++;
int nLength = btAryData.length;
int nEpcLength = nLength - 4;
String strEPC = StringTool.byteArrayToString(btAryData, 3, nEpcLength);
String strPC = StringTool.byteArrayToString(btAryData, 1, 2);
String strRSSI = String.valueOf(btAryData[nLength - 1] & 0xFF);
setMaxMinRSSI(btAryData[nLength - 1] & 0xFF);
byte btTemp = btAryData[0];
byte btAntId = (byte) ((btTemp & 0x03) + 1);
m_curInventoryBuffer.nCurrentAnt = btAntId & 0xFF;
byte btFreq = (byte) ((btTemp & 0xFF) >> 2);
String strFreq = getFreqString(btFreq);
InventoryTagMap tag = null;
Integer findIndex = m_curInventoryBuffer.dtIndexMap.get(strEPC);
if (findIndex == null) {
tag = new InventoryTagMap();
tag.strPC = strPC;
tag.strEPC = strEPC;
tag.strRSSI = strRSSI;
tag.nReadCount = 1;
tag.strFreq = strFreq;
m_curInventoryBuffer.lsTagList.add(tag);
m_curInventoryBuffer.dtIndexMap.put(strEPC, m_curInventoryBuffer.lsTagList.size() - 1);
} else {
tag = m_curInventoryBuffer.lsTagList.get(findIndex);
tag.strRSSI = strRSSI;
tag.nReadCount++;
tag.strFreq = strFreq;
}
m_curInventoryBuffer.dtEndInventory = new Date();
refreshInventoryReal(btCmd, m_curInventoryBuffer);
}
}
}
private void processFastSwitchInventory(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) { // 轮询因为错误结束
strErrorCode = ERROR.format(btAryData[0]);
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
refreshFastSwitch(INVENTORY_ERR_END, m_curInventoryBuffer);
runLoopFastSwitch();
} else if (btAryData.length == 0x02) { // 轮询过程中出现错误,但未结束
strErrorCode = ERROR.format(btAryData[1]);
String strLog = strCmd + "失败,失败原因: " + strErrorCode + "--" + "天线" + ((btAryData[0] & 0xFF) + 1);
writeLog(strLog, ERROR.FAIL);
} else if (btAryData.length == 0x07) { // 轮询正常结束
// m_nSwitchTotal, m_nSwitchTime
int nSwitchTotal = (btAryData[0] & 0xFF) * 255 * 255 + (btAryData[1] & 0xFF) * 255 + (btAryData[2] & 0xFF);
int nSwitchTime = (btAryData[3] & 0xFF) * 255 * 255 * 255 + (btAryData[4] & 0xFF) * 255 * 255 + (btAryData[5] & 0xFF) * 255 + (btAryData[6] & 0xFF);
m_curInventoryBuffer.nDataCount = nSwitchTotal;
m_curInventoryBuffer.nCommandDuration = nSwitchTime;
writeLog(strCmd, ERROR.SUCCESS);
refreshFastSwitch(INVENTORY_END, m_curInventoryBuffer);
runLoopFastSwitch();
} else {
m_nTotal++;
int nLength = btAryData.length;
int nEpcLength = nLength - 4;
// 增加盘存明细表
String strEPC = StringTool.byteArrayToString(btAryData, 3, nEpcLength);
String strPC = StringTool.byteArrayToString(btAryData, 1, 2);
String strRSSI = String.valueOf(btAryData[nLength - 1] & 0xFF);
setMaxMinRSSI(btAryData[nLength - 1] & 0xFF);
byte btTemp = btAryData[0];
byte btAntId = (byte) ((btTemp & 0x03) + 1);
m_curInventoryBuffer.nCurrentAnt = btAntId & 0xFF;
// String strAntId = String.valueOf(btAntId & 0xFF);
byte btFreq = (byte) ((btTemp & 0xFF) >> 2);
String strFreq = getFreqString(btFreq);
InventoryTagMap tag = null;
Integer findIndex = m_curInventoryBuffer.dtIndexMap.get(strEPC);
if (findIndex == null) {
tag = new InventoryTagMap();
tag.strPC = strPC;
//tag.strEPC = tools.covertAscii(strEPC.replace(" ",""));
tag.strEPC = strEPC;
tag.strRSSI = strRSSI;
tag.nReadCount = 1;
tag.strFreq = strFreq;
tag.nAnt1 = 0;
tag.nAnt2 = 0;
tag.nAnt3 = 0;
tag.nAnt4 = 0;
switch (btAntId) {
case 0x01:
tag.nAnt1 = 1;
break;
case 0x02:
tag.nAnt2 = 1;
break;
case 0x03:
tag.nAnt3 = 1;
break;
case 0x04:
tag.nAnt4 = 1;
break;
default:
break;
}
m_curInventoryBuffer.lsTagList.add(tag);
m_curInventoryBuffer.dtIndexMap.put(strEPC, m_curInventoryBuffer.lsTagList.size() - 1);
} else {
tag = m_curInventoryBuffer.lsTagList.get(findIndex);
tag.strRSSI = strRSSI;
tag.nReadCount++;
;
tag.strFreq = strFreq;
switch (btAntId) {
case 0x01:
tag.nAnt1++;
break;
case 0x02:
tag.nAnt2++;
break;
case 0x03:
tag.nAnt3++;
break;
case 0x04:
tag.nAnt4++;
break;
default:
break;
}
}
m_curInventoryBuffer.dtEndInventory = new Date();
refreshFastSwitch(btCmd, m_curInventoryBuffer);
}
}
/**
* processCustomizedSessionTargetInventory 与 processRealTimeInventory 返回一致。
*
* @param msgTran
* 消息包内容
*/
private void processCustomizedSessionTargetInventory(MessageTran msgTran) {
processRealTimeInventory(msgTran);
}
private void processSetImpinjFastTid(MessageTran msgTran) {
processSet(msgTran);
}
private void processSetAndSaveImpinjFastTid(MessageTran msgTran) {
processSet(msgTran);
}
private void processGetImpinjFastTid(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
if (btAryData[0] == 0x00 || (btAryData[0] & 0xFF) == 0x8D) {
m_curReaderSetting.btReadId = msgTran.getReadId();
m_curReaderSetting.btMonzaStatus = btAryData[0];
refreshReaderSetting(btCmd, m_curReaderSetting);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
}
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processGetInventoryBuffer(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
} else {
int nDataLen = btAryData.length;
int nEpcLen = (btAryData[2] & 0xFF) - 4;
String strPC = StringTool.byteArrayToString(btAryData, 3, 2);
String strEPC = StringTool.byteArrayToString(btAryData, 5, nEpcLen);
String strCRC = StringTool.byteArrayToString(btAryData, 5 + nEpcLen, 2);
String strRSSI = String.valueOf(btAryData[nDataLen - 3] & 0xFF);
setMaxMinRSSI(btAryData[nDataLen - 3] & 0xFF);
byte btTemp = btAryData[nDataLen - 2];
byte btAntId = (byte) ((btTemp & 0x03) + 1);
int nReadCount = btAryData[nDataLen - 1] & 0xFF;
InventoryTagMap tag = new InventoryTagMap();
tag.strPC = strPC;
tag.strCRC = strCRC;
//tag.strEPC = tools.covertAscii(strEPC.replace(" ",""));
tag.strEPC = strEPC;
tag.btAntId = btAntId;
tag.strRSSI = strRSSI;
tag.nReadCount = nReadCount;
m_curInventoryBuffer.lsTagList.add(tag);
m_curInventoryBuffer.dtIndexMap.put(strEPC, m_curInventoryBuffer.lsTagList.size() - 1);
refreshInventory(btCmd, m_curInventoryBuffer);
writeLog(strCmd, ERROR.SUCCESS);
}
}
/**
* processGetAndResetInventoryBuffer 和 processGetInventoryBuffer 返回一致。
*
* @param msgTran
* 消息包内容
*/
private void processGetAndResetInventoryBuffer(MessageTran msgTran) {
processGetInventoryBuffer(msgTran);
}
private void processGetInventoryBufferTagCount(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x02) {
m_curInventoryBuffer.nTagCount = (btAryData[0] & 0xFF) * 256 + (btAryData[1] & 0xFF);
refreshInventory(btCmd, m_curInventoryBuffer);
String strLog = strCmd + ":" + String.valueOf(m_curInventoryBuffer.nTagCount);
writeLog(strLog, ERROR.FAIL);
return;
} else if (btAryData.length == 0x01) {
strErrorCode = ERROR.format(btAryData[0]);
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void processResetInventoryBuffer(MessageTran msgTran) {
byte btCmd = msgTran.getCmd();
byte[] btAryData = msgTran.getAryData();
String strCmd = CMD.format(btCmd);
String strErrorCode = "";
if (btAryData.length == 0x01) {
if (btAryData[0] == ERROR.SUCCESS) {
refreshInventory(btCmd, m_curInventoryBuffer);
writeLog(strCmd, ERROR.SUCCESS);
return;
} else {
strErrorCode = ERROR.format(btAryData[0]);
}
} else {
strErrorCode = "未知错误";
}
String strLog = strCmd + "失败,失败原因: " + strErrorCode;
writeLog(strLog, ERROR.FAIL);
}
private void setMaxMinRSSI(int nRSSI) {
if (m_curInventoryBuffer.nMaxRSSI < nRSSI) {
m_curInventoryBuffer.nMaxRSSI = nRSSI;
}
if (m_curInventoryBuffer.nMinRSSI == 0) {
m_curInventoryBuffer.nMinRSSI = nRSSI;
} else if (m_curInventoryBuffer.nMinRSSI > nRSSI) {
m_curInventoryBuffer.nMinRSSI = nRSSI;
}
}
private String getFreqString(byte btFreq) {
if (m_curReaderSetting.btRegion == 4) {
float nExtraFrequency = (float) (btFreq & 0xFF) * (m_curReaderSetting.btUserDefineFrequencyInterval & 0xFF) * 10;
float nstartFrequency = (float) ((float) (m_curReaderSetting.nUserDefineStartFrequency & 0xFF)) / 1000;
float nStart = (float) (nstartFrequency + nExtraFrequency / 1000);
String strTemp = String.format("%.3f", nStart);
return strTemp;
} else {
if ((btFreq & 0xFF) < 0x07) {
float nStart = (float) (865.00f + (float) (btFreq & 0xFF) * 0.5f);
String strTemp = String.format("%.2f", nStart);
return strTemp;
} else {
float nStart = (float) (902.00f + ((float) (btFreq & 0xFF) - 7) * 0.5f);
String strTemp = String.format("%.2f", nStart);
return strTemp;
}
}
}
/**
* 循环盘询
*/
private void runLoopInventroy() {
Log.i("toolsdebug", "runLoopInventroy runLoopInventroy");
if (m_curInventoryBuffer.bLoopInventoryReal) {
// m_bLockTab = true;
// btnInventory.Enabled = false;
if (m_curInventoryBuffer.bLoopCustomizedSession) { // 自定义Session和Inventoried
Log.i("toolsdebug", "bLoopCustomizedSession bLoopCustomizedSession"); // Flag
mReader.customizedSessionTargetInventory(m_curReaderSetting.btReadId, m_curInventoryBuffer.btSession, m_curInventoryBuffer.btTarget, m_curInventoryBuffer.btRepeat);
} else { // 实时盘存
Log.i("ReaderHelper", "runLoopInventroy realTimeInventory");
mReader.realTimeInventory(m_curReaderSetting.btReadId, m_curInventoryBuffer.btRepeat);
}
} else if (m_curInventoryBuffer.bLoopInventory) {
Log.i("ReaderHelper", "runLoopInventroy inventory");
mReader.inventory(m_curReaderSetting.btReadId, m_curInventoryBuffer.btRepeat);
}
/*
* //校验盘存是否所有天线均完成 if ( m_curInventoryBuffer.nIndexAntenna <
* m_curInventoryBuffer.lAntenna.size() - 1 ||
* m_curInventoryBuffer.nCommond == 0) {
*
* if (m_curInventoryBuffer.nCommond == 0) {
* m_curInventoryBuffer.nCommond = 1;
*
* if (m_curInventoryBuffer.bLoopInventoryReal) { //m_bLockTab = true;
* //btnInventory.Enabled = false; if
* (m_curInventoryBuffer.bLoopCustomizedSession) {
* //自定义Session和Inventoried Flag
* //mReader.customizedSessionTargetInventory
* (m_curReaderSetting.btReadId, m_curInventoryBuffer.btSession,
* m_curInventoryBuffer.btTarget, m_curInventoryBuffer.btRepeat); } else
* { //实时盘存 mReader.realTimeInventory(m_curReaderSetting.btReadId,
* m_curInventoryBuffer.btRepeat);
*
* } } else if (m_curInventoryBuffer.bLoopInventory) {
* mReader.inventory(m_curReaderSetting.btReadId,
* m_curInventoryBuffer.btRepeat); } } else {
* m_curInventoryBuffer.nCommond = 0;
* m_curInventoryBuffer.nIndexAntenna++;
*
* byte btWorkAntenna =
* m_curInventoryBuffer.lAntenna.get(m_curInventoryBuffer
* .nIndexAntenna); mReader.setWorkAntenna(m_curReaderSetting.btReadId,
* btWorkAntenna); m_curReaderSetting.btWorkAntenna = btWorkAntenna; } }
* else if (m_curInventoryBuffer.bLoopInventory ||
* m_curInventoryBuffer.bLoopInventoryReal) { //校验是否循环盘存
* m_curInventoryBuffer.nIndexAntenna = 0; m_curInventoryBuffer.nCommond
* = 0;
*
* byte btWorkAntenna =
* m_curInventoryBuffer.lAntenna.get(m_curInventoryBuffer
* .nIndexAntenna); mReader.setWorkAntenna(m_curReaderSetting.btReadId,
* btWorkAntenna); m_curReaderSetting.btWorkAntenna = btWorkAntenna; }
*/
}
private void runLoopFastSwitch() {
if (m_curInventoryBuffer.bLoopInventory) {
mReader.fastSwitchAntInventory(m_curReaderSetting.btReadId, m_curInventoryBuffer.btA, m_curInventoryBuffer.btStayA, m_curInventoryBuffer.btB, m_curInventoryBuffer.btStayB, m_curInventoryBuffer.btC, m_curInventoryBuffer.btStayC, m_curInventoryBuffer.btD, m_curInventoryBuffer.btStayD, m_curInventoryBuffer.btInterval, m_curInventoryBuffer.btFastRepeat);
}
}
}
package com.fn.useries.utils;
import android.os.Environment;
import com.fn.useries.reader.model.InventoryBuffer.InventoryTagMap;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class FileUtil {
public static boolean saveInventoryData(List<InventoryTagMap> data) {
FileOutputStream fos = null;
try {
Date time = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HHmmss", Locale.CHINA);
String dateString = formatter.format(time);
File path = Environment.getExternalStorageDirectory();
File file = new File(path + "/fn_log/U8/" + dateString + System.currentTimeMillis() + ".csv");
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
fos = new FileOutputStream(file);
String header="ID,EPC,PC,Count,RSSI,RISS\r\n";
fos.write(header.getBytes());
for(int i=0;i<data.size();i++){
String ID= String.valueOf(i+1);
String epc=data.get(i).strEPC;
String PC=data.get(i).strPC;
int Count=data.get(i).nReadCount;
String RSSI=(Integer.parseInt(data.get(i).strRSSI) - 129) +"";
String RISS=data.get(i).strFreq;
String datas=ID+","+epc+","+PC+","+Count+","+RSSI+","+RISS+"\r\n";
fos.write(datas.getBytes());
fos.flush();
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
return true;
}
}
package com.fn.useries.utils;
import android.util.Log;
import java.io.FileOutputStream;
public class M10_GPIO {
public static void _14443A_PowerOn() {
writeFile("/sys/bus/platform/devices/odroid-sysfs/ic14443a_enable", "1");
writeFile(
"/sys/bus/platform/devices/odroid-sysfs/ic14443a_serial_switch",
"0");
}
public static void _14443A_PowerOFF() {
writeFile("/sys/bus/platform/devices/odroid-sysfs/ic14443a_enable", "0");
writeFile(
"/sys/bus/platform/devices/odroid-sysfs/ic14443a_serial_switch",
"0");
}
public static void Infrared_PowerOn() {
writeFile("/syss/platform/devices/odroid-sysfs/infrared_enable_switch",
"0");
}
public static void Infrared_PowerOFF() {
writeFile("/syss/platform/devices/odroid-sysfs/rfid_serial_switch", "0");
}
public static void R1000_PowerOn() {
writeFile("/sys/bus/platform/devices/odroid-sysfs/r1000_enable", "1");
writeFile("/sys/bus/platform/devices/odroid-sysfs/r1000_serial_switch",
"1");
}
public static void R1000_PowerOFF() {
writeFile("/sys/bus/platform/devices/odroid-sysfs/r1000_enable", "0");
writeFile("/sys/bus/platform/devices/odroid-sysfs/r1000_serial_switch",
"0");
}
public static void W433_PowerOn() {
writeFile("/sys/bus/platform/devices/odroid-sysfs/rfid_enable", "1");
writeFile("/sys/ bus/platform/devices/odroid-sysfs/rfid_serial_switch",
"0");
}
public static void W433_PowerOff() {
writeFile("/sys/bus/platform/devices/odroid-sysfs/rfid_enable", "0");
writeFile("/sys/ bus/platform/devices/odroid-sysfs/rfid_serial_switch",
"0");
}
private static void writeF() {
/*
* String cmd = "chmod 666 " + device.getAbsolutePath() + "\n" +
* "exit\n"; su.getOutputStream().write(cmd.getBytes());
*/
}
// 写数据
private static boolean writeFile(String fileName, String writestr) {
try {
// Process su = Runtime.getRuntime().exec("su"); // /system/bin/
FileOutputStream fout = new FileOutputStream(fileName);
byte[] bytes = writestr.getBytes();
fout.write(bytes);
fout.close();
} catch (Exception e) {
e.printStackTrace();
Log.e("M10_GPIO", e.getMessage());
return false;
}
return true;
}
}
package com.fn.useries.utils;
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import com.stm.asset.R;
import com.stm.asset.base.StmApplication;
import java.util.Map;
import java.util.TreeMap;
public class MusicPlayer {
private Context mContext;
private static MusicPlayer sInstance;
public static class Type {
public final static int OK = 1;
public final static int MUSIC_ERROR = 2;
}
private SoundPool mSp;
private Map<Integer, Integer> sSpMap;
private MusicPlayer(Context context) {
mContext = context;
sSpMap = new TreeMap<Integer, Integer>();
mSp = new SoundPool(2, AudioManager.STREAM_MUSIC, 100);
sSpMap.put(Type.OK, mSp.load(mContext, R.raw.ok, 1));
sSpMap.put(Type.MUSIC_ERROR, mSp.load(mContext, R.raw.error, 1));
// sSpMap.put(Type.MUSIC_FOCUSED, mSp.load(mContext, R.raw.focused, 1))
// ;
}
static {
sInstance = new MusicPlayer(StmApplication.getInstance().getApplicationContext());
}
public static MusicPlayer getInstance() {
return sInstance;
}
public void play(int type) {
if (U8Property.getSoftSound() == 0) {
return;
}
if (sSpMap.get(type) == null)
return;
mSp.play(sSpMap.get(type), 1, 1, 0, 0, 1);
}
}
\ No newline at end of file
package com.fn.useries.utils;
import java.util.ArrayList;
import java.util.regex.Pattern;
public class StringTool {
/**
* 字符串转16进制数组,字符串以空格分割。
* @param strHexValue 16进制字符串
* @return 数组
*/
public static byte[] stringToByteArray(String strHexValue) {
String[] strAryHex = strHexValue.split(" ");
byte[] btAryHex = new byte[strAryHex.length];
try {
int nIndex = 0;
for (String strTemp : strAryHex) {
btAryHex[nIndex] = (byte) Integer.parseInt(strTemp, 16);
nIndex++;
}
} catch (NumberFormatException e) {
}
return btAryHex;
}
/**
* 字符数组转为16进制数组。
* @param strAryHex 要转换的字符串数组
* @param nLen 长度
* @return 数组
*/
public static byte[] stringArrayToByteArray(String[] strAryHex, int nLen) {
if (strAryHex == null) return null;
if (strAryHex.length < nLen) {
nLen = strAryHex.length;
}
byte[] btAryHex = new byte[nLen];
try {
for (int i = 0; i < nLen; i++) {
btAryHex[i] = (byte) Integer.parseInt(strAryHex[i], 16);
}
} catch (NumberFormatException e) {
}
return btAryHex;
}
/**
* 16进制字符数组转成字符串。
* @param btAryHex 要转换的字符串数组
* @param nIndex 起始位置
* @param nLen 长度
* @return 字符串
*/
public static String byteArrayToString(byte[] btAryHex, int nIndex, int nLen) {
if (nIndex + nLen > btAryHex.length) {
nLen = btAryHex.length - nIndex;
}
String strResult = String.format("%02X", btAryHex[nIndex]);
for (int nloop = nIndex + 1; nloop < nIndex + nLen; nloop++ ) {
String strTemp = String.format(" %02X", btAryHex[nloop]);
strResult += strTemp;
}
return strResult;
}
/**
* 将字符串按照指定长度截取并转存为字符数组,空格忽略。
* @param strValue 输入字符串
* @return 数组
*/
public static String[] stringToStringArray(String strValue, int nLen) {
String[] strAryResult = null;
if (strValue != null && !strValue.equals("")) {
ArrayList<String> strListResult = new ArrayList<String>();
String strTemp = "";
int nTemp = 0;
for (int nloop = 0; nloop < strValue.length(); nloop++) {
if (strValue.charAt(nloop) == ' ') {
continue;
} else {
nTemp++;
if (!Pattern.compile("^(([A-F])*([a-f])*(\\d)*)$")
.matcher(strValue.substring(nloop, nloop + 1))
.matches()) {
return strAryResult;
}
strTemp += strValue.substring(nloop, nloop + 1);
//判断是否到达截取长度
if ((nTemp == nLen) || (nloop == strValue.length() - 1
&& (strTemp != null && !strTemp.equals("")))) {
strListResult.add(strTemp);
nTemp = 0;
strTemp = "";
}
}
}
if (strListResult.size() > 0) {
strAryResult = new String[strListResult.size()];
for (int i = 0; i < strAryResult.length; i++) {
strAryResult[i] = strListResult.get(i);
}
}
}
return strAryResult;
}
}
package com.fn.useries.utils;
import android.util.Log;
import com.fn.useries.reader.model.InventoryBuffer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
public class Tools {
// byte 转十六进制
public static String Bytes2HexString(byte[] b, int size) {
String ret = "";
for (int i = 0; i < size; i++) {
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1) {
hex = "0" + hex;
}
ret += hex.toUpperCase();
}
return ret;
}
public static byte uniteBytes(byte src0, byte src1) {
byte _b0 = Byte.decode("0x" + new String(new byte[] { src0 })).byteValue();
_b0 = (byte) (_b0 << 4);
byte _b1 = Byte.decode("0x" + new String(new byte[] { src1 })).byteValue();
byte ret = (byte) (_b0 ^ _b1);
return ret;
}
// 十六进制转byte
public static byte[] HexString2Bytes(String src) {
int len = src.length() / 2;
byte[] ret = new byte[len];
byte[] tmp = src.getBytes();
for (int i = 0; i < len; i++) {
ret[i] = uniteBytes(tmp[i * 2], tmp[i * 2 + 1]);
}
return ret;
}
/* byte[]转Int */
public static int bytesToInt(byte[] bytes) {
int addr = bytes[0] & 0xFF;
addr |= ((bytes[1] << 8) & 0xFF00);
addr |= ((bytes[2] << 16) & 0xFF0000);
addr |= ((bytes[3] << 25) & 0xFF000000);
return addr;
}
/* Int转byte[] */
public static byte[] intToByte(int i) {
byte[] abyte0 = new byte[4];
abyte0[0] = (byte) (0xff & i);
abyte0[1] = (byte) ((0xff00 & i) >> 8);
abyte0[2] = (byte) ((0xff0000 & i) >> 16);
abyte0[3] = (byte) ((0xff000000 & i) >> 24);
return abyte0;
}
/**
* 获取系统时间,时间格式为: 年-月-日 时:分 秒
*
* @return
*/
public static String getTime() {
String model = "yyyy-MM-dd HH:mm:ss";
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat(model);
String dateTime = format.format(date);
return dateTime;
}
public static byte getCRC(byte[] cmd, int pos, int len) {
byte crc = (byte) 0x00;
for (int i = pos; i < len - 1; i++) {
crc += cmd[i];
}
return crc;
}
/**
* 字符串转16进制数组,字符串以空格分割。
*
* @param strHexValue
* 16进制字符串
* @return 数组
*/
public static byte[] stringToByteArray(String strHexValue) {
String[] strAryHex = strHexValue.split(" ");
byte[] btAryHex = new byte[strAryHex.length];
try {
int nIndex = 0;
for (String strTemp : strAryHex) {
btAryHex[nIndex] = (byte) Integer.parseInt(strTemp, 16);
nIndex++;
}
} catch (NumberFormatException e) {
}
return btAryHex;
}
/**
* 字符数组转为16进制数组。
*
* @param strAryHex
* 要转换的字符串数组
* @param nLen
* 长度
* @return 数组
*/
public static byte[] stringArrayToByteArray(String[] strAryHex, int nLen) {
if (strAryHex == null)
return null;
if (strAryHex.length < nLen) {
nLen = strAryHex.length;
}
byte[] btAryHex = new byte[nLen];
try {
for (int i = 0; i < nLen; i++) {
btAryHex[i] = (byte) Integer.parseInt(strAryHex[i], 16);
}
} catch (NumberFormatException e) {
}
return btAryHex;
}
/**
* 16进制字符数组转成字符串。
*
* @param btAryHex
* 要转换的字符串数组
* @param nIndex
* 起始位置
* @param nLen
* 长度
* @return 字符串
*/
public static String byteArrayToString(byte[] btAryHex, int nIndex, int nLen) {
if (nIndex + nLen > btAryHex.length) {
nLen = btAryHex.length - nIndex;
}
String strResult = String.format("%02X", btAryHex[nIndex]);
for (int nloop = nIndex + 1; nloop < nIndex + nLen; nloop++) {
String strTemp = String.format(" %02X", btAryHex[nloop]);
strResult += strTemp;
}
return strResult;
}
/**
* 将字符串按照指定长度截取并转存为字符数组,空格忽略。
*
* @param strValue
* 输入字符串
* @return 数组
*/
public static String[] stringToStringArray(String strValue, int nLen) {
String[] strAryResult = null;
if (strValue != null && !strValue.equals("")) {
ArrayList<String> strListResult = new ArrayList<String>();
String strTemp = "";
int nTemp = 0;
for (int nloop = 0; nloop < strValue.length(); nloop++) {
if (strValue.charAt(nloop) == ' ') {
continue;
} else {
nTemp++;
if (!Pattern.compile("^(([A-F])*([a-f])*(\\d)*)$").matcher(strValue.substring(nloop, nloop + 1)).matches()) {
return strAryResult;
}
strTemp += strValue.substring(nloop, nloop + 1);
// 判断是否到达截取长度
if ((nTemp == nLen) || (nloop == strValue.length() - 1 && (strTemp != null && !strTemp.equals("")))) {
strListResult.add(strTemp);
nTemp = 0;
strTemp = "";
}
}
}
if (strListResult.size() > 0) {
strAryResult = new String[strListResult.size()];
for (int i = 0; i < strAryResult.length; i++) {
strAryResult[i] = strListResult.get(i);
}
}
}
return strAryResult;
}
/**
* 16进制转ASCII
*
* @param hex
* @return
*/
public static String covertAscii(String hex) {
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder();
//49204c6f7665204a617661 split into two characters 49, 20, 4c...
for (int i = 0; i < hex.length() - 1; i += 2) {
//grab the hex in pairs
String output = hex.substring(i, (i + 2));
//convert hex to decimal
int decimal = Integer.parseInt(output, 16);
//convert the decimal to character
sb.append((char) decimal);
temp.append(decimal);
}
return sb.toString();
}
/**
* 冒泡排序
* 比较相邻的元素。如果第一个比第二个大,就交换他们两个。
* 对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对。在这一点,最后的元素应该会是最大的数。
* 针对所有的元素重复以上的步骤,除了最后一个。
* 持续每次对越来越少的元素重复上面的步骤,直到没有任何一对数字需要比较。
*/
public static List<InventoryBuffer.InventoryTagMap> bubbleSort(List<InventoryBuffer.InventoryTagMap> list)
{
String temp = "";
int size = list.size();
for(int i = 0 ; i < size-1; i ++)
{
for(int j = 0 ;j < size-1-i ; j++)
{
if (list.get(j).strEPC.length()>3){
try {
if(Integer.parseInt(list.get(j).strEPC.substring(list.get(j).strEPC.length()-5)) > Integer.parseInt(list.get(j+1).strEPC.substring(list.get(j+1).strEPC.length()-5))) //交换两数位置
{
temp = list.get(j).strEPC;
list.get(j).strEPC = list.get(j+1).strEPC;
list.get(j+1).strEPC = temp;
}
}catch (Exception e){
Log.i("Tools", "bubbleSort: error");
}
}
}
}
return list;
}
}
package com.fn.useries.utils;
import android.content.Context;
import android.content.SharedPreferences;
import com.stm.asset.base.StmApplication;
/**
* 类名称:U8Property
* 类描述:U8本地存储信息
* 创建人:story
* 创建时间:2021-12-17 14:02
*/
public class U8Property {
private static final String PREFERENCES_SYSTEM = "preferences_u8";
private static final String KEY_SESSION = "_session";
private static final String KEY_FLAG = "_flag";
private static final String KEY_STATE = "_state";
private static final String KEY_SOFTWARE_SOUND = "_software_sound";
static public int getSessionState(){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
return spf.getInt(KEY_SESSION, 0);
}
static public void saveSessionState(int state){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = spf.edit();
editor.putInt(KEY_SESSION, state);
editor.apply();
}
static public int getFlagState(){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
//SharedPreferences.Editor editor = spf.edit();
int state = spf.getInt(KEY_FLAG, 0);
return state;
}
static public void saveFlagState(int state){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = spf.edit();
editor.putInt(KEY_FLAG, state);
editor.apply();
}
static public int getVeeperState(){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
return spf.getInt(KEY_STATE, 0);
}
static public void saveBeeperState(int state){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = spf.edit();
editor.putInt(KEY_STATE, state);
editor.apply();
}
static public int getSoftSound(){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf =context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
//SharedPreferences.Editor editor = spf.edit();
return spf.getInt(KEY_SOFTWARE_SOUND, 1);
}
static public void saveSoftSound(int state){
Context context = StmApplication.getInstance().getApplicationContext();
SharedPreferences spf = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = spf.edit();
editor.putInt(KEY_SOFTWARE_SOUND, state);
editor.apply();
}
}
package com.stm.asset.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.stm.asset.R;
import com.stm.asset.model.AddressInfo;
import com.stm.asset.utils.StringUtils;
import java.util.List;
/**
* 类名称:AddressAdapter
* 类描述:地址适配器
* 创建人:story
* 创建时间:2022-01-06 09:52
*/
public class AddressAdapter extends BaseAdapter {
private List<AddressInfo> dataList;
private Context context;
public AddressAdapter(Context context, List<AddressInfo> dataList) {
this.context = context;
this.dataList = dataList;
}
@Override
public int getCount() {
return dataList == null ? 0 : dataList.size();
}
@Override
public Object getItem(int position) {
return dataList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder vh;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.view_select_id_item, null);
vh = new ViewHolder();
vh.nameTxt = convertView.findViewById(R.id.select_ip_item_name);
vh.ipTxt = convertView.findViewById(R.id.select_ip_item_ip);
vh.platformTxt = convertView.findViewById(R.id.select_ip_item_platform);
vh.selectImage = convertView.findViewById(R.id.select_ip_item_select_image);
convertView.setTag(vh);
} else {
vh = (ViewHolder) convertView.getTag();
}
AddressInfo addressInfo = dataList.get(position);
vh.nameTxt.setText(addressInfo.getName());
// 处理ip
StringBuffer sbf = new StringBuffer();
if (addressInfo.isHttps()) {
sbf.append("https://");
} else {
sbf.append("http://");
}
sbf.append(addressInfo.getIp());
if (!StringUtils.isEmptyOrNull(addressInfo.getPort())) {
sbf.append(":");
sbf.append(addressInfo.getPort());
}
vh.ipTxt.setText(sbf.toString());
vh.platformTxt.setText(addressInfo.getPlatform());
return convertView;
}
private class ViewHolder {
private TextView nameTxt, ipTxt, platformTxt;
private ImageView selectImage;
}
}
package com.stm.asset.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.fn.useries.reader.model.InventoryBuffer;
import com.fn.useries.utils.Tools;
import com.stm.asset.R;
import com.stm.asset.utils.StringUtils;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
/**
* 类名称:InventoryAdapter
* 类描述:盘询数据展示适配器
* 创建人:story
* 创建时间:2021-12-09 15:34
*/
public class InventoryAdapter extends BaseAdapter {
private LayoutInflater inflater;
private List<InventoryBuffer.InventoryTagMap> dataList;
public InventoryAdapter(Context context) {
inflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return dataList == null ? 0 : dataList.size();
}
@Override
public Object getItem(int position) {
return dataList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView =inflater.inflate(R.layout.view_inventory_item, null);
// viewHolder.idTxt = convertView.findViewById(R.id.item_inventory_id_txt);
viewHolder.epcTxt = convertView.findViewById(R.id.item_inventory_epc_txt);
// viewHolder.pcTxt = convertView.findViewById(R.id.item_inventory_pc_txt);
// viewHolder.timesTxt = convertView.findViewById(R.id.item_inventory_times_txt);
// viewHolder.rssiTxt = convertView.findViewById(R.id.item_inventory_rssi_txt);
// viewHolder.freqTxt = convertView.findViewById(R.id.item_inventory_freq_txt);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
InventoryBuffer.InventoryTagMap inventoryTagMap = dataList.get(position);
// viewHolder.idTxt.setText(String.valueOf(position+1));
try {
String epcStr = inventoryTagMap.strEPC;
byte[] bytes = Tools.stringToByteArray(epcStr);
String str = new String(bytes, StandardCharsets.UTF_8);
viewHolder.epcTxt.setText(str);
} catch (Exception e) {
e.printStackTrace();
}
// viewHolder.pcTxt.setText(inventoryTagMap.strPC);
// viewHolder.timesTxt.setText(String.valueOf(inventoryTagMap.nReadCount));
// try {
// viewHolder.rssiTxt.setText((Integer.parseInt(inventoryTagMap.strRSSI) - 129) + "dBm");
// } catch (Exception e) {
// viewHolder.rssiTxt.setText("");
// }
// viewHolder.freqTxt.setText(inventoryTagMap.strFreq);
return convertView;
}
public void setData(List<InventoryBuffer.InventoryTagMap> data, boolean isReset) {
if (dataList == null) {
dataList = new ArrayList<>();
}
if (isReset) {
dataList.clear();
}
if (data != null && data.size() > 0) {
// 处理标签数据
for (InventoryBuffer.InventoryTagMap item : data) {
String epcStr = item.strEPC;
if (!StringUtils.isEmptyOrNull(epcStr)) {
if (!hasItem(epcStr)) {
try {
byte[] bytes = Tools.stringToByteArray(epcStr);
String str = new String(bytes, StandardCharsets.UTF_8).trim();
if (StringUtils.isNumber(str)) {
dataList.add(item);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
notifyDataSetChanged();
}
private boolean hasItem(String epc) {
for (InventoryBuffer.InventoryTagMap item : dataList) {
String epcStr = item.strEPC;
if (epc.equals(epcStr)) {
return true;
}
}
return false;
}
public List<InventoryBuffer.InventoryTagMap> queryData() {
return dataList;
}
private class ViewHolder {
// private TextView idTxt, epcTxt, pcTxt, timesTxt, rssiTxt, freqTxt;
private TextView epcTxt;
}
}
package com.stm.asset.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.stm.asset.R;
import com.stm.asset.model.InventoryInfo;
import java.util.ArrayList;
import java.util.List;
/**
* 类名称:TaskAdapter
* 类描述:盘点任务适配器
* 创建人:story
* 创建时间:2021-12-07 15:27
*/
public class TaskAdapter extends BaseAdapter {
private LayoutInflater inflater;
private List<InventoryInfo> dataList;
public TaskAdapter(Context context) {
inflater = LayoutInflater.from(context);
}
@Override
public int getCount() {
return dataList == null ? 0 : dataList.size();
}
@Override
public Object getItem(int position) {
return dataList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
if (convertView == null) {
viewHolder = new ViewHolder();
convertView =inflater.inflate(R.layout.view_check_task_item, null);
// viewHolder.nameTxt = convertView.findViewById(R.id.task_item_name_txt);
viewHolder.numberTxt = convertView.findViewById(R.id.task_item_number_txt);
// viewHolder.userTxt = convertView.findViewById(R.id.task_item_user_txt);
// viewHolder.deptTxt = convertView.findViewById(R.id.task_item_dept_txt);
viewHolder.statusTxt = convertView.findViewById(R.id.task_item_status_txt);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
InventoryInfo taskInfo = dataList.get(position);
// viewHolder.nameTxt.setText(taskInfo.getName());
viewHolder.numberTxt.setText(taskInfo.getNumber());
// viewHolder.userTxt.setText(taskInfo.getUserName());
// viewHolder.deptTxt.setText(taskInfo.getUserDept());
String statusName = "";
if ("0".equals(taskInfo.getStatus())) {
statusName = "未上传";
} else if ("1".equals(taskInfo.getStatus())) {
statusName = "上传失败";
} else if ("2".equals(taskInfo.getStatus())) {
statusName = "上传成功";
}
viewHolder.statusTxt.setText(statusName);
return convertView;
}
public void setData(List<InventoryInfo> data) {
if (dataList == null) {
dataList = new ArrayList<>();
}
dataList.clear();
if (data != null && data.size() > 0) {
dataList.addAll(data);
}
notifyDataSetChanged();
}
private class ViewHolder {
// private TextView nameTxt, numberTxt, userTxt, deptTxt, statusTxt;
private TextView numberTxt, statusTxt;
}
}
package com.stm.asset.base;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.NonNull;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
/**
* 类名称:AppExecutors
* 类描述:线程管理
* 创建人:story
* 创建时间:2021-12-23 14:56
*/
public class AppExecutors {
private final Executor mDiskIO;
private final Executor mNetworkIO;
private final Executor mMainThread;
private AppExecutors(Executor diskIO, Executor networkIO, Executor mainThread) {
this.mDiskIO = diskIO;
this.mNetworkIO = networkIO;
this.mMainThread = mainThread;
}
public AppExecutors() {
this(Executors.newSingleThreadExecutor(), Executors.newFixedThreadPool(3), new MainThreadExecutor());
}
public Executor diskIO() {
return mDiskIO;
}
public Executor networkIO() {
return mNetworkIO;
}
public Executor mainThread() {
return mMainThread;
}
private static class MainThreadExecutor implements Executor {
private Handler mainThreadHandler = new Handler(Looper.getMainLooper());
@Override
public void execute(@NonNull Runnable command) {
mainThreadHandler.post(command);
}
}
}
package com.stm.asset.base;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.stm.asset.R;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.List;
import me.jessyan.autosize.internal.CustomAdapt;
/**
* 类名称:BaseActivity
* 类描述:Activity基类
* 创建人:story
* 创建时间:2021-08-07 09:47
*/
public abstract class BaseActivity extends Activity implements CustomAdapt {
protected WeakReference<Activity> weakReference;
protected StmApplication sApp;
protected TextView titleTxt, backTxt, rightTxt;
protected ImageView backImg, rightImg;
protected LinearLayout backLayout, rightLayout;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sApp = StmApplication.getInstance();
weakReference = new WeakReference<>((Activity) this);
sApp.enterActivity(weakReference);
}
protected void initTitle(){
try {
titleTxt = findViewById(R.id.common_title_middle_txt);
backImg = findViewById(R.id.common_title_back_img);
backTxt = findViewById(R.id.common_title_back_txt);
backLayout = findViewById(R.id.common_title_back_layout);
rightImg = findViewById(R.id.common_title_right_img);
rightTxt = findViewById(R.id.common_title_right_txt);
rightLayout = findViewById(R.id.common_title_right_layout);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onStop() {
super.onStop();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!isAppOnForeground()) {
try {
// 弹出Toast提示
StmApplication.getInstance().getCurrentAct().runOnUiThread(new Runnable() {
@Override
public void run() {
if (StmApplication.getInstance().isShowBackground()) {
StmApplication.getInstance().showToastShort(StmApplication.getInstance().getResources().getString(R.string.app_name) + "已经被切到后台运行");
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
}, 500);
}
@Override
protected void onDestroy() {
sApp.removeActivity(weakReference);
super.onDestroy();
}
@Override
public boolean isBaseOnWidth() {
return false;
}
@Override
public float getSizeInDp() {
return 846;
}
private boolean isAppOnForeground() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
String runningActivityPackageName;
int sdkVersion;
try {
sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK);
} catch (NumberFormatException e) {
sdkVersion = 0;
}
if (sdkVersion >= 21) {
runningActivityPackageName = getCurrentPkgName(getApplicationContext());
} else {
runningActivityPackageName = activityManager.getRunningTasks(1).get(0).topActivity.getPackageName();
}
if (getPackageName().equals(runningActivityPackageName)) {
return true;
}
return false;
}
private static String getCurrentPkgName(Context context) {
// 5x系统以后利用反射获取当前栈顶activity的包名.
ActivityManager.RunningAppProcessInfo currentInfo = null;
Field field = null;
int START_TASK_TO_FRONT = 2;
String pkgName = null;
try {
// 通过反射获取进程状态字段.
field = ActivityManager.RunningAppProcessInfo.class.getDeclaredField("processState");
} catch (Exception e) {
e.printStackTrace();
}
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List appList = am.getRunningAppProcesses();
ActivityManager.RunningAppProcessInfo app;
for (int i = 0; i < appList.size(); i++) {
app = (ActivityManager.RunningAppProcessInfo) appList.get(i);
//表示前台运行进程.
if (app.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
Integer state = null;
try {
state = field.getInt(app);// 反射调用字段值的方法,获取该进程的状态.
} catch (Exception e) {
e.printStackTrace();
}
// 根据这个判断条件从前台中获取当前切换的进程对象
if (state != null && state == START_TASK_TO_FRONT) {
currentInfo = app;
break;
}
}
}
if (currentInfo != null) {
pkgName = currentInfo.processName;
}
return pkgName;
}
}
package com.stm.asset.base;
import androidx.fragment.app.Fragment;
/**
* 类名称:BaseFragment
* 类描述:BaseFragment基类
* 创建人:story
* 创建时间:2021-12-07 14:40
*/
public abstract class BaseFragment extends Fragment {
}
package com.stm.asset.base;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import com.stm.asset.R;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.List;
import me.jessyan.autosize.internal.CustomAdapt;
/**
* 类名称:BaseFragmentActivity
* 类描述:FragmentActivity基类
* 创建人:story
* 创建时间:2021-12-07 13:48
*/
public abstract class BaseFragmentActivity extends FragmentActivity implements CustomAdapt {
protected WeakReference<Activity> weakReference;
protected StmApplication sApp;
protected TextView titleTxt, backTxt, rightTxt;
protected ImageView backImg, rightImg;
protected LinearLayout backLayout, rightLayout;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sApp = StmApplication.getInstance();
weakReference = new WeakReference<>((Activity) this);
sApp.enterActivity(weakReference);
}
protected void initTitle(){
try {
titleTxt = findViewById(R.id.common_title_middle_txt);
backImg = findViewById(R.id.common_title_back_img);
backTxt = findViewById(R.id.common_title_back_txt);
backLayout = findViewById(R.id.common_title_back_layout);
rightImg = findViewById(R.id.common_title_right_img);
rightTxt = findViewById(R.id.common_title_right_txt);
rightLayout = findViewById(R.id.common_title_right_layout);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onStop() {
super.onStop();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (!isAppOnForeground()) {
try {
// 弹出Toast提示
StmApplication.getInstance().getCurrentAct().runOnUiThread(new Runnable() {
@Override
public void run() {
if (StmApplication.getInstance().isShowBackground()) {
StmApplication.getInstance().showToastShort(StmApplication.getInstance().getResources().getString(R.string.app_name) + "已经被切到后台运行");
}
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}
}, 500);
}
@Override
protected void onDestroy() {
sApp.removeActivity(weakReference);
super.onDestroy();
}
@Override
public boolean isBaseOnWidth() {
return false;
}
@Override
public float getSizeInDp() {
return 846;
}
private boolean isAppOnForeground() {
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
String runningActivityPackageName;
int sdkVersion;
try {
sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK);
} catch (NumberFormatException e) {
sdkVersion = 0;
}
if (sdkVersion >= 21) {
runningActivityPackageName = getCurrentPkgName(getApplicationContext());
} else {
runningActivityPackageName = activityManager.getRunningTasks(1).get(0).topActivity.getPackageName();
}
if (getPackageName().equals(runningActivityPackageName)) {
return true;
}
return false;
}
private static String getCurrentPkgName(Context context) {
// 5x系统以后利用反射获取当前栈顶activity的包名.
ActivityManager.RunningAppProcessInfo currentInfo = null;
Field field = null;
int START_TASK_TO_FRONT = 2;
String pkgName = null;
try {
// 通过反射获取进程状态字段.
field = ActivityManager.RunningAppProcessInfo.class.getDeclaredField("processState");
} catch (Exception e) {
e.printStackTrace();
}
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List appList = am.getRunningAppProcesses();
ActivityManager.RunningAppProcessInfo app;
for (int i = 0; i < appList.size(); i++) {
app = (ActivityManager.RunningAppProcessInfo) appList.get(i);
//表示前台运行进程.
if (app.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
Integer state = null;
try {
state = field.getInt(app);// 反射调用字段值的方法,获取该进程的状态.
} catch (Exception e) {
e.printStackTrace();
}
// 根据这个判断条件从前台中获取当前切换的进程对象
if (state != null && state == START_TASK_TO_FRONT) {
currentInfo = app;
break;
}
}
}
if (currentInfo != null) {
pkgName = currentInfo.processName;
}
return pkgName;
}
}
package com.stm.asset.base;
public class ConfigKey {
public final static String GATEWAYIP = "mfms.citictrust.com.cn";
public final static String GATWAYPORT = "";
// http://10.50.251.101 18081 测试地址
// https://fms.citictrust.com.cn 生产地址
public final static String PLAYFORM = "FMPAPP";
// CJFKAPP 长江养老
public final static String SIGNATURENAME = "stream"; // 测试环境请配置成stream(生产环境具体再通知)
public final static String SIGNATUREPASSWORD = "stream123"; // 测试环境请配置成stream123(生产环境具体再通知)
public final static String HTTPS_CERTIFICATION_NAME = "feiyongmofang.cer";
public final static boolean DEBUG = true; // 是否打印测试数据
public final static boolean ISOPENHTTPS = true; // 是否开启https请求方式
}
package com.stm.asset.base;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import java.util.List;
/**
* 类名称:FragPageAdapter
* 类描述:Fragment页面适配器
* 创建人:story
* 创建时间:2021-12-07 16:41
*/
public class FragPageAdapter extends FragmentPagerAdapter {
private List<Fragment> fragmentsList;
public FragPageAdapter(FragmentManager fm) {
super(fm);
}
public FragPageAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragmentsList = fragments;
}
@Override
public int getCount() {
return fragmentsList.size();
}
@NonNull
@Override
public Fragment getItem(int arg0) {
return fragmentsList.get(arg0);
}
@Override
public int getItemPosition(@NonNull Object object) {
return super.getItemPosition(object);
}
}
package com.stm.asset.base;
public class InterfaceKey {
private final static String GETWAY = "GATEWAY/";
public final static String UNIONLOGINAPP = GETWAY + "app/login"; // 登录
public final static String QURYPAGEHOMEUSERINFO = GETWAY + "app/quryPageHomeUserInfo"; // 获取用户信息
public final static String QUERYVERSIONAPP = GETWAY + "queryAppVersionApp"; // 查询版本号
public final static String SCANINVENTORY = GETWAY + "app/ams/scanInventory"; // 上传资产编号
public final static String KRMOBILE = "/krmobile/";
/**
* 首模块
*/
public final static String LOGIN = GETWAY + "unionLoginApp.app"; // 登录
public final static String CHECKCONNECT = GETWAY + "checkConnectApp"; // 测试连接
public final static String CHANGEPASSWORDAPP = GETWAY + "changePasswordApp"; // 修改密码
public final static String GETCHECKCODEAPP = GETWAY + "getCheckcodeApp"; // 获取验证码
public final static String RESETPASSWORDBYEMAILAPP = GETWAY + "resetPassWordByEmailApp"; // 邮箱重置密码
public final static String GETPHONECODEAPP = GETWAY + "getPhoneCodeApp"; // 获取手机验证码
public final static String RESETPASSWORDBYPHONEAPP = GETWAY + "resetPassWordByPhoneApp"; // 通过手机重置密码
public final static String CHECKPSWBYPHONEAPP = GETWAY + "checkPswByPhoneApp"; //
public final static String UPDATEMOBILEPHONEAPP = GETWAY + "updateMobilePhoneApp";
public final static String UPDATEEMAILAPP = GETWAY + "updateEmailApp";
public final static String UPDATEIDCARDAPP = GETWAY + "updateIdCardApp";
public final static String SENDPHONECODEAPP = GETWAY + "sendPhoneCodeApp";
public final static String QUERYUSERNOTICE = GETWAY + "queryUserNoticeApp"; // 通知中心
public final static String UPDATENOTICESTATUS = GETWAY + "updateNoticeStatusApp"; // 通知更新状态
public final static String DELETENOTICE = GETWAY + "deleteNoticeApp"; // 删除通知
public final static String QUERYBILLDETAILLISTAPP = GETWAY + "queryBillDetailListApp"; // 单据关联明细列表
public final static String GETUPLOADRUL = GETWAY + "getUploadStorageURLApp"; // 获取上传文件url
public final static String GETENCLOSURETYPE = GETWAY + "getEnclosureType"; // 获取上传附件类型
public final static String SAVEATTACHEMNTINFO = GETWAY + "saveAttachmentInfoApp"; // 上传文件
public final static String QUERYUSERTRIPITEM = GETWAY + "queryUserTripItemApp"; // 行程规划单节点通知(3小时)
public final static String QUERYMAINPAGEDATAAPP = GETWAY + "queryMainPageDataApp"; // 行程规划单节点通知(3小时),通知消息数,以及审批数量
public final static String QUERYSOCIALUSER = GETWAY + "querySocialUserInfoApp"; // 查询个人信息(聊天)
public final static String SWITCHDEPATEMENT = GETWAY + "switchDepatementApp"; // 切换部门
public final static String SETDEFAULTDEPT = GETWAY + "setDefaultDepatementApp"; // 切换默认部门
public final static String QUERYUNREADNOTICECOUNT = GETWAY + "queryUnreadNoticeCountApp"; // 未读消息数
public final static String CORPINFO = GETWAY + "corpInfoApp"; // 查询企业名片信息
public final static String QUERYEMPOTHERCERTAPP = GETWAY + "queryEmpOtherCertApp"; // 查询用户的其他证件信息
public final static String UPDATEUSERINFOAPP = GETWAY + "updateUserInfoApp"; // 修改用户个人信息,可以修改:英文姓、英文名、生日、国籍、性别
public final static String LOGOPERATIONAPP = GETWAY + "logOperationApp"; // 操作日志
public final static String QUERYNOREADNOTICEMESSAGECOUNT = "queryNoReadNoticeMessageCount";//我的消息条数
/**
* 首模块
*/
/**
* 单据模块
*/
public final static String QRYBILLTYPE = GETWAY + "qryBillType"; // 3.0单据类型
public final static String TRIPPLANBUDGETDEPTSAPP = GETWAY + "tripplanBudgetDeptsApp"; // 归属部门
public final static String QUERYBILLTYPE = GETWAY + "queryBillTypeApp"; // 查询用户可填写的单据类型
public final static String SEARCHBILLFILEDSCUSTOMACTION = GETWAY + "searchBillFiledsCustomActionApp"; // 查询创建单据所需字段及配置
public final static String FINDACTIVITITASKSWITHPERSONALPROCESSAPP = GETWAY + "findActivitiTasksWithPersonalProcessApp";
public final static String FINDCOMPLETEDTASKSWITPERSONALPROCESSAPP = GETWAY + "findcompletedTasksWitPersonalProcessApp";
public final static String SEARCHFIELDDATAAPP = GETWAY + "searchFieldDataApp"; // 单据字段数据源
public final static String RIGHTDATATREEAPP = GETWAY + "rightDatatreeApp"; // 单据字段数据源
public final static String SAVEBILLBUSINESFORMSUBMIT = GETWAY + "saveBillBusinesFormSubmitApp"; // 创建修改单据
public final static String SAVEBILL = GETWAY + "saveBillBusinesFormApp"; // 保存单据
public final static String QUERYBILLFLOWAPP = GETWAY + "queryBillFlowApp"; // 获取单据审批人及审批状态
public final static String GETFROMTASKLIST = GETWAY + "viewAllProcessNodeAssigneeApp"; // 查询单据审批流程
public final static String SHOWBILLFROMACTION = GETWAY + "editAndShowBillFormActionApp"; // 单据明细
public final static String BILLSKIPWORKFLOWACTIONAPP = GETWAY + "billSkipWorkFlowActionApp"; // 单个单据审批
public final static String BATCHAPPROVAL = GETWAY + "batchApprovalApp"; // 单据批量审批
public final static String QUERYMBILL = GETWAY + "queryCurrentUserMainDataListApp";
public final static String FLOWBACKTASK = GETWAY + "backBillWorkFlowActionApp"; // 退回审批//单据列表
public final static String FLOWREGAINACTION = GETWAY + "workFlowRegainActionApp"; // 撤回单据
public final static String ENDBILLWORKFLOW = GETWAY + "endBillWorkFlowActionApp"; // 终止单据
public final static String DELETEATTACHMENTINFO = GETWAY + "deleteAttachmentInfoApp"; // 删除附件
public final static String BILLPURSUE = GETWAY + "billPursueApp"; // 单据催办
public final static String BILLADDSIGN = GETWAY + "endorseBillWorkFlowActionApp"; // 单据加签
public final static String SELECTENDORSECONTACT = GETWAY + "selectEndorseContactApp"; // 常用加签人查询
public final static String APPROVALREJECTED = GETWAY + "approvalRejectedApp"; // 单据驳回
public final static String DELETEBILLFORM = GETWAY + "deleteBillFormApp"; // 单据删除
public final static String EXISTENDORSER = GETWAY + "existEndorserApp"; // 查询被加签人是否已参与过审批
public final static String QUERYBILLTASKUSER = GETWAY + "queryBillTaskUserApp"; // 查询是否创建沟通
public final static String QUERYDELEGATEPERSON = GETWAY + "queryDelegatePersonApp"; // 查询委托人列表
public final static String DELEGATETASKLISTAPP = GETWAY + "delegateTaskListApp"; // 任务委托列表接口
public final static String SETAUTODELEGATEPROCESS = GETWAY + "setAutoDelegateProcessApp"; // 添加用户委托任务
public final static String QUERYBUDGETAPP = GETWAY + "queryBudgetApp";
public final static String DELETEDELEGATEPERSONAPP = GETWAY + "deleteDelegatePersonApp"; // 删除用户委托任务
public final static String EXISTSLOANBILLAPP = GETWAY + "existsLoanBillApp"; // 是否存在未还清的借款单校验
public final static String BILLREDRUSH = GETWAY + "billRedRushApp"; // 单据红冲
public final static String EDITCONTRACTAPP = GETWAY + "editContractApp"; // 合同详情
public final static String QUERYUSERNOTICEMESSAGE = GETWAY + "queryUserNoticeMessage"; // 我的消息
public final static String CHANGEUSERNOTICESTATUS = GETWAY + "changeUserNoticeStatus"; // 消息标记已读
public final static String DELETEUSERNOTICEREFUSERBYID = GETWAY + "deleteUserNoticeRefUserById"; // 消息标记已读
public final static String GETONEKEYREFEXPENSELIST = GETWAY + "getOneKeyRefExpenseList"; // 一键报销获取单据列表
/**
* 单据模块
*/
public final static String QRYBILLTEMPLATEBYBILLINFOIDANDBILLID = GETWAY + "qryBillTemplateByBillInfoIdAndBillId"; // 单据模板
public final static String SAVEBILLFORDRAFT = GETWAY + "saveBillForDraft";
public final static String SUBMITBILLFORAPPROVE = GETWAY + "submitBillForApprove";// 提交审批
public final static String QUERYCURRENTUSERDATALIST = GETWAY + "queryCurrentUserDataList"; // 我的单据
public final static String QRYCODITIONSELECTION = GETWAY + "qryCoditionSelection"; // 筛选
// 单据状态
public final static String DELETEDRAFTBILLBYMAINID = GETWAY + "deleteDraftBillByMainId";
public final static String MODIFYINVOICEINFO = GETWAY + "modifyInvoiceInfo";// 发票保存修改
public final static String QRYINVOICEINFOPAGE = GETWAY + "qryInvoiceInfoPage"; // 发票列表查询
public final static String DELETEINVOICEINFO = GETWAY + "deleteInvoiceInfo"; // 删除发票
public final static String QRYINVOICEINFOBYID = GETWAY + "qryInvoiceInfoById"; // 发票详情
public final static String QRYINVOICEAUTHEMP = GETWAY + "qryInvoiceAuthEmp"; // 授权人选择借款
public final static String INVOICEAUTHORIZATION = GETWAY + "invoiceAuthorization"; // 授权接口
public final static String SENDBACKTASK = GETWAY + "sendBackTask"; // 工作流退回
public final static String QUERYPREVIOUSNODES = GETWAY + "queryPreviousNodes"; // 查询可退回节点
public final static String CALLBACKTASK = GETWAY + "callBackTask"; // 流程收回/撤回
public final static String AWAKENWORKFLOW = GETWAY + "awakenWorkflow"; // 流程唤醒
public final static String TERMINATEWORKFLOW = GETWAY + "deleteDraftBillByMainId"; // 流程终止
public final static String ADDITIONTASK = GETWAY + "additionTask"; // 加签
public final static String QRYCURRENTUSERTODOLIST = GETWAY + "qryCurrentUserToDoList"; // 代办任务列表
public final static String QRYCURRENTUSERCOMPLATETASKLIST = GETWAY + "qryCurrentUserComplateTaskList"; // 已办任务列表
public final static String QUERYFLOWPROGRESS = GETWAY + "queryFlowProgress"; // 单据进度
public final static String QRYWFTASKALLEMP = GETWAY + "qryWfTaskAllEmp"; // 流程全部人员选择
public final static String BATCHAPPROVALAPP = GETWAY + "batchApproval"; // 流程全部人员选择
public final static String QUERYBILLSENDLIST = GETWAY + "queryBillSendList"; // 抄送列表
public final static String QUERYBILLSEND = GETWAY + "queryBillSend"; // 抄送
public final static String FLOWREMINDERS = GETWAY + "flowReminders";// 催办
public final static String ONEKEYEXPENSEBILL = GETWAY + "oneKeyExpenseBill";// 一键报销获取单据模板
public final static String FINDCORPDELEGATETASKLIST = GETWAY + "findCorpDelegateTaskList";// 任务委托列表
public final static String REDDASHEDBILL = GETWAY + "redDashedBill";// 红冲
public final static String QRYINVOICEREFRULEBYTYPE = GETWAY + "qryInvoiceRefRuleByType";// 发票模板
public final static String RECREATEVOUCHERBYMAINID = GETWAY + "recreateVoucherByMainId";// 刷新凭证区
public final static String AUTOCREATEBILL = GETWAY + "autoCreateBill";// 发票一键报销生产单据
public final static String QRYFOLDERDATA = GETWAY + "qryFolderData";// 查询发票票夹列表
public final static String ADDFOLDER = GETWAY + "addFolder";// 添加票夹
public final static String ADDFOLDERREF = GETWAY + "addFolderRef";// 关联发票带票夹
public final static String QRYACCOUNTINFOPAGE = GETWAY + "qryAccountInfoPage";// 发票账本列表
public final static String DELETEACCOUNTINFO = GETWAY + "deleteAccountInfo";// 发票账本删除
public final static String ADDACCOUNTINFO = GETWAY + "addAccountInfo";// 立即添加账本
public final static String MODIFYACCOUNTINFO = GETWAY + "modifyAccountInfo";// 修改账本
public final static String ADDACCOUNTBYINVOICE = GETWAY + "addAccountByInvoice";// 发票自动生成账本
public final static String QRYACCOUNTINFOBYID = GETWAY + "qryAccountInfoById";// 获取账本明细
public final static String BATCHINVOICEBYWEIXIN = GETWAY + "batchInvoiceByWeixin";// 存储微信票夹数据到我的发票
public final static String GRYOAUTH2WEIXINUSERINFO = GETWAY + "qryOauth2WeiXinUserInfo";// 根据微信用户Code获取相关信息
public final static String AUTHORIZEDUSERS = GETWAY + "authorizedUsers";// 记录用户授权
/**
* 更多模块
*/
public final static String AITOTHERPERSON = GETWAY + "aitOtherPersonApp"; // @接口
public final static String QUERYDATAACCESSDEPTS = GETWAY + "queryDataAccessDeptsApp"; // 报表归属部门
// 报表模块
/**
* 更多模块
*/
/**
* 商旅模块
*/
public final static String GETUSERBUSIESSINFO = KRMOBILE + "getUserBusiessInfo"; // 获取商旅权限以及城市版本号接口
public final static String QUERYCITYLIST = KRMOBILE + "queryCityListByUserDemand"; // 查询城市列表(通用接口)
// 联系人
public final static String QUERYFLIGHTPERSONSINFOBYLOGINNAMEAPP = GETWAY + "queryFlightPersonsInfoByLoginnameApp";
public final static String QUERYINTERNATIONALFLIGHTPERSONAPP = GETWAY + "queryInternationalFlightPersonApp"; // 查询国际常用联系人
public final static String QUERYCRETIFICATEINFOLISTAPP = GETWAY + "queryCertificateinfoListApp"; // 查询国际常用联系人证件
public final static String QUERYFLIGHTPERSONSINFOAPP = GETWAY + "queryFlightPersonsInfoApp";
public final static String SAVECOMMENTFLIGHTPERSONSINFOAPP = GETWAY + "saveCommentFlightPersonsInfoApp";
public final static String ADDINTERNATIONALFLIGHTPERSONAPP = GETWAY + "addInternationalFlightPersonApp"; // 添加国际常用联系人
public final static String ADDCERTIFICATEINFOAPP = GETWAY + "addCertificateinfoApp"; // 添加国际常用联系人证件
public final static String ADDCERTIFICATEAPP = GETWAY + "addCertificateApp"; // 添加国际常用联系人证件(个人中心)
public final static String DELETECOMMENTFLIGHTPERSONSINFOAPP = GETWAY + "deleteCommentFlightPersonsInfoApp";
public final static String DELETEINTERNATIONALFLIGHTPERSONAPP = GETWAY + "deleteInternationalFlightPersonApp"; // 删除国际常用联系人
public final static String DELETECERTIFICATEINFOBYIDAPP = GETWAY + "deleteCertificateinfoByIdApp"; // 删除国际常用联系人证件
// 机票模块
public static final String PLANELISTAPP = KRMOBILE + "getLightSearchApp"; // 机票查询接口
public static final String FLIGHTQUERY = KRMOBILE + "interNationalFlightQuery"; // 国际机票查询列表接口
public final static String FLIGHTORDERCANCEL = GETWAY + "flightOrderCancelApp"; // 机票订单取消接口
public final static String GETPRICECHECK = KRMOBILE + "getPriceCheckApp"; // 机票价格验证
public final static String GETFLIGHTCHANGESEARCH = KRMOBILE + "getFlightChangeSearchApp"; // 改签机票查询
public final static String GETREFUNDAPPLY1 = GETWAY + "flightRefundApplyApp"; // 退票
public final static String GETINTERREFUNDAPPLY = GETWAY + "interFlightRefundApplyApp"; // 国际机票退票
public final static String FLIGHTCHANGEAPPLY = GETWAY + "flightChangeApplyApp"; // 改期在当前行程单内
public final static String FLIGHANGEAPPLYAFTER = GETWAY + "flightChangeApplyAfterApp"; // 改期在当前行程外
public final static String INTERFLIGHTCHANGEAPPLY = GETWAY + "interFlightChangeApplyApp"; // (国际机票)改期在当前行程单内
public final static String INTERFLIGHANGEAPPLYAFTER = GETWAY + "interFlightChangeApplyAfterApp"; // (国际机票)改期在当前行程外
public final static String REVOKECHANGYPP = GETWAY + "revokeChangeApplyApp"; // 机票改签撤销
public final static String REVOKEINTERFLIGHTCHANGYPP = GETWAY + "revokeInterFlightChangeApplyApp"; // 机票改签撤销
public final static String INTERNATIONALTICKETRULE = KRMOBILE + "interNationalNewTicketRule"; // 国际机票退改及行李规则
public final static String CANCELINTERFLIGHTBEFOREAPPROVALAPP = GETWAY + "cancelInterFlightBeforeApprovalApp"; // 国际机票取消(审批前)
public final static String CANCELINTERFLIGHTAPP = GETWAY + "cancelInterFlightApp"; // 国际机票取消
// 酒店模块
public static final String GETMULTIHOTELS = GETWAY + "getMultiHotels"; // 酒店查询接口
public final static String GETSINGLEHOTEL = GETWAY + "getSingleHotel"; // 获取酒店详情
public final static String QUERYKEYWORD = GETWAY + "getKeywords"; // 根据关键字获取酒店列表
public final static String CANCELHOTELBEFORE = GETWAY + "cancelHotelBeforeApp"; // 酒店退订(审批前)
public final static String FUZZYSEARCHHOTELS = KRMOBILE + "fuzzySearchHotels"; // 酒店联想
public final static String QUERYHOTELLIST = KRMOBILE + "queryHotelList"; // 酒店列表
public final static String QUERYHOTELDETAILS = KRMOBILE + "queryHotelDetails"; // 酒店详情
public final static String GETHOTELBUSIAREAANDBRANDS = KRMOBILE + "getHotelBusiAreaAndBrands"; // 酒店品牌
public final static String QUERYCITYLISTNONBOOKAPP = GETWAY + "queryCityListNonBookApp"; // 获取城市,包含县级城市
public final static String GETNATIONALITIESAPP = GETWAY + "getNationalitiesApp"; // 获取国籍信息
public final static String QUERYNEARBYHOTELS = KRMOBILE + "queryNearbyHotels";
// 租车模块
public static final String GETCARBASEINFO = KRMOBILE + "getCarBaseInfo"; // 获取车辆基本信息
public static final String GETESTIMATE = KRMOBILE + "getEstimate"; // 费用预估
public static final String CANCELORDER = GETWAY + "cancelOrder"; // 取消租车
public static final String GETORDERCOST = KRMOBILE + "getOrderCost"; // 获取租车订单计费信息
public static final String CHECKCANCELCOUNT = GETWAY + "checkCancelCount"; // 取消次数
public static final String RESENDCARRENTORDER = GETWAY + "resendCarRentOrder"; // 预定失败重发接口
public static final String CANCELCARORDERBEFORE = GETWAY + "cancelCarOrderBeforeApp"; // 取消租车节点
// 火车模块
public final static String SEARCHS2S = GETWAY + "searchS2s"; // 火车列表
public final static String GETTRAINLISTAPP = KRMOBILE + "getTrainListApp"; // 余票查询
public final static String QUERYTRAVELHISCITY = GETWAY + "queryTravelHisCity"; // 查询城市历史记录
public final static String PASSENGERCHECKAPP = KRMOBILE + "passengerCheckApp"; // 火车票乘客信息校验
public final static String TRAINREFUNDAPPLYAPP = GETWAY + "trainRefundApplyApp"; // 火车票退票申请服务
public final static String TRAINCHANGEAPPLYAPP = GETWAY + "trainChangeApplyApp"; // 火车票改签服务,行程单内(APP)
public final static String TRAINCHANGEAPPLYAFTERAPP = GETWAY + "trainChangeApplyAfterApp"; // 火车票改签服务,行程单外(APP)
public final static String REVOKETRAINCHANGEAPPLYAPP = GETWAY + "revokeTrainChangeApplyApp"; // 火车票撤销改签(APP)
public final static String CANCELTRAINORDERBEFOREAPP = GETWAY + "cancelTrainOrderBeforeApp"; // 火车票票取消(审批前)
// 其他模块
public final static String QUERYORDERLIST = GETWAY + "queryOrderListApp"; // 我的订单
public final static String QUERYCOPYOFAPPROVALLISTAPP = GETWAY + "queryCopyOfApprovalListApp"; // 抄送列表
public final static String COPYOFAPPROVALAPP = GETWAY + "copyOfApprovalApp"; // 审批抄送
/**
* 商旅模块
*/
/**
* 行程规划单
*/
public final static String CREATTRIPPLANAPP = GETWAY + "creatTripPlanApp"; // 创建行程单接口
public final static String IFOVERBUDGETAPP = GETWAY + "ifOverBudgetApp";
public final static String QUERYTRIPPLANLIST = GETWAY + "queryTripPlanListApp"; // 我的行程列表
public final static String QUERYTRIPPLAN = GETWAY + "queryTripPlanApp"; // 行程规划详情接口
public final static String DELETETRIPPLANITEM = GETWAY + "deleteTripPlanItemApp"; // 删除行程节点
public final static String SUBMITTRIPPLANITEM = GETWAY + "submitTripPlanItemApp"; // 新增行程节点提交审批
public final static String ADDTRIPPLANITEM = GETWAY + "addTripPlanItemApp"; // 行程规划单补单接口
public final static String UPDATETRIPPLANITEM = GETWAY + "updateTripPlanItemApp"; // 修改行程节点接口
public final static String ENDTRIPPLAN = GETWAY + "endTripPlanApp"; // 完结行程
public final static String CHANGETRIPPLANITEM = GETWAY + "changeTripPlanItemApp"; // 已审批的节点迁出到其他已审补批的行程中
public final static String CHECKISREIMBURSEMENTAPP = GETWAY + "checkIsReimbursementApp"; // 一健报销
public final static String QUERYBILLRECORDIDEXIST = GETWAY + "queryBillRecordIdListApp"; // 查询服务端recordid记录
public final static String CHECKTRIPPLANITEMEXIST = GETWAY + "checkTripPlanItemExistApp"; // 根据证件号校验机票节占,酒店节点,火车节点
public final static String QUERYTRAVELCODEAPP = GETWAY + "queryTravelCodeApp"; // 补单页面获取维度信息
public final static String QUERYTRAVELPLANDETAILFILED = GETWAY + "queryTravelPlanDetailFiledsApp"; // 行程规划单查询明细区字段
/**
* 行程规划单
*/
public final static String COTROLSTANDARDSVALIDATEAPP = GETWAY + "cotrolStandardsValidateApp"; // 职级校验
public final static String DOFEEDBACKAPP = GETWAY + "doFeedbackApp"; // 意见反馈
public final static String QUERYSOCIALUSERLISTAPP = GETWAY + "querySocialUserListApp"; // 模糊查询沟通人员
public final static String QUERYSOCIALUSERINFOAPP = GETWAY + "querySocialUserInfoApp"; // 查询person详细信息
public final static String CREATECHATGROUPAPP = GETWAY + "createChatGroupApp"; // 创建沟通
public final static String ADDPERSONTOCHATGROUPAPP = GETWAY + "addPersonToChatGroupApp"; // 添加群组人员
public final static String DELETEPERSONINCHATGROUPAPP = GETWAY + "deletePersonInChatGroupApp"; // 退出沟通
/**
* 报表
*/
public final static String QUERYBUDGETRATE = GETWAY + "queryBudgetRateApp"; // 预算执行率
public final static String QUERYBUDGETCOMPRISE = GETWAY + "queryBudgetCompriseApp";// 预算构成
public final static String QUERYBUDGETPERSON = GETWAY + "queryBudgetPersonApp";// 个人预算
public final static String QUERYBUDGETCOMPRISEINFO = GETWAY + "queryBudgetCompriseInfoApp";// 预算构成详情
public final static String GETDIM = GETWAY + "getSubjectListApp"; // 得到科目列表(报表)
public final static String QUERYPERSONALLOANSINFOAPP = GETWAY + "queryPersonalLoansInfoApp"; // 个人借款查询
public final static String QUERYAPPROVALAGEINGINFOAPP = GETWAY + "queryApprovalAgeingInfoApp"; // 审批时效性queryEmpDebtInfoApp
public final static String QUERYEMPDEBTINFOAPP = GETWAY + "queryEmpDebtInfoApp"; // 员工欠款报表
public final static String QUERYPERSONALLOANSDETAILAPP = GETWAY + "queryPersonalLoansDetailApp";// 员工欠款单据查询
public final static String QUERYBUDGETBILLDETAILAPP = GETWAY + "queryBudgetBillDetailApp";
public final static String QUERYTASKBILLTYPEAPP = GETWAY + "queryTaskBillTypeApp";// 审批列表单据类型查询
public final static String QUERYTASKDEPTAPP = GETWAY + "queryTaskDeptApp";// 审批列表组织机构查询
// public final static String
// TRIPPLANBUDGETDEPTSAPP="tripplanBudgetDeptsApp";
public final static String QUERYSYSBILLTYPEAPP = GETWAY + "querySysBillTypeApp";// 审批时效性
// 单据类型
public final static String QUERYAPPLICANTAPP = GETWAY + "queryApplicantApp";// 根据部门查询部门下人
public final static String QUERYPERSONALLOANSBILLAPP = GETWAY + "queryPersonalLoansBillApp";
public final static String QUERYPERSONALREPAYMENTBILLAPP = GETWAY + "queryPersonalRepaymentBillApp";
public final static String QUERYEMPDEBTINFODETAILAPP = GETWAY + "queryEmpDebtInfoDetailApp"; // 员工欠款
public final static String BATCHGLORITYINVOICECHECK = GETWAY + "batchGlorityInvoiceCheck"; // 发票识别
}
package com.stm.asset.base;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.widget.Toast;
import androidx.multidex.MultiDex;
import com.fn.useries.reader.server.ReaderHelper;
import com.stm.asset.model.UserInfo;
import com.tencent.bugly.crashreport.CrashReport;
import java.lang.ref.WeakReference;
import java.util.Stack;
/**
* 类名称:StmApplication
* 类描述:自定义Application
* 创建人:story
* 创建时间:2021-08-07 09:49
*/
public class StmApplication extends Application {
private static StmApplication instance;
private Stack<WeakReference<Activity>> mActivityStack;
private boolean isShowBackground = true; // 是否提示切换到后台,防止某些地方不需要提示
private static Toast toastLong;
private static Toast toastShort;
private UserInfo userInfo;
private AppExecutors appExecutors;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
@Override
public void onCreate() {
super.onCreate();
instance = this;
try {
//实例化ReaderHelper并setContext
ReaderHelper.setContext(getApplicationContext());
} catch (Exception e) {
e.printStackTrace();
}
appExecutors = new AppExecutors();
// 开启bugly异常捕获
CrashReport.UserStrategy strategy = new CrashReport.UserStrategy(getApplicationContext());
strategy.setAppChannel("BASE"); //设置渠道
CrashReport.initCrashReport(getApplicationContext(), "24e17bedee", true, strategy);
}
public static StmApplication getInstance() {
return instance;
}
public void enterActivity(WeakReference<Activity> weakReference) {
if (mActivityStack == null) {
mActivityStack = new Stack<>();
}
mActivityStack.add(weakReference);
}
public void removeActivity(WeakReference<Activity> weakReference) {
if (mActivityStack != null) {
mActivityStack.remove(weakReference);
}
}
public Activity getCurrentAct() {
Activity activity = null;
if (mActivityStack != null) {
activity = mActivityStack.lastElement().get();
}
return activity;
}
public boolean isShowBackground() {
return isShowBackground;
}
public void setShowBackground(boolean showBackground) {
isShowBackground = showBackground;
}
public void showToastLong(String msg) {
if (toastLong == null) {
toastLong = Toast.makeText(getBaseContext(), msg, Toast.LENGTH_LONG);
} else {
toastLong.setText(msg);
}
toastLong.show();
}
public void showToastShort(String msg) {
if (toastShort == null) {
toastShort = Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT);
} else {
toastShort.setText(msg);
}
toastShort.show();
}
public UserInfo getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
// public String getHttpStr() {
// String httpSb;
// if (PropertyUtil.isUseHttps(this)) {
// httpSb = "https";
// } else {
// httpSb = "http";
// }
// return httpSb;
// }
public AppExecutors getAppExecutors() {
return appExecutors;
}
}
package com.stm.asset.dao;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;
import com.stm.asset.model.InventoryInfo;
import java.util.List;
/**
* 类名称:InventoryInfoDao
* 类描述:InventoryInfoDao
* 创建人:story
* 创建时间:2021-12-09 16:36
*/
@Dao
public interface InventoryInfoDao {
/**
* 查询所有数据
*/
@Query("select * from inventoryInfo")
List<InventoryInfo> getAllInventoryInfoList();
@Query("select * from inventoryInfo where (status = '0' or status = '1') and userName = :userName")
List<InventoryInfo> getUndoInventoryList(String userName);
@Query("select * from inventoryInfo where status = '2' and userName = :userName")
List<InventoryInfo> getDoneInventoryList(String userName);
/**
* 插入数据
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
long[] insertInventoryList(List<InventoryInfo> inventoryInfoList);
/**
* 修改数据
*/
@Update
int updateInventory(InventoryInfo inventoryInfo);
/**
* 删除数据
*/
@Delete
int deleteInventoryList(List<InventoryInfo> inventoryInfoList);
}
package com.stm.asset.database;
import androidx.room.Database;
import androidx.room.RoomDatabase;
import com.stm.asset.dao.InventoryInfoDao;
import com.stm.asset.model.InventoryInfo;
/**
* 类名称:InventoryInfoDatabase
* 类描述:InventoryInfoDatabase
* 创建人:story
* 创建时间:2021-12-09 16:52
*/
@Database(entities = {InventoryInfo.class}, version = 1, exportSchema = false)
public abstract class InventoryInfoDatabase extends RoomDatabase {
public abstract InventoryInfoDao inventoryInfoDao();
}
package com.stm.asset.http;
import org.apache.http.conn.ConnectTimeoutException;
import java.net.SocketTimeoutException;
/**
* 类名称:HttpException
* 类描述:请求异常封装
* 创建人:story
* 创建时间:2021-12-14 14:56
*/
public class HttpException extends Exception {
private static final long serialVersionUID = -4699234082428363296L;
private int exceptionCode;
private Throwable throwable;
public HttpException() {}
public HttpException(String detailMessage) {
super(detailMessage);
}
public HttpException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
this.throwable =throwable;
}
public HttpException(Throwable throwable) {
super(throwable);
this.throwable =throwable;
}
public HttpException(int exceptionCode) {
this.exceptionCode = exceptionCode;
}
public HttpException(int exceptionCode, String detailMessage) {
super(detailMessage);
this.exceptionCode = exceptionCode;
}
public HttpException(int exceptionCode, String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
this.exceptionCode = exceptionCode;
this.throwable =throwable;
}
public HttpException(int exceptionCode, Throwable throwable) {
super(throwable);
this.exceptionCode = exceptionCode;
this.throwable =throwable;
}
public int getExceptionCode() {
return exceptionCode;
}
public boolean isConnectTimeout(){
if (this.throwable instanceof ConnectTimeoutException || this.throwable instanceof SocketTimeoutException) {
return true;
}
return false;
}
public Throwable getThrowable() {
return throwable;
}
}
package com.stm.asset.http;
import com.stm.asset.base.InterfaceKey;
import com.stm.asset.json.CommonMapJson;
import com.stm.asset.json.CommonStringJson;
import com.stm.asset.json.ListUserInfo;
/**
* 类名称:HttpService
* 类描述:封装请求服务
* 创建人:story
* 创建时间:2021-12-11 16:00
*/
public class HttpService {
private static HttpService instance;
private HttpService() {}
public static HttpService getInstance() {
if (instance == null) {
instance = new HttpService();
}
return instance;
}
public void unionLoginApp(String accout, String password, RequestCallback<CommonStringJson> requestCallback) {
RequestParams params = new RequestParams();
params.addBodyParameter("username", accout);
params.addBodyParameter("password", password);
HttpUtil.getInstance().sendJson(InterfaceKey.UNIONLOGINAPP, params, requestCallback);
}
public void quryPageHomeUserInfo(String accessToken, RequestCallback<ListUserInfo> requestCallback) {
RequestParams params = new RequestParams();
params.addBodyParameter("accessToken", accessToken);
HttpUtil.getInstance().sendJson(InterfaceKey.QURYPAGEHOMEUSERINFO, params, requestCallback);
}
public void queryAppVersionApp(RequestCallback<CommonMapJson> requestCallback) {
RequestParams params = new RequestParams();
HttpUtil.getInstance().sendJson(InterfaceKey.QUERYVERSIONAPP, params, requestCallback);
}
public void scanInventory(String numberList, RequestCallback<CommonStringJson> requestCallback) {
RequestParams params = new RequestParams();
params.addBodyParameter("numList", numberList);
HttpUtil.getInstance().sendJson(InterfaceKey.SCANINVENTORY, params, requestCallback);
}
}
package com.stm.asset.http;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.stm.asset.base.StmApplication;
import com.stm.asset.utils.PropertyUtil;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.annotations.EverythingIsNonNull;
/**
* 类名称:HttpUtil
* 类描述:网络请求工具类
* 创建人:story
* 创建时间:2021-12-10 17:15
*/
public class HttpUtil {
private static HttpUtil httpUtil;
private OkHttpClient okHttpClient;
private HttpUtil() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addInterceptor(new LoggingInterceptor());
if (PropertyUtil.isUseHttps(StmApplication.getInstance().getApplicationContext())) {
try {
builder.hostnameVerifier(TrustAllSSLSocketFactory.getHostnameVerifier());
builder.sslSocketFactory(TrustAllSSLSocketFactory.createSSLSocketFactory(), new TrustAllSSLSocketFactory.TrustAllManager());
} catch (Exception e) {
e.printStackTrace();
}
}
builder.callTimeout(6000, TimeUnit.MILLISECONDS);
builder.connectTimeout(6000, TimeUnit.MILLISECONDS);
builder.readTimeout(30000, TimeUnit.MILLISECONDS);
builder.writeTimeout(30000, TimeUnit.MILLISECONDS);
okHttpClient = builder.build();
}
public static HttpUtil getInstance() {
if (httpUtil == null) {
httpUtil = new HttpUtil();
}
return httpUtil;
}
public void sendJson1(String interfaceName, RequestParams requestParams, RequestCallback callback) {
// StmApplication.getInstance().getAppExecutors().networkIO().execute(new Runnable() {
// @Override
// public void run() {
//
// }
// });
Request.Builder builder = new Request.Builder();
String url = buildUrl(interfaceName);
Log.i("HttpUtil", String.format("请求方法: %s", url));
builder.url(url);
if (requestParams.getHeaders() != null && requestParams.getHeaders().size() > 0) {
for (Map.Entry<String, String> headerEntry : requestParams.getHeaders().entrySet()) {
builder.header(headerEntry.getKey(), headerEntry.getValue());
}
}
if (requestParams.getBodyParams() != null && requestParams.getBodyParams().size() > 0) {
Log.i("HttpUtil", String.format("请求参数:%s", new Gson().toJson(requestParams.getBodyParams())));
// RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(requestParams.getBodyParams()));
// builder.post(requestBody);
FormBody.Builder bodyBuilder = new FormBody.Builder();
for (Map.Entry<String, String> entry : requestParams.getBodyParams().entrySet()) {
bodyBuilder.add(entry.getKey(), entry.getValue());
}
builder.post(bodyBuilder.build());
}
Request request = builder.build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
@EverythingIsNonNull
public void onFailure(Call call, IOException e) {
callback.onFailure(new HttpException(e.getCause()), e.getMessage());
}
@Override
@EverythingIsNonNull
public void onResponse(Call call, Response response) {
boolean flag = false;
if (response.isSuccessful()) {
try {
ResponseBody body = response.body();
if (body != null) {
String result = body.string();
Log.i("HttpUtil", result);
callback.onSuccess(new Gson().fromJson(result, TypeToken.get(callback.getType()).getType()));
flag = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (!flag) {
callback.onFailure(new HttpException("返回数据异常"), "返回数据异常");
}
}
});
}
public void sendJson(String interfaceName, RequestParams requestParams, RequestCallback callback) {
Request.Builder builder = new Request.Builder();
String url = buildUrl(interfaceName);
Log.i("HttpUtil", String.format("请求方法: %s", url));
builder.url(url);
if (requestParams.getHeaders() != null && requestParams.getHeaders().size() > 0) {
for (Map.Entry<String, String> headerEntry : requestParams.getHeaders().entrySet()) {
builder.header(headerEntry.getKey(), headerEntry.getValue());
}
}
if (requestParams.getBodyParams() != null && requestParams.getBodyParams().size() > 0) {
Log.i("HttpUtil", String.format("请求参数:%s", new Gson().toJson(requestParams.getBodyParams())));
// RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(requestParams.getBodyParams()));
// builder.post(requestBody);
FormBody.Builder bodyBuilder = new FormBody.Builder();
for (Map.Entry<String, String> entry : requestParams.getBodyParams().entrySet()) {
bodyBuilder.add(entry.getKey(), entry.getValue());
}
builder.post(bodyBuilder.build());
}
Request request = builder.build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
@EverythingIsNonNull
public void onFailure(Call call, IOException e) {
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
callback.onFailure(new HttpException(e.getCause()), e.getMessage());
}
});
}
@Override
@EverythingIsNonNull
public void onResponse(Call call, Response response) {
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
boolean flag = false;
if (response.isSuccessful()) {
try {
ResponseBody body = response.body();
if (body != null) {
String result = body.string();
Log.i("HttpUtil", result);
callback.onSuccess(new Gson().fromJson(result, TypeToken.get(callback.getType()).getType()));
flag = true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (!flag) {
callback.onFailure(new HttpException("返回数据异常"), "返回数据异常");
}
}
});
}
});
}
private String buildUrl(String interfaceName) {
StmApplication sap = StmApplication.getInstance();
StringBuilder sbd = new StringBuilder();
boolean isHttps = PropertyUtil.isUseHttps(sap.getApplicationContext());
if (isHttps) {
sbd.append("https://");
} else {
sbd.append("http://");
}
String address = PropertyUtil.getHttpAddress(sap.getApplicationContext());
sbd.append(address);
String port = PropertyUtil.getHttpPort(sap.getApplicationContext());
if (port != null && !port.equals("")) {
sbd.append(":");
sbd.append(port);
}
sbd.append("/");
sbd.append(interfaceName);
sbd.append(".app");
return sbd.toString();
}
}
package com.stm.asset.http;
import android.util.Log;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
/**
* 类名称:LoggingInterceptor
* 类描述:请求日志拦截
* 创建人:story
* 创建时间:2021-12-10 17:35
*/
public class LoggingInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
Response response = chain.proceed(request);
Log.i("LoggingInterceptor", String.format("请求地址: %s", response.request().url()));
ResponseBody responseBody = response.body();
if (responseBody != null) {
try {
MediaType mediaType = responseBody.contentType();
byte[] responseBytes = responseBody.bytes();
Log.i("LoggingInterceptor", String.format("请求返回:%s", new String(responseBytes)));
response = response.newBuilder()
.body(ResponseBody.create(mediaType, responseBytes))
.build();
} catch (Exception e) {
e.printStackTrace();
}
}
// if (responseBody != null && responseBody.contentLength() > 0) {
// BufferedSource bufferedSource = responseBody.source();
// bufferedSource.request(Long.MAX_VALUE);
// Buffer buffer = bufferedSource.getBuffer();
// Charset charset = Charset.forName("utf-8");
// MediaType contentType = responseBody.contentType();
// if (contentType != null) {
// try {
// charset = contentType.charset(Charset.forName("utf-8"));
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// if (charset != null) {
// String result = buffer.clone().readString(charset);
// Log.i("LoggingInterceptor", String.format("请求返回:%s", result));
// }
// }
return response;
}
}
package com.stm.asset.http;
import com.stm.asset.base.ConfigKey;
import java.security.MessageDigest;
public class MD5Util implements java.io.Serializable {
/**
* 加密算法
*/
public static String encodeByMd5(String plainText) {
StringBuffer buf = new StringBuffer("");
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i = 0;
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
} catch (Exception e) {
e.printStackTrace();
}
//return buf.toString(); //32位的加密
return buf.toString().substring(8,24); // 16位的加密
}
/**
* 加密算法
*/
public static String encodeByMd5_32(String plainText) {
StringBuffer buf = new StringBuffer("");
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();
int i = 0;
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
} catch (Exception e) {
e.printStackTrace();
}
return buf.toString(); //32位的加密
}
//获取MD5串
public static String getAuthenticator(Long currentTime){
StringBuffer sPwd = new StringBuffer();
sPwd.append(ConfigKey.SIGNATURENAME).append(ConfigKey.SIGNATUREPASSWORD).append(currentTime);
String authenticator = MD5Util.encodeByMd5_32(sPwd.toString()).toUpperCase();
return authenticator;
}
}
package com.stm.asset.http;
import com.stm.asset.json.BaseInfo;
/**
* 类名称:RequestCallback
* 类描述:请求返回封装
* 创建人:story
* 创建时间:2021-12-11 15:55
*/
public abstract class RequestCallback<T extends BaseInfo> {
private Class<T> type;
public abstract void onSuccess(T responseInfo);
public abstract void onFailure(HttpException error, String msg);
public RequestCallback(Class<T> clazz) {
this.type = clazz;
}
public Class<T> getType() {
return type;
}
}
package com.stm.asset.http;
import com.stm.asset.base.StmApplication;
import com.stm.asset.utils.PropertyUtil;
import com.stm.asset.utils.SystemUtil;
import java.util.HashMap;
import java.util.Map;
/**
* 类名称:RequestParams
* 类描述:网络请求参数封装
* 创建人:story
* 创建时间:2021-12-10 17:15
*/
public class RequestParams {
private Map<String, String> headers;
private Map<String, String> bodyParams;
public RequestParams() {
addCommonParams();
}
public Map<String, String> getHeaders() {
return headers;
}
public Map<String, String> getBodyParams() {
return bodyParams;
}
/**
* 添加header
*/
public void addHeader(String name, String value) {
if (this.headers == null) {
this.headers = new HashMap<>();
}
this.headers.put(name, value);
}
/**
* 添加body参数
*/
public void addBodyParameter(String name, String value) {
if (bodyParams == null) {
bodyParams = new HashMap<>();
}
bodyParams.put(name, value);
}
private void addCommonParams(){
if (bodyParams == null) {
bodyParams = new HashMap<>();
}
bodyParams.put("machinecode", "h5");
bodyParams.put("machinetype", "h5");
bodyParams.put("channelcode", "APP");
bodyParams.put("terminalcode", "fee");
bodyParams.put("platform", PropertyUtil.getHttpPlatform(StmApplication.getInstance().getApplicationContext()));
long currentTime = System.currentTimeMillis();
bodyParams.put("currenttime", String.valueOf(currentTime));
bodyParams.put("authenticator", MD5Util.getAuthenticator(currentTime));
if (StmApplication.getInstance().getUserInfo() != null) {
bodyParams.put("accessToken", PropertyUtil.getAccessToken(StmApplication.getInstance().getApplicationContext()));
}
}
}
\ No newline at end of file
package com.stm.asset.http;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
public class TrustAllSSLSocketFactory {
public static SSLSocketFactory createSSLSocketFactory() {
SSLSocketFactory sslFactory = null;
try {
SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, new TrustManager[] { new TrustAllManager() }, new SecureRandom());
sslFactory = sslContext.getSocketFactory();
} catch (Exception e) {
e.printStackTrace();
}
return sslFactory;
}
public static HostnameVerifier getHostnameVerifier() {
return new TrustAllHostname();
}
private static class TrustAllHostname implements HostnameVerifier {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
}
public static class TrustAllManager implements X509TrustManager {
@Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
}
}
package com.stm.asset.json;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 类名称:BaseInfo
* 类描述:请求返回基础类
* 创建人:story
* 创建时间:2021-12-14 14:46
*/
public class BaseInfo implements Serializable {
private static final long serialVersionUID = -5800150937418965637L;
private String msgType; // 响应消息类型 N:正常 E:错误
private String rspCode; // 响应码 000000:正常 其他为错误码
private String rspMsg;
private String rspTime; // 系统时间
// private T rspData; // 响应数据 msgType为N时返回用户信息
private List<Map<String, String>> head;// 处理分页时的数据
private List<Map<String, String>> headList;// 处理分页时的数据
private List<Map<String, String>> warnList;// 警告信息的处理(警告用户风险,若用户继续确认,仍可提交)
public String getMsgType() {
return msgType;
}
public void setMsgType(String msgType) {
this.msgType = msgType;
}
public String getRspCode() {
return rspCode;
}
public void setRspCode(String rspCode) {
this.rspCode = rspCode;
}
public String getRspMsg() {
return rspMsg;
}
public void setRspMsg(String rspMsg) {
this.rspMsg = rspMsg;
}
public String getRspTime() {
return rspTime;
}
public void setRspTime(String rspTime) {
this.rspTime = rspTime;
}
// public T getRspData() {
// return rspData;
// }
//
// public void setRspData(T rspData) {
// this.rspData = rspData;
// }
public List<Map<String, String>> getHead() {
return head;
}
public void setHead(List<Map<String, String>> head) {
this.head = head;
}
public List<Map<String, String>> getHeadList() {
return headList;
}
public void setHeadList(List<Map<String, String>> headList) {
this.headList = headList;
}
public List<Map<String, String>> getWarnList() {
return warnList;
}
public void setWarnList(List<Map<String, String>> warnList) {
this.warnList = warnList;
}
public boolean isSucess() {
if ("000000".equals(this.rspCode)) {
return true;
}
return false;
}
}
package com.stm.asset.json;
import java.util.List;
import java.util.Map;
/**
* 类名称:CommonListMapJson
* 类描述:常用ListMap返回类
* 创建人:story
* 创建时间:2021-12-14 14:51
*/
public class CommonListMapJson extends BaseInfo {
private static final long serialVersionUID = 2677831404656997579L;
private List<Map<String, String>> rspData;
public List<Map<String, String>> getRspData() {
return rspData;
}
public void setRspData(List<Map<String, String>> rspData) {
this.rspData = rspData;
}
}
package com.stm.asset.json;
import java.util.Map;
/**
* 类名称:CommonMapJson
* 类描述:常用Map返回类
* 创建人:story
* 创建时间:2021-12-14 14:50
*/
public class CommonMapJson extends BaseInfo {
private static final long serialVersionUID = 2410670796256546600L;
private Map<String, String> rspData;
public Map<String, String> getRspData() {
return rspData;
}
public void setRspData(Map<String, String> rspData) {
this.rspData = rspData;
}
}
package com.stm.asset.json;
/**
* 类名称:CommonStringJson
* 类描述:常用字符串返回类
* 创建人:story
* 创建时间:2021-12-14 14:50
*/
public class CommonStringJson extends BaseInfo {
private static final long serialVersionUID = 6711484331694503504L;
private String rspData;
public String getRspData() {
return rspData;
}
public void setRspData(String rspData) {
this.rspData = rspData;
}
}
package com.stm.asset.json;
import com.stm.asset.model.LoginInfo;
/**
* 类名称:ListUserInfo
* 类描述:登录返回实体类
* 创建人:story
* 创建时间:2021-12-14 17:28
*/
public class ListUserInfo extends BaseInfo {
private static final long serialVersionUID = -4992321996771893423L;
private LoginInfo rspData;
public void setRspData(LoginInfo rspData) {
this.rspData = rspData;
}
public LoginInfo getRspData() {
return rspData==null?new LoginInfo():rspData;
}
}
package com.stm.asset.keyboard;
public class KeyBoardUtil {
/**
* 判断是否全由数字组成
* @param str
* @return
*/
public static boolean isNumeric(String str) {
for (int i = 0; i < str.length(); i++) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
}
package com.stm.asset.keyboard;
public class KeyModel {
public KeyModel(int code,String lable){
this.code = code;
this.lable = lable;
}
private String lable;
private int code;
public String getLable() {
return lable;
}
public int getCode() {
return code;
}
}
package com.stm.asset.keyboard;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.Editable;
import android.text.InputType;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.stm.asset.R;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
/**
* Created by Administrator on 2018/3/7 0007.
*/
public class SafeKeyboard {
private static final String TAG = "SafeKeyboard";
private Context mContext; //上下文
private LinearLayout layout;
private View keyContainer; //自定义键盘的容器View
private SafeKeyboardView keyboardView; //键盘的View
private Keyboard keyboardNumber; //数字键盘
private Keyboard keyboardNumber2; //数字键盘2,用于可切换键盘
private Keyboard keyboardLetter; //字母键盘
private Keyboard keyboardSymbol; //符号键盘
private TextView keyboardTip; //自定义键盘提示信息
private static boolean isCapes = false;
private boolean isShowStart = false;
private boolean isHideStart = false;
private int keyboardType = 1;
private static final long HIDE_TIME = 300;
private static final long SHOW_DELAY = 200;
private static final long SHOW_TIME = 300;
private static final long DELAY_TIME = 100;
private Handler showHandler = new Handler(Looper.getMainLooper());
private Handler hEndHandler = new Handler(Looper.getMainLooper());
private Handler sEndHandler = new Handler(Looper.getMainLooper());
private Drawable delDrawable;
private Drawable lowDrawable;
private Drawable upDrawable;
private int keyboardContainerResId;
private int keyboardResId;
private FrameLayout keyboardLayer;
private TranslateAnimation showAnimation;
private TranslateAnimation hideAnimation;
private long lastTouchTime;
private EditText mEditText;
private String preKeyBoardName;
SafeKeyboard(Context mContext, LinearLayout layout, EditText mEditText, int id, int keyId, String preKeyBoardName) {
this.mContext = mContext;
this.layout = layout;
this.mEditText = mEditText;
this.keyboardContainerResId = id;
this.keyboardResId = keyId;
this.preKeyBoardName = preKeyBoardName;
initKeyboard();
initAnimation();
addListeners();
}
SafeKeyboard(Context mContext, LinearLayout layout, EditText mEditText, int id, int keyId,
Drawable del, Drawable low, Drawable up) {
this.mContext = mContext;
this.layout = layout;
this.mEditText = mEditText;
this.keyboardContainerResId = id;
this.keyboardResId = keyId;
this.delDrawable = del;
this.lowDrawable = low;
this.upDrawable = up;
initKeyboard();
initAnimation();
addListeners();
}
private void initAnimation() {
showAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF
, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
hideAnimation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF
, 0.0f, Animation.RELATIVE_TO_SELF, 1.0f);
showAnimation.setDuration(SHOW_TIME);
hideAnimation.setDuration(HIDE_TIME);
showAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
isShowStart = true;
// 在这里设置可见, 会出现第一次显示键盘时直接闪现出来, 没有动画效果, 后面正常
// keyContainer.setVisibility(View.VISIBLE);
// 动画持续时间 SHOW_TIME 结束后, 不管什么操作, 都需要执行, 把 isShowStart 值设为 false; 否则
// 如果 onAnimationEnd 因为某些原因没有执行, 会影响下一次使用
sEndHandler.removeCallbacks(showEnd);
sEndHandler.postDelayed(showEnd, SHOW_TIME);
}
@Override
public void onAnimationEnd(Animation animation) {
isShowStart = false;
keyContainer.clearAnimation();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
hideAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
isHideStart = true;
// 动画持续时间 HIDE_TIME 结束后, 不管什么操作, 都需要执行, 把 isHideStart 值设为 false; 否则
// 如果 onAnimationEnd 因为某些原因没有执行, 会影响下一次使用
hEndHandler.removeCallbacks(hideEnd);
hEndHandler.postDelayed(hideEnd, HIDE_TIME);
}
@Override
public void onAnimationEnd(Animation animation) {
isHideStart = false;
if (keyContainer.getVisibility() != View.GONE) {
keyContainer.setVisibility(View.GONE);
}
keyContainer.clearAnimation();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
@SuppressLint("ClickableViewAccessibility")
private void initKeyboard() {
keyContainer = LayoutInflater.from(mContext).inflate(keyboardContainerResId, layout, true);
keyContainer.setVisibility(View.GONE);
keyboardNumber = new Keyboard(mContext, R.xml.keyboard_num); //实例化数字键盘
keyboardNumber2 = new Keyboard(mContext, R.xml.keyboard_num2); //实例化数字键盘2
keyboardLetter = new Keyboard(mContext, R.xml.keyboard_letter); //实例化字母键盘
keyboardSymbol = new Keyboard(mContext, R.xml.keyboard_symbol); //实例化符号键盘
keyboardTip = (TextView) keyContainer.findViewById(R.id.keyboardTip);
keyboardTip.setText(preKeyBoardName+mContext.getResources().getString(
R.string.safe_keyboard
));
keyboardLayer = (FrameLayout) keyContainer.findViewById(R.id.keyboardLayer);
// 由于符号键盘与字母键盘共用一个KeyBoardView, 所以不需要再为符号键盘单独实例化一个KeyBoardView
keyboardView = (SafeKeyboardView) keyContainer.findViewById(keyboardResId);
keyboardView.setDelDrawable(delDrawable);
keyboardView.setLowDrawable(lowDrawable);
keyboardView.setUpDrawable(upDrawable);
keyboardView.setKeyboard(keyboardLetter); //给键盘View设置键盘
keyboardView.setEnabled(true);
keyboardView.setPreviewEnabled(false);
keyboardView.setOnKeyboardActionListener(listener);
FrameLayout done = (FrameLayout) keyContainer.findViewById(R.id.keyboardDone);
done.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (isKeyboardShown()) {
hideKeyboard();
}
}
});
keyboardView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return event.getAction() == MotionEvent.ACTION_MOVE;
}
});
keyboardView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
if (!view.hasFocus()){
hideKeyboard();
}
}
});
}
// 设置键盘点击监听
private KeyboardView.OnKeyboardActionListener listener = new KeyboardView.OnKeyboardActionListener() {
@Override
public void onPress(int primaryCode) {
if (keyboardType == 3) {
keyboardView.setPreviewEnabled(false);
} else {
keyboardView.setPreviewEnabled(false);
if (primaryCode == -1 || primaryCode == -5 || primaryCode == 32 || primaryCode == -2
|| primaryCode == 100860 || primaryCode == -35) {
keyboardView.setPreviewEnabled(false);
} else {
keyboardView.setPreviewEnabled(false);
}
}
}
@Override
public void onRelease(int primaryCode) {
}
@Override
public void onKey(int primaryCode, int[] keyCodes) {
try {
Editable editable = mEditText.getText();
int start = mEditText.getSelectionStart();
int end = mEditText.getSelectionEnd();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {
// 隐藏键盘
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE || primaryCode == -35) {
// 回退键,删除字符
if (editable != null && editable.length() > 0) {
if (start == end) { //光标开始和结束位置相同, 即没有选中内容
editable.delete(start - 1, start);
} else { //光标开始和结束位置不同, 即选中EditText中的内容
editable.delete(start, end);
}
}
} else if (primaryCode == Keyboard.KEYCODE_SHIFT) {
// 大小写切换
changeKeyboardLetterCase();
// 重新setKeyboard, 进而系统重新加载, 键盘内容才会变化(切换大小写)
keyboardType = 1;
switchKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_MODE_CHANGE) {
// 数字与字母键盘互换
if (keyboardType == 3) { //当前为数字键盘
keyboardType = 1;
} else { //当前不是数字键盘
keyboardType = 3;
}
switchKeyboard();
} else if (primaryCode == 100860) {
// 字母与符号切换
if (keyboardType == 2) { //当前是符号键盘
keyboardType = 1;
} else { //当前不是符号键盘, 那么切换到符号键盘
keyboardType = 2;
}
switchKeyboard();
} else {
// 输入键盘值
// editable.insert(start, Character.toString((char) primaryCode));
editable.replace(start, end, Character.toString((char) primaryCode));
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onText(CharSequence text) {
}
@Override
public void swipeLeft() {
}
@Override
public void swipeRight() {
}
@Override
public void swipeDown() {
}
@Override
public void swipeUp() {
}
};
private void switchKeyboard() {
/*switch (keyboardType) {
case 1:
keyboardView.setKeyboard(keyboardLetter);
break;
case 2:
keyboardView.setKeyboard(keyboardSymbol);
break;
case 3:
//keyboardView.setKeyboard(keyboardNumber);
setRandomkeys(keyboardNumber2);
break;
default:
Log.e(TAG, "ERROR keyboard type");
break;
}*/
if (keyboardType == 1){
keyboardView.setKeyboard(keyboardLetter);
}else if (keyboardType == 2){
keyboardView.setKeyboard(keyboardSymbol);
}else if (keyboardType == 3){
setRandomkeys(keyboardNumber2);
}else {
Log.e(TAG, "ERROR keyboard type");
}
}
private void changeKeyboardLetterCase() {
List<Keyboard.Key> keyList = keyboardLetter.getKeys();
if (isCapes) {
for (Keyboard.Key key : keyList) {
if (key.label != null && isUpCaseLetter(key.label.toString())) {
key.label = key.label.toString().toLowerCase();
key.codes[0] += 32;
}
}
} else {
for (Keyboard.Key key : keyList) {
if (key.label != null && isLowCaseLetter(key.label.toString())) {
key.label = key.label.toString().toUpperCase();
key.codes[0] -= 32;
}
}
}
isCapes = !isCapes;
keyboardView.setCap(isCapes);
}
public void hideKeyboard() {
//关闭禁止截屏功能
((Activity)mContext).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
keyboardType = 1;
keyContainer.clearAnimation();
keyContainer.startAnimation(hideAnimation);
}
/**
* 只起到延时开始显示的作用
*/
private final Runnable showRun = new Runnable() {
@Override
public void run() {
showKeyboard();
}
};
private final Runnable hideEnd = new Runnable() {
@Override
public void run() {
isHideStart = false;
if (keyContainer.getVisibility() != View.GONE) {
keyContainer.setVisibility(View.GONE);
}
}
};
private final Runnable showEnd = new Runnable() {
@Override
public void run() {
isShowStart = false;
// 在迅速点击不同输入框时, 造成自定义软键盘和系统软件盘不停的切换, 偶尔会出现停在使用系统键盘的输入框时, 没有隐藏
// 自定义软键盘的情况, 为了杜绝这个现象, 加上下面这段代码
if (!mEditText.isFocused()) {
hideKeyboard();
}
}
};
private void showKeyboard() {
Keyboard tempKB = keyboardLetter;
//设为数字键盘
if (mEditText.getInputType() == InputType.TYPE_CLASS_NUMBER
|| mEditText.getInputType() == InputType.TYPE_CLASS_PHONE){
Log.i("tag",mEditText.getInputType()+","+InputType.TYPE_CLASS_NUMBER);
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)keyboardView.getLayoutParams();
params.setMargins(dp2px(mContext,10),dp2px(mContext,5),dp2px(mContext,10),0);
keyboardView.setLayoutParams(params);
tempKB = keyboardNumber;
setRandomkeys(tempKB);
}else {
keyboardView.setKeyboard(tempKB);
}
keyContainer.setVisibility(View.VISIBLE);
keyContainer.clearAnimation();
keyContainer.startAnimation(showAnimation);
//防止截屏录屏
((Activity)mContext).getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,WindowManager.LayoutParams.FLAG_SECURE);
}
private boolean isLowCaseLetter(String str) {
String letters = "abcdefghijklmnopqrstuvwxyz";
return letters.contains(str);
}
private boolean isUpCaseLetter(String str) {
String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
return letters.contains(str);
}
@SuppressLint("ClickableViewAccessibility")
private void addListeners() {
mEditText.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
hideSystemKeyBoard((EditText) v);
if (!isKeyboardShown() && !isShowStart) {
showHandler.removeCallbacks(showRun);
showHandler.postDelayed(showRun, SHOW_DELAY);
}
}
return false;
}
});
mEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
boolean result = isValidTouch();
if (v instanceof EditText) {
if (!hasFocus) {
if (result) {
if (isKeyboardShown() && !isHideStart) {
hideKeyboard();
}
} else {
hideKeyboard();
}
} else {
hideSystemKeyBoard((EditText) v);
if (result) {
if (!isKeyboardShown() && !isShowStart) {
showHandler.removeCallbacks(showRun);
showHandler.postDelayed(showRun, SHOW_DELAY);
}
} else {
showHandler.removeCallbacks(showRun);
showHandler.postDelayed(showRun, SHOW_DELAY + DELAY_TIME);
}
}
}
}
});
}
public boolean isShow() {
return isKeyboardShown();
}
//隐藏系统键盘关键代码
private void hideSystemKeyBoard(EditText edit) {
this.mEditText = edit;
InputMethodManager imm = (InputMethodManager) this.mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null)
return;
boolean isOpen = imm.isActive();
if (isOpen) {
imm.hideSoftInputFromWindow(edit.getWindowToken(), 0);
}
int currentVersion = Build.VERSION.SDK_INT;
String methodName = null;
if (currentVersion >= 16) {
methodName = "setShowSoftInputOnFocus";
} else if (currentVersion >= 14) {
methodName = "setSoftInputShownOnFocus";
}
if (methodName == null) {
edit.setInputType(0);
} else {
try {
Method setShowSoftInputOnFocus = EditText.class.getMethod(methodName, Boolean.TYPE);
setShowSoftInputOnFocus.setAccessible(true);
setShowSoftInputOnFocus.invoke(edit, Boolean.FALSE);
} catch (NoSuchMethodException e1) {
edit.setInputType(0);
} catch (IllegalAccessException e2) {
} catch (InvocationTargetException e3) {
} catch (IllegalArgumentException e4) {
}
}
}
private boolean isKeyboardShown() {
return keyContainer.getVisibility() == View.VISIBLE;
}
private boolean isValidTouch() {
long thisTouchTime = SystemClock.elapsedRealtime();
if (thisTouchTime - lastTouchTime > 500) {
lastTouchTime = thisTouchTime;
return true;
}
lastTouchTime = thisTouchTime;
return false;
}
public void setDelDrawable(Drawable delDrawable) {
this.delDrawable = delDrawable;
keyboardView.setDelDrawable(delDrawable);
}
public void setLowDrawable(Drawable lowDrawable) {
this.lowDrawable = lowDrawable;
keyboardView.setLowDrawable(lowDrawable);
}
public void setUpDrawable(Drawable upDrawable) {
this.upDrawable = upDrawable;
keyboardView.setUpDrawable(upDrawable);
}
/**
* 随机数字键
*/
private void setRandomkeys(Keyboard keyboard) {
List<Keyboard.Key> keyList = keyboard.getKeys();
List<Keyboard.Key> newkeyList = new ArrayList<Keyboard.Key>();
for (int i = 0, size = keyList.size(); i < size; i++) {
Keyboard.Key key = keyList.get(i);
CharSequence label = key.label;
if (label != null && KeyBoardUtil.isNumeric(label.toString())) {
//此时keylist和newkeylist存放的都是key
newkeyList.add(key);
}
}
int count = newkeyList.size();
List<KeyModel> resultList = new ArrayList<KeyModel>();
//存放所需要的一堆新的键对象
LinkedList<KeyModel> temp = new LinkedList<KeyModel>();
for (int i = 0; i < count; i++) {
temp.add(new KeyModel(48 + i, i + ""));
}
//随机数随机生成数字
Random rand = new SecureRandom();
rand.setSeed(SystemClock.currentThreadTimeMillis());
for (int i = 0; i < count; i++) {
int num = rand.nextInt(count - i);
KeyModel model = temp.get(num);
//打乱顺序后将key存放入resultlist
resultList.add(new KeyModel(model.getCode(), model.getLable()));
temp.remove(num);
}
//此时,temp中是空的,resultlist存放的为随机后的keymodel集合
for (int i = 0, size = newkeyList.size(); i < size; i++) {
//将resultlist中的每一个对象一一对应赋值给newkeyList的相应对象
Keyboard.Key newKey = newkeyList.get(i);
KeyModel resultmodle = resultList.get(i);
newKey.label = resultmodle.getLable();
newKey.codes[0] = resultmodle.getCode();
}
keyboardView.setKeyboard(keyboard);
}
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
public static int dp2px(Context context, float dpValue) {
float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
}
package com.stm.asset.keyboard;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import com.stm.asset.R;
public class SafeKeyboardManager {
private static String preKeyBoardName = "";
public static void initKeyBoard(String preKeyBoardName){
SafeKeyboardManager.preKeyBoardName = preKeyBoardName;
}
public static void registKeyboard(Activity activity, EditText safeEdit){
LinearLayout linearLayout = new LinearLayout(activity);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.gravity = Gravity.BOTTOM;
activity.addContentView(linearLayout,layoutParams);
@SuppressLint("InflateParams") View view = LayoutInflater.from(activity).inflate(R.layout.layout_keyboard_containor, null);
SafeKeyboard safeKeyboard = new SafeKeyboard(activity, linearLayout, safeEdit,
R.layout.layout_keyboard_containor, view.findViewById(R.id.safeKeyboardLetter).getId(),
SafeKeyboardManager.preKeyBoardName);
safeKeyboard.setDelDrawable(activity.getResources().getDrawable(R.drawable.icon_del2));
safeKeyboard.setLowDrawable(activity.getResources().getDrawable(R.drawable.icon_capital_default3));
safeKeyboard.setUpDrawable(activity.getResources().getDrawable(R.drawable.icon_capital_default2));
}
}
package com.stm.asset.keyboard;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.inputmethodservice.Keyboard;
import android.inputmethodservice.KeyboardView;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import com.stm.asset.R;
import java.lang.reflect.Field;
import java.util.List;
/**
* Created by Administrator on 2018/3/7 0007.
*/
public class SafeKeyboardView extends KeyboardView {
private static final String TAG = "SafeKeyboardView";
private Context mContext;
private boolean isCap;
private Drawable delDrawable;
private Drawable lowDrawable;
private Drawable upDrawable;
/**
* 按键的宽高至少是图标宽高的倍数
*/
private static final int ICON2KEY = 2;
public SafeKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
this.mContext = context;
}
public SafeKeyboardView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
this.mContext = context;
}
private void init() {
this.isCap = false;
this.delDrawable = null;
this.lowDrawable = null;
this.upDrawable = null;
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
try {
List<Keyboard.Key> keys = getKeyboard().getKeys();
for (Keyboard.Key key : keys) {
if (key.codes[0] == -5 || key.codes[0] == -2 || key.codes[0] == 100860 || key.codes[0] == -1
|| key.codes[0] == -3)
drawSpecialKey(canvas, key);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void drawSpecialKey(Canvas canvas, Keyboard.Key key) {
if (key.codes[0] == -5) {
drawKeyBackground(R.drawable.keyboard_change, canvas, key);
drawTextAndIcon(canvas, key, delDrawable);
} else if (key.codes[0] == -2 || key.codes[0] == 100860) {
drawKeyBackground(R.drawable.keyboard_change, canvas, key);
drawTextAndIcon(canvas, key, null);
} else if (key.codes[0] == -1) {
if (isCap) {
drawKeyBackground(R.drawable.keyboard_change, canvas, key);
drawTextAndIcon(canvas, key, upDrawable);
} else {
drawKeyBackground(R.drawable.keyboard_change, canvas, key);
drawTextAndIcon(canvas, key, lowDrawable);
}
}else if (key.codes[0] == -3){
drawKeyBackground(R.drawable.keyboard_confirm,canvas,key);
drawTextAndIcon(canvas,key,null);
}
}
private void drawKeyBackground(int id, Canvas canvas, Keyboard.Key key) {
Drawable drawable = mContext.getResources().getDrawable(id);
int[] state = key.getCurrentDrawableState();
if (key.codes[0] != 0) {
drawable.setState(state);
}
drawable.setBounds(key.x, key.y, key.x + key.width, key.y + key.height);
drawable.draw(canvas);
}
private void drawTextAndIcon(Canvas canvas, Keyboard.Key key, @Nullable Drawable drawable) {
try {
Rect bounds = new Rect();
Paint paint = new Paint();
paint.setTextAlign(Paint.Align.CENTER);
paint.setAntiAlias(true);
paint.setColor(Color.BLACK);
if (key.label != null) {
String label = key.label.toString();
Field field;
if (label.length() > 1 && key.codes.length < 2) {
int labelTextSize = 0;
try {
field = KeyboardView.class.getDeclaredField(getContext().getString(R.string.mLabelTextSize));
field.setAccessible(true);
labelTextSize = (Integer) field.get(this);
} catch (NoSuchFieldException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e2) {
e2.printStackTrace();
}
paint.setTextSize(labelTextSize);
paint.setTypeface(Typeface.DEFAULT_BOLD);
if (key.label.equals("确认")){
paint.setColor(Color.WHITE);
}
} else {
int keyTextSize = 0;
try {
field = KeyboardView.class.getDeclaredField(getContext().getString(R.string.mLabelTextSize));
field.setAccessible(true);
keyTextSize = (Integer) field.get(this);
} catch (NoSuchFieldException e1) {
e1.printStackTrace();
} catch (IllegalAccessException e2) {
e2.printStackTrace();
}
paint.setTextSize(keyTextSize);
paint.setTypeface(Typeface.DEFAULT);
}
paint.getTextBounds(key.label.toString(), 0, key.label.toString().length(), bounds);
canvas.drawText(key.label.toString(), key.x + (key.width / 2),
(key.y + key.height / 2) + bounds.height() / 2, paint);
}
if (drawable == null) return;
// 约定: 最终图标的宽度和高度都需要在按键的宽度和高度的二分之一以内
// 如果: 图标的实际宽度和高度都在按键的宽度和高度的二分之一以内, 那就不需要变换, 否则就需要等比例缩小
int iconSizeWidth, iconSizeHeight;
key.icon = drawable;
int iconH = px2dip(mContext, key.icon.getIntrinsicHeight());
int iconW = px2dip(mContext, key.icon.getIntrinsicWidth());
if (key.width >= (ICON2KEY * iconW) && key.height >= (ICON2KEY * iconH)) {
//图标的实际宽度和高度都在按键的宽度和高度的二分之一以内, 不需要缩放, 因为图片已经够小或者按键够大
setIconSize(canvas, key, iconW, iconH);
} else {
//图标的实际宽度和高度至少有一个不在按键的宽度或高度的二分之一以内, 需要等比例缩放, 因为此时图标的宽或者高已经超过按键的二分之一
//需要把超过的那个值设置为按键的二分之一, 另一个等比例缩放
//不管图标大小是多少, 都以宽度width为标准, 把图标的宽度缩放到和按键一样大, 并同比例缩放高度
double multi = 1.0 * iconW / key.width;
int tempIconH = (int) (iconH / multi);
if (tempIconH <= key.height) {
//宽度相等时, 图标的高度小于等于按键的高度, 按照现在的宽度和高度设置图标的最终宽度和高度
iconSizeHeight = tempIconH / ICON2KEY;
iconSizeWidth = key.width / ICON2KEY;
} else {
//宽度相等时, 图标的高度大于按键的高度, 这时按键放不下图标, 需要重新按照高度缩放
double mul = 1.0 * iconH / key.height;
int tempIconW = (int) (iconW / mul);
iconSizeHeight = key.height / ICON2KEY;
iconSizeWidth = tempIconW / ICON2KEY;
}
setIconSize(canvas, key, iconSizeWidth, iconSizeHeight);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void setIconSize(Canvas canvas, Keyboard.Key key, int iconSizeWidth, int iconSizeHeight) {
int left = key.x + (key.width - iconSizeWidth) / 2;
int top = key.y + (key.height - iconSizeHeight) / 2;
int right = key.x + (key.width + iconSizeWidth) / 2;
int bottom = key.y + (key.height + iconSizeHeight) / 2;
key.icon.setBounds(left, top, right, bottom);
key.icon.draw(canvas);
key.icon = null;
}
public void setCap(boolean cap) {
isCap = cap;
}
public void setDelDrawable(Drawable delDrawable) {
this.delDrawable = delDrawable;
}
public void setLowDrawable(Drawable lowDrawable) {
this.lowDrawable = lowDrawable;
}
public void setUpDrawable(Drawable upDrawable) {
this.upDrawable = upDrawable;
}
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
}
package com.stm.asset.model;
import java.io.Serializable;
/**
* 类名称:AddressInfo
* 类描述:请求地址详情
* 创建人:story
* 创建时间:2022-01-06 10:04
*/
public class AddressInfo implements Serializable {
private static final long serialVersionUID = 1801015901518969341L;
private String name;
private String ip;
private String port;
private boolean isHttps;
private String platform;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public boolean isHttps() {
return isHttps;
}
public void setHttps(boolean https) {
isHttps = https;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
}
package com.stm.asset.model;
import java.io.Serializable;
/**
* 类名称:CheckTaskInfo
* 类描述:盘点任务实体类
* 创建人:story
* 创建时间:2021-12-07 15:11
*/
public class CheckTaskInfo implements Serializable {
private static final long serialVersionUID = 1644638878669069343L;
private String taskId;
private String taskName; // 任务名称
private String creater; // 创建人
private String createTime; // 创建时间
private String taskNum; // 盘点总数
private String taskArea; // 盘点区域
private String taskStatus; // 盘点状态
private String taskStatusName; // 状态说明
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getTaskName() {
return taskName;
}
public void setTaskName(String taskName) {
this.taskName = taskName;
}
public String getCreater() {
return creater;
}
public void setCreater(String creater) {
this.creater = creater;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getTaskNum() {
return taskNum;
}
public void setTaskNum(String taskNum) {
this.taskNum = taskNum;
}
public String getTaskArea() {
return taskArea;
}
public void setTaskArea(String taskArea) {
this.taskArea = taskArea;
}
public String getTaskStatus() {
return taskStatus;
}
public void setTaskStatus(String taskStatus) {
this.taskStatus = taskStatus;
}
public String getTaskStatusName() {
return taskStatusName;
}
public void setTaskStatusName(String taskStatusName) {
this.taskStatusName = taskStatusName;
}
}
package com.stm.asset.model;
import java.io.Serializable;
/**
* 类名称:CorpInfo
* 类描述:企业实体类
* 创建人:story
* 创建时间:2021-12-14 17:24
*/
public class CorpInfo implements Serializable {
private static final long serialVersionUID = -119966012740920874L;
private String id; //公司ID
private String name; //公司名字
private boolean isSelect; //是否选择 true选择
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isSelect() {
return isSelect;
}
public void setSelect(boolean select) {
isSelect = select;
}
}
package com.stm.asset.model;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey;
import java.io.Serializable;
/**
* 类名称:InventoryInfo
* 类描述:盘询数据实体类
* 创建人:story
* 创建时间:2021-12-09 16:24
*/
@Entity(tableName = "inventoryInfo")
public class InventoryInfo implements Serializable {
private static final long serialVersionUID = 1060118962039231156L;
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id")
private long id;
@ColumnInfo(name = "name")
private String name; // 资产名称
@ColumnInfo(name = "number")
private String number; // 资产编码
@ColumnInfo(name = "userName")
private String userName; // 使用人
@ColumnInfo(name = "userDept")
private String userDept; // 使用部门
@ColumnInfo(name = "status")
private String status; // 状态:0,未提交;1,提交失败;2,提交成功
@ColumnInfo(name = "item01")
private String item01;
@ColumnInfo(name = "item02")
private String item02;
@ColumnInfo(name = "item03")
private String item03;
@ColumnInfo(name = "item04")
private String item04;
@ColumnInfo(name = "item05")
private String item05;
@ColumnInfo(name = "item06")
private String item06;
@ColumnInfo(name = "item07")
private String item07;
@ColumnInfo(name = "item08")
private String item08;
@ColumnInfo(name = "item09")
private String item09;
@ColumnInfo(name = "item10")
private String item10;
public InventoryInfo(){}
@Ignore
public InventoryInfo(String name, String number, String userName, String userDept, String item01, String item02){
this.name = name;
this.number = number;
this.userName = userName;
this.userDept = userDept;
this.item01 = item01;
this.item02 = item02;
this.status = "0";
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserDept() {
return userDept;
}
public void setUserDept(String userDept) {
this.userDept = userDept;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getItem01() {
return item01;
}
public void setItem01(String item01) {
this.item01 = item01;
}
public String getItem02() {
return item02;
}
public void setItem02(String item02) {
this.item02 = item02;
}
public String getItem03() {
return item03;
}
public void setItem03(String item03) {
this.item03 = item03;
}
public String getItem04() {
return item04;
}
public void setItem04(String item04) {
this.item04 = item04;
}
public String getItem05() {
return item05;
}
public void setItem05(String item05) {
this.item05 = item05;
}
public String getItem06() {
return item06;
}
public void setItem06(String item06) {
this.item06 = item06;
}
public String getItem07() {
return item07;
}
public void setItem07(String item07) {
this.item07 = item07;
}
public String getItem08() {
return item08;
}
public void setItem08(String item08) {
this.item08 = item08;
}
public String getItem09() {
return item09;
}
public void setItem09(String item09) {
this.item09 = item09;
}
public String getItem10() {
return item10;
}
public void setItem10(String item10) {
this.item10 = item10;
}
}
package com.stm.asset.model;
import java.io.Serializable;
import java.util.List;
/**
* 类名称:LoginInfo
* 类描述:登录返回数据
* 创建人:story
* 创建时间:2021-12-14 17:26
*/
public class LoginInfo implements Serializable {
private static final long serialVersionUID = -5421078409061430086L;
private UserInfo userInfo; //单公司登录返回的信息
private List<CorpInfo> corpInfo; //多公司第一次登录返回的信息
public UserInfo getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public List<CorpInfo> getCorpInfo() {
return corpInfo;
}
public void setCorpInfo(List<CorpInfo> corpInfo) {
this.corpInfo = corpInfo;
}
}
package com.stm.asset.model;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 类名称:UserInfo
* 类描述:用户信息
* 创建人:story
* 创建时间:2021-12-10 13:52
*/
public class UserInfo implements Serializable {
private static final long serialVersionUID = 4921393251645885049L;
private String id; //账户ID
private String empId; //雇员ID
private String name; //全名
private String userName; //登录账号,对应以前登录返回的loginname
private String corpid; //企业ID
private String corpname; //企业名称
private String no; //工号
private String gender; //性别:M男;F女
private String birthday; //生日
private String rank; //职级
private String empIdCardNo; //证件号
private String empMobileNo; //手机
private String email; //电子邮箱
private String type; //正式;非正式
private String sts; //雇员有效状态(Y有效;N无效)
private String displayName; //用户显示名
private String logoURL; //logo图
private String synSource; //是否显示修改密码 1 隐藏,0 显示
//适配国际机票新添加几个字段,其中性别用原有的gender
private String firstName;//英文姓
private String secondName;//英文名
private String nationality;//国籍
private String nationalityKey;// 国籍Key
private String birth;//生日 此字段暂时弃用
private String accesstoken;
private String isSysManager; //是否系统管理员
private String seessionId; //上次登录seesionID
private String lastLoginIp; //上次登录IP
private String isLoginout; //是否已退出系统
private String logincount; //登录次数
private String depatementId; //用户默认部门ID
private String depatementName; //用户默认部门名称
private String currentDepatementId; //用户当前部门ID
private String currentDepatementName; //用户当前部门名字
private String imgUrl; //头像
private String pushflag; //极光推送标识
private String krtcitycodeversion;
private String reportrole;
private String[] reportRight; //报表权限
private List<String> userRoles; //用户所有角色
private List<String> userExcludeRoles; //用户没有的角色
private List<Map<String, String>> userDepatement; //用户所属部门
private String userDepatementStr; //用户所属部门json串
private Map<String,String> permissiondata; //商旅预订权限控制
private String permissiondataStr; //商旅预订权限控制字符串
private Map<String,String> bankInfo; //银行账号信息
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getEmpId() {
return empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUsername() {
return userName;
}
public void setUsername(String username) {
this.userName = username;
}
public String getCorpid() {
return corpid;
}
public void setCorpid(String corpid) {
this.corpid = corpid;
}
public String getCorpname() {
return corpname;
}
public void setCorpname(String corpname) {
this.corpname = corpname;
}
public String getNo() {
return no;
}
public void setNo(String no) {
this.no = no;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
}
public String getEmpIdCardNo() {
return empIdCardNo;
}
public void setEmpIdCardNo(String empIdCardNo) {
this.empIdCardNo = empIdCardNo;
}
public String getEmpMobileNo() {
return empMobileNo;
}
public void setEmpMobileNo(String empMobileNo) {
this.empMobileNo = empMobileNo;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSts() {
return sts;
}
public void setSts(String sts) {
this.sts = sts;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getLogoURL() {
return logoURL;
}
public void setLogoURL(String logoURL) {
this.logoURL = logoURL;
}
public String getSynSource() {
return synSource;
}
public void setSynSource(String synSource) {
this.synSource = synSource;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getSecondName() {
return secondName;
}
public void setSecondName(String secondName) {
this.secondName = secondName;
}
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public String getNationalityKey() {
return nationalityKey;
}
public void setNationalityKey(String nationalityKey) {
this.nationalityKey = nationalityKey;
}
public String getBirth() {
return birth;
}
public void setBirth(String birth) {
this.birth = birth;
}
public String getAccesstoken() {
return accesstoken;
}
public void setAccesstoken(String accesstoken) {
this.accesstoken = accesstoken;
}
public String getIsSysManager() {
return isSysManager;
}
public void setIsSysManager(String isSysManager) {
this.isSysManager = isSysManager;
}
public String getSeessionId() {
return seessionId;
}
public void setSeessionId(String seessionId) {
this.seessionId = seessionId;
}
public String getLastLoginIp() {
return lastLoginIp;
}
public void setLastLoginIp(String lastLoginIp) {
this.lastLoginIp = lastLoginIp;
}
public String getIsLoginout() {
return isLoginout;
}
public void setIsLoginout(String isLoginout) {
this.isLoginout = isLoginout;
}
public String getLogincount() {
return logincount;
}
public void setLogincount(String logincount) {
this.logincount = logincount;
}
public String getDepatementId() {
return depatementId;
}
public void setDepatementId(String depatementId) {
this.depatementId = depatementId;
}
public String getDepatementName() {
return depatementName;
}
public void setDepatementName(String depatementName) {
this.depatementName = depatementName;
}
public String getCurrentDepatementId() {
return currentDepatementId;
}
public void setCurrentDepatementId(String currentDepatementId) {
this.currentDepatementId = currentDepatementId;
}
public String getCurrentDepatementName() {
return currentDepatementName;
}
public void setCurrentDepatementName(String currentDepatementName) {
this.currentDepatementName = currentDepatementName;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public String getPushflag() {
return pushflag;
}
public void setPushflag(String pushflag) {
this.pushflag = pushflag;
}
public String getKrtcitycodeversion() {
return krtcitycodeversion;
}
public void setKrtcitycodeversion(String krtcitycodeversion) {
this.krtcitycodeversion = krtcitycodeversion;
}
public String getReportrole() {
return reportrole;
}
public void setReportrole(String reportrole) {
this.reportrole = reportrole;
}
public String[] getReportRight() {
return reportRight;
}
public void setReportRight(String[] reportRight) {
this.reportRight = reportRight;
}
public List<String> getUserRoles() {
return userRoles;
}
public void setUserRoles(List<String> userRoles) {
this.userRoles = userRoles;
}
public List<String> getUserExcludeRoles() {
return userExcludeRoles;
}
public void setUserExcludeRoles(List<String> userExcludeRoles) {
this.userExcludeRoles = userExcludeRoles;
}
public List<Map<String, String>> getUserDepatement() {
return userDepatement;
}
public void setUserDepatement(List<Map<String, String>> userDepatement) {
this.userDepatement = userDepatement;
}
public String getUserDepatementStr() {
return userDepatementStr;
}
public void setUserDepatementStr(String userDepatementStr) {
this.userDepatementStr = userDepatementStr;
}
public Map<String, String> getPermissiondata() {
return permissiondata;
}
public void setPermissiondata(Map<String, String> permissiondata) {
this.permissiondata = permissiondata;
}
public String getPermissiondataStr() {
return permissiondataStr;
}
public void setPermissiondataStr(String permissiondataStr) {
this.permissiondataStr = permissiondataStr;
}
public Map<String, String> getBankInfo() {
return bankInfo;
}
public void setBankInfo(Map<String, String> bankInfo) {
this.bankInfo = bankInfo;
}
}
package com.stm.asset.page;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import com.stm.asset.R;
import com.stm.asset.base.BaseFragmentActivity;
import com.stm.asset.base.FragPageAdapter;
import com.stm.asset.view.LoadingDialog;
import java.util.ArrayList;
import java.util.List;
/**
* 类名称:CheckTaskActivity
* 类描述:盘点任务页面
* 创建人:story
* 创建时间:2021-12-07 13:54
*/
public class CheckTaskActivity extends BaseFragmentActivity implements View.OnClickListener {
private TextView unfinishedTxt, finishedTxt;
private ViewPager selectVPager;
private FragPageAdapter fragPageAdapter;
private List<Fragment> fragmentList;
private TaskFragment unfinishedTaskFgm;
private TaskFragment finishedTaskFgm;
private LoadingDialog loadingDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_task);
initView();
}
private void initView() {
initTitle();
titleTxt.setText("盘点任务");
findViewById(R.id.common_title_back_layout).setOnClickListener(this);
unfinishedTxt = findViewById(R.id.task_unfinished_txt);
finishedTxt = findViewById(R.id.task_finished_txt);
unfinishedTxt.setText("未盘点任务(0)");
finishedTxt.setText("已完成任务");
unfinishedTxt.setSelected(true);
finishedTxt.setSelected(false);
unfinishedTxt.setOnClickListener(this);
finishedTxt.setOnClickListener(this);
selectVPager = findViewById(R.id.task_content);
fragmentList = new ArrayList<>();
unfinishedTaskFgm = TaskFragment.instance(this,"A");
fragmentList.add(unfinishedTaskFgm);
fragPageAdapter = new FragPageAdapter(getSupportFragmentManager(), fragmentList);
selectVPager.setAdapter(fragPageAdapter);
loadingDialog = new LoadingDialog(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.common_title_back_layout:
finish();
break;
case R.id.task_unfinished_txt:
if (!unfinishedTxt.isSelected()) {
unfinishedTxt.setSelected(true);
finishedTxt.setSelected(false);
selectVPager.setCurrentItem(0);
}
break;
case R.id.task_finished_txt:
if (!finishedTxt.isSelected()) {
if (finishedTaskFgm == null) {
finishedTaskFgm = TaskFragment.instance(this,"B");
fragmentList.add(finishedTaskFgm);
fragPageAdapter.notifyDataSetChanged();
}
unfinishedTxt.setSelected(false);
finishedTxt.setSelected(true);
selectVPager.setCurrentItem(1);
}
break;
}
}
public void setUnfinishedNum(int num) {
String str = "未盘点任务(" + num + ")";
unfinishedTxt.setText(str);
}
public void setFinishedNum(int num) {
String str = "已完成任务";
finishedTxt.setText(str);
}
public LoadingDialog getLoadingDialog() {
return loadingDialog;
}
public void refreshData() {
if (unfinishedTaskFgm != null) {
unfinishedTaskFgm.loadData();
}
if (finishedTaskFgm != null) {
finishedTaskFgm.loadData();
}
}
}
package com.stm.asset.page;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.fn.useries.operation.U8Series;
import com.fn.useries.reader.ERROR;
import com.fn.useries.utils.MusicPlayer;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
import com.stm.asset.base.StmApplication;
import com.stm.asset.utils.ViewUtil;
import com.stm.asset.view.TextMoveLayout;
/**
* 类名称:DeviceSetActivity
* 类描述:设备参数设置
* 创建人:story
* 创建时间:2021-12-15 11:10
*/
public class DeviceSetActivity extends BaseActivity implements View.OnClickListener {
private static final String MODEL = "U8";
private TextMoveLayout powerLayout;
private SeekBar powerSb;
private TextView moveTextDBM;
private ViewGroup.LayoutParams layoutParams;
private EditText temperatureEt;
private Spinner sessionSpinner;
private Spinner flagSpinner;
private U8Series mUSeries;
private int screenWidth;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_device_set);
initView();
}
private void initView() {
initTitle();
screenWidth = ViewUtil.getScreenWidth(this);
moveTextDBM = new TextView(this);
moveTextDBM.setBackgroundColor(Color.rgb(245, 245, 245));
moveTextDBM.setTextColor(Color.rgb(0, 161, 229));
moveTextDBM.setTextSize(26);
moveTextDBM.layout(0, 5, screenWidth, 80);
titleTxt.setText("设备参数");
findViewById(R.id.common_title_back_layout).setOnClickListener(this);
powerLayout = findViewById(R.id.set_power_layout);
powerSb = findViewById(R.id.set_power_sb);
powerSb.setOnSeekBarChangeListener(new OnSeekBarChangeListenerImp());
powerSb.setMax(33);
layoutParams = new ViewGroup.LayoutParams(screenWidth, 40);
temperatureEt = findViewById(R.id.set_temperature_et);
findViewById(R.id.set_temperature_read_btn).setOnClickListener(this);
sessionSpinner = findViewById(R.id.set_inventory_session_spinner);
flagSpinner = findViewById(R.id.set_inventory_flag_spinner);
findViewById(R.id.inventory_save_btn).setOnClickListener(this);
mUSeries = U8Series.getInstance();
}
@Override
protected void onResume() {
super.onResume();
mUSeries.modulePowerOn(MODEL);
powerLayout.removeAllViews();
powerLayout.addView(moveTextDBM, layoutParams);
if (mUSeries != null) {
getPower();
getInventoryParams();
}
}
@Override
protected void onPause() {
super.onPause();
mUSeries.modulePowerOff(MODEL);
}
private void getPower() {
try {
Thread.sleep(800);
String outPowerSetParams = mUSeries.getParams(U8Series.PARA_POWER);
Log.i("DeviceSetActivity", "M10_U8:getPower " + outPowerSetParams);
if (outPowerSetParams.trim().equalsIgnoreCase(ERROR.RECEVICE_INCOMPLETE)) {
MusicPlayer.getInstance().play(MusicPlayer.Type.MUSIC_ERROR);
StmApplication.getInstance().showToastShort(getResources().getString(R.string.device_set_get_power_fail) + " " + outPowerSetParams);
return;
}
refreshPowerView(outPowerSetParams);
// 显示软件提示音
} catch (Exception e) {
Log.i("DeviceSetActivity", "M10_U8:getPowerParamsException " + e.toString());
}
}
private void getInventoryParams() {
String[] mItems = { "s0", "s1", "s2", "s3" };
String[] mItemsFlag = { "A", "B" };
ArrayAdapter<String> simpleAdapter = new ArrayAdapter<>(this, R.layout.view_simple_spinner_item, mItems);
sessionSpinner.setAdapter(simpleAdapter);
String sessionParams = mUSeries.getParams(U8Series.SESSIONSTATE);
if (sessionParams != null && !"".equals(sessionParams)) {
sessionSpinner.setSelection(Integer.parseInt(sessionParams));
}
simpleAdapter = new ArrayAdapter<>(this, R.layout.view_simple_spinner_item, mItemsFlag);
flagSpinner.setAdapter(simpleAdapter);
String flagParams = mUSeries.getParams(U8Series.FLAGSTATE);
if (flagParams != null && !"".equals(flagParams)) {
flagSpinner.setSelection(Integer.parseInt(flagParams));
}
}
private void refreshPowerView(String powerValue) {
String str = powerValue + "dBm";
moveTextDBM.setText(str);
powerSb.setProgress(Integer.parseInt(powerValue));
}
private void getTemperature() {
temperatureEt.setText("");
try {
String strTemperature = mUSeries.getParams(U8Series.TEMPERATURE);
if (strTemperature.trim().equalsIgnoreCase(ERROR.RECEVICE_INCOMPLETE)) {// 接收异常
MusicPlayer.getInstance().play(MusicPlayer.Type.MUSIC_ERROR);
StmApplication.getInstance().showToastShort(ERROR.RECEVICE_INCOMPLETE);
return;
}
MusicPlayer.getInstance().play(MusicPlayer.Type.OK);
temperatureEt.setText(strTemperature);
} catch (Exception e) {
MusicPlayer.getInstance().play(MusicPlayer.Type.MUSIC_ERROR);
Log.i("DeviceSetActivity", "M10_U8:getTemperatureParamsException" + e.toString());
e.printStackTrace();
}
}
private boolean setSessionAndFlag() {
int sessionIndex = sessionSpinner.getSelectedItemPosition();
int flagIndex = flagSpinner.getSelectedItemPosition();
boolean setSessionStateResult = mUSeries.setParams(U8Series.SESSIONSTATE, Byte.toString((byte) sessionIndex));
boolean setFlagStateResult = mUSeries.setParams(U8Series.FLAGSTATE, Byte.toString((byte) flagIndex));
return (setSessionStateResult && setFlagStateResult);
}
private boolean setPower() {
byte btOutputPower;
try {
String powerStr = moveTextDBM.getText().toString();
btOutputPower = (byte) Integer.parseInt(powerStr.subSequence(0, powerStr.indexOf("dBm")).toString());
} catch (Exception e) {
return false;
}
try {
return mUSeries.setParams(U8Series.PARA_POWER, Byte.toString(btOutputPower));
} catch (Exception e) {
Log.i("DeviceSetActivity", "M10_U8:setPowerParamsException" + e.toString());
return false;
}
}
private void saveSet() {
if (setSessionAndFlag() && setPower()) {
MusicPlayer.getInstance().play(MusicPlayer.Type.OK);
StmApplication.getInstance().showToastShort("设置成功");
return;
}
StmApplication.getInstance().showToastShort("设置失败");
MusicPlayer.getInstance().play(MusicPlayer.Type.MUSIC_ERROR);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.common_title_back_layout:
finish();
break;
case R.id.set_temperature_read_btn:
getTemperature();
break;
case R.id.inventory_save_btn:
saveSet();
break;
}
}
private class OnSeekBarChangeListenerImp implements SeekBar.OnSeekBarChangeListener {
// 触发操作,拖动
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
float value = ((float) screenWidth / (float) 35) * (float) 0.8;
int moveStep = Math.round(value);
moveTextDBM.setWidth(80);
moveTextDBM.layout((progress * moveStep), 5, screenWidth, 80);
String str = progress + "dBm";
moveTextDBM.setText(str);
}
// 表示进度条刚开始拖动,开始拖动时候触发的操作
public void onStartTrackingTouch(SeekBar seekBar) {
}
// 停止拖动时候
public void onStopTrackingTouch(SeekBar seekBar) {
}
}
}
package com.stm.asset.page;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.room.Room;
import com.fn.useries.model.ResponseHandler;
import com.fn.useries.operation.U8Series;
import com.fn.useries.reader.model.InventoryBuffer;
import com.fn.useries.reader.server.ReaderHelper;
import com.fn.useries.utils.Tools;
import com.stm.asset.R;
import com.stm.asset.adapter.InventoryAdapter;
import com.stm.asset.base.BaseActivity;
import com.stm.asset.base.StmApplication;
import com.stm.asset.dao.InventoryInfoDao;
import com.stm.asset.database.InventoryInfoDatabase;
import com.stm.asset.model.InventoryInfo;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 类名称:InventoryActivity
* 类描述:盘询页面
* 创建人:story
* 创建时间:2021-12-09 10:33
*/
public class InventoryActivity extends BaseActivity implements View.OnClickListener {
private static final String MODEL = "U8";
private Button beginBtn;
private TextView txtCountTxt;
private U8Series mUSeries;
private ReaderHelper mReaderHelper;
private InventoryBuffer m_curInventoryBuffer;
private Handler mHandler;
private boolean isInventory;
private long mRefreshTime;
private InventoryAdapter inventoryAdapter;
private InventoryInfoDao inventoryInfoDao;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.actitity_inventory);
initView();
mHandler = new Handler();
try {
mReaderHelper = ReaderHelper.getDefaultHelper();
m_curInventoryBuffer = mReaderHelper.getCurInventoryBuffer();
InventoryInfoDatabase database = Room.databaseBuilder(this, InventoryInfoDatabase.class, "inventoryInfoDemo").build();
inventoryInfoDao = database.inventoryInfoDao();
mUSeries = U8Series.getInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onResume() {
super.onResume();
mUSeries.modulePowerOn(MODEL);
}
@Override
protected void onPause() {
super.onPause();
mUSeries.modulePowerOff(MODEL);
}
private void initView() {
initTitle();
titleTxt.setText("资产盘询");
findViewById(R.id.common_title_back_layout).setOnClickListener(this);
beginBtn = findViewById(R.id.inventory_begin_btn);
beginBtn.setOnClickListener(this);
beginBtn.setClickable(true);
txtCountTxt = findViewById(R.id.inventory_txt_count_txt);
ListView listView = findViewById(R.id.inventory_data_list);
inventoryAdapter = new InventoryAdapter(this);
listView.setAdapter(inventoryAdapter);
findViewById(R.id.inventory_finish_btn).setOnClickListener(this);
findViewById(R.id.inventory_save_btn).setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.common_title_back_layout:
finish();
break;
case R.id.inventory_begin_btn:
beginBtn.setClickable(false);
beginBtn.setText(R.string.inventory_btn_doing);
isInventory = true;
mRefreshTime = new Date().getTime();
mUSeries.startInventory(new ResponseHandler() {
@Override
public void onSuccess(String msg, Object data, byte[] parameters) {
super.onSuccess(msg, data, parameters);
if (U8Series.REFRESHLIST.equals(msg)) {
List<InventoryBuffer.InventoryTagMap> list = (List<InventoryBuffer.InventoryTagMap>) data;
if (list.size() > 0) {
inventoryAdapter.setData(list, false);
}
}
}
@Override
public void onFailure(String msg) {
super.onFailure(msg);
StmApplication.getInstance().showToastShort(getResources().getText(R.string.inventory_disk_failure) + msg);
}
});
mHandler.postDelayed(mRefreshRunnable, 500);
break;
case R.id.inventory_finish_btn:
isInventory = false;
try {
mUSeries.stopInventory();
} catch (Exception e) {
e.printStackTrace();
}
mHandler.removeCallbacks(mRefreshRunnable);
beginBtn.setClickable(true);
beginBtn.setText(R.string.inventory_btn_begin);
break;
case R.id.inventory_save_btn:
if (isInventory) {
StmApplication.getInstance().showToastShort("正在盘询,请稍后操作");
} else {
List<InventoryBuffer.InventoryTagMap> dataList = inventoryAdapter.queryData();
if (dataList != null && dataList.size() > 0) {
List<InventoryInfo> insertList = new ArrayList<>();
for (InventoryBuffer.InventoryTagMap map : dataList) {
try {
String epcStr = map.strEPC;
byte[] bytes = Tools.stringToByteArray(epcStr);
String str = new String(bytes, StandardCharsets.UTF_8);
InventoryInfo inventoryInfo = new InventoryInfo();
inventoryInfo.setNumber(str.trim());
inventoryInfo.setStatus("0");
inventoryInfo.setUserName(StmApplication.getInstance().getUserInfo().getUsername());
insertList.add(inventoryInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
StmApplication.getInstance().getAppExecutors().diskIO().execute(new Runnable() {
@Override
public void run() {
inventoryInfoDao.insertInventoryList(insertList);
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
StmApplication.getInstance().showToastShort("保存成功");
inventoryAdapter.setData(null, true);
}
});
}
});
}
}
break;
}
}
private Runnable mRefreshRunnable = new Runnable() {
public void run() {
refreshText();
mHandler.postDelayed(this, 2000);
}
};
private void refreshText() {
String countTxtFormat = InventoryActivity.this.getString(R.string.inventory_count_text);
long now = new Date().getTime();
String text = String.format(countTxtFormat, inventoryAdapter.getCount(), mReaderHelper.getInventoryTotal(), m_curInventoryBuffer.nReadRate, (now - mRefreshTime) / 1000);
// List<InventoryBuffer.InventoryTagMap> list = m_curInventoryBuffer.lsTagList;
// if (list.size() > 0) {
// InventoryBuffer.InventoryTagMap item = list.get(0);
// String str = "strPC:" + item.strPC + " strCRC:" + item.strCRC + " strEPC:" + item.strEPC + " btAntId:" + item.btAntId + " strRSSI:" + item.strRSSI + " nReadCount:" + item.nReadCount + " strFreq:" + item.strFreq + " nAnt1:" + item.nAnt1 + " nAnt2:" + item.nAnt2 + " nAnt3:" + item.nAnt3 + " nAnt4:" + item.nAnt4;
// StmApplication.getInstance().showToastShort(str);
// }
txtCountTxt.setText(text);
}
}
package com.stm.asset.page;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
import com.stm.asset.base.StmApplication;
import com.stm.asset.http.HttpException;
import com.stm.asset.http.HttpService;
import com.stm.asset.http.RequestCallback;
import com.stm.asset.json.CommonStringJson;
import com.stm.asset.json.ListUserInfo;
import com.stm.asset.keyboard.SafeKeyboardManager;
import com.stm.asset.model.LoginInfo;
import com.stm.asset.utils.NetworkUtil;
import com.stm.asset.utils.PropertyUtil;
import com.stm.asset.view.LoadingDialog;
/**
* 类名称:LoginActivity
* 类描述:登录
* 创建人:story
* 创建时间:2021-12-10 09:45
*/
public class LoginActivity extends BaseActivity implements View.OnClickListener {
private EditText accountEt, pwdEt;
private LinearLayout deleteLayout;
private boolean isAccountFocus;
private LoadingDialog loadingDialog;
private int setBtnClickCount = 0;//IP设置按钮的点击次数
private long lastClickTime = 0;//上次点击时间
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 禁止app录屏和截屏
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.activity_login);
initView();
}
private void initView() {
initTitle();
titleTxt.setText("登录");
accountEt = findViewById(R.id.login_account_et);
pwdEt = findViewById(R.id.login_pwd_et);
deleteLayout = findViewById(R.id.login_account_delete_layout);
findViewById(R.id.common_title_back_layout).setOnClickListener(this);
findViewById(R.id.login_login_btn).setOnClickListener(this);
deleteLayout.setOnClickListener(this);
accountEt.addTextChangedListener(textWatcher);
accountEt.setOnFocusChangeListener(new AccountFocusChangeListener());
SafeKeyboardManager.initKeyBoard(getString(R.string.app_name));
SafeKeyboardManager.registKeyboard(this, pwdEt);
String accountStr = PropertyUtil.getRememberAccount(this);
accountEt.setText(accountStr);
loadingDialog = new LoadingDialog(this);
// 切换IP
findViewById(R.id.common_title_right_layout).setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.common_title_back_layout:
finish();
break;
case R.id.login_account_delete_layout:
accountEt.setText("");
break;
case R.id.login_login_btn:
String accountStr = accountEt.getText().toString();
String passwordStr = pwdEt.getText().toString();
if ("".equals(accountStr)) {
StmApplication.getInstance().showToastShort("请填写用户名");
return;
}
if ("".equals(passwordStr)) {
StmApplication.getInstance().showToastShort("请填写密码");
return;
}
if (NetworkUtil.isNetworkAvailable(LoginActivity.this)) {
loadingDialog.show();
HttpService.getInstance().unionLoginApp(accountStr, passwordStr, login_cb);
} else {
StmApplication.getInstance().showToastShort(getString(R.string.net_settings));
}
break;
case R.id.common_title_right_layout:
long now = System.currentTimeMillis();
if(now - lastClickTime < 800) {
setBtnClickCount++;
} else {
setBtnClickCount = 1;
}
lastClickTime = now;
if(setBtnClickCount >= 10) {
setBtnClickCount = 0;
// Intent selectIpIntent = new Intent();
// selectIpIntent.setClass(this, SelectIPActivity.class);
// startActivityForResult(selectIpIntent, 1);
}
break;
}
}
private TextWatcher textWatcher = new TextWatcher() {
@Override
public void afterTextChanged(Editable arg0) {
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
if (!"".equals(arg0.toString()) && isAccountFocus) {
if (deleteLayout.getVisibility() == View.GONE)
deleteLayout.setVisibility(View.VISIBLE);
} else {
deleteLayout.setVisibility(View.GONE);
}
pwdEt.setText("");
}
};
private RequestCallback<CommonStringJson> login_cb = new RequestCallback<CommonStringJson>(CommonStringJson.class) {
@Override
public void onSuccess(CommonStringJson responseInfo) {
if (responseInfo.isSucess()) {
StmApplication.getInstance().showToastShort("登录成功");
String accessToken = responseInfo.getRspData();
PropertyUtil.setAccessToken(StmApplication.getInstance().getApplicationContext(), accessToken);
HttpService.getInstance().quryPageHomeUserInfo(accessToken, userInfo_cb);
} else {
StmApplication.getInstance().showToastShort(responseInfo.getRspMsg());
loadingDialog.dismiss();
}
}
@Override
public void onFailure(HttpException error, String msg) {
loadingDialog.dismiss();
StmApplication.getInstance().showToastShort(msg);
}
};
private RequestCallback<ListUserInfo> userInfo_cb = new RequestCallback<ListUserInfo>(ListUserInfo.class) {
@Override
public void onSuccess(ListUserInfo responseInfo) {
loadingDialog.dismiss();
if (responseInfo.isSucess()) {
StmApplication.getInstance().showToastShort("登录成功");
LoginInfo loginInfo = responseInfo.getRspData();
if (loginInfo != null && loginInfo.getUserInfo() != null) {
StmApplication.getInstance().setUserInfo(loginInfo.getUserInfo());
finish();
}
} else {
StmApplication.getInstance().showToastShort(responseInfo.getRspMsg());
}
}
@Override
public void onFailure(HttpException error, String msg) {
loadingDialog.dismiss();
StmApplication.getInstance().showToastShort(msg);
}
};
private class AccountFocusChangeListener implements View.OnFocusChangeListener {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
if (!"".equals(accountEt.getText().toString()))
deleteLayout.setVisibility(View.VISIBLE);
} else {
if (deleteLayout.getVisibility() == View.VISIBLE)
deleteLayout.setVisibility(View.GONE);
}
isAccountFocus = hasFocus;
}
}
}
package com.stm.asset.page;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.core.app.ActivityCompat;
import com.fn.useries.model.Message;
import com.fn.useries.operation.IUSeries;
import com.fn.useries.operation.U8Series;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
import com.stm.asset.base.StmApplication;
import com.stm.asset.http.HttpException;
import com.stm.asset.http.HttpService;
import com.stm.asset.http.RequestCallback;
import com.stm.asset.json.CommonMapJson;
import com.stm.asset.model.UserInfo;
import com.stm.asset.utils.NetworkUtil;
import com.stm.asset.utils.VersionUtil;
import com.stm.asset.utils.ViewUtil;
import com.stm.asset.view.CommonAlertDialog;
import com.stm.asset.view.LoadingDialog;
import java.util.Map;
/**
* 类名称:MainActivity
* 类描述:主页面
* 创建人:story
* 创建时间:2021-12-08 16:39
*/
public class MainActivity extends BaseActivity implements View.OnClickListener {
private static final String MODEL = "U8";
private static final int REQUEST_TO_SET = 10001;
private RelativeLayout logoutLayout;
private View logoutLine;
private TextView userTxt;
private IUSeries mUSeries;
private boolean setFlag = false;
private UserInfo userInfo;
private LoadingDialog loadingDialog;
private Map<String, String> versionMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
U8Series.setContext(StmApplication.getInstance().getApplicationContext());
mUSeries = U8Series.getInstance();
Message openSerialMsg = mUSeries.openSerialPort(MODEL);
Log.i("MainActivity", "code:" + openSerialMsg.getCode());
if (openSerialMsg.getCode() != 0) {
jumpToConfigurationTool();
} else {
setFlag = true;
}
loadingDialog = new LoadingDialog(this);
}
private void initView() {
userTxt = findViewById(R.id.main_user_txt);
logoutLayout = findViewById(R.id.main_logout_layout);
logoutLine = findViewById(R.id.main_logout_line);
userTxt.setOnClickListener(this);
findViewById(R.id.main_inventory_data_layout).setOnClickListener(this);
findViewById(R.id.main_begin_inventory_layout).setOnClickListener(this);
findViewById(R.id.main_settings_layout).setOnClickListener(this);
logoutLayout.setOnClickListener(this);
}
private void jumpToConfigurationTool() {
Intent intent = new Intent();
intent.putExtra("modelName", MODEL);
intent.putExtra("packageName", getPackageName());
intent.putExtra("activityName", MainActivity.class.getName());
intent.setClass(this, SetAndSaveActivity.class);
startActivityForResult(intent, REQUEST_TO_SET);
}
@Override
protected void onResume() {
super.onResume();
userInfo = StmApplication.getInstance().getUserInfo();
if (userInfo != null) {
String str = "用户:" + userInfo.getName();
userTxt.setText(str);
logoutLayout.setVisibility(View.VISIBLE);
logoutLine.setVisibility(View.VISIBLE);
} else {
userTxt.setText("登录");
logoutLayout.setVisibility(View.GONE);
logoutLine.setVisibility(View.GONE);
}
// getVersionIno();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (setFlag) {
mUSeries.closeSerialPort();
}
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.main_user_txt:
if (userInfo == null) {
Intent loginIntent = new Intent();
loginIntent.setClass(MainActivity.this, LoginActivity.class);
startActivity(loginIntent);
}
break;
case R.id.main_inventory_data_layout:
if (userInfo != null) {
Intent gotoTaskIntent = new Intent();
gotoTaskIntent.setClass(MainActivity.this, CheckTaskActivity.class);
startActivity(gotoTaskIntent);
} else {
Intent loginIntent = new Intent();
loginIntent.setClass(MainActivity.this, LoginActivity.class);
startActivity(loginIntent);
}
break;
case R.id.main_begin_inventory_layout:
if (userInfo != null) {
if (!setFlag) {
Message openSerialMsg = mUSeries.openSerialPort(MODEL);
if (openSerialMsg.getCode() != 0) {
jumpToConfigurationTool();
} else {
setFlag = true;
Intent inventoryIntent = new Intent();
inventoryIntent.setClass(MainActivity.this, InventoryActivity.class);
startActivity(inventoryIntent);
}
} else {
Intent inventoryIntent = new Intent();
inventoryIntent.setClass(MainActivity.this, InventoryActivity.class);
startActivity(inventoryIntent);
}
break;
} else {
Intent loginIntent = new Intent();
loginIntent.setClass(MainActivity.this, LoginActivity.class);
startActivity(loginIntent);
}
case R.id.main_settings_layout:
if (!setFlag) {
Message openSerialMsg = mUSeries.openSerialPort(MODEL);
if (openSerialMsg.getCode() != 0) {
jumpToConfigurationTool();
} else {
setFlag = true;
Intent inventoryIntent = new Intent();
inventoryIntent.setClass(MainActivity.this, DeviceSetActivity.class);
startActivity(inventoryIntent);
}
} else {
Intent deviceSetIntent = new Intent();
deviceSetIntent.setClass(MainActivity.this, DeviceSetActivity.class);
startActivity(deviceSetIntent);
}
break;
case R.id.main_logout_layout:
userInfo = null;
StmApplication.getInstance().setUserInfo(null);
userTxt.setText("登录");
logoutLayout.setVisibility(View.GONE);
logoutLine.setVisibility(View.GONE);
StmApplication.getInstance().showToastShort("退出成功");
break;
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == REQUEST_TO_SET) {
Message openSerialMsg = mUSeries.openSerialPort(MODEL);
if (openSerialMsg.getCode() == 0) {
setFlag = true;
}
}
return;
}
super.onActivityResult(requestCode, resultCode, data);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
showExitDialog();
return true;
}
return super.dispatchKeyEvent(event);
}
private void showExitDialog() {
int dialog_width = (int) (ViewUtil.getScreenWidth(this) * 4 / 5.0);
final CommonAlertDialog dialog = new CommonAlertDialog(MainActivity.this);
dialog.setViewParams(new LinearLayout.LayoutParams(dialog_width, -2));
dialog.show();
dialog.setText("提示", "确定退出" + getResources().getString(R.string.app_name) + "吗?", "确定");
dialog.setSureListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (dialog.isShowing()) {
dialog.dismiss();
}
sApp.setShowBackground(false);
MainActivity.this.finish();
}
});
}
private void getVersionIno() {
if (NetworkUtil.isNetworkAvailable(MainActivity.this)) {
loadingDialog.show();
HttpService.getInstance().queryAppVersionApp(version_cb);
} else {
StmApplication.getInstance().showToastShort(getString(R.string.net_settings));
}
}
private void showVersionDialog() {
String appName = getResources().getString(R.string.app_name);
String content = "检测到"+ appName + "新版本v" + versionMap.get("vesion");
int dialog_width = (int) (ViewUtil.getScreenWidth(this) * 4 / 5.0);
final CommonAlertDialog dialog = new CommonAlertDialog(MainActivity.this);
dialog.setViewParams(new LinearLayout.LayoutParams(dialog_width, -2));
dialog.show();
final String forceStr = versionMap.get("forceflag");
if ("0".equals(forceStr)) { // 强制升级
dialog.setText("提示", content, "现在升级", "退出程序");
} else {
dialog.setText("提示", content, "现在升级", "暂不升级");
}
dialog.setSureListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (dialog.isShowing()) {
dialog.dismiss();
}
// 权限检查
int perRes = ActivityCompat.checkSelfPermission(MainActivity.this, "android.permission.READ_EXTERNAL_STORAGE");
int perRes2 = ActivityCompat.checkSelfPermission(MainActivity.this, "android.permission.WRITE_EXTERNAL_STORAGE");
if (perRes == PackageManager.PERMISSION_DENIED || perRes2 == PackageManager.PERMISSION_DENIED) {
sApp.setShowBackground(false);
// ActivityCompat.requestPermissions(MainActivity.this, new String[] {"android.permission.READ_EXTERNAL_STORAGE", "android.permission.WRITE_EXTERNAL_STORAGE"}, IConstant.PERMISSION_REQUEST_SELECT_PHOTO);
} else {
// TODO
}
}
});
dialog.setCancelListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (dialog.isShowing()) {
dialog.dismiss();
}
if ("0".equals(forceStr)) {
sApp.setShowBackground(false);
MainActivity.this.finish();
}
}
});
}
private RequestCallback<CommonMapJson> version_cb = new RequestCallback<CommonMapJson>(CommonMapJson.class) {
@Override
public void onSuccess(CommonMapJson responseInfo) {
if (responseInfo.isSucess()) {
versionMap = responseInfo.getRspData();
if (versionMap!= null && versionMap.containsKey("versionMap") && VersionUtil.needUpdate(versionMap.get("vesion"))) {
showVersionDialog();
}
}
}
@Override
public void onFailure(HttpException error, String msg) {
}
};
}
package com.stm.asset.page;
import android.os.Bundle;
import android.widget.ListView;
import androidx.annotation.Nullable;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
/**
* 类名称:BaseActivity
* 类描述:选择IP
* 创建人:story
* 创建时间:2022-01-05 21:05
*/
public class SelectIPActivity extends BaseActivity {
private ListView listView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_ip);
}
private void initView() {
listView = findViewById(R.id.select_list);
// listView.setAdapter();
}
}
package com.stm.asset.page;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
import com.stm.asset.base.StmApplication;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import cn.fuen.xmldemo.entity.Device;
import cn.fuen.xmldemo.model.DeviceModel;
import cn.fuen.xmldemo.model.DeviceModelImp;
public class SetAndSaveActivity extends BaseActivity implements OnClickListener, OnItemSelectedListener, OnCheckedChangeListener {
public static final String _4_0_3 = "4.0.3";
public static final String _5_1_1 = "5.1.1";
public static final int M96DisplayHeight = 782;
public static final int M10ADisplayHeight = 640;
private Button btn_save;
private CheckBox cb_enable;
private Spinner spinnerModel;
private Spinner spinnerSerialPort;
private Spinner spinnerBaud;
private Context mContext;
private List<String> modelList = new ArrayList<>();
private List<String> serialPortList = new ArrayList<>();
private List<String> baudList = new ArrayList<>();
// 写入list集合
private List<Device> writeList = new ArrayList<>();
// 读取出的数据信息存储集合
private List<Device> readList = new ArrayList<>();
// 读取出的数据model存储集合
// private List<String> readModels = new ArrayList<>();
// 为方便动态设置radioGroup被选择的RadioButton位置,创建List存储
private List<RadioGroup> rgList = new ArrayList<>();
// 新建一个btnList存储radiobutton的状态
private List<String> btnList = new ArrayList<String>();
// 声明DeviceModel
private DeviceModelImp deviceModel;
// 设置一默认参数Device方便设置调用
private Device mDefaultDevice = new Device();
private List<String> mDefaultGPIOList = new ArrayList<>();
// 存储上下电区域TextView 方便动态添加及获取
private List<TextView> onTvList = new ArrayList<>();
private boolean versionCheckSucceed = true;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getApplicationContext();
deviceModel = new DeviceModel(mContext);
setContentView(R.layout.activity_setandsave);
// reload();
initView();
if (versionCheckSucceed) {
setAdapter();
getModelType();
// 对Modelspinner及Button实现监听
setListener();
}
}
@Override
public void finish() {
// if (versionCheckSucceed)
// jumpToModel();
super.finish();
}
// private void jumpToModel() {
// // 判断是完成否已经配置
// Intent in = new Intent();
// Intent jumpIntent = getIntent();
// if (jumpIntent.getStringExtra("packageName") == null || jumpIntent.getStringExtra("activityName") == null)
// return;
// in.setClassName(jumpIntent.getStringExtra("packageName"), jumpIntent.getStringExtra("activityName"));
// startActivity(in);
// }
/**
* 获取intent传进的参数,并将当前页面
*/
private void getModelType() {
String modeName = (String) getIntent().getStringExtra("modelName");
if (modeName != null) {
spinnerModel.setSelection(modelList.indexOf(modeName));
setModelConfig(mDefaultDevice);
}
}
/**
* 设置一个默认Device参数方便调用
*/
private void setDefaultDevice(int length) {
mDefaultDevice.setSerialPort(serialPortList.get(0));
mDefaultDevice.setBaudRate(9600);
mDefaultDevice.setEnable(false);
for (int i = 0; i < length; i++) {
mDefaultGPIOList.add("无");
}
mDefaultDevice.setGpios(mDefaultGPIOList);
}
/**
* 根据形参Device刷新当前界面
*/
private void setModelConfig(Device d) {
// 设置串口spinner
for (int i = 0; i < serialPortList.size(); i++) {
if (d.getSerialPort().equals(serialPortList.get(i))) {
spinnerSerialPort.setSelection(i);
}
}
// 设置波特率spinner
for (int i = 0; i < baudList.size(); i++) {
if (d.getBaudRate() == Integer.parseInt(baudList.get(i))) {
spinnerBaud.setSelection(i);
}
}
// 设置enableCheckBox
cb_enable.setChecked(d.isEnable());
// 设置上下电参数
List<String> gpioList = d.getGpios();
Log.i("see", "gpioList de size " + gpioList.size() + "");
Log.i("see", "rgList de size " + rgList.size() + "");
for (int i = 0; i < gpioList.size(); i++) {
int index = getchildIndex(gpioList.get(i));
rgList.get(i).check(rgList.get(i).getChildAt(index).getId());
}
}
// 设置adapter
private void setAdapter() {
String[] baudsStrings = getResources().getStringArray(R.array.spinarr_baud);
List<String> baudsList = new ArrayList<>();
for (int i = 0; i < baudsStrings.length; i++) {
baudsList.add(baudsStrings[i]);
}
ArrayAdapter<String> modelAdapter = new ArrayAdapter<>(this, R.layout.spinner_item, modelList);
spinnerModel.setAdapter(modelAdapter);
ArrayAdapter<String> baudAdapter = new ArrayAdapter<>(this, R.layout.spinner_item, baudsList);
spinnerBaud.setAdapter(baudAdapter);
ArrayAdapter<String> portAdapter = new ArrayAdapter<>(this, R.layout.spinner_item, serialPortList);
spinnerSerialPort.setAdapter(portAdapter);
}
/**
* 整个界面设置监听
*/
private void setListener() {
// spinner控件的监听
spinnerModel.setOnItemSelectedListener(this);
// saveBtn的监控
btn_save.setOnClickListener(this);
// checkBox监听
cb_enable.setOnCheckedChangeListener(this);
}
/**
* 顶部spinner model切换监听
*/
// 上一次点击的position默认是0
private int lastPosition = 0;
@Override
public void onItemSelected(AdapterView<?> arg0, View v, int position, long arg3) {
if (versionCheckSucceed) {
// 判断当前点击事件位置和上一次点击事件位置是否相同 ,不同则更新writeList
if (position != lastPosition) {
updataWriteList();
}
if (writeList.size() != 0) {
// 若此次点击的model在读取到的集合中
Device device = getDeviceFromModel(modelList.get(position));
if (device != null) {
setModelConfig(device);
} else {
setModelConfig(mDefaultDevice);
}
} else {
// 若此次点击的model不在读取集合中,将各个设置项置为默认状态
setModelConfig(mDefaultDevice);
}
lastPosition = position;
}
}
/**
* 根据传进model字符串获取Device
*
* @return Device
*/
public Device getDeviceFromModel(String model) {
Device device = null;
for (Device d : writeList) {
if (d.getModel().equals(model)) {
device = d;
}
}
return device;
}
// 在切换model或点击保存时将页面信息保存到内存中
private void updataWriteList() {
// 此处判断 此次要存到内存中的Device是否之前设置过,若设置过则把之前的remove掉
Iterator<Device> iterator = writeList.iterator();
while (iterator.hasNext()) {
Device d = iterator.next();
if (d.getModel().equals(modelList.get(lastPosition))) {
iterator.remove(); // 注意这个地方
}
}
Device device = new Device();
device.setModel(modelList.get(lastPosition));
device.setEnable(cb_enable.isChecked());
device.setSerialPort(spinnerSerialPort.getSelectedItem().toString());
device.setBaudRate(Integer.parseInt(spinnerBaud.getSelectedItem().toString()));
initRadioBtn();
for (int i = 0; i < checkedRBs.size(); i++) {
btnList.add(checkedRBs.get(i).getText().toString());
}
device.setGpios(btnList);
writeList.add(device);
btnList.clear();
Log.i("writesize", writeList.size() + "");
}
// 获取GPIO状态对应的RadioGroup中的位置
private int getchildIndex(String state) {
if (state.equals("1")) {
return 0;
} else if (state.equals("0")) {
return 1;
} else if (state.equals("无")) {
return 2;
}
return -1;
}
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.saveBtn && versionCheckSucceed) {
updataWriteList();
// 储存writeList中的model字符串
List<String> bufList = new ArrayList<>();
for (Device d : writeList) {
bufList.add(d.getModel());
}
if (readList != null) {
for (Device rd : readList) {
Log.i("writesize", Boolean.toString(rd == null));
if (!bufList.contains(rd.getModel())) {
writeList.add(rd);
}
}
}
deviceModel.writeXML(writeList, rgList.size() / 2);
StmApplication.getInstance().showToastShort("success");
} else if (id == R.id.common_title_back_layout) {
setResult(RESULT_OK);
finish();
}
}
/**
* 动态加载GPIO区域控件
*
* @param release
*/
private void updataGPIOUI(String release) {
String[] valueStrings = new String[] { "1", "0", "无" };
if (release.equals("m10")) {
String[] m10_GPIO = getResources().getStringArray(R.array.m10_GPIO);
RelativeLayout onRelativeLayout = findViewById(R.id.relativeLayoutON_main);
addViewTo(m10_GPIO, valueStrings, onRelativeLayout, R.id.poweron);
RelativeLayout offRelativeLayout = findViewById(R.id.relativeLayoutOFF_main);
addViewTo(m10_GPIO, valueStrings, offRelativeLayout, R.id.poweroff);
} else if (release.equals("m10A")) {
String[] m10A_GPIO = getResources().getStringArray(R.array.m10A_GPIO);
RelativeLayout onRelativeLayout = findViewById(R.id.relativeLayoutON_main);
addViewTo(m10A_GPIO, valueStrings, onRelativeLayout, R.id.poweron);
RelativeLayout offRelativeLayout = findViewById(R.id.relativeLayoutOFF_main);
addViewTo(m10A_GPIO, valueStrings, offRelativeLayout, R.id.poweroff);
} else if (release.equals("m96")) {
String[] m96_GPIO = getResources().getStringArray(R.array.m96_GPIO);
RelativeLayout onRelativeLayout = findViewById(R.id.relativeLayoutON_main);
addViewTo(m96_GPIO, valueStrings, onRelativeLayout, R.id.poweron);
RelativeLayout offRelativeLayout = findViewById(R.id.relativeLayoutOFF_main);
addViewTo(m96_GPIO, valueStrings, offRelativeLayout, R.id.poweroff);
}
}
@SuppressWarnings("deprecation")
private void addViewTo(String[] m10_GPIO, String[] valueStrings, RelativeLayout relativeLayout, int startViewId) {
TextView textView1 = new TextView(mContext);
textView1.setId(R.id.special_define_set_text);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.RIGHT_OF, startViewId);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
params.setMargins(23, 0, 0, 0);
textView1.setLayoutParams(params);
textView1.setPadding(0, 15, 0, 20);
textView1.setText(m10_GPIO[0]);
textView1.setTextSize(13);
textView1.setTextColor(0xFF000000);
relativeLayout.addView(textView1);
/*********************** RadioButton ******************************/
RadioGroup radioGroup1 = new RadioGroup(mContext);
radioGroup1.setId(R.id.special_define_set_radio);
RelativeLayout.LayoutParams rgLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rgLayoutParams.addRule(RelativeLayout.ALIGN_TOP, textView1.getId());
// rgLayoutParams.addRule(RelativeLayout.RIGHT_OF, tv.getId());
// rgLayoutParams.addRule(RelativeLayout.RIGHT_OF, textView1.getId());
rgLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
rgLayoutParams.setMargins(0, 0, 50, 0);
radioGroup1.setLayoutParams(rgLayoutParams);
radioGroup1.setOrientation(RadioGroup.HORIZONTAL);
for (int a = 0; a < valueStrings.length; a++) {
RadioButton rbButton = new RadioButton(mContext);
RadioGroup.LayoutParams rbParams = new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
rbButton.setLayoutParams(rbParams);
rbButton.setText(valueStrings[a]);
rbButton.setTextSize(12);
rbButton.setTextColor(0xFF000000);
rbButton.setId(1000 + a);
Bitmap b = null;
rbButton.setButtonDrawable(new BitmapDrawable(b));
Drawable drawable = getResources().getDrawable(R.drawable.abc_radio);
drawable.setBounds(0, 0, 50, 50);
rbButton.setCompoundDrawables(drawable, null, null, null);
rbButton.setPadding(5, 0, 0, 0);
radioGroup1.addView(rbButton);
if (a == 2) {
radioGroup1.check(rbButton.getId());
}
}
relativeLayout.addView(radioGroup1);
onTvList.add(textView1);
rgList.add(radioGroup1);
for (int i = 1; i < m10_GPIO.length; i++) {
// 设置
TextView textView = new TextView(mContext);
textView.setId(i);
RelativeLayout.LayoutParams tvParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
// tvParams.setMargins(15, 0, 0, 0); textView1
tvParams.addRule(RelativeLayout.ALIGN_LEFT, textView1.getId());
// Log.i("see", onTvList.size() + "");
// Log.i("see", "i-1" + " " + (i - 1) + " " + (onTvList.get(i -
// 1).getId()));
tvParams.addRule(RelativeLayout.BELOW, onTvList.get(i - 1).getId());
textView.setLayoutParams(tvParams);
textView.setPadding(0, 10, 0, 20);
textView.setText(m10_GPIO[i]);
textView.setTextSize(13);
textView.setTextColor(0xFF000000);
relativeLayout.addView(textView);
// RadioGroup
RadioGroup rGroup = new RadioGroup(mContext);
rGroup.setId(100 + i);
RelativeLayout.LayoutParams rgParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
rgParams.addRule(RelativeLayout.ALIGN_TOP, textView.getId());
// rgLayoutParams.addRule(RelativeLayout.RIGHT_OF, tv.getId());
rgParams.addRule(RelativeLayout.ALIGN_LEFT, radioGroup1.getId());
rGroup.setLayoutParams(rgParams);
rGroup.setOrientation(RadioGroup.HORIZONTAL);
for (int a = 0; a < valueStrings.length; a++) {
RadioButton rbButton = new RadioButton(mContext);
RadioGroup.LayoutParams rbParams = new RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT);
rbButton.setLayoutParams(rbParams);
rbButton.setText(valueStrings[a]);
rbButton.setTextSize(12);
rbButton.setTextColor(0xFF000000);
rbButton.setId(1000 + a);
Bitmap b = null;
rbButton.setButtonDrawable(new BitmapDrawable(b));
Drawable drawable = getResources().getDrawable(R.drawable.abc_radio);
drawable.setBounds(0, 0, 50, 50);
rbButton.setCompoundDrawables(drawable, null, null, null);
rbButton.setPadding(5, 0, 0, 0);
rGroup.addView(rbButton);
if (a == 2) {
rGroup.check(rbButton.getId());
}
}
relativeLayout.addView(rGroup);
onTvList.add(textView);
rgList.add(rGroup);
}
}
/**
* 实例化页面上方xml添加的控件
*/
@SuppressWarnings("deprecation")
private void initView() {
initTitle();
titleTxt.setText("设备基本设置");
backLayout.setOnClickListener(this);
btn_save = findViewById(R.id.saveBtn);
cb_enable = findViewById(R.id.enableCheckBox);
Bitmap b = null;
cb_enable.setButtonDrawable(new BitmapDrawable(b));
Drawable drawable = getResources().getDrawable(R.drawable.abc_checkbox);
drawable.setBounds(0, 0, 60, 60);
cb_enable.setCompoundDrawables(drawable, null, null, null);
cb_enable.setPadding(5, 0, 0, 0);
spinnerSerialPort = findViewById(R.id.serialport_spinner);
spinnerBaud = findViewById(R.id.baudRate_spinner);
spinnerModel = findViewById(R.id.model_spinner);
String SystemRelease = android.os.Build.VERSION.RELEASE;
if (SystemRelease.equals(_4_0_3)) {
// 根据不同机型 重新设置界面显示
updataGPIOUI("m10");
// 设置串口spinner中数据
String[] m10SerialPort = getResources().getStringArray(R.array.m10SerialPort);
for (int i = 0; i < m10SerialPort.length; i++) {
serialPortList.add(m10SerialPort[i]);
}
setDefaultDevice(rgList.size());
String[] modelsStrings = getResources().getStringArray(R.array.m10_models);
for (int i = 0; i < modelsStrings.length; i++) {
modelList.add(modelsStrings[i]);
}
} else if (SystemRelease.equals(_5_1_1)) {
if (getWindowManager().getDefaultDisplay().getHeight() == M10ADisplayHeight) {
// 根据不同机型 重新设置界面显示
updataGPIOUI("m10A");
String[] m10ASerialPort = getResources().getStringArray(R.array.m10ASerialPort);
for (int i = 0; i < m10ASerialPort.length; i++) {
serialPortList.add(m10ASerialPort[i]);
}
setDefaultDevice(rgList.size());
String[] modelsStrings = getResources().getStringArray(R.array.m10_models);
for (int i = 0; i < modelsStrings.length; i++) {
modelList.add(modelsStrings[i]);
}
} else {
// 根据不同机型 重新设置界面显示
updataGPIOUI("m96");
String[] m10ASerialPort = getResources().getStringArray(R.array.m96SerialPort);
for (int i = 0; i < m10ASerialPort.length; i++) {
serialPortList.add(m10ASerialPort[i]);
}
setDefaultDevice(rgList.size());
String[] modelsStrings = getResources().getStringArray(R.array.m96_models);
for (int i = 0; i < modelsStrings.length; i++) {
modelList.add(modelsStrings[i]);
}
}
} else {
versionCheckSucceed = false;
StmApplication.getInstance().showToastShort("此设备系统版本异常 请与技术支持人员联系");
}
}
private List<RadioButton> checkedRBs = new ArrayList<>();
/**
* 每次调用获得点击到的radiobutton
*/
public void initRadioBtn() {
checkedRBs.clear();
for (int i = 0; i < rgList.size(); i++) {
RadioButton checkedRb = findViewById(rgList.get(i).getCheckedRadioButtonId());
checkedRBs.add(checkedRb);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
@Override
protected void onDestroy() {
super.onDestroy();
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
setResult(RESULT_OK);
finish();
return true;
}
return super.dispatchKeyEvent(event);
}
}
package com.stm.asset.page;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.room.Room;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.stm.asset.R;
import com.stm.asset.adapter.TaskAdapter;
import com.stm.asset.base.BaseFragment;
import com.stm.asset.base.StmApplication;
import com.stm.asset.dao.InventoryInfoDao;
import com.stm.asset.database.InventoryInfoDatabase;
import com.stm.asset.http.HttpException;
import com.stm.asset.http.HttpService;
import com.stm.asset.http.RequestCallback;
import com.stm.asset.json.CommonStringJson;
import com.stm.asset.model.InventoryInfo;
import com.stm.asset.utils.NetworkUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 类名称:TaskFragment
* 类描述:盘点任务Fragment,包括未盘点和已完成
* 创建人:story
* 创建时间:2021-12-07 14:43
*/
public class TaskFragment extends BaseFragment implements View.OnClickListener {
private RelativeLayout noneLayout;
private TaskAdapter taskAdapter;
private List<InventoryInfo> inventoryInfoList;
private String type; // 类型:A:未盘点 B:已完成
private InventoryInfoDao inventoryInfoDao;
private CheckTaskActivity checkTaskActivity;
private TaskFragment(CheckTaskActivity checkTaskActivity, String type) {
this.checkTaskActivity = checkTaskActivity;
this.type = type;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_task, null);
ListView listView = view.findViewById(R.id.fgm_task_list);
noneLayout = view.findViewById(R.id.fgm_task_none_layout);
taskAdapter = new TaskAdapter(getActivity());
listView.setAdapter(taskAdapter);
Button testBtn = view.findViewById(R.id.task_test_btn);
Button saveBtn = view.findViewById(R.id.task_upload_btn);
Button cleanBtn = view.findViewById(R.id.task_clean_btn);
saveBtn.setOnClickListener(this);
cleanBtn.setOnClickListener(this);
testBtn.setOnClickListener(this);
if ("B".equals(type)) {
saveBtn.setVisibility(View.GONE);
}
// testBtn.setVisibility(View.VISIBLE);
InventoryInfoDatabase database = Room.databaseBuilder(checkTaskActivity, InventoryInfoDatabase.class, "inventoryInfoDemo").build();
inventoryInfoDao = database.inventoryInfoDao();
loadData();
return view;
}
public void loadData() {
StmApplication.getInstance().getAppExecutors().diskIO().execute(new Runnable() {
@Override
public void run() {
if (inventoryInfoDao != null) {
if ("A".equals(type)) {
inventoryInfoList = inventoryInfoDao.getUndoInventoryList(StmApplication.getInstance().getUserInfo().getUsername());
} else if ("B".equals(type)) {
inventoryInfoList = inventoryInfoDao.getDoneInventoryList(StmApplication.getInstance().getUserInfo().getUsername());
}
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
taskAdapter.setData(inventoryInfoList);
if (checkTaskActivity != null) {
if ("A".equals(type)) {
checkTaskActivity.setUnfinishedNum(inventoryInfoList.size());
} else if ("B".equals(type)) {
checkTaskActivity.setFinishedNum(inventoryInfoList.size());
}
}
if (inventoryInfoList != null && inventoryInfoList.size() > 0) {
noneLayout.setVisibility(View.GONE);
} else {
noneLayout.setVisibility(View.VISIBLE);
}
}
});
}
}
});
}
public static TaskFragment instance(CheckTaskActivity checkTaskActivity, String type) {
return new TaskFragment(checkTaskActivity, type);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.task_upload_btn:
if (NetworkUtil.isNetworkAvailable(checkTaskActivity)) {
if (inventoryInfoList != null && inventoryInfoList.size() > 0) {
List<String> strList = new ArrayList<>();
for (InventoryInfo info : inventoryInfoList) {
strList.add(info.getNumber());
}
StringBuffer sbf = new StringBuffer();
for (String str : strList) {
if (sbf.toString().equals("")) {
sbf.append("[\"");
sbf.append(str);
sbf.append("\"");
} else {
sbf.append(",\"");
sbf.append(str);
sbf.append("\"");
}
}
if (strList.size() > 0) {
sbf.append("]");
}
checkTaskActivity.getLoadingDialog().show();
HttpService.getInstance().scanInventory(sbf.toString(), scan_cb);
}
} else {
StmApplication.getInstance().showToastShort(getString(R.string.net_settings));
}
break;
case R.id.task_clean_btn:
// String str = "{\"numList\":[\"0300320\",\"0300409\"],\"msg\":\"扫码总数量:3,失败数量:2,失败资产编号为[0300320, 0300409]\"}";
if (inventoryInfoList != null) {
StmApplication.getInstance().getAppExecutors().diskIO().execute(new Runnable() {
@Override
public void run() {
inventoryInfoDao.deleteInventoryList(inventoryInfoList);
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
StmApplication.getInstance().showToastShort("清空成功");
inventoryInfoList.clear();
taskAdapter.setData(inventoryInfoList);
if ("A".equals(type)) {
checkTaskActivity.setUnfinishedNum(inventoryInfoList.size());
} else if ("B".equals(type)) {
checkTaskActivity.setFinishedNum(inventoryInfoList.size());
}
noneLayout.setVisibility(View.VISIBLE);
}
});
}
});
}
break;
case R.id.task_test_btn:
String str = "0300261,0300462,0300313,0300260,030495,0300204,0300182,030731,010301686,010301109,030496,0300107,0300160,031083,030732,030840,0300320,0300409,0300331";
String[] strArr = str.split(",");
if (strArr.length > 0) {
StmApplication.getInstance().getAppExecutors().diskIO().execute(new Runnable() {
@Override
public void run() {
List<InventoryInfo> list = new ArrayList<>();
for (int i=0;i<strArr.length;i++) {
InventoryInfo info = new InventoryInfo();
info.setNumber(strArr[i]);
info.setStatus("0");
info.setUserName(StmApplication.getInstance().getUserInfo().getUsername());
list.add(info);
}
inventoryInfoDao.insertInventoryList(list);
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
checkTaskActivity.refreshData();
}
});
}
});
}
break;
}
}
private RequestCallback<CommonStringJson> scan_cb = new RequestCallback<CommonStringJson>(CommonStringJson.class) {
@Override
public void onSuccess(CommonStringJson responseInfo) {
checkTaskActivity.getLoadingDialog().dismiss();
if (responseInfo.isSucess()) {
String str = responseInfo.getRspData();
Map<String, Object> failedMap = new Gson().fromJson(str, new TypeToken<Map<String, Object>>(){}.getType());
if (failedMap != null && failedMap.get("numList") != null) {
List<String> numList = (List<String>) failedMap.get("numList");
if (numList != null && numList.size() > 0) {
StmApplication.getInstance().showToastShort(String.valueOf(failedMap.get("msg")));
// 处理盘点失败数据
StmApplication.getInstance().getAppExecutors().diskIO().execute(new Runnable() {
@Override
public void run() {
if (inventoryInfoList != null && inventoryInfoList.size() > 0) {
for (InventoryInfo inventoryInfo : inventoryInfoList) {
boolean success = true;
for (String itemStr : numList) {
if (itemStr.equals(inventoryInfo.getNumber())) {
success = false;
}
}
if (success) {
inventoryInfo.setStatus("2");
inventoryInfoDao.updateInventory(inventoryInfo);
} else {
inventoryInfo.setStatus("1");
inventoryInfoDao.updateInventory(inventoryInfo);
}
}
StmApplication.getInstance().getAppExecutors().mainThread().execute(new Runnable() {
@Override
public void run() {
checkTaskActivity.refreshData();
}
});
}
}
});
} else {
StmApplication.getInstance().showToastShort("上传成功");
}
} else {
StmApplication.getInstance().showToastShort("上传成功");
}
} else {
StmApplication.getInstance().showToastShort(responseInfo.getRspMsg());
}
}
@Override
public void onFailure(HttpException error, String msg) {
checkTaskActivity.getLoadingDialog().dismiss();
StmApplication.getInstance().showToastShort(msg);
}
};
}
package com.stm.asset.page;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
/**
* 类名称:TaskInfoActivity
* 类描述:盘点任务详情页面
* 创建人:story
* 创建时间:2021-12-08 10:23
*/
public class TaskInfoActivity extends BaseActivity implements View.OnClickListener {
private String taskId;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_task_info);
initView();
}
private void initView() {
initTitle();
findViewById(R.id.common_title_back_layout).setOnClickListener(this);
taskId = getIntent().getStringExtra("taskId");
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.common_title_back_layout:
finish();
break;
}
}
}
package com.stm.asset.page;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.stm.asset.R;
import com.stm.asset.base.BaseActivity;
/**
* 类名称:WelcomeActivity
* 类描述:欢迎页
* 创建人:story
* 创建时间:2021-08-07 09:46
*/
public class WelcomeActivity extends BaseActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
Intent intent = new Intent();
intent.setClass(WelcomeActivity.this, MainActivity.class);
WelcomeActivity.this.startActivity(intent);
WelcomeActivity.this.finish();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
}
package com.stm.asset.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import java.io.IOException;
import java.util.UUID;
public class DeviceUuidFactory {
private static final String PREFS_FILE = "device_id.xml";
private static final String PREFS_DEVICE_ID = "device_id";
private static DeviceUuidFactory instance = new DeviceUuidFactory();
private static UUID uuid;
private DeviceUuidFactory() {}
public static DeviceUuidFactory getInstance() {
if (instance == null) {
instance = new DeviceUuidFactory();
}
return instance;
}
public String getDeviceId(Context context) {
if (uuid == null) {
synchronized(DeviceUuidFactory.class) {
if (uuid == null) {
SharedPreferences prefs = context.getSharedPreferences( PREFS_FILE, 0);
String id = prefs.getString(PREFS_DEVICE_ID, null);
if (id != null) {
uuid = UUID.fromString(id);
} else {
String androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
try {
if (!"9774d56d682e549c".equals(androidId) && androidId != null) {
uuid = UUID.nameUUIDFromBytes(androidId.getBytes("utf8"));
} else {
String deviceId = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
uuid = deviceId!=null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")) : UUID.randomUUID();
}
} catch (SecurityException | IOException e) {
e.printStackTrace();
}
}
}
}
}
return uuid.toString();
}
}
package com.stm.asset.utils;
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
*
*类名称:NetworkUtil.java
*类描述:
*创建人:张小兵
*创建时间:2015-1-30 上午11:03:40
*
**/
public class NetworkUtil {
/**
* 检查当前网络是否可用
*/
public static boolean isNetworkAvailable(Activity activity) {
Context context = activity.getApplicationContext();
// 获取手机所有连接管理对象(包括对wi-fi,net等连接的管理)
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager == null){
return false;
} else {
// 获取NetworkInfo对象
NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();
if (networkInfo != null && networkInfo.length > 0) {
for (NetworkInfo item : networkInfo) {
if (item.getState() == NetworkInfo.State.CONNECTED){
return item.isAvailable();
}
}
}
}
return false;
}
public static boolean isNetworkAvailable(Context context) {
// 获取手机所有连接管理对象(包括对wi-fi,net等连接的管理)
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager == null){
return false;
} else {
// 获取NetworkInfo对象
NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();
if (networkInfo != null && networkInfo.length > 0) {
for (NetworkInfo item : networkInfo) {
if (item.getState() == NetworkInfo.State.CONNECTED){
return item.isAvailable();
}
}
}
}
return false;
}
/**
* 获取网络类型
* @return 0 无网络 1wifi 2 手机网络
*/
public static int getNetworkType(Context context) {
final ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo info = connectivityManager.getActiveNetworkInfo();
if (info != null) {
if (info.getType() == ConnectivityManager.TYPE_WIFI) {
return 1;
} else {
return 2;
}
} else {
return 0;
}
}
}
package com.stm.asset.utils;
import android.content.Context;
import android.content.SharedPreferences;
import com.stm.asset.base.ConfigKey;
/**
* 类名称:PropertyUtil
* 类描述:配置工具类
* 创建人:story
* 创建时间:2021-08-07 09:32
*/
public class PropertyUtil {
private static final String PREFERENCES_SYSTEM = "preferences_system";
private static final String KEY_IS_FIRST_BEGIN = "key_is_first_begin"; // 首次进入
private static final String KEY_REMEMBER_ACCOUNT = "key_remember_account"; // 上次登录用户名
private static final String KEY_HTTP_ADDRESS = "key_http_address"; // Http Address
private static final String KEY_HTTP_PORT = "key_http_port"; // Http Port
private static final String KEY_HTTP_PLATFORM = "key_http_platform"; // Http Platform
private static final String KEY_USE_HTTPS = "key_use_https"; // 是否启用Https
private static final String KEY_ENCRYPT_PWD = "key_encrypt_pwd"; // 作为请求的全局sign
private static final String KEY_ACCESS_TOKEN = "key_access_token"; // 作为请求的全局sign
public static boolean isFirstBegin(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
return preferences.getBoolean(KEY_IS_FIRST_BEGIN, true);
}
public static void setFirstBegin(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putBoolean(KEY_IS_FIRST_BEGIN, false).apply();
}
public static String getRememberAccount(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
return preferences.getString(KEY_REMEMBER_ACCOUNT, "");
}
public static void setRememberAccount(Context context, String account) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_IS_FIRST_BEGIN, account).apply();
}
public static String getHttpAddress(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
String address = preferences.getString(KEY_HTTP_ADDRESS, "");
if (address == null || "".equals(address)) {
address = ConfigKey.GATEWAYIP;
}
return address;
}
public static void setHttpAddress(Context context, String address) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_HTTP_ADDRESS, address).apply();
}
public static String getHttpPort(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
String port = preferences.getString(KEY_HTTP_PORT, "");
if (port == null || "".equals(port)) {
port = ConfigKey.GATWAYPORT;
}
return port;
}
public static void setHttpPort(Context context, String port) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_HTTP_PORT, port).apply();
}
public static String getHttpPlatform(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
String platform = preferences.getString(KEY_HTTP_PLATFORM, "");
if (platform == null || "".equals(platform)) {
platform = ConfigKey.PLAYFORM;
}
return platform;
}
public static void setHttpPlatform(Context context, String platform) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_HTTP_PLATFORM, platform).apply();
}
public static String getEncryptPwd(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
return preferences.getString(KEY_ENCRYPT_PWD, "");
}
public static void setEncryptPwd(Context context, String sign) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_ENCRYPT_PWD, sign).apply();
}
public static boolean isUseHttps(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
String isUse = preferences.getString(KEY_USE_HTTPS, "");
if ("aa".equals(isUse)) {
return true;
} else if ("bb".equals(isUse)) {
return false;
}
return ConfigKey.ISOPENHTTPS;
}
public static void setUseHttps(Context context, boolean isUse) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_USE_HTTPS, isUse ? "aa" : "bb").apply();
}
public static String getAccessToken(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
return preferences.getString(KEY_ACCESS_TOKEN, "");
}
public static void setAccessToken(Context context, String accessToken) {
SharedPreferences preferences = context.getSharedPreferences(PREFERENCES_SYSTEM, Context.MODE_PRIVATE);
preferences.edit().putString(KEY_ACCESS_TOKEN, accessToken).apply();
}
}
package com.stm.asset.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.security.KeyPairGeneratorSpec;
import android.util.Base64;
import java.math.BigInteger;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.spec.AlgorithmParameterSpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.crypto.Cipher;
import javax.security.auth.x500.X500Principal;
/**
* 类名称:RSAForShareUtil
* 类描述:加密工具类,对SharedPreferences数据做RSA加密(加密会产生耗时,建议非必要数据不要加密)
* 创建人:story
* 创建时间:2021-08-07 09:34
*/
public class RSAForShareUtil {
private static final String ECB_PKCS1_PADDING = "RSA/ECB/PKCS1Padding";//加密填充方式
private static String mAlias = "stmKey";
/**
* 判断是否创建过秘钥
*/
private static boolean isHaveKeyStore() {
try {
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
//从Android加载密钥对密钥存储库中
PrivateKey privateKey = (PrivateKey) ks.getKey(mAlias, null);
if (privateKey == null) {
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
/**
* 创建一个公共和私人密钥,并将其存储使用Android密钥存储库中,因此,只有这个应用程序将能够访问键。
* @param context context
*/
private static KeyPair generateRSAKeyPair(Context context) throws InvalidAlgorithmParameterException, NoSuchProviderException, NoSuchAlgorithmException {
//创建一个开始和结束时间,有效范围内的密钥对才会生成。
Calendar start = new GregorianCalendar();
Calendar end = new GregorianCalendar();
end.add(Calendar.YEAR, 5);
//使用别名来检索的key
AlgorithmParameterSpec spec = new KeyPairGeneratorSpec.Builder(context)
.setAlias(mAlias)
// 用于生成自签名证书的主题 X500Principal 接受 RFC 1779/2253的专有名词
.setSubject(new X500Principal("CN=" + mAlias))
//用于自签名证书的序列号生成的一对。
.setSerialNumber(BigInteger.valueOf(1337))
// 签名在有效日期范围内
.setStartDate(start.getTime())
.setEndDate(end.getTime())
.build();
KeyPairGenerator kpGenerator = KeyPairGenerator.getInstance("RSA", "AndroidKeyStore");
kpGenerator.initialize(spec);
return kpGenerator.generateKeyPair();
}
/**
* 获得本地AndroidKeyStore中的公钥
*/
private static PublicKey getLocalPublicKey() {
try {
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
//从Android加载密钥对密钥存储库中
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return ks.getCertificate(mAlias).getPublicKey();
} else {
KeyStore.Entry entry = ks.getEntry(mAlias, null);
if (!(entry instanceof KeyStore.PrivateKeyEntry)) {
return null;
} else {
return ((KeyStore.PrivateKeyEntry) entry).getCertificate().getPublicKey();
}
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 加密数据
* @param data data
*/
private static String encryptData(Context context, String data) {
if (data != null) {
try {
PublicKey publicKey;
if (isHaveKeyStore()) {
publicKey = getLocalPublicKey();
} else {
KeyPair keyPair = generateRSAKeyPair(context);
publicKey = keyPair.getPublic();
}
if (publicKey != null) {
// 得到公钥
X509EncodedKeySpec keySpec = new X509EncodedKeySpec(publicKey.getEncoded());
KeyFactory kf = KeyFactory.getInstance("RSA");
PublicKey keyPublic = kf.generatePublic(keySpec);
// 加密数据
Cipher cp = Cipher.getInstance(ECB_PKCS1_PADDING);
cp.init(Cipher.ENCRYPT_MODE, keyPublic);
byte[] encryptBytes = cp.doFinal(data.getBytes());
return Base64.encodeToString(encryptBytes, Base64.DEFAULT);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return data;
}
/**
* 用私钥解密数据
* @param encodeData encodeData
*/
private static String decryptData(String encodeData) {
if (encodeData != null) {
try {
byte[] encodeBytes = Base64.decode(encodeData, Base64.DEFAULT);
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
//从Android加载密钥对密钥存储库中
PrivateKey keyPrivate = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
keyPrivate = (PrivateKey) ks.getKey(mAlias, null);
} else {
KeyStore.Entry entry = ks.getEntry(mAlias, null);
if (entry instanceof KeyStore.PrivateKeyEntry) {
keyPrivate = ((KeyStore.PrivateKeyEntry) entry).getPrivateKey();
}
}
if (keyPrivate != null) {
// 解密数据
Cipher cp = Cipher.getInstance(ECB_PKCS1_PADDING);
cp.init(Cipher.DECRYPT_MODE, keyPrivate);
byte[] arr = cp.doFinal(encodeBytes);
return new String(arr);
}
} catch (Exception e) {
e.printStackTrace();
}
}
return encodeData;
}
/**
* @param key key
* @param isTrue isTrue
*/
public static void setBoolean(Context context, String name, String key, boolean isTrue) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
preferences.edit().putString(key, RSAForShareUtil.encryptData(context, isTrue ? "1" : "0")).apply();
}
public static boolean getBoolean(Context context, String name, String key, boolean def) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
String str = preferences.getString(key, "0");
if (!"0".equals(str)) {
String i = RSAForShareUtil.decryptData(str);
if ("1".equals(i)) {
return true;
} else if ("0".equals(i)) {
return false;
}
}
return def;
}
public static void setInt(Context context, String name, String key, int data) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
preferences.edit().putString(key, RSAForShareUtil.encryptData(context, String.valueOf(data))).apply();
}
public static int getInt(Context context, String name, String key, int def) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
String str = preferences.getString(key, "0");
if (!"0".equals(str)) {
String deStr = RSAForShareUtil.decryptData(str);
if (deStr != null) {
return Integer.parseInt(deStr);
}
}
return def;
}
public static void setString(Context context, String name, String key, String data) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
preferences.edit().putString(key, RSAForShareUtil.encryptData(context, data)).apply();
}
public static String getString(Context context, String name, String key, String def) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
String str = preferences.getString(key, "0");
if (!"0".equals(str)) {
return RSAForShareUtil.decryptData(str);
}
return def;
}
public static void remove(Context context, String name, String key) {
SharedPreferences preferences = context.getSharedPreferences(name, Context.MODE_PRIVATE);
preferences.edit().remove(key).apply();
}
}
package com.stm.asset.utils;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* 类名称:StringUtils
* 类描述:字符串工具类
* 创建人:story
* 创建时间:2021-12-22 17:30
*/
public class StringUtils {
public static boolean isEmptyOrNull(String str) {
return (str == null || "".equals(str));
}
public static boolean isNumber(String str) {
Pattern p = Pattern.compile("[0-9]*");
Matcher m = p.matcher(str.trim());
return m.matches();
}
}
package com.stm.asset.utils;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri;
/**
*
* 类名称:SystemUtil
* 类描述: 系统操作工具类
* 创建人:谢明峰
* 创建时间:2014-12-23 下午2:24:12
*
*/
public class SystemUtil {
// 打电话
public static void callPhone(Activity context, String phoneNumber) {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel: "+ phoneNumber));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
public static String getAppVersionName(Activity activity) {
PackageInfo info;
try {
info = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
return info.versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return null;
}
public static String getAppVersionName(Context context) {
PackageInfo info = null;
try {
info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
return info.versionName;
} catch (NameNotFoundException e) {
e.printStackTrace();
}
return null;
}
public static String getDeviceNO(Context context){
return DeviceUuidFactory.getInstance().getDeviceId(context);
}
}
package com.stm.asset.utils;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import com.stm.asset.base.StmApplication;
/**
* 类名称:VersionUtil
* 类描述:版本工具类
* 创建人:story
* 创建时间:2021-12-23 20:15
*/
public class VersionUtil {
public static boolean needUpdate(String serCode) {
boolean flag = false;
try {
if (!StringUtils.isEmptyOrNull(serCode)) {
PackageManager packageManager = StmApplication.getInstance().getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(StmApplication.getInstance().getPackageName(), 0);
String verName = packageInfo.versionName;
String[] verArrayService = serCode.split("\\.");
String[] verArrayBase = verName.split("\\.");
for(int i=0; i < verArrayService.length; i++) {
if (verArrayBase.length > i) {
int serInt = Integer.parseInt(verArrayService[i]);
int basInt = Integer.parseInt(verArrayBase[i]);
if (serInt > basInt) {
flag = true;
break;
} else if (serInt < basInt) {
break;
}
} else {
flag = true;
break;
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return flag;
}
}
package com.stm.asset.utils;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.view.Display;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListAdapter;
import android.widget.ListView;
import com.stm.asset.base.StmApplication;
/**
*
* 类名称:ViewUtil 类描述: 控件工具类 创建人:谢明峰 创建时间:2014-12-23 下午2:22:19
*
* @version
*
*/
public class ViewUtil {
public static int getScreenWidth(Activity activity) {
Display display = activity.getWindow().getWindowManager().getDefaultDisplay();
return Math.min(display.getHeight(), display.getWidth());
}
public static int getScreenWidth() {
Display display = ((WindowManager) StmApplication.getInstance().getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
return Math.min(display.getHeight(), display.getWidth());
}
public static int getScreenHeight() {
Display display = ((WindowManager) StmApplication.getInstance().getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
return Math.max(display.getHeight(), display.getWidth());
}
public static int getScreenHeight(Activity activity) {
Display display = activity.getWindow().getWindowManager().getDefaultDisplay();
return Math.max(display.getHeight(), display.getWidth());
}
public static int getStatusHeight(Context activity) {
int statusHeight;
Rect localRect = new Rect();
((Activity) activity).getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
statusHeight = localRect.top;
if (0 == statusHeight) {
Class<?> localClass;
try {
localClass = Class.forName("com.android.internal.R$dimen");
Object localObject = localClass.newInstance();
int i5 = Integer.parseInt(localClass.getField("status_bar_height").get(localObject).toString());
statusHeight = activity.getResources().getDimensionPixelSize(i5);
} catch (Exception e) {
e.printStackTrace();
}
}
return statusHeight;
}
/**
* view转bitmap
*/
public static Bitmap convertViewToBitmap(View view) {
view.setDrawingCacheEnabled(true);
view.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap cacheBitmap = view.getDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
return bitmap;
}
public static void measureView(View view) {
ViewGroup.LayoutParams p = view.getLayoutParams();
if (p == null) {
p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0, p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
view.measure(childWidthSpec, childHeightSpec);
}
public static int dip2px(Context context, float dipValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dipValue * scale + 0.5f);
}
public static int px2dip(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
/**
* 将px值转换为sp值,保证文字大小不变
*/
public static int px2sp(Context context, float pxValue) {
final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (pxValue / fontScale + 0.5f);
}
/**
* 将sp值转换为px值,保证文字大小不变
*/
public static int sp2px(Context context, float spValue) {
final float fontScale = context.getResources().getDisplayMetrics().scaledDensity;
return (int) (spValue * fontScale + 0.5f);
}
public static int getScreenWidth(Context context) {
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
return Math.min(display.getHeight(), display.getWidth());
}
public static int getScreenHeight(Context context) {
Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
return Math.max(display.getHeight(), display.getWidth());
}
public static void setListViewHeight(ListView listView, int dividerHeight) {
// 获取ListView对应的Adapter
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) { // listAdapter.getCount()返回数据项的数目
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0); // 计算子项View 的宽高
totalHeight += listItem.getMeasuredHeight(); // 统计所有子项的总高度
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (dividerHeight + 5);
listView.setLayoutParams(params);
}
/**
* 得到列表无数据图片params
*/
public static LayoutParams getNodataImgParams(Activity activity) {
int nodataWidth = (int) (ViewUtil.getScreenWidth(activity) * 2 / 5.0);
int nodataHeight = (int) (nodataWidth * 7 / 6.0);
LayoutParams nodataParams = new LayoutParams(nodataWidth, nodataHeight);
nodataParams.topMargin = (nodataWidth);
return nodataParams;
}
}
package com.stm.asset.view;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.stm.asset.R;
import com.stm.asset.utils.ViewUtil;
/**
* 类名称:CommonAlertDialog
* 类描述:基本提示弹出框
* 创建人:story
* 创建时间:2021-09-04 15:38
*/
public class CommonAlertDialog extends Dialog implements android.view.View.OnClickListener {
private TextView titleTxt, contentTxt, sureTxt, cancelTxt;
private float widthScale = 0f;
private LinearLayout.LayoutParams params;
private Context context;
public CommonAlertDialog(Context context){
super(context,R.style.BaseDialog);
this.context=context;
}
public CommonAlertDialog(Context context,float widthScale ){
super(context,R.style.BaseDialog);
this.context=context;
this.widthScale=widthScale;
}
@SuppressLint("InflateParams")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = LayoutInflater.from(this.context).inflate(R.layout.view_common_dialog, null);
titleTxt = view.findViewById(R.id.common_dialog_title_txt);
contentTxt = view.findViewById(R.id.common_dialog_content_txt);
sureTxt = view.findViewById(R.id.common_dialog_sure_txt);
cancelTxt = view.findViewById(R.id.common_dialog_cancel_txt);
cancelTxt.setOnClickListener(this);
sureTxt.setOnClickListener(this);
if (widthScale > 0) {
Window dialogWindow = this.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER);
this.getWindow().setAttributes(lp);
int dialog_width = (int) (ViewUtil.getScreenWidth(context) * widthScale);
view.setMinimumHeight(dialog_width/2);
this.params=new LinearLayout.LayoutParams(dialog_width, ViewGroup.LayoutParams.WRAP_CONTENT);
}
if(this.params==null)
this.setContentView(view);
else
this.setContentView(view, this.params);
}
/**
* 设置内容
*/
public void setText(String content){
this.contentTxt.setText(content);
}
/**
* 隐藏标题
*/
public void hadeTitleLayout(){
this.titleTxt.setVisibility(View.GONE);
}
/**
* 设置标题和内容
*/
public void setText(String title,String content){
this.titleTxt.setText(title);
this.contentTxt.setText(content);
}
/**
* 设置标题、内容和确定按钮内容
*/
public void setText(String title, String content, String sure){
this.titleTxt.setText(title);
this.contentTxt.setText(content);
this.sureTxt.setText(sure);
}
/**
* 设置标题、内容、确定和取消按钮内容
*/
public void setText(String title, String content, String sure, String cancel){
this.titleTxt.setText(title);
this.contentTxt.setText(content);
this.sureTxt.setText(sure);
this.cancelTxt.setText(cancel);
}
public void setSureListener(View.OnClickListener listener){
this.sureTxt.setOnClickListener(listener);
}
public void setCancelListener(View.OnClickListener listener){
this.cancelTxt.setOnClickListener(listener);
}
public void hideCancelBtn() {
this.cancelTxt.setVisibility(View.GONE);
findViewById(R.id.common_dialog_devices_line).setVisibility(View.GONE);
}
public void setViewParams(LinearLayout.LayoutParams params){
this.params=params;
}
@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.common_dialog_cancel_txt:
this.dismiss();
break;
}
}
}
package com.stm.asset.view;
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnDismissListener;
import android.os.Bundle;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.stm.asset.R;
import com.stm.asset.utils.ViewUtil;
import java.util.Timer;
import java.util.TimerTask;
public class LoadingDialog extends Dialog implements OnDismissListener{
public static final int SUCCESS =1;
public static final int FAILURE =2;
public static final int WARN =3;
private Activity activity;
private View view;
private TextView msg_txt;
private ImageView logoImg;
private ProgressBar probar;
private LinearLayout bgLayout;
private int width;
private String message = null;
private LayoutParams params;
private OnLoadingDialogResultListener listener;
private int post_time =0;
private int tag =0;
private int state;
public interface OnLoadingDialogResultListener{
void dialogResult(int tag, int state);
}
public LoadingDialog(Activity context) {
super(context,R.style.LoadDialog);
this.activity =context;
message = "正在加载...";
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
view = LayoutInflater.from(this.activity).inflate(R.layout.view_common_loading_dialog, null);
msg_txt = view.findViewById(R.id.common_loading_msg);
probar = view.findViewById(R.id.common_loading_probar);
logoImg = view.findViewById(R.id.common_loading_logo_img);
bgLayout = view.findViewById(R.id.common_loading_bg_layout);
msg_txt.setText(this.message);
int width = (int) (ViewUtil.getScreenWidth(activity) / 5.0 *3 / 4.0);
ViewUtil.measureView(msg_txt);
FrameLayout.LayoutParams param =new FrameLayout.LayoutParams(width, width);
probar.setLayoutParams(param);
logoImg.setLayoutParams(param);
Window dialogWindow = this.getWindow();
dialogWindow.setGravity(Gravity.CENTER);
this.setContentView(view);
this.setOnDismissListener(this);
this.setCanceledOnTouchOutside(false);
this.setCancelable(false);
}
public void setText(String message) {
this.message = message;
msg_txt.setText(this.message);
}
public void setText(int resId) {
setText(getContext().getResources().getString(resId));
}
public void setWidth(int width){
this.width =width;
}
public void setOnLoadingDialogResultListener(OnLoadingDialogResultListener listener){
this.listener =listener;
}
public void setTag(int tag){
this.tag =tag;
}
@Override
public void show() {
super.show();
probar.setVisibility(View.VISIBLE);
msg_txt.setText(message);
}
private void closeDialog(){
final Timer t = new Timer();
LoadingDialog.this.dismiss();
t.schedule(new TimerTask() {
public void run() {
if (listener!=null){
listener.dialogResult(tag, state);
}
t.cancel();
}
}, post_time);
}
@Override
public void onDismiss(DialogInterface dialog) {
state =0;
}
OnKeyListener keylistener = new OnKeyListener(){
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode==KeyEvent.KEYCODE_BACK&&event.getRepeatCount()==0) {
return true;
} else {
return false;
}
}
};
}
package com.stm.asset.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
/**
* 类名称:TextMoveLayout
* 类描述:自定义移动控件
* 创建人:story
* 创建时间:2021-12-15 11:30
*/
public class TextMoveLayout extends ViewGroup {
public TextMoveLayout(Context context) {
super(context);
}
public TextMoveLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public TextMoveLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
}
}
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/abc_btn_check_to_on_mtrl_015" android:state_checked="true"/>
<item android:drawable="@drawable/abc_btn_check_to_on_mtrl_000" android:state_checked="false"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/abc_btn_radio_to_on_mtrl_015" android:state_checked="true" />
<item android:drawable="@drawable/abc_btn_radio_to_on_mtrl_000" android:state_checked="false" />
</selector>
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_load_probar"
android:pivotX="50%"
android:pivotY="50%"
/>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/bg_btn_shape_white_press" android:state_pressed="true" />
<item android:drawable="@android:color/transparent" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@color/common_while_click"
android:endColor="@color/common_while_click"
android:angle="270"/>
<corners
android:bottomRightRadius="@dimen/common_circle_size"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@color/colorPrimary"
android:endColor="@color/colorPrimary"
android:angle="270"/>
<corners android:topLeftRadius="@dimen/common_circle_size"
android:topRightRadius="@dimen/common_circle_size"
android:bottomLeftRadius="@dimen/common_circle_size"
android:bottomRightRadius="@dimen/common_circle_size"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:drawable="@drawable/bg_common_sb_progress_backgroud"/>
<item android:id="@android:id/progress"
android:drawable="@drawable/bg_common_sb_progress_pro" />
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:startColor="#8a8c8f"
android:endColor="#8a8c8f" />
<corners android:radius="5dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#11a9ec"
android:endColor="#11a9ec"
android:angle="270"
/>
<corners android:radius="5dip" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:drawable="@drawable/bg_common_sb_progress_backgroud"/>
<item android:id="@android:id/progress">
<clip android:drawable="@drawable/bg_common_sb_progress_fill" />
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@android:color/white"
android:endColor="@android:color/white"
android:angle="270"/>
<corners android:topLeftRadius="@dimen/common_circle_size"
android:topRightRadius="@dimen/common_circle_size"
android:bottomLeftRadius="@dimen/common_circle_size"
android:bottomRightRadius="@dimen/common_circle_size"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- 顶部带圆角 白色背景 灰色边框 无下边框 长方体 -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white" />
<!-- <corners android:topLeftRadius="2dp" android:topRightRadius="2dp" -->
<!-- android:bottomRightRadius="2dp" android:bottomLeftRadius="2dp" /> -->
<stroke android:width="1dp" android:color="@color/colorPrimary" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="1dp" />
<solid android:color="@color/keyboardNormal" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="1dp" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@color/colorPrimary"
android:endColor="@color/colorPrimary"
android:angle="270"/>
<corners android:topLeftRadius="@dimen/common_circle_size"
android:topRightRadius="@dimen/common_circle_size"
android:bottomLeftRadius="@dimen/common_circle_size"
android:bottomRightRadius="@dimen/common_circle_size"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/bg_tab_ellipse_left_select" android:state_selected="true" />
<item android:drawable="@drawable/bg_tab_ellipse_left_unselect" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@color/colorPrimary"
android:endColor="@color/colorPrimary"
android:angle="270"/>
<corners android:topLeftRadius="@dimen/common_circle_size"
android:topRightRadius="0px"
android:bottomLeftRadius="@dimen/common_circle_size"
android:bottomRightRadius="0px"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@android:color/white"
android:endColor="@android:color/white"
android:angle="270"/>
<corners android:topLeftRadius="@dimen/common_circle_size"
android:topRightRadius="0px"
android:bottomLeftRadius="@dimen/common_circle_size"
android:bottomRightRadius="0px"/>
<stroke
android:width="1px"
android:color="@color/colorPrimary"
/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/bg_tab_ellipse_right_select" android:state_selected="true" />
<item android:drawable="@drawable/bg_tab_ellipse_right_unselect" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@color/colorPrimary"
android:endColor="@color/colorPrimary"
android:angle="270"/>
<corners android:topLeftRadius="0px"
android:topRightRadius="@dimen/common_circle_size"
android:bottomLeftRadius="0px"
android:bottomRightRadius="@dimen/common_circle_size"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="@android:color/white"
android:endColor="@android:color/white"
android:angle="270"/>
<corners android:topLeftRadius="0px"
android:topRightRadius="@dimen/common_circle_size"
android:bottomLeftRadius="0px"
android:bottomRightRadius="@dimen/common_circle_size"/>
<stroke
android:width="1px"
android:color="@color/colorPrimary" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:color="@android:color/white" android:state_selected="true" />
<item android:color="@color/colorPrimary" />
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/keyboardPress" />
<corners android:radius="5dp" />
<stroke android:width="0.5dp"
android:color="#858687"></stroke>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/keyboardNormal" />
<corners android:radius="5dp" />
<stroke android:width="0.5dp"
android:color="#858687"></stroke>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--数字键盘专用-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/keyboardPress" />
<corners android:radius="0dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#ACB3BF" />
<corners android:radius="0dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="@color/keyboardPress" />
<corners android:radius="0dp" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/colorPrimary" />
<corners android:radius="0dp" />
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--字母键盘符号键盘专用-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#ACB3BF" />
<corners android:radius="5dp" />
<stroke android:width="0.5dp"
android:color="#858687"></stroke>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/keyboardKeyBack" />
<corners android:radius="5dp" />
<stroke android:width="0.5dp"
android:color="#858687"></stroke>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--数字键盘专用-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="#ACB3BF" />
<corners android:radius="0dp" />
<stroke android:width="0.5dp"
android:color="#DCDCDC"></stroke>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/keyboardKeyBack" />
<corners android:radius="0dp" />
<stroke android:width="0.5dp"
android:color="#DCDCDC"></stroke>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.InventoryActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical">
<include
android:id="@+id/inventory_title"
layout="@layout/view_common_title"/>
<ListView
android:id="@+id/inventory_data_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:dividerHeight="@dimen/xxsmall_padding"
android:divider="@color/colorPrimary"
android:fadingEdge="none"
android:overScrollMode="never"
android:scrollbars="none"/>
<HorizontalScrollView
android:id="@+id/inventory_txt_count_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/xlarge_padding"
android:paddingStart="@dimen/xlarge_padding"
android:paddingEnd="@dimen/xlarge_padding"
android:focusable="true" >
<TextView
android:id="@+id/inventory_txt_count_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</HorizontalScrollView>
<LinearLayout
android:id="@+id/inventory_btn_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/inventory_btn_margin_bottom">
<Button
android:id="@+id/inventory_begin_btn"
android:layout_width="0dp"
android:layout_height="@dimen/common_btn_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/inventory_btn_begin"/>
<Button
android:id="@+id/inventory_finish_btn"
android:layout_width="0dp"
android:layout_height="@dimen/common_btn_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/inventory_btn_finish"/>
<Button
android:id="@+id/inventory_save_btn"
android:layout_width="0dp"
android:layout_height="@dimen/common_btn_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/inventory_btn_save"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.CheckTaskActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintVertical_weight="1"
android:orientation="vertical"
android:background="@android:color/white"
app:layout_constraintTop_toTopOf="parent">
<include
android:id="@+id/task_title"
layout="@layout/view_common_title"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="@dimen/large_padding"
android:paddingRight="@dimen/large_padding"
android:paddingTop="@dimen/normal_padding"
android:paddingBottom="@dimen/normal_padding" >
<TextView
android:id="@+id/task_unfinished_txt"
android:layout_width="0dip"
android:layout_height="@dimen/check_task_tab_height"
android:layout_weight="1.0"
android:background="@drawable/bg_tab_ellipse_left"
android:gravity="center"
android:textColor="@drawable/bg_tab_ellipse_txt"
android:textSize="@dimen/xlarge_text_size" />
<TextView
android:id="@+id/task_finished_txt"
android:layout_width="0dip"
android:layout_height="@dimen/check_task_tab_height"
android:layout_weight="1.0"
android:background="@drawable/bg_tab_ellipse_right"
android:gravity="center"
android:textColor="@drawable/bg_tab_ellipse_txt"
android:textSize="@dimen/xlarge_text_size"/>
</LinearLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/task_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:fadingEdge="none"
android:focusable="true"
android:overScrollMode="never" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.DeviceSetActivity">
<include
android:id="@+id/device_set_title"
layout="@layout/view_common_title"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:id="@+id/device_set_content_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@id/device_set_title"
android:layout_marginTop="@dimen/device_set_margin_top">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding"
android:text="@string/device_set_power"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xlarge_text_size" />
<com.stm.asset.view.TextMoveLayout
android:id="@+id/set_power_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/device_set_text_move_height"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding"/>
<SeekBar
android:id="@+id/set_power_sb"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="@dimen/device_set_sb_height"
android:thumb="@drawable/ic_common_thumb"
android:progressDrawable="@drawable/bg_common_sb_progress"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/device_set_item_margin_top"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/normal_text_size"
android:text="@string/device_set_power_text_start" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:textSize="@dimen/normal_text_size"
android:text="@string/device_set_power_text_end" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding"
android:layout_marginTop="@dimen/device_set_margin_item"
android:text="@string/device_set_temperature"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xlarge_text_size" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@dimen/device_set_item_margin_top"
android:layout_marginBottom="@dimen/device_set_item_margin_top"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding" >
<EditText
android:id="@+id/set_temperature_et"
android:layout_width="0dp"
android:layout_height="@dimen/device_set_edit_height"
android:layout_weight="2"
android:background="@drawable/bg_edit_diamond"
android:gravity="center_vertical|center_horizontal"
android:enabled="false"
android:inputType="text"
android:singleLine="true"
android:textSize="@dimen/normal_text_size"
android:textColor="@color/common_txt_value"/>
<Button
android:id="@+id/set_temperature_read_btn"
android:layout_width="0dp"
android:layout_height="@dimen/device_set_edit_height"
android:layout_weight="1"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/device_set_temperature_read"/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding"
android:layout_marginTop="@dimen/device_set_margin_item"
android:text="@string/device_set_inventory"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xlarge_text_size" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/device_set_inventory_height"
android:layout_marginTop="@dimen/device_set_item_margin_top"
android:orientation="horizontal"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding" >
<TextView
android:layout_width="@dimen/device_set_inventory_txt_width"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/device_set_inventory_session"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/small_text_size"/>
<Spinner
android:id="@+id/set_inventory_session_spinner"
android:layout_width="@dimen/device_set_inventory_spinner_width"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_gravity="center_vertical"
android:textColor="@color/common_txt_value" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/device_set_inventory_height"
android:layout_marginTop="@dimen/device_set_item_margin_top"
android:orientation="horizontal"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xxlarge_padding" >
<TextView
android:layout_width="@dimen/device_set_inventory_txt_width"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/device_set_inventory_flag"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/small_text_size"/>
<Spinner
android:id="@+id/set_inventory_flag_spinner"
android:layout_width="@dimen/device_set_inventory_spinner_width"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/xlarge_padding"
android:layout_gravity="center_vertical"
android:textColor="@color/common_txt_value" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/device_set_margin_item">
<Button
android:id="@+id/inventory_save_btn"
android:layout_width="@dimen/device_set_save_width"
android:layout_height="@dimen/common_btn_height"
android:layout_centerHorizontal="true"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/device_set_save"/>
</RelativeLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.LoginActivity">
<include
android:id="@+id/login_title"
layout="@layout/view_common_title"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/login_title"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/white"
android:gravity="center_vertical"
android:padding="@dimen/large_padding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@color/common_txt_key"
android:text="@string/login_name" />
<EditText
android:id="@+id/login_account_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/normal_padding"
android:layout_weight="1.0"
android:textSize="@dimen/xlarge_text_size"
android:background="@null"
android:hint="@string/login_name_hint"
android:singleLine="true" />
<LinearLayout
android:id="@+id/login_account_delete_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="@dimen/small_padding"
android:visibility="gone" >
<ImageView
android:layout_width="@dimen/login_delete_width"
android:layout_height="@dimen/login_delete_width"
android:background="@drawable/ic_login_delete"
android:contentDescription="@string/app_name"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_line_height"
android:background="@color/colorPrimary"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@android:color/white"
android:gravity="center_vertical"
android:padding="@dimen/large_padding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@color/common_txt_key"
android:text="@string/login_pwd" />
<EditText
android:id="@+id/login_pwd_et"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/normal_padding"
android:layout_weight="1.0"
android:background="@null"
android:inputType="textPassword"
android:hint="@string/login_pwd_hint"
android:singleLine="true"
android:textSize="@dimen/xlarge_text_size"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_line_height"
android:background="@color/colorPrimary"/>
<!-- <LinearLayout-->
<!-- android:layout_width="fill_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center_vertical"-->
<!-- android:orientation="horizontal"-->
<!-- android:paddingLeft="@dimen/large_padding"-->
<!-- android:paddingRight="@dimen/large_padding" >-->
<!-- <TextView-->
<!-- style="@style/Common_cell_key_txt_tyle"-->
<!-- android:layout_marginBottom="@dimen/large_padding"-->
<!-- android:layout_marginTop="@dimen/large_padding"-->
<!-- android:text="验证码\u3000" />-->
<!-- <EditText-->
<!-- android:id="@+id/login_code_edit"-->
<!-- style="@style/Common_cell_value_txt_tyle"-->
<!-- android:layout_marginLeft="@dimen/text_key_value_padding_size"-->
<!-- android:layout_weight="1.0"-->
<!-- android:background="@null"-->
<!-- android:hint="请填写验证码"-->
<!-- android:singleLine="true" />-->
<!-- <ImageView-->
<!-- android:id="@+id/login_code_img"-->
<!-- android:layout_width="@dimen/home_title_logo_width_size"-->
<!-- android:layout_height="@dimen/mlarge_icon_size"-->
<!-- android:layout_marginLeft="10dip"-->
<!-- android:background="@drawable/check_code_default_icon"-->
<!-- android:scaleType="fitXY" />-->
<!-- </LinearLayout>-->
<!-- <View-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/common_line_height"-->
<!-- android:background="@color/colorPrimary"/>-->
<!-- <LinearLayout-->
<!-- android:layout_width="fill_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:gravity="center_vertical"-->
<!-- android:orientation="horizontal"-->
<!-- android:paddingBottom="@dimen/login_savepw_top_margin"-->
<!-- android:paddingTop="@dimen/login_savepw_top_margin"-->
<!-- android:paddingLeft="@dimen/large_padding"-->
<!-- android:paddingRight="@dimen/large_padding">-->
<!-- <ImageView-->
<!-- android:id="@+id/login_remember_img"-->
<!-- android:layout_width="@dimen/login_savepw_icon_size"-->
<!-- android:layout_height="@dimen/login_savepw_icon_size"-->
<!-- android:background="@drawable/login_checkbox_unselect_icon" />-->
<!-- <TextView-->
<!-- android:id="@+id/login_remember_txt"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="3dip"-->
<!-- android:layout_weight="1.0"-->
<!-- android:text="保存密码"-->
<!-- android:textColor="@color/common_txt_color_hint"-->
<!-- android:textSize="@dimen/normal_text_size" />-->
<!-- <TextView-->
<!-- android:id="@+id/login_findpw_txt"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="3dip"-->
<!-- android:text="找回密码"-->
<!-- android:textColor="#25a9ff"-->
<!-- android:textSize="@dimen/normal_text_size"-->
<!-- android:visibility="gone" />-->
<!-- </LinearLayout>-->
<Button
android:id="@+id/login_login_btn"
android:layout_width="match_parent"
android:layout_height="@dimen/common_btn_height"
android:layout_marginStart="@dimen/xxlarge_padding"
android:layout_marginEnd="@dimen/xlarge_padding"
android:layout_marginTop="@dimen/login_btn_margin_top"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/login_do_btn"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.MainActivity">
<TextView
android:id="@+id/main_user_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginTop="@dimen/main_user_margin"
android:layout_marginStart="@dimen/main_user_margin"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/xxlarge_text_size"/>
<TextView
android:id="@+id/main_title_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/main_user_txt"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="@dimen/main_title_margin_top"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/xxxlarge_text_size"
android:text="@string/main_title"/>
<LinearLayout
android:id="@+id/main_task_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/white"
app:layout_constraintTop_toBottomOf="@+id/main_title_txt"
android:layout_marginTop="@dimen/main_content_margin_top"
android:paddingStart="@dimen/main_content_margin_left"
android:paddingEnd="@dimen/main_content_margin_left">
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_coarse_line_height"
android:background="@color/colorPrimary"/>
<RelativeLayout
android:id="@+id/main_inventory_data_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/common_row_height"
android:layout_marginStart="@dimen/main_content_padding"
android:layout_marginEnd="@dimen/main_content_padding"
android:layout_marginTop="@dimen/main_content_padding_top"
android:layout_marginBottom="@dimen/main_content_padding_top">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/main_inventory_data"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xxlarge_text_size"/>
<ImageView
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:src="@drawable/icon_main_go"
android:contentDescription="@string/app_name"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_coarse_line_height"
android:background="@color/colorPrimary"/>
<RelativeLayout
android:id="@+id/main_begin_inventory_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/common_row_height"
android:layout_marginStart="@dimen/main_content_padding"
android:layout_marginEnd="@dimen/main_content_padding"
android:layout_marginTop="@dimen/main_content_padding_top"
android:layout_marginBottom="@dimen/main_content_padding_top">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/main_begin_inventory"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xxlarge_text_size"/>
<ImageView
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:src="@drawable/icon_main_go"
android:contentDescription="@string/app_name"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_coarse_line_height"
android:background="@color/colorPrimary"/>
<RelativeLayout
android:id="@+id/main_settings_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/common_row_height"
android:layout_marginStart="@dimen/main_content_padding"
android:layout_marginEnd="@dimen/main_content_padding"
android:layout_marginTop="@dimen/main_content_padding_top"
android:layout_marginBottom="@dimen/main_content_padding_top">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/main_settings"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xxlarge_text_size"/>
<ImageView
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:src="@drawable/icon_main_go"
android:contentDescription="@string/app_name"/>
</RelativeLayout>
<View
android:id="@+id/main_logout_line"
android:layout_width="match_parent"
android:layout_height="@dimen/common_coarse_line_height"
android:background="@color/colorPrimary"/>
<RelativeLayout
android:id="@+id/main_logout_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/common_row_height"
android:layout_marginStart="@dimen/main_content_padding"
android:layout_marginEnd="@dimen/main_content_padding"
android:layout_marginTop="@dimen/main_content_padding_top"
android:layout_marginBottom="@dimen/main_content_padding_top">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="@string/main_logout"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/xxlarge_text_size"/>
<ImageView
android:layout_width="@dimen/normal_icon_size"
android:layout_height="@dimen/normal_icon_size"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:src="@drawable/icon_main_go"
android:contentDescription="@string/app_name"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_coarse_line_height"
android:background="@color/colorPrimary"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.SelectIPActivity">
<include
android:id="@+id/select_title"
layout="@layout/view_common_title"
app:layout_constraintTop_toTopOf="parent"/>
<ListView
android:id="@+id/select_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:layout_constraintTop_toBottomOf="@+id/select_title"
android:divider="@color/colorPrimary"
android:dividerHeight="@dimen/common_coarse_line_height" >
</ListView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.SetAndSaveActivity">
<include
android:id="@+id/base_set_title"
app:layout_constraintTop_toTopOf="parent"
layout="@layout/view_common_title"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/base_set_title"
android:background="#FFDEDEDE">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="模块:"
android:textColor="#FF000000"
android:textSize="18sp" />
<Spinner
android:id="@+id/model_spinner"
android:layout_width="120dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/saveBtn"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:background="@drawable/bg_shape_btn"
android:text="保存设置"
android:textColor="#FF000000"
android:textSize="16sp" />
<CheckBox
android:drawableLeft="@drawable/abc_checkbox"
android:id="@+id/enableCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="启用"
android:textColor="#FF000000"
android:textSize="17sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="串口:"
android:textColor="#FF000000"
android:textSize="18sp" />
<Spinner
android:id="@+id/serialport_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="波特率:"
android:textColor="#FF000000"
android:textSize="18sp" />
<Spinner
android:id="@+id/baudRate_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="5dp" />
<RelativeLayout
android:id="@+id/relativeLayoutON_main"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- "上电" -->
<TextView
android:id="@+id/poweron"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="上电"
android:textColor="#FF000000"
android:textSize="18sp"
android:textStyle="bold" />
</RelativeLayout>
<!-- 上电设置部分结束 -->
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="5dp"
android:background="#FFADADAD" />
<!-- 下电设置 -->
<RelativeLayout
android:id="@+id/relativeLayoutOFF_main"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- "下电" -->
<TextView
android:id="@+id/poweroff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:text="下电"
android:textColor="#FF000000"
android:textSize="18sp"
android:textStyle="bold" />
<!-- 下电GPIO -->
</RelativeLayout>
<!-- end -->
</LinearLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.TaskInfoActivity">
<include
android:id="@+id/info_title"
layout="@layout/view_common_title"
app:layout_constraintTop_toTopOf="parent"/>
<LinearLayout
android:id="@+id/info_number_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/info_title"
android:layout_marginTop="@dimen/task_info_margin_top"
android:layout_marginStart="@dimen/normal_padding"
android:layout_marginEnd="@dimen/normal_padding"
android:background="@android:color/white">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:textColor="@android:color/white"
android:textSize="@dimen/xlarge_text_size"
android:gravity="center_horizontal"
android:text="@string/task_info_num_total"/>
<TextView
android:id="@+id/info_num_total_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/xlarge_text_size"
android:text="100"/>
</LinearLayout>
<View
android:layout_width="@dimen/common_line_height"
android:layout_height="match_parent"
android:background="@android:color/white" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:textColor="@android:color/white"
android:textSize="@dimen/xlarge_text_size"
android:gravity="center_horizontal"
android:text="@string/task_info_num_undo"/>
<TextView
android:id="@+id/info_num_undo_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/xlarge_text_size"
android:text="40"/>
</LinearLayout>
<View
android:layout_width="@dimen/common_line_height"
android:layout_height="match_parent"
android:background="@android:color/white" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:textColor="@android:color/white"
android:textSize="@dimen/xlarge_text_size"
android:gravity="center_horizontal"
android:text="@string/task_info_num_done"/>
<TextView
android:id="@+id/info_num_done_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/xlarge_text_size"
android:text="60"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/white"
app:layout_constraintTop_toBottomOf="@+id/info_number_layout"
android:layout_marginTop="@dimen/task_info_margin_top">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="@dimen/large_padding"
android:paddingEnd="@dimen/large_padding">
<TextView
android:id="@+id/info_tab_undo_txt"
android:layout_width="wrap_content"
android:layout_height="@dimen/xlarge_icon_size"
android:background="@drawable/bg_tab_ellipse_left"
android:gravity="center"
android:textColor="@drawable/bg_tab_ellipse_txt"
android:textSize="@dimen/normal_text_size"
android:text="@string/task_info_num_undo"/>
<TextView
android:id="@+id/info_tab_done_txt"
android:layout_width="wrap_content"
android:layout_height="@dimen/xlarge_icon_size"
android:background="@drawable/bg_tab_ellipse_right"
android:gravity="center"
android:textColor="@drawable/bg_tab_ellipse_txt"
android:textSize="@dimen/normal_text_size"
android:text="@string/task_info_num_done"/>
</LinearLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/info_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:fadingEdge="none"
android:overScrollMode="never" >
</androidx.viewpager.widget.ViewPager>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".page.WelcomeActivity">
<ImageView
android:id="@+id/welcome_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:contentDescription="@string/app_name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/ic_welcome"/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/fgm_task_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:dividerHeight="@dimen/xxsmall_padding"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginBottom="@dimen/check_task_btn_layout_height"
android:divider="@color/colorPrimary"
android:fadingEdge="none"
android:overScrollMode="never"
android:scrollbars="none"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/common_btn_height"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="@dimen/check_task_margin_bottom"
android:layout_marginBottom="@dimen/check_task_margin_bottom"
android:layout_marginStart="@dimen/xxxlarge_padding"
android:layout_marginEnd="@dimen/xxxlarge_padding"
android:orientation="horizontal">
<Button
android:id="@+id/task_test_btn"
android:layout_width="0dp"
android:layout_height="@dimen/common_btn_height"
android:layout_weight="1"
android:layout_marginEnd="@dimen/check_task_btn_margin"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/check_task_test"
android:visibility="gone"/>
<Button
android:id="@+id/task_upload_btn"
android:layout_width="0dp"
android:layout_height="@dimen/common_btn_height"
android:layout_weight="1"
android:layout_marginEnd="@dimen/check_task_btn_margin"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/check_task_upload"/>
<Button
android:id="@+id/task_clean_btn"
android:layout_width="0dp"
android:layout_height="@dimen/common_btn_height"
android:layout_weight="1"
android:background="@drawable/bg_shape_btn"
android:textSize="@dimen/xlarge_text_size"
android:textColor="@android:color/white"
android:text="@string/check_task_clean"/>
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:id="@+id/fgm_task_content"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- app:layout_constraintTop_toTopOf="parent"-->
<!-- android:orientation="vertical">-->
<!-- <ListView-->
<!-- android:id="@+id/fgm_task_list"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_weight="1"-->
<!-- android:dividerHeight="@dimen/xxsmall_padding"-->
<!-- android:divider="@color/colorPrimary"-->
<!-- android:fadingEdge="none"-->
<!-- android:overScrollMode="never"-->
<!-- android:scrollbars="none"/>-->
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/common_btn_height"-->
<!-- android:layout_marginTop="@dimen/check_task_margin_bottom"-->
<!-- android:layout_marginBottom="@dimen/check_task_margin_bottom"-->
<!-- android:layout_marginStart="@dimen/xxxlarge_padding"-->
<!-- android:layout_marginEnd="@dimen/xxxlarge_padding"-->
<!-- android:orientation="horizontal">-->
<!-- <Button-->
<!-- android:id="@+id/task_upload_btn"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="@dimen/common_btn_height"-->
<!-- android:layout_weight="1"-->
<!-- android:layout_marginEnd="@dimen/check_task_btn_margin"-->
<!-- android:background="@drawable/bg_shape_btn"-->
<!-- android:textSize="@dimen/xlarge_text_size"-->
<!-- android:textColor="@android:color/white"-->
<!-- android:text="@string/check_task_upload"/>-->
<!-- <Button-->
<!-- android:id="@+id/task_clean_btn"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="@dimen/common_btn_height"-->
<!-- android:layout_weight="1"-->
<!-- android:background="@drawable/bg_shape_btn"-->
<!-- android:textSize="@dimen/xlarge_text_size"-->
<!-- android:textColor="@android:color/white"-->
<!-- android:text="@string/check_task_clean"/>-->
<!-- </LinearLayout>-->
<!-- </LinearLayout>-->
<include
android:id="@+id/fgm_task_none_layout"
layout="@layout/view_common_list_none"
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#D0D3D9"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DCDCDC" />
<RelativeLayout
android:id="@+id/keyboardHeader"
android:layout_width="match_parent"
android:layout_height="@dimen/keyboard_tip_height"
android:background="#F8F8F8">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:orientation="horizontal"
tools:ignore="RelativeOverlap,UseCompoundDrawables">
<TextView
android:id="@+id/keyboardTip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/safe_keyboard"
android:textColor="#666666"
android:textSize="16sp" />
</LinearLayout>
<FrameLayout
android:id="@+id/keyboardDone"
android:layout_width="60sp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="@drawable/bg_keyboard_done">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="完成"
android:textColor="#007AFF" />
</FrameLayout>
</RelativeLayout>
<FrameLayout
android:id="@+id/keyboardLayer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2sp"
android:layout_marginBottom="10sp"
android:paddingTop="5sp">
<com.stm.asset.keyboard.SafeKeyboardView
android:id="@+id/safeKeyboardLetter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:background="#D0D3D9"
android:focusable="true"
android:focusableInTouchMode="true"
android:keyBackground="@drawable/keyboard_press_bg"
android:keyTextColor="@android:color/black"
android:shadowColor="@android:color/white"
android:shadowRadius="0.0" />
</FrameLayout>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView_item"
android:singleLine="true"
android:textSize="18sp"
android:textColor="#FF000000"
android:background="#FFFFFFFF"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/normal_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="@string/check_task_item_name"/>
<TextView
android:id="@+id/task_item_name_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:layout_marginStart="@dimen/large_padding"
android:gravity="center"
android:background="@drawable/bg_check_task_item_status"
android:textColor="@color/common_txt_value" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="@string/check_task_item_number"/>
<TextView
android:id="@+id/task_item_number_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
<TextView
android:id="@+id/task_item_status_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:layout_marginStart="@dimen/large_padding"
android:gravity="center"
android:background="@drawable/bg_check_task_item_status"
android:textColor="@color/common_txt_value"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="@string/check_task_item_user"/>
<TextView
android:id="@+id/task_item_user_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:layout_marginStart="@dimen/large_padding"
android:gravity="center"
android:background="@drawable/bg_check_task_item_status"
android:textColor="@color/common_txt_value"
android:visibility="invisible"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="@string/check_task_item_dept"/>
<TextView
android:id="@+id/task_item_dept_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.4"
android:layout_marginStart="@dimen/large_padding"
android:gravity="center"
android:background="@drawable/bg_check_task_item_status"
android:textColor="@color/common_txt_value"
android:visibility="invisible"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_dialog_common_shape">
<TextView
android:id="@+id/common_dialog_title_txt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="@dimen/large_padding"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size" />
<TextView
android:id="@+id/common_dialog_content_txt"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:padding="@dimen/large_padding"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/small_text_size" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/common_line_height"
android:background="@color/colorPrimary"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/common_dialog_cancel_txt"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:background="@drawable/bg_btn_shape_white"
android:gravity="center"
android:paddingBottom="@dimen/small_padding"
android:paddingTop="@dimen/small_padding"
android:text="@string/common_cancel"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/normal_text_size" />
<View
android:id="@+id/common_dialog_devices_line"
android:layout_width="@dimen/common_line_height"
android:layout_height="match_parent"
android:background="@color/colorPrimary" />
<TextView
android:id="@+id/common_dialog_sure_txt"
android:layout_width="0dp"
android:layout_height="70dp"
android:layout_weight="1"
android:background="@drawable/bg_btn_shape_white"
android:gravity="center"
android:paddingBottom="@dimen/small_padding"
android:paddingTop="@dimen/small_padding"
android:text="@string/common_sure"
android:textColor="@color/colorPrimary"
android:textSize="@dimen/normal_text_size" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<ImageView
android:id="@+id/common_none_img"
android:layout_width="180dip"
android:layout_height="210dip"
android:layout_centerInParent="true"
android:src="@drawable/ic_none_date"
android:contentDescription="@string/app_name"/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/common_loading_bg_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:gravity="center" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageView
android:id="@+id/common_loading_logo_img"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_gravity="center"
android:background="@drawable/ic_common_loading_logo" />
<ProgressBar
android:id="@+id/common_loading_probar"
android:layout_width="80dip"
android:layout_height="80dip"
android:layout_gravity="center"
android:clickable="false"
android:gravity="center"
android:indeterminateDrawable="@drawable/anim_load_probar" />
</FrameLayout>
<TextView
android:id="@+id/common_loading_msg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dip"
android:gravity="center"
android:singleLine="true"
android:text="正在加载..."
android:textColor="@android:color/white"
android:visibility="gone" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/top_title_bar_height_size"
android:background="@color/colorPrimary"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/common_title_back_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="@dimen/large_padding"
android:paddingEnd="@dimen/mlarge_icon_size" >
<ImageView
android:id="@+id/common_title_back_img"
android:layout_width="@dimen/mlarge_icon_size"
android:layout_height="@dimen/mlarge_icon_size"
android:background="@drawable/icon_back_white"
android:contentDescription="@string/app_name"/>
<TextView
android:id="@+id/common_title_back_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/common_back"
android:textColor="@android:color/white"
android:textSize="@dimen/xlarge_text_size"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/common_title_right_layout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="@dimen/large_padding"
android:paddingEnd="@dimen/mlarge_icon_size">
<ImageView
android:id="@+id/common_title_right_img"
android:layout_width="@dimen/mlarge_icon_size"
android:layout_height="@dimen/mlarge_icon_size"
android:contentDescription="@string/app_name"/>
<TextView
android:id="@+id/common_title_right_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:textSize="@dimen/xlarge_text_size"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/common_title_middle_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:ellipsize="end"
android:gravity="center"
android:singleLine="true"
android:textColor="@android:color/white"
android:textSize="@dimen/xxlarge_text_size" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/normal_padding">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="id"/>
<TextView
android:id="@+id/item_inventory_id_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="@string/inventory_item_epc"/>
<TextView
android:id="@+id/item_inventory_epc_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="pc"/>
<TextView
android:id="@+id/item_inventory_pc_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="times"/>
<TextView
android:id="@+id/item_inventory_times_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="rssi"/>
<TextView
android:id="@+id/item_inventory_rssi_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/check_task_item_height"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:gravity="start"
android:textColor="@color/common_txt_key"
android:textSize="@dimen/normal_text_size"
android:text="freq"/>
<TextView
android:id="@+id/item_inventory_freq_txt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.5"
android:layout_gravity="center_vertical"
android:gravity="end"
android:textColor="@color/common_txt_value"
android:textSize="@dimen/normal_text_size"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="@dimen/normal_padding"
android:paddingBottom="@dimen/normal_padding" >
<TextView
android:id="@+id/select_ip_item_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:ellipsize="end"
android:gravity="center"
android:lines="1" />
<TextView
android:id="@+id/select_ip_item_ip"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="4"
android:ellipsize="middle"
android:gravity="center"
android:singleLine="true" />
<TextView
android:id="@+id/select_ip_item_platform"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:ellipsize="end"
android:gravity="center"
android:lines="1" />
<ImageView
android:id="@+id/select_ip_item_select_image"
android:layout_width="@dimen/small_icon_size"
android:layout_height="@dimen/small_icon_size"
android:layout_gravity="center_vertical"
android:contentDescription="@string/app_name"
android:src="@drawable/icon_common_blue_select"
android:visibility="gone"/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:paddingStart="3dp"
android:textColor="@color/colorPrimary"
android:textSize="28sp" />
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="spinarr_serialport">
<item>/dev/ttySAC0</item>
<item>/dev/ttySAC1</item>
<item>/dev/ttySAC2</item>
<item>/dev/ttySAC3</item>
<item>/dev/ttyHSL0</item>
<item>/dev/ttyHSL1</item>
<item>/dev/ttyHSL2</item>
</string-array>
<string-array name="spinarr_model">
<item>BD</item>
<item>BE</item>
<item>CB</item>
<item>CD</item>
<item>CG</item>
<item>H1</item>
<item>H2</item>
<item>H7</item>
<item>Id_card</item>
<item>NFC</item>
<item>U1</item>
<item>U6</item>
<item>U7</item>
<item>U8</item>
<item>W3</item>
<item>W9</item>
</string-array>
<string-array name="spinarr_baud">
<item>9600</item>
<item>19200</item>
<item>38400</item>
<item>57600</item>
<item>115200</item>
</string-array>
<string-array name="m10_GPIO">
<item>ic14443a_enable</item>
<item>ic14443a_sw</item>
<item>infrared</item>
<item>rfid_enable</item>
<item>rfid_sw</item>
<item>r1000_enable</item>
<item>r1000_sw</item>
<item>ic15693_enable</item>
<item>ic15693_sw</item>
<item >gps_enable</item>
<item >gps_sw</item>
<item>bardecoder</item>
</string-array>
<string-array name="m10A_GPIO">
<item>gpio898</item>
<!-- <item>gpio899</item>-->
<!-- <item>gpio908</item>-->
<!-- <item>gpio909</item>-->
<item>gpio910</item>
<!-- <item>bardecoder</item>-->
</string-array>
<string-array name="m96_GPIO">
<item >gpio912</item>
<item >gpio914</item>
<item >gpio918</item>
<item >gpio928</item>
</string-array>
<string-array name="m10SerialPort">
<item>/dev/ttySAC0</item>
<item>/dev/ttySAC1</item>
<item>/dev/ttySAC2</item>
<item>/dev/ttySAC3</item>
</string-array>
<string-array name="m10ASerialPort">
<item>/dev/ttyHSL0</item>
<item>/dev/ttyHSL1</item>
</string-array>
<string-array name="m96SerialPort">
<item>/dev/ttyHSL0</item>
<item>/dev/ttyHSL1</item>
</string-array>
<string-array name="m10_models">
<item>H1</item>
<item>H2</item>
<item>H4</item>
<item>H5</item>
<item>H7</item>
<item>U1</item>
<item>U4</item>
<item>U5</item>
<item>U6</item>
<item>U7</item>
<item>U8</item>
<item>BD</item>
<item>BH</item>
<item>CD</item>
</string-array>
<string-array name="m96_models">
<item >U6</item>
<item >BD</item>
<item >BH</item>
</string-array>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#11a9ec</color>
<color name="colorPrimaryDark">#047BFB</color>
<color name="colorAccent">#ff9a14</color>
<color name="common_btn_down">#ffc272</color>
<color name="common_btn_up">#ff9a14</color>
<color name="common_txt_value">#202020</color>
<color name="common_txt_key">#6b6b6b</color>
<color name="common_while_click">#E2E2E2</color>
<!-- 太保安全键盘 -->
<color name="deepDark">#222222</color>
<color name="keyboardBackColor">#212121</color>
<color name="keyboardKeyBack">#FFFFFF</color>
<color name="darkGray">#a9a9a9</color>
<color name="lightGray">#d3d3d3</color>
<color name="keyboardNormal">#a9a9a9</color>
<color name="keyboardDeep">#991c69ac</color>
<color name="keyboardPress">#ACB3BF</color>
<color name="colorRed">#FF0000</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- 基础尺寸 -->
<dimen name="top_title_bar_height_size">80dp</dimen>
<dimen name="xxxlarge_padding">40dp</dimen>
<dimen name="xxlarge_padding">32dp</dimen>
<dimen name="xlarge_padding">18dp</dimen>
<dimen name="large_padding">16dp</dimen>
<dimen name="normal_padding">12dp</dimen>
<dimen name="small_padding">8dp</dimen>
<dimen name="mxsmall_padding">6dp</dimen>
<dimen name="xsmall_padding">4dp</dimen>
<dimen name="xxsmall_padding">3dp</dimen>
<dimen name="xxxlarge_text_size">48sp</dimen>
<dimen name="xxlarge_text_size">32sp</dimen>
<dimen name="xlarge_text_size">32sp</dimen>
<dimen name="normal_text_size">30sp</dimen>
<dimen name="small_text_size">28sp</dimen>
<dimen name="msmall_text_size">20sp</dimen>
<dimen name="xsmall_text_size">16sp</dimen>
<dimen name="xxlarge_icon_size">44dp</dimen>
<dimen name="xlarge_icon_size">32dp</dimen>
<dimen name="mlarge_icon_size">36dp</dimen>
<dimen name="large_icon_size">21dp</dimen>
<dimen name="normal_icon_size">16dp</dimen>
<dimen name="small_icon_size">12dp</dimen>
<dimen name="xsmall_icon_size">8dp</dimen>
<dimen name="xxsmall_icon_size">4dp</dimen>
<dimen name="common_line_height">0.5dp</dimen>
<dimen name="common_coarse_line_height">1dp</dimen>
<dimen name="common_row_height">55dp</dimen>
<dimen name="common_circle_size">20dp</dimen>
<dimen name="common_btn_height">70dp</dimen>
<!-- main页面 -->
<dimen name="main_user_margin">30dp</dimen>
<dimen name="main_title_margin_top">50dp</dimen>
<dimen name="main_content_margin_top">80dp</dimen>
<dimen name="main_content_margin_left">15dp</dimen>
<dimen name="main_content_padding">10dp</dimen>
<dimen name="main_content_padding_top">20dp</dimen>
<!-- 盘询页面 -->
<dimen name="inventory_btn_margin_bottom">30dp</dimen>
<!-- 盘点任务列表页面 -->
<dimen name="check_task_item_height">35dp</dimen>
<dimen name="check_task_tab_height">50dp</dimen>
<dimen name="check_task_margin_bottom">20dp</dimen>
<dimen name="check_task_btn_layout_height">110dp</dimen>
<dimen name="check_task_btn_margin">30dp</dimen>
<!-- 盘点详情页面 -->
<dimen name="task_info_margin_top">15dp</dimen>
<!-- 设备设置 -->
<dimen name="device_set_margin_top">20dp</dimen>
<dimen name="device_set_text_move_height">50dp</dimen>
<dimen name="device_set_item_margin_top">5dp</dimen>
<dimen name="device_set_margin_item">30dp</dimen>
<dimen name="device_set_edit_height">60dp</dimen>
<dimen name="device_set_inventory_height">50dp</dimen>
<dimen name="device_set_inventory_txt_width">140dp</dimen>
<dimen name="device_set_inventory_spinner_width">180dp</dimen>
<dimen name="device_set_save_width">180dp</dimen>
<dimen name="device_set_sb_height">10dp</dimen>
<!-- 登录 -->
<dimen name="login_delete_width">20dp</dimen>
<dimen name="login_btn_margin_top">80dp</dimen>
<!-- 密码键盘 -->
<dimen name="key_height">42dp</dimen>
<dimen name="key_num_height">50dp</dimen>
<dimen name="key_horizontal_gap">10dp</dimen>
<dimen name="key_vertical_gap">10dp</dimen>
<dimen name="keyboard_tip_height">40dp</dimen>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="special_define_set_radio" type="id" />
<item name="special_define_set_text" type="id" />
</resources>
\ No newline at end of file
<resources>
<string name="app_name">资产盘点</string>
<!-- 常用词语 -->
<string name="common_sure">确定</string>
<string name="common_cancel">取消</string>
<string name="common_back">返回</string>
<string name="net_settings">当前网络状况不佳,请检查网络设置</string>
<!-- main主页 -->
<string name="main_title">RFID盘点系统</string>
<string name="main_inventory_data">盘点数据</string>
<string name="main_begin_inventory">开始盘点</string>
<string name="main_settings">参数设置</string>
<string name="main_logout">退出登录</string>
<!-- 盘询页面 -->
<string name="inventory_btn_begin">开始盘询</string>
<string name="inventory_btn_doing">盘询中</string>
<string name="inventory_btn_finish">结束盘询</string>
<string name="inventory_btn_save">保存</string>
<string name="inventory_disk_failure">盘询失败,错误码</string>
<string name="inventory_count_text" formatted="false">已盘:%d个,总数:%d条,速度:%d个/秒,耗时:%d秒</string>
<string name="inventory_item_epc">资产编码</string>
<!-- 盘点任务列表页面 -->
<string name="check_task_item_name">资产名称</string>
<string name="check_task_item_number">资产编码</string>
<string name="check_task_item_user">使用人</string>
<string name="check_task_item_dept">使用部门</string>
<string name="check_task_upload">数据上传</string>
<string name="check_task_test">测试</string>
<string name="check_task_clean">清\u3000\u3000空</string>
<!-- 盘点任务详情页面 -->
<string name="task_info_num_total">盘点总数</string>
<string name="task_info_num_undo">未盘数量</string>
<string name="task_info_num_done">已盘数量</string>
<string name="task_info_tab_undo">未盘列表</string>
<string name="task_info_tab_done">已盘列表</string>
<!-- 设备设置 -->
<string name="device_set_power">功率设置</string>
<string name="device_set_power_text_start">0dBm</string>
<string name="device_set_power_text_end">33dBm</string>
<string name="device_set_temperature">温度检测</string>
<string name="device_set_temperature_read">读取</string>
<string name="device_set_inventory">盘询参数</string>
<string name="device_set_inventory_session">session</string>
<string name="device_set_inventory_flag">盘询标识</string>
<string name="device_set_save">保\u3000\u3000存</string>
<string name="device_set_power_success">功率设置成功!</string>
<string name="device_set_power_fail">功率设置失败!</string>
<string name="device_set_get_power_fail">功率获取失败!</string>
<!-- 登录页面 -->
<string name="login_name">用\u0020户\u0020名</string>
<string name="login_pwd">密\u0020\u3000\u0020码</string>
<string name="login_name_hint">请输入用户名</string>
<string name="login_pwd_hint">请输入密码</string>
<string name="login_do_btn">登\u3000\u3000录</string>
<!-- U8引入 -->
<string name="str_set_epc_match_failed">设置标签匹配失败</string>
<string name="lose_configurationfile">配置文件丢失</string>
<string name="exception_occurred">发生异常,异常信息:%s</string>
<string name="version_exception">程序版本有误</string>
<string name="serialPort_not_open">串口操作异常</string>
<string name="u8_success">success</string>
<!-- 密码键盘 -->
<string name="description">SafeKeyboard</string>
<string name="safe_keyboard">安全键盘</string>
<string name="keyboard_key1">"&#64;"</string>
<string name="keyboard_key2">"&#38;"</string>
<string name="keyboard_key3">\"</string>
<string name="keyboard_key4">"&#60;"</string>
<string name="keyboard_key5">"&#62;"</string>
<string name="keyboard_system">"系统键盘"</string>
<string name="keyboard_demo_new">"安全软键盘"</string>
<string name="mLabelTextSize">mLabelTextSize</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="BaseDialog" parent="@android:style/Theme.Dialog">
<!-- 边框 -->
<item name="android:windowFrame">@null</item>
<!-- 是否浮现在activity之上 -->
<item name="android:windowIsFloating">true</item>
<!-- 半透明 -->
<item name="android:windowIsTranslucent">false</item>
<!-- 无标题 -->
<item name="android:windowNoTitle">true</item>
<!-- 背景透明 -->
<item name="android:windowBackground">@android:color/transparent</item>
<!-- 模糊 -->
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.5</item>
</style>
<style name="LoadDialog" parent="@style/BaseDialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground"> @android:color/transparent </item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:backgroundDimAmount">0.6</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="1%p"
android:keyHeight="@dimen/key_height"
android:keyWidth="10%p"
android:verticalGap="@dimen/key_vertical_gap">
<Row>
<Key
android:codes="113"
android:keyEdgeFlags="left"
android:keyLabel="q"
android:keyWidth="8.9%p" />
<Key
android:codes="119"
android:keyLabel="w"
android:keyWidth="8.9%p" />
<Key
android:codes="101"
android:keyLabel="e"
android:keyWidth="8.9%p" />
<Key
android:codes="114"
android:keyLabel="r"
android:keyWidth="8.9%p" />
<Key
android:codes="116"
android:keyLabel="t"
android:keyWidth="8.9%p" />
<Key
android:codes="121"
android:keyLabel="y"
android:keyWidth="8.9%p" />
<Key
android:codes="117"
android:keyLabel="u"
android:keyWidth="8.9%p" />
<Key
android:codes="105"
android:keyLabel="i"
android:keyWidth="8.9%p" />
<Key
android:codes="111"
android:keyLabel="o"
android:keyWidth="8.9%p" />
<Key
android:codes="112"
android:keyEdgeFlags="right"
android:keyLabel="p"
android:keyWidth="8.9%p" />
</Row>
<Row>
<Key
android:codes="97"
android:horizontalGap="5.5%p"
android:keyEdgeFlags="left"
android:keyLabel="a"
android:keyWidth="9%p" />
<Key
android:codes="115"
android:keyLabel="s"
android:keyWidth="9%p" />
<Key
android:codes="100"
android:keyLabel="d"
android:keyWidth="9%p" />
<Key
android:codes="102"
android:keyLabel="f"
android:keyWidth="9%p" />
<Key
android:codes="103"
android:keyLabel="g"
android:keyWidth="9%p" />
<Key
android:codes="104"
android:keyLabel="h"
android:keyWidth="9%p" />
<Key
android:codes="106"
android:keyLabel="j"
android:keyWidth="9%p" />
<Key
android:codes="107"
android:keyLabel="k"
android:keyWidth="9%p" />
<Key
android:codes="108"
android:keyEdgeFlags="right"
android:keyLabel="l"
android:keyWidth="9%p" />
</Row>
<Row>
<Key
android:codes="-1"
android:isModifier="true"
android:isSticky="true"
android:keyEdgeFlags="left"
android:keyWidth="13%p" />
<Key
android:codes="122"
android:horizontalGap="1.5%p"
android:keyLabel="z"
android:keyWidth="9%p" />
<Key
android:codes="120"
android:keyLabel="x"
android:keyWidth="9%p" />
<Key
android:codes="99"
android:keyLabel="c"
android:keyWidth="9%p" />
<Key
android:codes="118"
android:keyLabel="v"
android:keyWidth="9%p" />
<Key
android:codes="98"
android:keyLabel="b"
android:keyWidth="9%p" />
<Key
android:codes="110"
android:keyLabel="n"
android:keyWidth="9%p" />
<Key
android:codes="109"
android:keyLabel="m"
android:keyWidth="9%p" />
<Key
android:codes="-5"
android:horizontalGap="1.5%p"
android:isRepeatable="true"
android:keyWidth="13%p" />
</Row>
<Row android:rowEdgeFlags="bottom">
<Key
android:codes="-2"
android:keyLabel="123"
android:keyWidth="19%p" />
<Key
android:codes="32"
android:isRepeatable="false"
android:keyLabel=""
android:keyWidth="58%p" />
<Key
android:codes="100860"
android:keyEdgeFlags="right"
android:keyLabel="#+="
android:keyWidth="19%p" />
</Row>
</Keyboard>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="0dp"
android:keyHeight="@dimen/key_num_height"
android:keyWidth="33.33%p"
android:verticalGap="0dp"
>
<Row>
<Key
android:codes="49"
android:keyLabel="1" />
<Key
android:codes="50"
android:keyLabel="2" />
<Key
android:codes="-5"
android:isRepeatable="true" />
</Row>
<Row>
<Key
android:codes="51"
android:keyLabel="3" />
<Key
android:codes="52"
android:keyLabel="4" />
<Key
android:codes="53"
android:keyLabel="5" />
</Row>
<Row>
<Key
android:codes="54"
android:keyLabel="6" />
<Key
android:codes="55"
android:keyLabel="7" />
<Key
android:codes="56"
android:keyLabel="8" />
</Row>
<Row>
<Key
android:codes="57"
android:keyLabel="9" />
<Key
android:codes="48"
android:keyLabel="0" />
<Key
android:codes="-3"
android:keyLabel="确认" />
</Row>
</Keyboard>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
android:horizontalGap="@dimen/key_horizontal_gap"
android:keyHeight="@dimen/key_num_height"
android:keyWidth="33.33%p"
android:verticalGap="0dp">
<Row>
<Key
android:codes="49"
android:keyLabel="1" />
<Key
android:codes="50"
android:keyLabel="2" />
<Key
android:codes="51"
android:keyLabel="3" />
</Row>
<Row>
<Key
android:codes="52"
android:keyLabel="4" />
<Key
android:codes="53"
android:keyLabel="5" />
<Key
android:codes="54"
android:keyLabel="6" />
</Row>
<Row>
<Key
android:codes="55"
android:keyLabel="7" />
<Key
android:codes="56"
android:keyLabel="8" />
<Key
android:codes="57"
android:keyLabel="9" />
</Row>
<Row>
<Key
android:codes="-2"
android:keyLabel="ABC" />
<Key
android:codes="48"
android:keyLabel="0" />
<Key
android:codes="-5"
android:isRepeatable="true" />
</Row>
</Keyboard>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Keyboard
xmlns:android="http://schemas.android.com/apk/res/android"
android:keyHeight="42dp"
android:keyWidth="10%p"
android:horizontalGap="1%p"
android:verticalGap="@dimen/key_vertical_gap">
<Row>
<Key android:keyWidth="8.9%p" android:codes="33" android:keyLabel="!" android:keyEdgeFlags="left" />
<Key android:keyWidth="8.9%p" android:codes="64" android:keyLabel="@string/keyboard_key1" /><!--@-->
<Key android:keyWidth="8.9%p" android:codes="35" android:keyLabel="#" />
<Key android:keyWidth="8.9%p" android:codes="36" android:keyLabel="$" />
<Key android:keyWidth="8.9%p" android:codes="37" android:keyLabel="%" />
<Key android:keyWidth="8.9%p" android:codes="94" android:keyLabel="^" />
<Key android:keyWidth="8.9%p" android:codes="38" android:keyLabel="@string/keyboard_key2" /><!--&-->
<Key android:keyWidth="8.9%p" android:codes="42" android:keyLabel="*" />
<Key android:keyWidth="8.9%p" android:codes="40" android:keyLabel="(" />
<Key android:keyWidth="8.9%p" android:codes="41" android:keyLabel=")" android:keyEdgeFlags="right" />
</Row>
<Row>
<Key android:keyWidth="8.9%p" android:codes="39"
android:keyEdgeFlags="left" android:keyLabel="'" />
<Key android:keyWidth="8.9%p" android:codes="34" android:keyLabel="@string/keyboard_key3" /> <!--"-->
<Key android:keyWidth="8.9%p" android:codes="61" android:keyLabel="=" />
<Key android:keyWidth="8.9%p" android:codes="95" android:keyLabel="_" />
<Key android:keyWidth="8.9%p" android:codes="58" android:keyLabel=":" />
<Key android:keyWidth="8.9%p" android:codes="59" android:keyLabel=";" />
<Key android:keyWidth="8.9%p" android:codes="63" android:keyLabel="\?" />
<Key android:keyWidth="8.9%p" android:codes="126" android:keyLabel="~" />
<Key android:keyWidth="8.9%p" android:codes="124" android:keyLabel="|" />
<Key android:keyWidth="8.9%p" android:codes="183" android:keyEdgeFlags="right"
android:keyLabel="·" />
</Row>
<Row>
<Key android:horizontalGap="3.5%p" android:keyWidth="9%p" android:codes="43" android:keyLabel="+" />
<Key android:keyWidth="9%p" android:codes="45" android:keyLabel="-" />
<Key android:keyWidth="9%p" android:codes="92" android:keyLabel="\\" />
<Key android:keyWidth="9%p" android:codes="47" android:keyLabel="/" />
<Key android:keyWidth="9%p" android:codes="91" android:keyLabel="[" />
<Key android:keyWidth="9%p" android:codes="93" android:keyLabel="]" />
<Key android:keyWidth="9%p" android:codes="123" android:keyLabel="{" />
<Key android:keyWidth="9%p" android:codes="125" android:keyLabel="}" />
<Key android:horizontalGap="3.5%p" android:keyWidth="13%p" android:codes="-5"
android:isRepeatable="true"/>
</Row>
<Row android:rowEdgeFlags="bottom">
<Key android:keyWidth="13%p" android:codes="-2"
android:keyLabel="123" />
<Key android:keyWidth="9%p" android:horizontalGap="1.5%p" android:codes="44" android:keyLabel="," />
<Key android:keyWidth="9%p" android:codes="46" android:keyLabel="." />
<Key android:keyWidth="9%p" android:codes="60" android:keyLabel="@string/keyboard_key4" />
<!--<-->
<!-->-->
<Key android:keyWidth="9%p" android:codes="62" android:keyLabel="@string/keyboard_key5" />
<Key android:keyWidth="9%p" android:codes="8364" android:keyLabel="€" />
<Key android:keyWidth="9%p" android:codes="163" android:keyLabel="£" />
<Key android:keyWidth="9%p" android:codes="165" android:keyLabel="¥" />
<Key android:keyWidth="13%p" android:codes="100860" android:horizontalGap="1.5%p"
android:keyEdgeFlags="right" android:keyLabel="ABC" />
</Row>
</Keyboard>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="." />
</paths>
\ No newline at end of file
package com.stm.asset;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
\ No newline at end of file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
#Sat Aug 07 09:30:18 CST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
File added
include ':app'
rootProject.name='Asset'
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment