Compare commits
11 Commits
57094bfbd4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d43980458 | |||
| 0800e0eaf0 | |||
| ce30c6cf7b | |||
| cdc07256ee | |||
| 47715f0fd6 | |||
| 59c228f36c | |||
| 5769b7670b | |||
| 12c928f059 | |||
| 724e691188 | |||
| e24a8955a2 | |||
| ec798944ad |
@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk 30
|
compileSdk 28
|
||||||
buildToolsVersion '30.0.3'
|
buildToolsVersion '30.0.3'
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
@ -11,7 +11,7 @@ android {
|
|||||||
minSdk 28
|
minSdk 28
|
||||||
targetSdk 28
|
targetSdk 28
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.13"
|
versionName "2.4"
|
||||||
|
|
||||||
// 1.0 IDATA广播模式处理
|
// 1.0 IDATA广播模式处理
|
||||||
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
||||||
@ -27,7 +27,20 @@ android {
|
|||||||
// 1.11 霍尼韦尔EDA52
|
// 1.11 霍尼韦尔EDA52
|
||||||
// 1.12 屏幕旋转,采取配置化模式(只能竖屏、横屏);取消旋转屏幕就重置activity生命周期
|
// 1.12 屏幕旋转,采取配置化模式(只能竖屏、横屏);取消旋转屏幕就重置activity生命周期
|
||||||
// 1.13 新大陆pda 兼容广播模式;NLS-NFT10
|
// 1.13 新大陆pda 兼容广播模式;NLS-NFT10
|
||||||
|
// 1.14 瑞芯 rk3566_r 添加引用 librockchip.so; 新加一个方法,返回当前PDA的厂家和型号
|
||||||
|
// 1.15 系统状态栏根据配置进行设置
|
||||||
|
// 1.16 idata pda 不设置模式
|
||||||
|
// 1.17 霍尼韦尔EDA51、EDA50P,调用扫描枪的方法,在关闭的时候停止调用扫描枪
|
||||||
|
// 1.18 瑞兴平板,读取扫描结果,使用同步加锁模式
|
||||||
|
// 1.19 index页面接入初始化数据
|
||||||
|
// 2.1 注册PDA的信息存储到文件内部,采取mac+固定加密串的MD5加密校验
|
||||||
|
// 2.2 安卓14以上,无法获取mac地址,修改成获取唯一id作为mac地址
|
||||||
|
// 2.3 适配IOT_Device:sc55g PDA 广播模式
|
||||||
|
// 2.4 适配 qualcomm:mc50 PDA 广播模式
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
ndk {
|
||||||
|
abiFilters 'armeabi-v7a'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//签名配置
|
//签名配置
|
||||||
@ -75,7 +88,7 @@ android {
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.symbol:emdk:+'
|
compileOnly 'com.symbol:emdk:9.1.1'
|
||||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'com.google.android.material:material:1.2.1'
|
implementation 'com.google.android.material:material:1.2.1'
|
||||||
implementation 'com.google.code.gson:gson:2.6.2'
|
implementation 'com.google.code.gson:gson:2.6.2'
|
||||||
@ -85,4 +98,5 @@ dependencies {
|
|||||||
//implementation fileTree(include: ['*.aar'], dir: 'libs')
|
//implementation fileTree(include: ['*.aar'], dir: 'libs')
|
||||||
// 全屏,没有状态栏
|
// 全屏,没有状态栏
|
||||||
api 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
api 'com.readystatesoftware.systembartint:systembartint:1.0.3'
|
||||||
|
implementation files('libs/armeabi-v7a/librockchip.so')
|
||||||
}
|
}
|
||||||
@ -99,19 +99,6 @@
|
|||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
function saveSetting(){
|
|
||||||
var data=JSON.stringify({
|
|
||||||
"address":document.getElementById('address').value,
|
|
||||||
"port":document.getElementById('port').value,
|
|
||||||
"path":document.getElementById('path').value,
|
|
||||||
"screen_rotation":document.getElementById('screen_rotation').value
|
|
||||||
});
|
|
||||||
window.NetworkSettingEngine.saveSetting(data);
|
|
||||||
window.View.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -135,6 +122,10 @@
|
|||||||
<label>屏幕旋转</label>
|
<label>屏幕旋转</label>
|
||||||
<input id="screen_rotation" value="3" name="screen_rotation" placeholder="1:强制竖屏;2:强制横屏;3:横竖都转">
|
<input id="screen_rotation" value="3" name="screen_rotation" placeholder="1:强制竖屏;2:强制横屏;3:横竖都转">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="net-list">
|
||||||
|
<label>隐藏状态栏</label>
|
||||||
|
<input id="hide_bar" value="1" name="hide_bar" placeholder="1:隐藏;0:显示">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="operation">
|
<div class="operation">
|
||||||
<button style="background: #1989fa;" onclick="saveSetting()">保存</button>
|
<button style="background: #1989fa;" onclick="saveSetting()">保存</button>
|
||||||
@ -143,4 +134,35 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
var dstr = window.NetworkSettingEngine.getStringSetting();
|
||||||
|
if (dstr.length > 0) {
|
||||||
|
var d = JSON.parse(dstr);
|
||||||
|
document.getElementById('address').value = d.address;
|
||||||
|
document.getElementById('port').value = d.port;
|
||||||
|
document.getElementById('path').value = d.path;
|
||||||
|
document.getElementById('screen_rotation').value = d.screen_rotation;
|
||||||
|
document.getElementById('hide_bar').value = d.hide_bar;
|
||||||
|
console.log("d_data_end_=========================");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
function saveSetting(){
|
||||||
|
var data=JSON.stringify({
|
||||||
|
"address":document.getElementById('address').value,
|
||||||
|
"port":document.getElementById('port').value,
|
||||||
|
"path":document.getElementById('path').value,
|
||||||
|
"screen_rotation":document.getElementById('screen_rotation').value,
|
||||||
|
"hide_bar":document.getElementById('hide_bar').value
|
||||||
|
});
|
||||||
|
window.NetworkSettingEngine.saveSetting(data);
|
||||||
|
window.View.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -10,6 +10,8 @@ package chaoran.business;
|
|||||||
|
|
||||||
public enum BrandEnum {
|
public enum BrandEnum {
|
||||||
//枚举名即为valueOf()
|
//枚举名即为valueOf()
|
||||||
|
QUALCOMM("qualcomm", "qualcomm"),
|
||||||
|
IOT_DEVICE("新大陆", "iot_device"),
|
||||||
NEW_LAND("新大陆", "newland"),
|
NEW_LAND("新大陆", "newland"),
|
||||||
HISENSE("海信", "hisense"),
|
HISENSE("海信", "hisense"),
|
||||||
UROVO("DT50 Lite", "urovo"),
|
UROVO("DT50 Lite", "urovo"),
|
||||||
@ -44,7 +46,7 @@ public enum BrandEnum {
|
|||||||
code = new String();
|
code = new String();
|
||||||
}
|
}
|
||||||
for (BrandEnum brandEnum : values()) {
|
for (BrandEnum brandEnum : values()) {
|
||||||
if (brandEnum.code.equals(code.toLowerCase())) {
|
if (brandEnum.code.equalsIgnoreCase(code)) {
|
||||||
return brandEnum;
|
return brandEnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.res.AssetManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
@ -16,6 +17,7 @@ import android.media.MediaPlayer;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
import android.util.JsonReader;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -32,13 +34,19 @@ import androidx.appcompat.app.ActionBar;
|
|||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import chaoran.business.BrandEnum;
|
import chaoran.business.BrandEnum;
|
||||||
import chaoran.business.R;
|
import chaoran.business.R;
|
||||||
import chaoran.business.adapter.*;
|
import chaoran.business.adapter.*;
|
||||||
|
import chaoran.business.engine.entity.NetworkSetting;
|
||||||
import chaoran.business.engine.impl.NetworkSettingEngine;
|
import chaoran.business.engine.impl.NetworkSettingEngine;
|
||||||
import chaoran.business.engine.SettingEngine;
|
import chaoran.business.engine.SettingEngine;
|
||||||
import chaoran.business.engine.impl.TekVoiceEngine;
|
import chaoran.business.engine.impl.TekVoiceEngine;
|
||||||
@ -58,11 +66,10 @@ import chaoran.business.utils.StatusBarUtil;
|
|||||||
public class MainActivity extends AppCompatActivity implements ResultListener{
|
public class MainActivity extends AppCompatActivity implements ResultListener{
|
||||||
|
|
||||||
public static int SCREEN_ROTATION = 3; // 屏幕旋转的设置
|
public static int SCREEN_ROTATION = 3; // 屏幕旋转的设置
|
||||||
|
public static int hideBar = 0; // 屏幕旋转的设置
|
||||||
|
|
||||||
MyOrientationDetector myOrientationDetector;
|
MyOrientationDetector myOrientationDetector;
|
||||||
|
|
||||||
private static int latestOrientation = 0; // 添加一个标志位;最后屏幕的方向
|
|
||||||
|
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
private Adapter adapter;
|
private Adapter adapter;
|
||||||
private VoiceEngine voiceEngine;
|
private VoiceEngine voiceEngine;
|
||||||
@ -85,6 +92,25 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String readInitFile(Context context) {
|
||||||
|
StringBuffer init = new StringBuffer();
|
||||||
|
try {
|
||||||
|
AssetManager assetManager = context.getAssets();
|
||||||
|
// 打开文件输入流
|
||||||
|
InputStream inputStream = assetManager.open("init.json");
|
||||||
|
// 使用BufferedReader进行逐行读取
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
init.append(line);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.e("AssetError", "Failed to read asset file: init.json", e);
|
||||||
|
}
|
||||||
|
return init.toString();
|
||||||
|
}
|
||||||
|
|
||||||
private void initData() {
|
private void initData() {
|
||||||
BrandEnum brand = BrandEnum.code(Build.MANUFACTURER);
|
BrandEnum brand = BrandEnum.code(Build.MANUFACTURER);
|
||||||
Toast.makeText(this, Build.MANUFACTURER, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, Build.MANUFACTURER, Toast.LENGTH_LONG).show();
|
||||||
@ -138,6 +164,12 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
case NEW_LAND:
|
case NEW_LAND:
|
||||||
adapter = new NewlandAdapter(this, this);
|
adapter = new NewlandAdapter(this, this);
|
||||||
break;
|
break;
|
||||||
|
case IOT_DEVICE:
|
||||||
|
adapter = new IOT_DeviceAdapter(this, this);
|
||||||
|
break;
|
||||||
|
case QUALCOMM:
|
||||||
|
adapter = new QualcommAdapter(this, this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (null != adapter) {
|
if (null != adapter) {
|
||||||
adapter.start();
|
adapter.start();
|
||||||
@ -154,8 +186,7 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
WebSettings settings = webView.getSettings();
|
WebSettings settings = webView.getSettings();
|
||||||
settings.setJavaScriptEnabled(true);
|
settings.setJavaScriptEnabled(true);
|
||||||
|
|
||||||
// StatusBarUtil.transparencyBar( this); // 设置全部透明,需要在页面设置一个参数进行布局的样式跳转,不同的手机端,状态栏高度不一样(apk设置状态栏高度无效,这个是安卓9的一个bug),所以在此采取隐藏状态栏
|
|
||||||
StatusBarUtil.hideStatusBar( this); // 设置全部透明
|
|
||||||
|
|
||||||
//设置接口进行windows暴露
|
//设置接口进行windows暴露
|
||||||
settings.setDomStorageEnabled(true);
|
settings.setDomStorageEnabled(true);
|
||||||
@ -167,6 +198,10 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
webView.addJavascriptInterface(this, "View");
|
webView.addJavascriptInterface(this, "View");
|
||||||
webView.addJavascriptInterface(new LocalAddressUtil(this, this, webView), "Localpda");
|
webView.addJavascriptInterface(new LocalAddressUtil(this, this, webView), "Localpda");
|
||||||
webView.loadUrl(url());
|
webView.loadUrl(url());
|
||||||
|
// StatusBarUtil.transparencyBar( this); // 设置全部透明,需要在页面设置一个参数进行布局的样式跳转,不同的手机端,状态栏高度不一样(apk设置状态栏高度无效,这个是安卓9的一个bug),所以在此采取隐藏状态栏
|
||||||
|
if (hideBar == 1) {
|
||||||
|
StatusBarUtil.hideStatusBar( this); // 设置全部透明
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//配置客户端
|
//配置客户端
|
||||||
@ -301,13 +336,41 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
private String url() {
|
private String url() {
|
||||||
SharedPreferences spf = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
|
SharedPreferences spf = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
|
||||||
Integer port = spf.getInt("port", -1);
|
Integer port = spf.getInt("port", -1);
|
||||||
|
Map<String, Object> map = null;
|
||||||
if (port == -1) {
|
if (port == -1) {
|
||||||
|
try {
|
||||||
|
// String init = readInitFile(this);
|
||||||
|
String init = null;
|
||||||
|
if (init != null && init.length() > 0) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
map = gson.fromJson(init, new TypeToken<Map<String, Object>>(){}.getType());
|
||||||
|
// 说明采取了配置,并且存在ip才认为是一个合法的json配置
|
||||||
|
if (map.containsKey("ip") && map.get("ip").toString().length() > 0) {
|
||||||
|
NetworkSetting initData = new NetworkSetting();
|
||||||
|
initData.setAddress(map.get("ip").toString());
|
||||||
|
initData.setPort(Integer.parseInt(map.get("port").toString()));
|
||||||
|
initData.setPath(map.get("path").toString());
|
||||||
|
initData.setScreen_rotation(Integer.parseInt(map.getOrDefault("screen_rotation", "3").toString()));
|
||||||
|
initData.setHide_bar(Integer.parseInt(map.getOrDefault("hide_bar", "3").toString()));
|
||||||
|
settingEngine.saveSetting(initData);
|
||||||
|
spf = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
|
||||||
|
port = initData.getPort();
|
||||||
|
}else {
|
||||||
|
map = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e) {
|
||||||
|
Log.e("MainActivity", "get init file error");
|
||||||
|
}
|
||||||
|
if (map == null) {
|
||||||
return "file:///android_asset/demo/index.html";
|
return "file:///android_asset/demo/index.html";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String address = spf.getString("address", "").replaceAll(" ", "");
|
String address = spf.getString("address", "").replaceAll(" ", "");
|
||||||
String path = spf.getString("path", "").replaceAll(" ", "");
|
String path = spf.getString("path", "").replaceAll(" ", "");
|
||||||
String link = address.concat(":").concat(String.valueOf(port)).concat(path);
|
String link = address.concat(":").concat(String.valueOf(port)).concat(path);
|
||||||
SCREEN_ROTATION = spf.getInt("screen_rotation", 3);
|
SCREEN_ROTATION = spf.getInt("screen_rotation", 3);
|
||||||
|
hideBar = spf.getInt("hide_bar", 3);
|
||||||
return link.startsWith("http://") ? link : "http://".concat(link);
|
return link.startsWith("http://") ? link : "http://".concat(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,13 +474,11 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
if (SCREEN_ROTATION == 1 || SCREEN_ROTATION == 3) {
|
if (SCREEN_ROTATION == 1 || SCREEN_ROTATION == 3) {
|
||||||
if (rotate == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || rotate == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
if (rotate == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || rotate == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||||
activity.setRequestedOrientation(rotate);
|
activity.setRequestedOrientation(rotate);
|
||||||
latestOrientation = rotate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SCREEN_ROTATION == 2 || SCREEN_ROTATION == 3) {
|
if (SCREEN_ROTATION == 2 || SCREEN_ROTATION == 3) {
|
||||||
if (rotate == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || rotate == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
if (rotate == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || rotate == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
|
||||||
activity.setRequestedOrientation(rotate);
|
activity.setRequestedOrientation(rotate);
|
||||||
latestOrientation = rotate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -426,69 +487,6 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*class MyOrientationDetector implements SensorEventListener {
|
|
||||||
|
|
||||||
private Activity activity;
|
|
||||||
|
|
||||||
public MyOrientationDetector(Activity activity) {
|
|
||||||
this.activity = activity;
|
|
||||||
Sensor orientationSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
|
|
||||||
sensorManager.registerListener(this, orientationSensor, SensorManager.SENSOR_DELAY_NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(SensorEvent event) {
|
|
||||||
|
|
||||||
int angle = ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
|
||||||
if (latestOrientation == angle) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (SCREEN_ROTATION == 1) {
|
|
||||||
if (Surface.ROTATION_0 == angle) {
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
||||||
latestOrientation = angle;
|
|
||||||
}else if (Surface.ROTATION_180 == angle) {
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
|
||||||
latestOrientation = angle;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}else if (SCREEN_ROTATION == 2) {
|
|
||||||
if (Surface.ROTATION_90 == angle) {
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
||||||
latestOrientation = angle;
|
|
||||||
}else if (Surface.ROTATION_270 == angle) {
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
|
||||||
latestOrientation = angle;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int tmpAngle = latestOrientation;
|
|
||||||
latestOrientation = angle;
|
|
||||||
switch (angle) {
|
|
||||||
case Surface.ROTATION_0:
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_90:
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_180:
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
|
||||||
break;
|
|
||||||
case Surface.ROTATION_270:
|
|
||||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
latestOrientation = tmpAngle;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig) {
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import chaoran.business.R;
|
|||||||
|
|
||||||
public class NetworkSettingActivity extends AppCompatActivity {
|
public class NetworkSettingActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private EditText address, path, port, screen_rotation;
|
private EditText address, path, port, screen_rotation, hide_bar;
|
||||||
private Button save, cancel;
|
private Button save, cancel;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,6 +36,7 @@ public class NetworkSettingActivity extends AppCompatActivity {
|
|||||||
path = findViewById(R.id.path);
|
path = findViewById(R.id.path);
|
||||||
port = findViewById(R.id.port);
|
port = findViewById(R.id.port);
|
||||||
screen_rotation = findViewById(R.id.screen_rotation);
|
screen_rotation = findViewById(R.id.screen_rotation);
|
||||||
|
hide_bar = findViewById(R.id.hide_bar);
|
||||||
save = findViewById(R.id.save);
|
save = findViewById(R.id.save);
|
||||||
cancel = findViewById(R.id.cancel);
|
cancel = findViewById(R.id.cancel);
|
||||||
SharedPreferences sharedPreferences = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = this.getSharedPreferences("crtech", Context.MODE_PRIVATE);
|
||||||
@ -43,6 +44,7 @@ public class NetworkSettingActivity extends AppCompatActivity {
|
|||||||
path.setText(sharedPreferences.getString("path", ""));
|
path.setText(sharedPreferences.getString("path", ""));
|
||||||
port.setText(String.valueOf(sharedPreferences.getInt("port", -1)));
|
port.setText(String.valueOf(sharedPreferences.getInt("port", -1)));
|
||||||
screen_rotation.setText(String.valueOf(sharedPreferences.getInt("screen_rotation", 3)));
|
screen_rotation.setText(String.valueOf(sharedPreferences.getInt("screen_rotation", 3)));
|
||||||
|
hide_bar.setText(String.valueOf(sharedPreferences.getInt("hide_bar", 0)));
|
||||||
cancel.setOnClickListener((e) -> this.finish());
|
cancel.setOnClickListener((e) -> this.finish());
|
||||||
save.setOnClickListener((e) -> saveSetting());
|
save.setOnClickListener((e) -> saveSetting());
|
||||||
}
|
}
|
||||||
@ -53,6 +55,7 @@ public class NetworkSettingActivity extends AppCompatActivity {
|
|||||||
editor.putString("path", path.getText().toString().trim());
|
editor.putString("path", path.getText().toString().trim());
|
||||||
editor.putInt("port", Integer.parseInt(port.getText().toString().trim()));
|
editor.putInt("port", Integer.parseInt(port.getText().toString().trim()));
|
||||||
editor.putInt("screen_rotation", Integer.parseInt(screen_rotation.getText().toString().trim()));
|
editor.putInt("screen_rotation", Integer.parseInt(screen_rotation.getText().toString().trim()));
|
||||||
|
editor.putInt("hide_bar", Integer.parseInt(hide_bar.getText().toString().trim()));
|
||||||
editor.commit();
|
editor.commit();
|
||||||
this.finish();
|
this.finish();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,6 +8,10 @@ import android.content.IntentFilter;
|
|||||||
import chaoran.business.activity.ResultListener;
|
import chaoran.business.activity.ResultListener;
|
||||||
import chaoran.business.strategy.Strategy;
|
import chaoran.business.strategy.Strategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 23-6-13 霍尼韦尔EDA56使用
|
||||||
|
* 25-1-14 兰陵县人民医院 测试可以使用(唐圆圆)
|
||||||
|
*/
|
||||||
public class HoneywellEda56Adapter implements Adapter {
|
public class HoneywellEda56Adapter implements Adapter {
|
||||||
private Context context;
|
private Context context;
|
||||||
private ResultListener resultListener;
|
private ResultListener resultListener;
|
||||||
|
|||||||
@ -39,7 +39,7 @@ public class IDataAdapter implements Adapter {
|
|||||||
|
|
||||||
public Receiver() {
|
public Receiver() {
|
||||||
scannerInerface = new ScannerInerface(context);
|
scannerInerface = new ScannerInerface(context);
|
||||||
scannerInerface.setOutputMode(1);
|
// scannerInerface.setOutputMode(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,56 @@
|
|||||||
|
package chaoran.business.adapter;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
|
||||||
|
import chaoran.business.activity.ResultListener;
|
||||||
|
import chaoran.business.strategy.Strategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 适配 sc55g
|
||||||
|
*/
|
||||||
|
public class IOT_DeviceAdapter implements Adapter {
|
||||||
|
private Context context;
|
||||||
|
private ResultListener resultListener;
|
||||||
|
private Strategy strategy;
|
||||||
|
|
||||||
|
|
||||||
|
public IOT_DeviceAdapter(Context context, ResultListener resultListener) {
|
||||||
|
this.context = context;
|
||||||
|
this.resultListener = resultListener;
|
||||||
|
strategy = new Receiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
strategy.executeStrategy(resultListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
strategy.exclusiveStrategy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Receiver extends BroadcastReceiver implements Strategy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
resultListener.result(intent.getStringExtra("message"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeStrategy(ResultListener resultListener) {
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction("com.speedata.showdecodedata");
|
||||||
|
filter.setPriority(2);
|
||||||
|
context.registerReceiver(this, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exclusiveStrategy() {
|
||||||
|
context.unregisterReceiver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package chaoran.business.adapter;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
|
||||||
|
import chaoran.business.activity.ResultListener;
|
||||||
|
import chaoran.business.strategy.Strategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 适配 mc50
|
||||||
|
*/
|
||||||
|
public class QualcommAdapter implements Adapter {
|
||||||
|
private Context context;
|
||||||
|
private ResultListener resultListener;
|
||||||
|
private Strategy strategy;
|
||||||
|
|
||||||
|
|
||||||
|
public QualcommAdapter(Context context, ResultListener resultListener) {
|
||||||
|
this.context = context;
|
||||||
|
this.resultListener = resultListener;
|
||||||
|
strategy = new Receiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
strategy.executeStrategy(resultListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
strategy.exclusiveStrategy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Receiver extends BroadcastReceiver implements Strategy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
resultListener.result(intent.getStringExtra("data"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeStrategy(ResultListener resultListener) {
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction("com.scanner.broadcast");
|
||||||
|
filter.setPriority(2);
|
||||||
|
context.registerReceiver(this, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exclusiveStrategy() {
|
||||||
|
context.unregisterReceiver(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,10 +9,6 @@ package chaoran.business.adapter;
|
|||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.media.AudioManager;
|
|
||||||
import android.media.SoundPool;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import chaoran.business.R;
|
|
||||||
import chaoran.business.activity.ResultListener;
|
import chaoran.business.activity.ResultListener;
|
||||||
import chaoran.business.strategy.Strategy;
|
import chaoran.business.strategy.Strategy;
|
||||||
|
|
||||||
@ -83,18 +79,23 @@ public class RockChipAdapter implements Adapter {
|
|||||||
while (running) {
|
while (running) {
|
||||||
String data = data();
|
String data = data();
|
||||||
if (!data.equals("")) {
|
if (!data.equals("")) {
|
||||||
|
synchronized (RockChipAdapter.class) {
|
||||||
barcode[0] = barcode[0] + data;
|
barcode[0] = barcode[0] + data;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(20);
|
Thread.sleep(20);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
synchronized (RockChipAdapter.class) {
|
||||||
if (!"".equals(barcode[0])) {
|
if (!"".equals(barcode[0])) {
|
||||||
|
// Log.i("listen", "Thread result data: \t\t" + barcode[0] + "\t\t" + System.currentTimeMillis());
|
||||||
resultListener.result(barcode[0]);
|
resultListener.result(barcode[0]);
|
||||||
barcode[0] = "";
|
barcode[0] = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,17 +106,22 @@ public class RockChipAdapter implements Adapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String data() {
|
private String data() {
|
||||||
if (mFileInputStream == null) return "";
|
if (mFileInputStream == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
synchronized (RockChipAdapter.class) {
|
||||||
try {
|
try {
|
||||||
int size = mFileInputStream.available();
|
int size = mFileInputStream.available();
|
||||||
byte[] buffer = new byte[size];
|
byte[] buffer = new byte[size];
|
||||||
size = mFileInputStream.read(buffer);
|
size = mFileInputStream.read(buffer);
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
return new String(buffer);
|
String data = new String(buffer);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,8 @@ public class NetworkSetting extends Setting {
|
|||||||
|
|
||||||
private Integer screen_rotation;
|
private Integer screen_rotation;
|
||||||
|
|
||||||
|
private Integer hide_bar;
|
||||||
|
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
@ -45,4 +47,12 @@ public class NetworkSetting extends Setting {
|
|||||||
public void setScreen_rotation(Integer screen_rotation) {
|
public void setScreen_rotation(Integer screen_rotation) {
|
||||||
this.screen_rotation = screen_rotation;
|
this.screen_rotation = screen_rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getHide_bar() {
|
||||||
|
return hide_bar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHide_bar(Integer hide_bar) {
|
||||||
|
this.hide_bar = hide_bar;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -45,6 +45,7 @@ public class NetworkSettingEngine implements SettingEngine {
|
|||||||
networkSetting.setPort(port);
|
networkSetting.setPort(port);
|
||||||
networkSetting.setPath(path);
|
networkSetting.setPath(path);
|
||||||
networkSetting.setScreen_rotation(screen_rotation);
|
networkSetting.setScreen_rotation(screen_rotation);
|
||||||
|
networkSetting.setHide_bar(spf.getInt("hide_bar", 3));
|
||||||
return networkSetting;
|
return networkSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +57,10 @@ public class NetworkSettingEngine implements SettingEngine {
|
|||||||
editor.putString("path", networkSetting.getPath());
|
editor.putString("path", networkSetting.getPath());
|
||||||
editor.putInt("port", networkSetting.getPort());
|
editor.putInt("port", networkSetting.getPort());
|
||||||
editor.putInt("screen_rotation", networkSetting.getScreen_rotation());
|
editor.putInt("screen_rotation", networkSetting.getScreen_rotation());
|
||||||
|
editor.putInt("hide_bar", networkSetting.getHide_bar());
|
||||||
editor.commit();
|
editor.commit();
|
||||||
MainActivity.SCREEN_ROTATION = networkSetting.getScreen_rotation();
|
MainActivity.SCREEN_ROTATION = networkSetting.getScreen_rotation();
|
||||||
|
MainActivity.hideBar = networkSetting.getHide_bar();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,7 +57,8 @@ public class ScanServiceEDA50P extends Service
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
NotificationChannel channel = null;
|
NotificationChannel channel = null;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { //适配9.0service
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { //适配9.0service
|
||||||
|
// if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { //适配9.0service
|
||||||
channel = new NotificationChannel(notificationId, notificationName, NotificationManager.IMPORTANCE_HIGH);
|
channel = new NotificationChannel(notificationId, notificationName, NotificationManager.IMPORTANCE_HIGH);
|
||||||
notificationManager.createNotificationChannel(channel);
|
notificationManager.createNotificationChannel(channel);
|
||||||
Notification notification = new Notification.Builder(getApplicationContext(), notificationId).build();
|
Notification notification = new Notification.Builder(getApplicationContext(), notificationId).build();
|
||||||
@ -78,9 +79,11 @@ public class ScanServiceEDA50P extends Service
|
|||||||
//Service被关闭之前回调
|
//Service被关闭之前回调
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.i(TAG, "onDestory方法被调用!");
|
Log.i(TAG, "onDestroy方法被调用!");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
if (mBarcodeReader != null) {
|
||||||
|
mBarcodeReader.release();
|
||||||
|
}
|
||||||
if (this.mInternalScannerReader != null) {
|
if (this.mInternalScannerReader != null) {
|
||||||
this.mInternalScannerReader.removeBarcodeListener(this);
|
this.mInternalScannerReader.removeBarcodeListener(this);
|
||||||
this.mInternalScannerReader.removeTriggerListener(this);
|
this.mInternalScannerReader.removeTriggerListener(this);
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
package chaoran.business.utils;
|
package chaoran.business.utils;
|
||||||
|
|
||||||
|
import static androidx.core.content.ContextCompat.getSystemService;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.bluetooth.le.ScanSettings;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.net.wifi.WifiInfo;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -19,11 +24,11 @@ import java.net.SocketException;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
import chaoran.business.BuildConfig;
|
import chaoran.business.BuildConfig;
|
||||||
import chaoran.business.R;
|
|
||||||
import chaoran.business.activity.MainActivity;
|
|
||||||
|
|
||||||
public class LocalAddressUtil {
|
public class LocalAddressUtil {
|
||||||
|
|
||||||
|
public final static String SSO_KEY = "!~CROP@CRTECH@PDA~!";
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
@ -62,6 +67,14 @@ public class LocalAddressUtil {
|
|||||||
@SuppressLint("JavascriptInterface")
|
@SuppressLint("JavascriptInterface")
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public String getMacAddress(){//可以兼容安卓7以下
|
public String getMacAddress(){//可以兼容安卓7以下
|
||||||
|
if (Build.VERSION.SDK_INT >= 34) { // Android 14 is code-named Tiramisu
|
||||||
|
try {
|
||||||
|
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "02:00:00:00:00:02";
|
||||||
|
}
|
||||||
|
}
|
||||||
String macAddress = null;
|
String macAddress = null;
|
||||||
StringBuffer buf = new StringBuffer();
|
StringBuffer buf = new StringBuffer();
|
||||||
NetworkInterface networkInterface = null;
|
NetworkInterface networkInterface = null;
|
||||||
@ -159,9 +172,45 @@ public class LocalAddressUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("JavascriptInterface")
|
||||||
|
@JavascriptInterface
|
||||||
|
public String registerMac(String applyMac) {
|
||||||
|
try {
|
||||||
|
String mac = this.getMacAddress();
|
||||||
|
String md5Hash = MD5.md5(mac + SSO_KEY);
|
||||||
|
if (md5Hash != null && md5Hash.equals(applyMac)) {
|
||||||
|
// 将允许注册适配的mac写入文件中
|
||||||
|
SharedPreferences.Editor editor = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE).edit();
|
||||||
|
editor.putString("checkMac", "success");
|
||||||
|
editor.commit();
|
||||||
|
return "success";
|
||||||
|
}
|
||||||
|
}catch (Exception ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("JavascriptInterface")
|
||||||
|
@JavascriptInterface
|
||||||
|
public String checkMacRegister() {
|
||||||
|
SharedPreferences sharedPreferences = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE);
|
||||||
|
return sharedPreferences.getString("checkMac", "error");
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("JavascriptInterface")
|
@SuppressLint("JavascriptInterface")
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public String getApkVersion() {
|
public String getApkVersion() {
|
||||||
return BuildConfig.VERSION_NAME;
|
return BuildConfig.VERSION_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暴露PDA的厂家和型号
|
||||||
|
* @return String 格式:厂家:型号
|
||||||
|
*/
|
||||||
|
@SuppressLint("JavascriptInterface")
|
||||||
|
@JavascriptInterface
|
||||||
|
public String getPdaInfo() {
|
||||||
|
return Build.MANUFACTURER + ":" + Build.MODEL.toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
34
app/src/main/java/chaoran/business/utils/MD5.java
Normal file
34
app/src/main/java/chaoran/business/utils/MD5.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package chaoran.business.utils;
|
||||||
|
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
|
// 从框架的MD5加密类拷贝过来的
|
||||||
|
public class MD5 {
|
||||||
|
private static final String key = "aa";
|
||||||
|
private static final char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
||||||
|
|
||||||
|
public static final String md5(String s) {
|
||||||
|
return s == null ? null : md5(s.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String md5(byte[] bytes) {
|
||||||
|
try {
|
||||||
|
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
|
||||||
|
mdTemp.update(bytes);
|
||||||
|
byte[] md = mdTemp.digest();
|
||||||
|
int j = md.length;
|
||||||
|
char[] str = new char[j * 2];
|
||||||
|
int k = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < j; ++i) {
|
||||||
|
byte byte0 = md[i];
|
||||||
|
str[k++] = hexDigits[byte0 >>> 4 & 15];
|
||||||
|
str[k++] = hexDigits[byte0 & 15];
|
||||||
|
}
|
||||||
|
|
||||||
|
return new String(str);
|
||||||
|
} catch (Exception var8) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,6 +7,28 @@
|
|||||||
android:id="@+id/table">
|
android:id="@+id/table">
|
||||||
|
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="隐藏状态栏:" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/hide_bar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="1:隐藏;0显示"
|
||||||
|
android:minWidth="150dp"
|
||||||
|
android:singleLine="true" />
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|||||||
Reference in New Issue
Block a user