Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e69a97436b | ||
|
|
4ba98f62cd | ||
|
|
623d62b641 | ||
|
|
b29d7fd377 | ||
|
|
8ecd50228a | ||
|
|
1a2fc7abb8 | ||
|
|
0f2aa11196 | ||
|
|
dbb4f24608 | ||
|
|
ee317c7b25 | ||
|
|
fe8595f747 |
@@ -33,3 +33,6 @@ Desktop.ini
|
||||
# Python
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# ZCode 会话目录
|
||||
.zcode/
|
||||
|
||||
@@ -1,64 +1,67 @@
|
||||
# MAG160C 热像仪逆向工程
|
||||
# MAG160C 热像仪统一工程
|
||||
|
||||
MAG160C 热像仪(160×120,USB VID 0x833C)的 USB 协议、官方 SDK 逆向、纯 C SDK
|
||||
和**官方渲染管线逐像素复刻**(demo3 v5)的完整工程。
|
||||
MAG160C 热像仪(160×120,15fps,USB VID `0x833C`)的逆向工程与双端实现:
|
||||
**C 参考实现**(Linux/Windows,源自官方 PC SDK 逆向)与**安卓统一 App**
|
||||
(Kotlin + Compose,适配 Android 16,整合官方 4 个 App 的功能)。
|
||||
|
||||
## 从这里开始
|
||||
## 从这里开始(新接手者阅读顺序)
|
||||
|
||||
新接手者按顺序阅读:
|
||||
|
||||
1. `analysis/reverse_20260813_full.md` — 官方管线 Ghidra 全量逆向 + 鬼影根因(最新)
|
||||
2. `analysis/session_state.md` — 当前会话状态与恢复点(心跳锚点)
|
||||
3. `交接_完整逆向工程说明_20260811.md` — 项目总交接(目录/环境/历史/失败路线)
|
||||
4. `analysis/protocol_spec.md` — USB 协议/帧/命令/温度规格
|
||||
5. `csdk/README.md` — **C SDK 完整使用文档**(构建/API/工具/测试)
|
||||
6. `csdk/tools/mag160c_demo3.c` — 主程序(官方管线复刻)
|
||||
|
||||
## 当前状态(2026-08-13)
|
||||
|
||||
- demo3 v5 已完整复刻官方渲染管线:DDT 校准表加载 → 快门驱动端点选择与
|
||||
Q12 插值 → ref=FFC 窗口 4×type1 帧均值 → NUC 查表 → 盲元补偿 →
|
||||
窗口 → LUT1024 重建 → 灰度 → 2x 升采样 → 官方调色板
|
||||
- 逐像素验证:NUC+盲元 0/19200、插值 0 误差、2x 0/76800、窗口一致
|
||||
- 同静态场景 gray 直方图与官方相关性 0.92(跨会话)
|
||||
- 原"鬼影"问题的根因已定位并复刻官方行为(见 reverse_20260813_full.md §7)
|
||||
|
||||
## 硬件
|
||||
|
||||
- 设备:MAG160C 热像仪,分辨率 160×120,15 fps
|
||||
- USB VID:`0x833C`,常见 PID:`0x0001`
|
||||
- 帧:19200 个小端 `uint16`;端点:命令 `0x03`/响应 `0x82`/实时帧 `0x81`
|
||||
|
||||
## 快速入口
|
||||
|
||||
```powershell
|
||||
# 编译 demo3(官方管线复刻)
|
||||
gcc -O2 -w -DMAG160C_STATIC -I"csdk\third_party\libusb\win64" -I"csdk\include" -I"csdk\src" `
|
||||
-o build-artifacts\mag160c_demo3.exe csdk\tools\mag160c_demo3.c `
|
||||
csdk\src\mag160c_display.c csdk\src\mag160c_error.c `
|
||||
csdk\third_party\libusb\win64\libusb-1.0.x64.a -lgdi32 -luser32
|
||||
|
||||
# 启动
|
||||
Start-Process "build-artifacts\mag160c_demo3.exe" -WorkingDirectory "build-artifacts"
|
||||
```
|
||||
|
||||
详细用法见 `csdk/README.md`。
|
||||
1. `docs/android_app/HANDOFF_DEVELOPMENT.md` — 安卓 App 总交接(必读)
|
||||
2. `docs/android_app/session_state.md` — 会话心跳与待办(最新进度)
|
||||
3. `analysis/README.md` — 逆向工程总目录索引(Linux/Windows/Android 三条线)
|
||||
4. `analysis/magcx_official_flow.md` — **权威 USB 协议结论**(官方源码逐行核对版)
|
||||
5. `analysis/protocol_spec.md` — 早期 PC 端协议逆向(硬件验证记录)
|
||||
6. `csdk/README.md` — C SDK 文档(构建/API/工具/测试)
|
||||
|
||||
## 仓库结构
|
||||
|
||||
| 路径 | 用途 |
|
||||
|---|---|
|
||||
| `csdk/` | 纯 C SDK + 工具(见 `csdk/README.md`)|
|
||||
| `analysis/` | 逆向证据:反编译导出(`ida/`)、协议规格、交接文档、抓帧数据 |
|
||||
| `IR_Camera_SDK-1.0.1/` | 原厂 Windows/Android/Linux SDK |
|
||||
| `build-artifacts/` | 运行目录(demo3 exe、DDT 表、官方抓帧工具)|
|
||||
| `docs/` `vendor-docs/` `app/` | 历史资料与模块文档 |
|
||||
| `tools/resume_rev.ps1` | 会话恢复脚本(心跳配套)|
|
||||
| `android/` | **安卓统一 App**(Kotlin + Compose,Gradle 工程,package `com.mag160c.thermal`):实时预览、拍照 MDT、录像、媒体库、离线分析、PDF 报告、任务巡检、设置 |
|
||||
| `csdk/` | 纯 C SDK(官方管线 C 复刻:渲染/温度/IR 会话/FFC 调度,见 `csdk/README.md`)|
|
||||
| `analysis/` | 逆向工程总目录(Linux/Windows/Android 三条 SDK 线的解包产物与结论,见 `analysis/README.md`)|
|
||||
| `IR_Camera_SDK-1.0.1/` | 原厂 Windows/Android/Linux SDK 原始包 |
|
||||
| `app/` | 官方安卓 APK 存档(普通版/专业版/ThermoScope/demo)|
|
||||
| `build-artifacts/` | 构建产物(安卓 APK、PC demo3、DDT 标定数据)|
|
||||
| `docs/android_app/` | 安卓 App 交接文档(HANDOFF / session_state / 逆向功能总表)|
|
||||
| `vendor-docs/` | 厂商资料 |
|
||||
| `tools/` | 会话恢复脚本 |
|
||||
|
||||
历史文档(早期 findings/progress/task_plan、根目录抓帧残留)已归档到
|
||||
`analysis/history/`;早期探索工具源码在 `csdk/tools/legacy/`。
|
||||
## 快速入口
|
||||
|
||||
### 安卓 App(构建/测试)
|
||||
```powershell
|
||||
cd C:\Project\MAG160C\android
|
||||
$env:JAVA_HOME = "C:\Tools\jdk-21"
|
||||
.\gradlew.bat :app:assembleDebug test --no-daemon
|
||||
# 产物:build-artifacts\mag160c-app-debug.apk
|
||||
```
|
||||
|
||||
### C 管线复刻 demo3
|
||||
```powershell
|
||||
gcc -O2 -w -DMAG160C_STATIC -I"csdk\third_party\libusb\win64" -I"csdk\include" -I"csdk\src" `
|
||||
-o build-artifacts\mag160c_demo3.exe csdk\tools\mag160c_demo3.c `
|
||||
csdk\src\mag160c_display.c csdk\src\mag160c_error.c `
|
||||
csdk\third_party\libusb\win64\libusb-1.0.x64.a -lgdi32 -luser32
|
||||
Start-Process "build-artifacts\mag160c_demo3.exe" -WorkingDirectory "build-artifacts"
|
||||
```
|
||||
|
||||
## 硬件
|
||||
|
||||
- 设备:MAG160C 热像仪机芯,160×120 @15fps
|
||||
- USB:VID `0x833C` PID `0x0001`;端点 0x03 命令 / 0x82 响应 / 0x81 图像流 /
|
||||
0x84 标定文件 / 0x05 标定上传
|
||||
- 协议细节:`analysis/magcx_official_flow.md`(权威)
|
||||
|
||||
## 里程碑
|
||||
|
||||
- 2026-08:官方 PC SDK(libmagcore/CoreSDKLib)逆向 + C 管线逐像素复刻(demo3)
|
||||
- 2026-09-06~09:安卓 App(纯 Kotlin,无 NDK):渲染管线移植(逐字节验证)、
|
||||
USB 层(官方协议 Java 源码逐行复刻)、相机式 UI、拍照/录像/媒体库/分析/PDF
|
||||
- 2026-09-10:真机联调打通(根因:USB 命令字节序反转,已修复并用单测锁死);
|
||||
官方 App 全量解包入库(jadx + Ghidra)
|
||||
|
||||
## 仓库说明
|
||||
|
||||
仓库包含官方 SDK、第三方依赖、二进制样本和抓帧数据。部分内容可能受原厂
|
||||
许可限制,仅用于本项目的互操作性研究和设备调试。大型文件使用 Git LFS。
|
||||
仓库包含官方 SDK、反编译产物、二进制样本和抓帧数据。部分内容可能受原厂许可
|
||||
限制,仅用于本项目的互操作性研究和设备调试。
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# analysis/ — MAG160C 逆向工程总目录
|
||||
|
||||
> 本目录汇总了 MAG160C 相关的**全部逆向工程材料**,覆盖三条产品线:
|
||||
> ① Linux SDK(libmagcore.so)② Windows SDK(CoreSDKLib.dll / ThermalSDK.dll)
|
||||
> ③ 官方安卓 App(MAG-Cx 普通版:Java 层 + libcxsdk.so / libcoresdk.so)。
|
||||
> 阅读顺序建议:先读本 README → `magcx_official_flow.md`(权威协议结论)
|
||||
> → 按需深入各分目录。
|
||||
|
||||
## 顶层文件(结论与工具)
|
||||
|
||||
| 文件 | 内容 |
|
||||
|---|---|
|
||||
| `magcx_official_flow.md` | **权威协议结论**(2026-09-10,官方 Java 源码逐行核对版):命令表、BasePara/CaliInfo 布局、连接序列、标定文件下载、FFC 逻辑 |
|
||||
| `protocol_spec.md` | 早期 PC 端逆向协议(libmagcore/CoreSDKLib,2026-08-10 硬件验证),历史参考 |
|
||||
| `gen_kotlin_tables.py` | 生成 `OfficialTables.kt`(palette256/T2E/E2T)的脚本 |
|
||||
| `render_offline.c` | PC 端参考渲染管线(gcc 编译),Kotlin 移植的逐字节差分基准 |
|
||||
| `official_render_frame.rgb` / `official_t2e_table.txt` / `t2e_table.json` / `test_ref_stats.txt` | PC 差分验证数据 |
|
||||
| `revtools.py` / `reverse_tools/` | 逆向辅助脚本 |
|
||||
|
||||
## sdk_re/ — 按 SDK 产品线归档
|
||||
|
||||
### `sdk_re/linux_libmagcore/` — Linux SDK(libmagcore.so.2.1.1,x86-64)
|
||||
- `magcore_disasm.txt`(全量反汇编)+ `magcore_defined.txt` / `magcore_dynsyms.txt` / `magcore_relocs.txt`
|
||||
- `disasm_*.txt`:关键函数级反汇编(LinkCameraEx / StartProcessImage / Raw2Temperature /
|
||||
ConvertResponse2Temp / ReviseTemperature / ffc / frameParse / AccumulatorPushFrame 等)
|
||||
- `all_functions_decomp_libmagcore.so_00100000.txt`:Ghidra 全量伪代码
|
||||
|
||||
### `sdk_re/windows_sdk/` — Windows SDK(CoreSDKLib.dll / ThermalSDK.dll)
|
||||
- `refs_CoreSDKLib.dll.txt` / `exports_decomp_CoreSDKLib.dll.txt` / `keyfuncs_decomp_CoreSDKLib.dll.txt`
|
||||
/ `callers_decomp_CoreSDKLib.dll.txt` / `coresdk_keyfuncs_disasm.txt` / `coresdk_windows_disasm.txt`
|
||||
- `exports_decomp_ThermalSDK.dll.txt` + `thermalsdk_dll/` + `thermalsdk_so/`(ThermalSDK 包装层)
|
||||
|
||||
### `sdk_re/android_app/` — 官方安卓 App(普通版 MAG-Cx,本管线上真机跑通的代码)
|
||||
- `jadx_magcx/`:**全量 Java 源码**(jadx 1.5.1)。核心:`cn/com/magnity/magnitycx/sdk/UsbCommunication.java`
|
||||
(USB 协议真身)、`P2DCmd.java`/`D2PCmd.java`(命令表)、`DeviceController.java`(JNI 封装)
|
||||
- `libcxsdk_decomp.txt`:Ghidra 全量伪代码(libcxsdk.so,1290 函数;Controller::StartProcess /
|
||||
PushFrame / LoadCalibrationTable 已核对)
|
||||
- `all_functions_decomp_libcoresdk_arm64.so_00100000.txt`:libcoresdk(arm64) 全量伪代码
|
||||
(专业版/网络路径,CNetComm 命令层)
|
||||
- `coresdk_arm64_defined.txt`:ARM64 库符号表
|
||||
|
||||
## history/ — 过程记录(按时间)
|
||||
`task_plan_20260714` → `findings_20260810` / `progress_20260810` / `handoff_20260810..13` /
|
||||
`交接_完整逆向工程说明_20260811`(PC SDK 全流程报告)→ `reverse_20260813_full` /
|
||||
`progress_reverse`。历史参考,协议细节以 `magcx_official_flow.md` 为准。
|
||||
|
||||
## preview/ — 渲染验证截图
|
||||
demo2_v3..v7 系列(管线复刻过程对照)、preview_*.png(安卓 UI 验证)。
|
||||
|
||||
## 与代码库的关系
|
||||
- `csdk/src/`:依据 Linux SDK 逆向写出的 C 参考实现(渲染/温度/IR 会话/FFC 调度),
|
||||
Kotlin 管线(android/app)与其逐字节差分验证一致。
|
||||
- `android/app/src/main/java/com/mag160c/thermal/usb/IrSession.kt`:官方
|
||||
UsbCommunication.java 的 Kotlin 等价实现(含小端命令、800ms 超时、0x84 标定下载)。
|
||||
- `docs/android_app/HANDOFF_DEVELOPMENT.md` §4.2 指向本目录。
|
||||
@@ -0,0 +1,103 @@
|
||||
# MAG160C 官方 MAG-Cx 完整逆向结论(2026-09-10,jadx + Ghidra 全量解包)
|
||||
|
||||
> 产物来源:
|
||||
> - Java 层:`analysis/sdk_re/android_app/jadx_magcx/`(jadx 1.5.1 反编译官方普通版 MAG-Cx.apk 全量源码)
|
||||
> - Native 层:`analysis/sdk_re/android_app/libcxsdk_decomp.txt`
|
||||
> (Ghidra 11.3.2 headless 全量反编译 lib/armeabi/libcxsdk.so,1290 函数)
|
||||
> - libcoresdk(arm64) 反编译已在 `analysis/sdk_re/android_app/`(专业版/网络路径)
|
||||
> - 本文结论全部来自以上反编译源码,与真机日志交叉验证(vivo V2509A, Android 16)。
|
||||
|
||||
## 1. USB 协议权威版(以官方 Java UsbCommunication.java 为准)
|
||||
|
||||
### 1.1 端点与超时
|
||||
| 端点 | 方向 | 用途 | 超时 |
|
||||
|---|---|---|---|
|
||||
| 0x03 | OUT | 命令(4B 小端 magic;FFC/激光/帧率带参数) | 800ms |
|
||||
| 0x82 | IN | 命令响应/ack(读 ≤64B) | 800ms |
|
||||
| 0x81 | IN | 图像流(28B 头 + 38400B + 28B 尾) | 800ms |
|
||||
| 0x84 | IN | 标定文件下载(16KB 块) | 800ms/块 |
|
||||
| 0x05 | OUT | 向相机发送标定(SendCaliFile 上传方向,本项目暂不用) | 800ms |
|
||||
|
||||
**全部 800ms**(官方 `TIMEOUT` 常量)。响应缓冲 64B。
|
||||
|
||||
### 1.2 命令集(P2DCmd,全部 4 字节小端)
|
||||
| 值 | 官方名 | 说明 |
|
||||
|---|---|---|
|
||||
| 0x6BB6B66B | GetParameter1 | → 0x5BB5B55B BasePara1(60B) |
|
||||
| 0x6BB6B66C | GetParameter2 | → 0x5BB5B55C BasePara2(60B) |
|
||||
| 0x6BB6B66D | SetParameter1 | 带 ack(64B 读) |
|
||||
| 0x6BB6B66E | SetParameter2 | 带 ack |
|
||||
| 0x6BB6B66F | GetCaliInfo | → 0x5BB5B55E {i32 size, i32 reserved, i64 date} |
|
||||
| 0x6BB6B670 | GetCaliFile | ack 0x5BB5B55D,随后相机在 0x84 推标定文件 |
|
||||
| 0x6BB6B671 | SendCaliFile | 上传方向(配 0x05 OUT) |
|
||||
| 0x6BB6B672 | SetShutterState | FFC!8B {magic LE, u32 on LE} |
|
||||
| 0x6BB6B673 | StartTransferImg | 开始推流,带 ack |
|
||||
| 0x6BB6B674 | StopTransferImg | 停流,带 ack |
|
||||
| 0x6BB6B675 | GetLifeTime | → 0x5BB5B561 {magic, i32 开机毫秒} |
|
||||
| 0x6BB6B676 | SetLaserState | 8B(激光,非省电!) |
|
||||
| 0x6BB6B677 | PowerSave | 8B |
|
||||
| 0x6BB6B678 | GetFPAState | → 0x5BB5B562 |
|
||||
| 0x6BB6B679 | SetFrameRate | 12B {magic, i32 interFrame, i32 interLine} |
|
||||
|
||||
D2P 响应魔数:5B=SendParameter1、5C=SendParameter2、5D=SendCaliFile、
|
||||
5E=SendCaliInfo、61=SendLifeTime(均在 0x5BB5B5xx 空间)。
|
||||
|
||||
**注意**:0x6BB6B66B 是回文数(字节对称),因此历史上"66b 有响应、其余全无"
|
||||
正是字节序反了的特征——非回文命令全部变成无效字节。`MagProtocolTest` 已锁死。
|
||||
|
||||
### 1.3 BasePara1(0x5BB5B55B payload,14×i32 = 56B)
|
||||
int[0] serialNumber;int[1] hwVersion(低24位)|devType(高8位);
|
||||
int[2] swVersion;int[4] fpaWidth;int[5] fpaHeight;int[6] fps;
|
||||
int[8] fpaGain;int[9] fpaFlip;int[10] interFrame;int[11] interLine。
|
||||
devType:0=c1, 1=c3, 2=c3p, **3=core160(MAG160C)**, 5=c1pro, 6=c1prolite。
|
||||
|
||||
### 1.4 官方连接序列(connect() + startTransfer())
|
||||
```
|
||||
1. write GetParameter1 → read 64B → BasePara1(失败则整个 connect 放弃)
|
||||
2. write GetParameter2 → read → BasePara2
|
||||
3. write GetCaliInfo → read → {size, reserved, date}
|
||||
4. 缓存判定:{caliDir}/{productType}.{serial}.{date} 存在且长度==size
|
||||
├─ 命中:直接 startTransfer()
|
||||
└─ 未命中:启动 ThreadCaliRecv(0x84 连续读,16KB/块,无数据 5s 放弃)
|
||||
→ sleep 50ms → write GetCaliFile(670)(waitForCmdAck 读 ack)
|
||||
→ 收满 size 字节存盘 → startTransfer(caliPath)
|
||||
5. startTransfer:
|
||||
a. native startProcess(w, h, serial, devType, shutterClose/OpenSpeed,
|
||||
ffcTriggerFrame, ffcTriggerTemperature, paletteIndex, baseLineAcc,
|
||||
caliPath) ← libcxsdk Controller::StartProcess → LoadCalibrationTable
|
||||
(caliPath),加载失败即 startProcess 失败并删除缓存文件
|
||||
b. native setEX / getExtParameter+setExtParameter(dwFlip) / setAutoEnlarge
|
||||
(全部 native,不占 USB)
|
||||
c. 启动 ThreadImgRecv + ThreadImgProcess → sleep 5ms
|
||||
→ write StartTransferImg(673)(waitForCmdAck 读 ack)
|
||||
```
|
||||
|
||||
### 1.5 图像流帧结构(与 FrameStream/管线一致)
|
||||
28B 头:0x1BB1B11B, frameIndex, dataLen(=w*h*2), type(0/1), period, 保留×3。
|
||||
38400B u16LE 像素。
|
||||
28B 尾:0x1BB1B11C, frameIndex, fpaTemp, intDrop(=type), reserved[2]。
|
||||
官方 ThreadImgRecv:搜头→凑满 frameBytes→校验尾→drop∈{0,1} 才交给处理线程;
|
||||
fpaTemp 在尾 +8(devType0/5/6/3),camTemp=fpaTemp-500。
|
||||
|
||||
### 1.6 FFC 触发(官方逻辑)
|
||||
- 双击/消息(MSG_TRIGGER_FFC)→ SetShutterState(672);
|
||||
- 每 16 帧查 GetLifeTime(675):devType1/2 按 6.5s/13s/19.5s/26s 档位触发 FFC;
|
||||
**devType0/5/6/3(含 core160)该路径不自动 FFC**(仅温度稳定标志)。
|
||||
- 本项目管线内部 FFC 调度(onFfc→672)为等效实现,且 672 相机随时接受。
|
||||
|
||||
## 2. 本项目复刻状态(IrSession.kt = 官方 UsbCommunication 等价物)
|
||||
- 连接序列 1-5 已逐行复刻(含 0x84 拉取、缓存 files/cali/{product}.{serial}.{date});
|
||||
- 命令打包小端(与官方 intToByteArray 一致)——**历史上 cmd4/cmd8 用
|
||||
ByteBuffer.putInt 默认大端导致非回文命令全部反转**(16 轮黑屏的根因,
|
||||
MagProtocolTest 锁死);
|
||||
- usfs 坑:bulk 读超时后端点被标 halted,后续传输全部瞬间失败,须每次失败后
|
||||
CLEAR_HALT(IrSession.diagnoseEndpoint);
|
||||
- 会话互斥(同一时刻仅一个 IrSession 持有相机)+ DETACHED 释放 + 去抖。
|
||||
|
||||
## 3. 工具与环境(2026-09-10 本机)
|
||||
- jadx 1.5.1:C:\Tools\jadx-1.5.1(反编译产物 C:\Tools\jadx-out,已拷贝入库
|
||||
analysis/sdk_re/android_app/jadx_magcx/)
|
||||
- Ghidra 11.3.2:C:\Tools\ghidra_11.3.2_PUBLIC;工程 C:\Tools\ghidra_proj\MagCX;
|
||||
全量反编译脚本 C:\Tools\ghidra_scripts_user\DumpAllDecomp.java
|
||||
- 重跑命令(PowerShell/cmd):
|
||||
`set JAVA_HOME=C:\Tools\jdk-21&& C:\Tools\ghidra_11.3.2_PUBLIC\support\analyzeHeadless.bat C:\Tools\ghidra_proj MagCX -process libcxsdk.so -scriptPath C:\Tools\ghidra_scripts_user -postScript DumpAllDecomp.java <输出文件>`
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbConnection;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
import com.google.zxing.ChecksumException;
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.RGBLuminanceSource;
|
||||
import com.google.zxing.Result;
|
||||
import com.google.zxing.common.HybridBinarizer;
|
||||
import com.google.zxing.qrcode.QRCodeReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AboutAboutActivity extends AppCompatActivity {
|
||||
private ImageView imageView_;
|
||||
private PackageInfo packInfo_;
|
||||
private TextView tvCompanyCaption_;
|
||||
private TextView tvCompany_;
|
||||
private TextView tvFWVersionCaption_;
|
||||
private TextView tvFWVersion_;
|
||||
private TextView tvHWVersionCaption_;
|
||||
private TextView tvHWVersion_;
|
||||
private TextView tvProductTypeCaption_;
|
||||
private TextView tvProductType_;
|
||||
private TextView tvRightCaption_;
|
||||
private TextView tvRight_;
|
||||
private TextView tvSWVersionCaption_;
|
||||
private TextView tvSWVersion_;
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about_about);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
setTitle(R.string.settingsAboutAbout);
|
||||
PackageManager packageManager = getPackageManager();
|
||||
try {
|
||||
this.packInfo_ = packageManager.getPackageInfo(getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
this.packInfo_ = null;
|
||||
}
|
||||
this.tvProductTypeCaption_ = (TextView) findViewById(R.id.id_text1);
|
||||
this.tvProductTypeCaption_.setText(R.string.productType);
|
||||
this.tvProductType_ = (TextView) findViewById(R.id.id_text2);
|
||||
if (UsbConnection.getInstance().isConnected()) {
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
this.tvProductType_.setText(R.string.c1);
|
||||
break;
|
||||
case 1:
|
||||
this.tvProductType_.setText(R.string.c3);
|
||||
break;
|
||||
case 2:
|
||||
this.tvProductType_.setText(R.string.c3p);
|
||||
break;
|
||||
case 3:
|
||||
this.tvProductType_.setText(R.string.core160);
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
this.tvProductType_.setText("");
|
||||
break;
|
||||
case 5:
|
||||
this.tvProductType_.setText(R.string.c1pro);
|
||||
break;
|
||||
case 6:
|
||||
this.tvProductType_.setText(R.string.c1prolite);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.tvProductType_.setText("");
|
||||
}
|
||||
View view = findViewById(R.id.id_swVersion);
|
||||
this.tvSWVersionCaption_ = (TextView) view.findViewById(R.id.id_text1);
|
||||
this.tvSWVersionCaption_.setText(R.string.swVersion);
|
||||
this.tvSWVersion_ = (TextView) view.findViewById(R.id.id_text2);
|
||||
if (this.packInfo_ != null) {
|
||||
this.tvSWVersion_.setText(this.packInfo_.versionName);
|
||||
}
|
||||
View view2 = findViewById(R.id.id_right);
|
||||
this.tvRightCaption_ = (TextView) view2.findViewById(R.id.id_text1);
|
||||
this.tvRightCaption_.setText(R.string.right);
|
||||
this.tvRight_ = (TextView) view2.findViewById(R.id.id_text2);
|
||||
this.tvRight_.setText(R.string.juge);
|
||||
View view3 = findViewById(R.id.id_fwVersion);
|
||||
this.tvFWVersionCaption_ = (TextView) view3.findViewById(R.id.id_text1);
|
||||
this.tvFWVersionCaption_.setText(R.string.fwVersion);
|
||||
this.tvFWVersion_ = (TextView) view3.findViewById(R.id.id_text2);
|
||||
if (UsbConnection.getInstance().isConnected()) {
|
||||
this.tvFWVersion_.setText(Integer.toString(MagApplication.magParameter.basePara1.swVersion));
|
||||
} else {
|
||||
this.tvFWVersion_.setText("");
|
||||
}
|
||||
View view4 = findViewById(R.id.id_hwVersion);
|
||||
this.tvHWVersionCaption_ = (TextView) view4.findViewById(R.id.id_text1);
|
||||
this.tvHWVersionCaption_.setText(R.string.hwVersion);
|
||||
this.tvHWVersion_ = (TextView) view4.findViewById(R.id.id_text2);
|
||||
if (UsbConnection.getInstance().isConnected()) {
|
||||
this.tvHWVersion_.setText(Integer.toString(MagApplication.magParameter.basePara1.hwVersion));
|
||||
} else {
|
||||
this.tvHWVersion_.setText("");
|
||||
}
|
||||
View view5 = findViewById(R.id.id_company);
|
||||
this.tvCompanyCaption_ = (TextView) view5.findViewById(R.id.id_text1);
|
||||
this.tvCompanyCaption_.setText(R.string.company);
|
||||
this.tvCompany_ = (TextView) view5.findViewById(R.id.id_text2);
|
||||
this.tvCompany_.setText("http://www.magnity.com.cn");
|
||||
this.tvCompany_.setTextColor(-12211576);
|
||||
this.tvCompany_.setPaintFlags(8);
|
||||
view5.setOnClickListener(new MagClickListener());
|
||||
this.imageView_ = (ImageView) findViewById(R.id.id_barcodeView);
|
||||
registerForContextMenu(this.imageView_);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
unregisterForContextMenu(this.imageView_);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.View.OnCreateContextMenuListener
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||
super.onCreateContextMenu(menu, v, menuInfo);
|
||||
menu.add(0, 2, 1, R.string.menu_read_barcode);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case 1:
|
||||
shareOnlineImage(this.imageView_);
|
||||
break;
|
||||
case 2:
|
||||
StatService.onEvent(getApplicationContext(), MagParameter.EVENT_ENTER_WECHAT_STORE_ID, MagParameter.EVENT_ENTER_WECHAT_STORE);
|
||||
readBarcode(this.imageView_);
|
||||
break;
|
||||
}
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPause(this);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onResume(this);
|
||||
}
|
||||
|
||||
private void shareOnlineImage(ImageView v) {
|
||||
Bitmap bmp = ((BitmapDrawable) v.getDrawable()).getBitmap();
|
||||
try {
|
||||
File file = new File(getExternalFilesDir("temp"), "barcode.jpg");
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(file);
|
||||
bmp.compress(Bitmap.CompressFormat.JPEG, 100, out);
|
||||
out.close();
|
||||
if (file.exists()) {
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(file));
|
||||
intent.addFlags(1);
|
||||
intent.setType("image/*");
|
||||
startActivity(Intent.createChooser(intent, getResources().getString(R.string.menu_share_barcode)));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
}
|
||||
|
||||
private void readBarcode(ImageView v) {
|
||||
Result re = null;
|
||||
try {
|
||||
Bitmap bmp = ((BitmapDrawable) v.getDrawable()).getBitmap();
|
||||
int width = bmp.getWidth();
|
||||
int height = bmp.getHeight();
|
||||
int[] data = new int[width * height];
|
||||
bmp.getPixels(data, 0, width, 0, 0, width, height);
|
||||
RGBLuminanceSource source = new RGBLuminanceSource(width, height, data);
|
||||
BinaryBitmap bitmap1 = new BinaryBitmap(new HybridBinarizer(source));
|
||||
QRCodeReader reader = new QRCodeReader();
|
||||
try {
|
||||
try {
|
||||
re = reader.decode(bitmap1);
|
||||
} catch (NotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (ChecksumException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (FormatException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
if (re == null) {
|
||||
Toast.makeText(this, R.string.tip_barcode_fail, 0).show();
|
||||
} else {
|
||||
Toast.makeText(this, String.format(getResources().getString(R.string.tip_goto_store), re.getText()), 0).show();
|
||||
StoreActivity.actionStart(this, re.getText());
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
private class MagClickListener implements View.OnClickListener {
|
||||
private MagClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_company /* 2131624064 */:
|
||||
Uri uri = Uri.parse("http://www.magnity.com.cn");
|
||||
Intent intent = new Intent("android.intent.action.VIEW", uri);
|
||||
AboutAboutActivity.this.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
import com.baidu.mobstat.StatService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AboutProductActivity extends AppCompatActivity {
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about_product);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
setTitle(R.string.settingsAboutProduct);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPause(this);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onResume(this);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BuildConfig {
|
||||
public static final String APPLICATION_ID = "cn.com.magnity.magnitycx";
|
||||
public static final String BUILD_TYPE = "release";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String FLAVOR = "";
|
||||
public static final int VERSION_CODE = 114;
|
||||
public static final String VERSION_NAME = "1.1.4";
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DialogFragmentMediaInfo extends DialogFragment {
|
||||
private static final String MEDIAFILEINFO = "mediaFileInfo";
|
||||
private MagOnClickListener magOnClickListener_;
|
||||
private ArrayList<String> mediaInfos_;
|
||||
|
||||
public static DialogFragmentMediaInfo newInstance(ArrayList<String> info) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putStringArrayList(MEDIAFILEINFO, info);
|
||||
DialogFragmentMediaInfo dlg = new DialogFragmentMediaInfo();
|
||||
dlg.setArguments(bundle);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
this.mediaInfos_ = bundle.getStringArrayList(MEDIAFILEINFO);
|
||||
}
|
||||
this.magOnClickListener_ = new MagOnClickListener();
|
||||
}
|
||||
|
||||
private void fillCatigory(View rootView, int viewId, int stringId, String name) {
|
||||
View item = rootView.findViewById(viewId);
|
||||
TextView text = (TextView) item.findViewById(R.id.id_text_item_left);
|
||||
text.setText(stringId);
|
||||
TextView text2 = (TextView) item.findViewById(R.id.id_text_item_right);
|
||||
text2.setText(name);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
int i;
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.dialog_fragment_media_info, (ViewGroup) null);
|
||||
Button btnOk = (Button) view.findViewById(R.id.id_btn_ok);
|
||||
btnOk.setOnClickListener(this.magOnClickListener_);
|
||||
try {
|
||||
int i2 = 0 + 1;
|
||||
try {
|
||||
boolean isVideo = Integer.parseInt(this.mediaInfos_.get(0)) != 0;
|
||||
int i3 = i2 + 1;
|
||||
fillCatigory(view, R.id.id_media_info_name, R.string.mediaInfoName, this.mediaInfos_.get(i2));
|
||||
int i4 = i3 + 1;
|
||||
fillCatigory(view, R.id.id_media_info_time, R.string.mediaInfoTime, this.mediaInfos_.get(i3));
|
||||
int i5 = i4 + 1;
|
||||
fillCatigory(view, R.id.id_media_info_size, R.string.mediaInfoSize, this.mediaInfos_.get(i4));
|
||||
if (isVideo) {
|
||||
i = i5 + 1;
|
||||
fillCatigory(view, R.id.id_media_info_duration, R.string.mediaInfoDuration, this.mediaInfos_.get(i5));
|
||||
} else {
|
||||
View item = view.findViewById(R.id.id_media_info_duration);
|
||||
item.setVisibility(8);
|
||||
i = i5 + 1;
|
||||
}
|
||||
int i6 = i + 1;
|
||||
fillCatigory(view, R.id.id_media_info_resolution, R.string.mediaInfoResolution, this.mediaInfos_.get(i));
|
||||
i2 = i6 + 1;
|
||||
fillCatigory(view, R.id.id_media_info_path, R.string.mediaInfoPath, this.mediaInfos_.get(i6));
|
||||
} catch (Exception e) {
|
||||
Logging.trace("Fail to get media info");
|
||||
builder.setView(view);
|
||||
return builder.create();
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
builder.setView(view);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private class MagOnClickListener implements View.OnClickListener {
|
||||
private MagOnClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_btn_ok /* 2131624096 */:
|
||||
DialogFragmentMediaInfo.this.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DialogFragmentMode extends DialogFragment {
|
||||
private ImageButton btnGoBack_;
|
||||
private ImageButton btnModeIr_;
|
||||
private ImageButton btnModePip_;
|
||||
private ModeClickListener modeClickListener_;
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setStyle(0, android.R.style.Theme.Black.NoTitleBar.Fullscreen);
|
||||
this.modeClickListener_ = new ModeClickListener();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.dialog_fragment_mode, container);
|
||||
this.btnGoBack_ = (ImageButton) rootView.findViewById(R.id.id_goback);
|
||||
this.btnModeIr_ = (ImageButton) rootView.findViewById(R.id.id_mode_ir);
|
||||
this.btnModePip_ = (ImageButton) rootView.findViewById(R.id.id_mode_pip);
|
||||
this.btnGoBack_.setOnClickListener(this.modeClickListener_);
|
||||
this.btnModeIr_.setOnClickListener(this.modeClickListener_);
|
||||
this.btnModePip_.setOnClickListener(this.modeClickListener_);
|
||||
setDialogProperty();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void setDialogProperty() {
|
||||
getDialog().requestWindowFeature(1);
|
||||
getDialog().setCanceledOnTouchOutside(true);
|
||||
Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.width = -1;
|
||||
windowParams.height = -2;
|
||||
window.setAttributes(windowParams);
|
||||
window.setGravity(48);
|
||||
window.setWindowAnimations(R.style.ThemeDialog);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.dimAmount = 0.4f;
|
||||
windowParams.alpha = 1.0f;
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
|
||||
private class ModeClickListener implements View.OnClickListener {
|
||||
private ModeClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_goback /* 2131624058 */:
|
||||
DialogFragmentMode.this.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DialogFragmentPalette extends DialogFragment implements View.OnClickListener {
|
||||
private View rootView_;
|
||||
private HashMap<Object, Object> mapIndex2Id_ = new HashMap<Object, Object>() { // from class: cn.com.magnity.magnitycx.DialogFragmentPalette.1
|
||||
{
|
||||
put(0, Integer.valueOf(R.id.id_palette_white_hot));
|
||||
put(1, Integer.valueOf(R.id.id_palette_black_hot));
|
||||
put(2, Integer.valueOf(R.id.id_palette_iron_bow));
|
||||
put(3, Integer.valueOf(R.id.id_palette_rain_bow));
|
||||
put(4, Integer.valueOf(R.id.id_palette_glow_bow));
|
||||
put(5, Integer.valueOf(R.id.id_palette_autumn));
|
||||
put(6, Integer.valueOf(R.id.id_palette_winter));
|
||||
put(7, Integer.valueOf(R.id.id_palette_hot_metal));
|
||||
put(8, Integer.valueOf(R.id.id_palette_jet));
|
||||
put(9, Integer.valueOf(R.id.id_palette_red_saturation));
|
||||
put(10, Integer.valueOf(R.id.id_palette_high_contrast));
|
||||
put(11, Integer.valueOf(R.id.id_palette_ret_hot));
|
||||
}
|
||||
};
|
||||
private HashMap<Object, Object> mapId2Index_ = new HashMap<Object, Object>() { // from class: cn.com.magnity.magnitycx.DialogFragmentPalette.2
|
||||
{
|
||||
put(Integer.valueOf(R.id.id_palette_white_hot), 0);
|
||||
put(Integer.valueOf(R.id.id_palette_black_hot), 1);
|
||||
put(Integer.valueOf(R.id.id_palette_iron_bow), 2);
|
||||
put(Integer.valueOf(R.id.id_palette_rain_bow), 3);
|
||||
put(Integer.valueOf(R.id.id_palette_glow_bow), 4);
|
||||
put(Integer.valueOf(R.id.id_palette_autumn), 5);
|
||||
put(Integer.valueOf(R.id.id_palette_winter), 6);
|
||||
put(Integer.valueOf(R.id.id_palette_hot_metal), 7);
|
||||
put(Integer.valueOf(R.id.id_palette_jet), 8);
|
||||
put(Integer.valueOf(R.id.id_palette_red_saturation), 9);
|
||||
put(Integer.valueOf(R.id.id_palette_high_contrast), 10);
|
||||
put(Integer.valueOf(R.id.id_palette_ret_hot), 11);
|
||||
}
|
||||
};
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
this.rootView_ = inflater.inflate(R.layout.dialog_fragment_palette, container);
|
||||
initPalette(this.rootView_);
|
||||
getDialog().requestWindowFeature(1);
|
||||
getDialog().setCanceledOnTouchOutside(true);
|
||||
getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.liveBackground)));
|
||||
return this.rootView_;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.dimAmount = 0.0f;
|
||||
windowParams.alpha = 0.7f;
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
private void initPalette(View rootView) {
|
||||
fillPalette(rootView, R.id.id_palette_white_hot, R.mipmap.palette_white_hot, R.string.paletteWhiteHot);
|
||||
fillPalette(rootView, R.id.id_palette_black_hot, R.mipmap.palette_black_hot, R.string.paletteBlackHot);
|
||||
fillPalette(rootView, R.id.id_palette_iron_bow, R.mipmap.palette_iron_bow, R.string.paletteIronBow);
|
||||
fillPalette(rootView, R.id.id_palette_rain_bow, R.mipmap.palette_rain_bow, R.string.paletteRainBow);
|
||||
fillPalette(rootView, R.id.id_palette_glow_bow, R.mipmap.palette_glow_bow, R.string.paletteGlowBow);
|
||||
fillPalette(rootView, R.id.id_palette_autumn, R.mipmap.palette_autumn, R.string.paletteAutumn);
|
||||
fillPalette(rootView, R.id.id_palette_winter, R.mipmap.palette_winter, R.string.paletteWinter);
|
||||
fillPalette(rootView, R.id.id_palette_hot_metal, R.mipmap.palette_hot_metal, R.string.paletteHotMetal);
|
||||
fillPalette(rootView, R.id.id_palette_jet, R.mipmap.palette_jet, R.string.paletteJet);
|
||||
fillPalette(rootView, R.id.id_palette_red_saturation, R.mipmap.palette_red_saturation, R.string.paletteRedSaturation);
|
||||
fillPalette(rootView, R.id.id_palette_high_contrast, R.mipmap.palette_high_contrast, R.string.paletteHighContrast);
|
||||
fillPalette(rootView, R.id.id_palette_ret_hot, R.mipmap.palette_red_hot, R.string.paletteRedhot);
|
||||
updateSelectionUi(0, SharedPreferencesManager.getInt("paletteIndex", 2));
|
||||
}
|
||||
|
||||
private void fillPalette(View rootView, int viewId, int imgId, int tvId) {
|
||||
View v = rootView.findViewById(viewId);
|
||||
v.setBackgroundColor(0);
|
||||
ImageButton viewer = (ImageButton) v.findViewById(R.id.id_palette_image);
|
||||
viewer.setImageResource(imgId);
|
||||
viewer.setOnClickListener(this);
|
||||
TextView tv = (TextView) v.findViewById(R.id.id_palette_label);
|
||||
tv.setText(tvId);
|
||||
}
|
||||
|
||||
void updateSelectionUi(int formerSelected, int currentSelected) {
|
||||
View v = this.rootView_.findViewById(((Integer) this.mapIndex2Id_.get(Integer.valueOf(formerSelected))).intValue());
|
||||
v.setBackgroundColor(0);
|
||||
View v2 = this.rootView_.findViewById(((Integer) this.mapIndex2Id_.get(Integer.valueOf(currentSelected))).intValue());
|
||||
v2.setBackgroundColor(1073741823);
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
ViewGroup parent;
|
||||
if (v.getId() == R.id.id_palette_image && (parent = (ViewGroup) v.getParent().getParent()) != null) {
|
||||
int index = ((Integer) this.mapId2Index_.get(Integer.valueOf(parent.getId()))).intValue();
|
||||
updateSelectionUi(SharedPreferencesManager.getInt("paletteIndex", 2), index);
|
||||
DeviceController.Lock();
|
||||
DeviceController.setColorPalette(index);
|
||||
DeviceController.Unlock();
|
||||
SharedPreferencesManager.putIntWithCommit("paletteIndex", index);
|
||||
}
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageButton;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DialogFragmentSetting extends DialogFragment {
|
||||
private ImageButton btnGoBack_;
|
||||
private ImageButton btnSettingInText_;
|
||||
private SettingClickListener settingClickListener_;
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setStyle(0, android.R.style.Theme.Black.NoTitleBar.Fullscreen);
|
||||
this.settingClickListener_ = new SettingClickListener();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.dialog_fragment_setting, container);
|
||||
this.btnGoBack_ = (ImageButton) rootView.findViewById(R.id.id_goback);
|
||||
this.btnSettingInText_ = (ImageButton) rootView.findViewById(R.id.id_setting_in_text);
|
||||
this.btnGoBack_.setOnClickListener(this.settingClickListener_);
|
||||
this.btnSettingInText_.setOnClickListener(this.settingClickListener_);
|
||||
setDialogProperty();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
void setDialogProperty() {
|
||||
getDialog().requestWindowFeature(1);
|
||||
getDialog().setCanceledOnTouchOutside(true);
|
||||
Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.width = -1;
|
||||
windowParams.height = -2;
|
||||
window.setAttributes(windowParams);
|
||||
window.setGravity(48);
|
||||
window.setWindowAnimations(R.style.ThemeDialog);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
WindowManager.LayoutParams windowParams = window.getAttributes();
|
||||
windowParams.dimAmount = 0.4f;
|
||||
windowParams.alpha = 1.0f;
|
||||
window.setAttributes(windowParams);
|
||||
}
|
||||
|
||||
private class SettingClickListener implements View.OnClickListener {
|
||||
private SettingClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_goback /* 2131624058 */:
|
||||
DialogFragmentSetting.this.dismiss();
|
||||
break;
|
||||
case R.id.id_setting_in_text /* 2131624119 */:
|
||||
Intent intent = new Intent(DialogFragmentSetting.this.getActivity(), (Class<?>) SupportActivity.class);
|
||||
DialogFragmentSetting.this.startActivity(intent);
|
||||
DialogFragmentSetting.this.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateOptionSelected;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DialogOption extends DialogFragment {
|
||||
private static final String ARGUMENT_LIST = "ARGUMENT_LIST";
|
||||
private static final int[] LIST_ITEMS = {R.id.id_option_sel1, R.id.id_option_sel2, R.id.id_option_sel3, R.id.id_option_sel4, R.id.id_option_sel5};
|
||||
private int initSel_;
|
||||
private DelegateOptionSelected intf_;
|
||||
private int itemId_;
|
||||
private int[] listNames_;
|
||||
private int tipId_;
|
||||
private int titleId_;
|
||||
|
||||
public static DialogOption newInstance(int titleId, int itemId, int[] listNames, int initSel, DelegateOptionSelected intf, int tipId) {
|
||||
Bundle bundle = new Bundle();
|
||||
ArrayList bundlelist = new ArrayList();
|
||||
bundlelist.add(Integer.valueOf(titleId));
|
||||
bundlelist.add(Integer.valueOf(itemId));
|
||||
bundlelist.add(listNames);
|
||||
bundlelist.add(Integer.valueOf(initSel));
|
||||
bundlelist.add(intf);
|
||||
bundlelist.add(Integer.valueOf(tipId));
|
||||
bundle.putParcelableArrayList(ARGUMENT_LIST, bundlelist);
|
||||
DialogOption dlg = new DialogOption();
|
||||
dlg.setArguments(bundle);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
ArrayList list = bundle.getParcelableArrayList(ARGUMENT_LIST);
|
||||
int i = 0 + 1;
|
||||
this.titleId_ = ((Integer) list.get(0)).intValue();
|
||||
int i2 = i + 1;
|
||||
this.itemId_ = ((Integer) list.get(i)).intValue();
|
||||
int i3 = i2 + 1;
|
||||
this.listNames_ = (int[]) list.get(i2);
|
||||
int i4 = i3 + 1;
|
||||
this.initSel_ = ((Integer) list.get(i3)).intValue();
|
||||
int i5 = i4 + 1;
|
||||
this.intf_ = (DelegateOptionSelected) list.get(i4);
|
||||
int i6 = i5 + 1;
|
||||
this.tipId_ = ((Integer) list.get(i5)).intValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
getDialog().requestWindowFeature(1);
|
||||
getDialog().setCanceledOnTouchOutside(true);
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View rootView = inflater.inflate(R.layout.dialog_fragment_option, (ViewGroup) null);
|
||||
MagClickListner magClickListner = new MagClickListner();
|
||||
int i = 0;
|
||||
View v = rootView.findViewById(R.id.id_option_title);
|
||||
((TextView) v).setText(this.titleId_);
|
||||
for (int id : this.listNames_) {
|
||||
View v2 = setText_(rootView, LIST_ITEMS[i], id, this.initSel_ == i);
|
||||
v2.setOnClickListener(magClickListner);
|
||||
i++;
|
||||
}
|
||||
for (int j = i; j < LIST_ITEMS.length; j++) {
|
||||
View v3 = rootView.findViewById(LIST_ITEMS[j]);
|
||||
v3.setVisibility(8);
|
||||
}
|
||||
if (this.tipId_ != 0) {
|
||||
View v4 = rootView.findViewById(R.id.id_text);
|
||||
v4.setVisibility(0);
|
||||
((TextView) v4).setText(this.tipId_);
|
||||
}
|
||||
View v5 = rootView.findViewById(R.id.id_btn_cancel);
|
||||
v5.setOnClickListener(magClickListner);
|
||||
builder.setView(rootView);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private View setText_(View rootView, int itemId, int stringId, boolean isSelected) {
|
||||
View item = rootView.findViewById(itemId);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text);
|
||||
txtView.setText(stringId);
|
||||
ImageView imgView = (ImageView) item.findViewById(R.id.id_setting_icon);
|
||||
if (isSelected) {
|
||||
imgView.setImageResource(R.mipmap.item_selected);
|
||||
} else {
|
||||
imgView.setImageResource(R.mipmap.item_unselected);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
private class MagClickListner implements View.OnClickListener {
|
||||
private MagClickListner() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
int id = v.getId();
|
||||
switch (id) {
|
||||
case R.id.id_option_sel1 /* 2131624100 */:
|
||||
DialogOption.this.intf_.onOptionSelected(DialogOption.this.itemId_, 0);
|
||||
DialogOption.this.dismiss();
|
||||
break;
|
||||
case R.id.id_option_sel2 /* 2131624101 */:
|
||||
DialogOption.this.intf_.onOptionSelected(DialogOption.this.itemId_, 1);
|
||||
DialogOption.this.dismiss();
|
||||
break;
|
||||
case R.id.id_option_sel3 /* 2131624102 */:
|
||||
DialogOption.this.intf_.onOptionSelected(DialogOption.this.itemId_, 2);
|
||||
DialogOption.this.dismiss();
|
||||
break;
|
||||
case R.id.id_option_sel4 /* 2131624103 */:
|
||||
DialogOption.this.intf_.onOptionSelected(DialogOption.this.itemId_, 3);
|
||||
DialogOption.this.dismiss();
|
||||
break;
|
||||
case R.id.id_option_sel5 /* 2131624104 */:
|
||||
DialogOption.this.intf_.onOptionSelected(DialogOption.this.itemId_, 4);
|
||||
DialogOption.this.dismiss();
|
||||
break;
|
||||
case R.id.id_btn_cancel /* 2131624106 */:
|
||||
DialogOption.this.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+409
@@ -0,0 +1,409 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import cn.com.magnity.magnitycx.FragmentMainCenter;
|
||||
import cn.com.magnity.magnitycx.MainActivity;
|
||||
import cn.com.magnity.magnitycx.sdk.BitmapUtilities;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import cn.com.magnity.magnitycx.sdk.TimerHelper;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbCommunication;
|
||||
import com.baidu.mobstat.Config;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentMainBottom extends Fragment implements MainActivity.DelegateFling, DelegateDeviceConnected, FragmentMainCenter.DelegateCapture {
|
||||
static final int PHOTO_MARGIN_MARGIN = 0;
|
||||
private ImageButton btnCapture_;
|
||||
private ImageButton btnPalette_;
|
||||
private Handler handler_;
|
||||
private RelativeLayout layoutSelection_;
|
||||
private MagClickListener magClickListener_;
|
||||
private int modeSelection_;
|
||||
private int screenHeight_;
|
||||
private int screenWidth_;
|
||||
private TimerHelper timerHelper_;
|
||||
private TextView tvPhoto_;
|
||||
private TextView tvRecord_;
|
||||
private ImageButton viewBrowse_;
|
||||
private View viewRecordingPoint_;
|
||||
private ImageView viewSelectPointer_;
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_main_bottom, container, false);
|
||||
init(rootView);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onResume() {
|
||||
ArrayList<String> fileNames = new ArrayList<>();
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
GlobalFunc.updateFileList(fileNames);
|
||||
if (fileNames.size() == 0) {
|
||||
this.viewBrowse_.setScaleType(ImageView.ScaleType.CENTER);
|
||||
this.viewBrowse_.setImageResource(R.mipmap.empty_photo);
|
||||
} else {
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + fileNames.get(0);
|
||||
int w = getResources().getDimensionPixelSize(R.dimen.mainBottomButtonSize);
|
||||
BitmapUtilities.getBitmapThumbnail(pathName, w, w);
|
||||
this.viewBrowse_.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
this.viewBrowse_.setImageBitmap(BitmapUtilities.getBitmapThumbnail(pathName, getResources().getDimensionPixelSize(R.dimen.mainBottomButtonSize), getResources().getDimensionPixelSize(R.dimen.mainBottomButtonSize)));
|
||||
}
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onStop() {
|
||||
if (DeviceController.isRecording()) {
|
||||
this.btnCapture_.performClick();
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
private void init(View v) {
|
||||
this.magClickListener_ = new MagClickListener();
|
||||
this.tvPhoto_ = (TextView) v.findViewById(R.id.id_photo);
|
||||
this.tvRecord_ = (TextView) v.findViewById(R.id.id_record);
|
||||
this.btnCapture_ = (ImageButton) v.findViewById(R.id.id_capture);
|
||||
this.btnPalette_ = (ImageButton) v.findViewById(R.id.id_palette);
|
||||
this.viewBrowse_ = (ImageButton) v.findViewById(R.id.id_browse);
|
||||
this.viewSelectPointer_ = (ImageView) v.findViewById(R.id.id_selector_point);
|
||||
this.layoutSelection_ = (RelativeLayout) v.findViewById(R.id.id_selection);
|
||||
this.viewRecordingPoint_ = v.findViewById(R.id.id_recording_point);
|
||||
this.tvPhoto_.setOnClickListener(this.magClickListener_);
|
||||
this.tvRecord_.setOnClickListener(this.magClickListener_);
|
||||
this.btnCapture_.setOnClickListener(this.magClickListener_);
|
||||
this.btnPalette_.setOnClickListener(this.magClickListener_);
|
||||
this.viewBrowse_.setOnClickListener(this.magClickListener_);
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
getActivity().getWindow().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
this.screenWidth_ = outMetrics.widthPixels;
|
||||
this.screenHeight_ = outMetrics.heightPixels;
|
||||
initModeSelection();
|
||||
onDeviceDisconnected();
|
||||
}
|
||||
|
||||
public void initModeSelection() {
|
||||
this.modeSelection_ = SharedPreferencesManager.getInt("modeSelection", 0);
|
||||
int orientation = getActivity().getResources().getConfiguration().orientation;
|
||||
RelativeLayout.LayoutParams layoutPhoto = (RelativeLayout.LayoutParams) this.tvPhoto_.getLayoutParams();
|
||||
RelativeLayout.LayoutParams layoutRecord = (RelativeLayout.LayoutParams) this.tvRecord_.getLayoutParams();
|
||||
if (layoutPhoto.getRules()[13] != 0) {
|
||||
layoutPhoto.addRule(13, 0);
|
||||
}
|
||||
if (layoutPhoto.getRules()[0] != 0) {
|
||||
layoutPhoto.addRule(0, 0);
|
||||
}
|
||||
if (layoutPhoto.getRules()[3] != 0) {
|
||||
layoutPhoto.addRule(3, 0);
|
||||
}
|
||||
if (layoutRecord.getRules()[13] != 0) {
|
||||
layoutRecord.addRule(13, 0);
|
||||
}
|
||||
if (layoutRecord.getRules()[1] != 0) {
|
||||
layoutRecord.addRule(1, 0);
|
||||
}
|
||||
if (layoutRecord.getRules()[2] != 0) {
|
||||
layoutRecord.addRule(2, 0);
|
||||
}
|
||||
if (this.modeSelection_ == 0) {
|
||||
this.btnCapture_.setImageResource(R.drawable.button_capture_photo_select);
|
||||
} else {
|
||||
this.btnCapture_.setImageResource(R.mipmap.recording_finished);
|
||||
}
|
||||
if (orientation == 1) {
|
||||
if (this.modeSelection_ == 0) {
|
||||
if (layoutPhoto.getRules()[13] == 0) {
|
||||
layoutPhoto.addRule(13);
|
||||
}
|
||||
if (layoutRecord.getRules()[1] == 0) {
|
||||
layoutRecord.addRule(1, R.id.id_photo);
|
||||
}
|
||||
this.tvPhoto_.setTextColor(getResources().getColor(R.color.selectedModeText));
|
||||
this.tvRecord_.setTextColor(getResources().getColor(R.color.textColor));
|
||||
return;
|
||||
}
|
||||
if (this.modeSelection_ == 1) {
|
||||
if (layoutRecord.getRules()[13] == 0) {
|
||||
layoutRecord.addRule(13);
|
||||
}
|
||||
if (layoutPhoto.getRules()[0] == 0) {
|
||||
layoutPhoto.addRule(0, R.id.id_record);
|
||||
}
|
||||
this.tvPhoto_.setTextColor(getResources().getColor(R.color.textColor));
|
||||
this.tvRecord_.setTextColor(getResources().getColor(R.color.selectedModeText));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.modeSelection_ == 0) {
|
||||
if (layoutPhoto.getRules()[13] == 0) {
|
||||
layoutPhoto.addRule(13);
|
||||
}
|
||||
if (layoutRecord.getRules()[2] == 0) {
|
||||
layoutRecord.addRule(2, R.id.id_photo);
|
||||
}
|
||||
this.tvPhoto_.setTextColor(getResources().getColor(R.color.selectedModeText));
|
||||
this.tvRecord_.setTextColor(getResources().getColor(R.color.textColor));
|
||||
return;
|
||||
}
|
||||
if (this.modeSelection_ == 1) {
|
||||
if (layoutRecord.getRules()[13] == 0) {
|
||||
layoutRecord.addRule(13);
|
||||
}
|
||||
if (layoutPhoto.getRules()[3] == 0) {
|
||||
layoutPhoto.addRule(3, R.id.id_record);
|
||||
}
|
||||
this.tvPhoto_.setTextColor(getResources().getColor(R.color.textColor));
|
||||
this.tvRecord_.setTextColor(getResources().getColor(R.color.selectedModeText));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected
|
||||
public void onDeviceConnected(UsbCommunication usbComm) {
|
||||
if (this.btnPalette_ != null) {
|
||||
this.btnPalette_.setVisibility(0);
|
||||
}
|
||||
if (this.btnCapture_ != null) {
|
||||
this.btnCapture_.setVisibility(0);
|
||||
}
|
||||
if (this.viewSelectPointer_ != null) {
|
||||
this.viewSelectPointer_.setVisibility(0);
|
||||
}
|
||||
if (this.layoutSelection_ != null) {
|
||||
this.layoutSelection_.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected
|
||||
public void onDeviceDisconnected() {
|
||||
if (DeviceController.isRecording()) {
|
||||
((MainActivity) getActivity()).getFragmentMainCenter().stopRecording();
|
||||
updateButtonsWhenRecordingStatusChanged(true);
|
||||
blinkWhenRecordingStatusChanged(false);
|
||||
getActivity().setRequestedOrientation(10);
|
||||
}
|
||||
if (this.btnPalette_ != null) {
|
||||
this.btnPalette_.setVisibility(4);
|
||||
}
|
||||
if (this.btnCapture_ != null) {
|
||||
if (this.modeSelection_ == 0) {
|
||||
this.btnCapture_.setImageResource(R.drawable.button_capture_photo_select);
|
||||
} else {
|
||||
this.btnCapture_.setImageResource(R.mipmap.recording_finished);
|
||||
}
|
||||
this.btnCapture_.setVisibility(4);
|
||||
}
|
||||
if (this.viewSelectPointer_ != null) {
|
||||
this.viewSelectPointer_.setVisibility(8);
|
||||
}
|
||||
if (this.layoutSelection_ != null) {
|
||||
this.layoutSelection_.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public Bitmap onCapture() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public void onCaptureFinished(String pathName) {
|
||||
this.viewBrowse_.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
this.viewBrowse_.setImageBitmap(BitmapUtilities.getBitmapThumbnail(pathName, getResources().getDimensionPixelSize(R.dimen.mainBottomButtonSize), getResources().getDimensionPixelSize(R.dimen.mainBottomButtonSize)));
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public boolean onStartRecording(String pathName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public void onStopRecording() {
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.MainActivity.DelegateFling
|
||||
public void afterFling(int index) {
|
||||
setNewSelection(index);
|
||||
}
|
||||
|
||||
void setNewSelection(int index) {
|
||||
String sProperty;
|
||||
if (this.modeSelection_ != index && !DeviceController.isRecording()) {
|
||||
float posPhoto = 0.0f;
|
||||
float posRecord = 0.0f;
|
||||
int orientation = getActivity().getResources().getConfiguration().orientation;
|
||||
if (orientation == 1) {
|
||||
sProperty = "x";
|
||||
if (index == 0) {
|
||||
posPhoto = (this.screenWidth_ - this.tvPhoto_.getWidth()) / 2;
|
||||
posRecord = posPhoto + 0.0f + this.tvPhoto_.getWidth();
|
||||
} else if (index == 1) {
|
||||
posRecord = (this.screenWidth_ - this.tvRecord_.getWidth()) / 2;
|
||||
posPhoto = (posRecord - 0.0f) - this.tvPhoto_.getWidth();
|
||||
}
|
||||
} else {
|
||||
sProperty = Config.EXCEPTION_TYPE;
|
||||
if (index == 0) {
|
||||
posPhoto = (this.screenHeight_ - this.tvPhoto_.getHeight()) / 2;
|
||||
posRecord = (posPhoto - 0.0f) - this.tvRecord_.getHeight();
|
||||
} else if (index == 1) {
|
||||
posRecord = (this.screenHeight_ - this.tvRecord_.getHeight()) / 2;
|
||||
posPhoto = posRecord + 0.0f + this.tvRecord_.getHeight();
|
||||
}
|
||||
}
|
||||
ObjectAnimator oaPhoto = ObjectAnimator.ofFloat(this.tvPhoto_, sProperty, posPhoto);
|
||||
oaPhoto.setDuration(300L);
|
||||
ObjectAnimator oaRecord = ObjectAnimator.ofFloat(this.tvRecord_, sProperty, posRecord);
|
||||
oaRecord.setDuration(300L);
|
||||
switch (index) {
|
||||
case 0:
|
||||
oaPhoto.setStartDelay(30L);
|
||||
this.tvPhoto_.setTextColor(getResources().getColor(R.color.selectedModeText));
|
||||
this.tvRecord_.setTextColor(getResources().getColor(R.color.textColor));
|
||||
this.btnCapture_.setImageResource(R.drawable.button_capture_photo_select);
|
||||
break;
|
||||
case 1:
|
||||
oaRecord.setStartDelay(30L);
|
||||
this.tvPhoto_.setTextColor(getResources().getColor(R.color.textColor));
|
||||
this.tvRecord_.setTextColor(getResources().getColor(R.color.selectedModeText));
|
||||
this.btnCapture_.setImageResource(R.mipmap.recording_finished);
|
||||
break;
|
||||
}
|
||||
oaPhoto.start();
|
||||
oaRecord.start();
|
||||
this.modeSelection_ = index;
|
||||
SharedPreferencesManager.putIntWithCommit("modeSelection", this.modeSelection_);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateButtonsWhenRecordingStatusChanged(boolean visible) {
|
||||
FragmentMainTop fragmentMainTop = ((MainActivity) getActivity()).getFragmentMainTop();
|
||||
if (visible) {
|
||||
this.viewSelectPointer_.setVisibility(0);
|
||||
this.viewBrowse_.setVisibility(0);
|
||||
this.layoutSelection_.setVisibility(0);
|
||||
fragmentMainTop.showButtonsWhenRecordingFinish();
|
||||
return;
|
||||
}
|
||||
this.viewSelectPointer_.setVisibility(8);
|
||||
this.viewBrowse_.setVisibility(4);
|
||||
this.layoutSelection_.setVisibility(8);
|
||||
fragmentMainTop.hideButtonsWhenRecordingStart();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void blinkWhenRecordingStatusChanged(boolean blink) {
|
||||
if (blink) {
|
||||
this.viewRecordingPoint_.setVisibility(0);
|
||||
this.handler_ = new Handler() { // from class: cn.com.magnity.magnitycx.FragmentMainBottom.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message msg) {
|
||||
if (DeviceController.isRecording()) {
|
||||
if (FragmentMainBottom.this.viewRecordingPoint_.getVisibility() == 0) {
|
||||
FragmentMainBottom.this.viewRecordingPoint_.setVisibility(4);
|
||||
} else {
|
||||
FragmentMainBottom.this.viewRecordingPoint_.setVisibility(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.timerHelper_ = new TimerHelper() { // from class: cn.com.magnity.magnitycx.FragmentMainBottom.2
|
||||
@Override // cn.com.magnity.magnitycx.sdk.TimerHelper
|
||||
public void run() {
|
||||
FragmentMainBottom.this.handler_.sendEmptyMessage(0);
|
||||
}
|
||||
};
|
||||
this.timerHelper_.start(0L, 500L);
|
||||
return;
|
||||
}
|
||||
this.timerHelper_.stop();
|
||||
this.viewRecordingPoint_.setVisibility(4);
|
||||
}
|
||||
|
||||
private class MagClickListener implements View.OnClickListener {
|
||||
private MagClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_photo /* 2131624122 */:
|
||||
FragmentMainBottom.this.setNewSelection(0);
|
||||
break;
|
||||
case R.id.id_record /* 2131624123 */:
|
||||
FragmentMainBottom.this.setNewSelection(1);
|
||||
break;
|
||||
case R.id.id_browse /* 2131624124 */:
|
||||
ArrayList<String> fileNames = new ArrayList<>();
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
GlobalFunc.updateFileList(fileNames);
|
||||
if (!fileNames.isEmpty()) {
|
||||
Intent intent = new Intent(FragmentMainBottom.this.getActivity(), (Class<?>) MediaSingleActivity.class);
|
||||
intent.putExtra(MediaSingleActivity.MEDIAWINDOWFLAG, 0);
|
||||
intent.putExtra(MediaSingleActivity.MEDIAINDEX, 0);
|
||||
intent.putStringArrayListExtra(MediaSingleActivity.MEDIANAMELIST, fileNames);
|
||||
FragmentMainBottom.this.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R.id.id_capture /* 2131624126 */:
|
||||
FragmentMainCenter fragmentMainCenter = ((MainActivity) FragmentMainBottom.this.getActivity()).getFragmentMainCenter();
|
||||
if (FragmentMainBottom.this.modeSelection_ == 0) {
|
||||
StatService.onEvent(FragmentMainBottom.this.getContext(), MagParameter.EVENT_PHOTO_ID, MagParameter.EVENT_PHOTO);
|
||||
fragmentMainCenter.capturePhoto();
|
||||
break;
|
||||
} else if (DeviceController.isRecording()) {
|
||||
fragmentMainCenter.stopRecording();
|
||||
FragmentMainBottom.this.updateButtonsWhenRecordingStatusChanged(true);
|
||||
FragmentMainBottom.this.blinkWhenRecordingStatusChanged(false);
|
||||
FragmentMainBottom.this.btnCapture_.setImageResource(R.mipmap.recording_finished);
|
||||
FragmentMainBottom.this.getActivity().setRequestedOrientation(10);
|
||||
break;
|
||||
} else if (fragmentMainCenter.startRecording()) {
|
||||
StatService.onEvent(FragmentMainBottom.this.getContext(), MagParameter.EVENT_VIDEO_ID, MagParameter.EVENT_VIDEO);
|
||||
FragmentMainBottom.this.updateButtonsWhenRecordingStatusChanged(false);
|
||||
FragmentMainBottom.this.blinkWhenRecordingStatusChanged(true);
|
||||
FragmentMainBottom.this.btnCapture_.setImageResource(R.mipmap.recording_normal);
|
||||
FragmentMainBottom.this.getActivity().setRequestedOrientation(14);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R.id.id_palette /* 2131624128 */:
|
||||
DialogFragmentPalette fragmentPalette = new DialogFragmentPalette();
|
||||
StatService.onEvent(FragmentMainBottom.this.getContext(), MagParameter.EVENT_COLOR_PALETTE_ID, MagParameter.EVENT_COLOR_PALETTE);
|
||||
fragmentPalette.show(FragmentMainBottom.this.getFragmentManager(), "FragmentPalette");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+345
@@ -0,0 +1,345 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.FragmentMainTop;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbCommunication;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbConnection;
|
||||
import cn.com.magnity.magnitycx.sdk.VisibleCamera;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import com.github.lzyzsd.circleprogress.DonutProgress;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentMainCenter extends Fragment implements DelegateDeviceConnected, FragmentMainTop.DelegateDisplayModeChanged, UsbCommunication.IProgressCallback {
|
||||
public static ImageViewerVisible imgViewerVisible_;
|
||||
private Bitmap bmpCaptured_;
|
||||
private ImageView imgViewAnim_;
|
||||
private ImageViewer imgViewer_;
|
||||
private LinearLayout layout_;
|
||||
private DonutProgress progBarLoading_;
|
||||
private String recordingFileName_ = "";
|
||||
private TextView tvTipInfo_;
|
||||
|
||||
public interface DelegateCapture {
|
||||
Bitmap onCapture();
|
||||
|
||||
void onCaptureFinished(String str);
|
||||
|
||||
boolean onStartRecording(String str);
|
||||
|
||||
void onStopRecording();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootViewer = inflater.inflate(R.layout.fragment_main_center, container, false);
|
||||
this.imgViewAnim_ = (ImageView) rootViewer.findViewById(R.id.id_imgViewAnim);
|
||||
this.imgViewer_ = (ImageViewer) rootViewer.findViewById(R.id.id_imgviewer);
|
||||
this.progBarLoading_ = (DonutProgress) rootViewer.findViewById(R.id.id_loading);
|
||||
this.tvTipInfo_ = (TextView) rootViewer.findViewById(R.id.id_text);
|
||||
imgViewerVisible_ = (ImageViewerVisible) rootViewer.findViewById(R.id.id_imgViewerVisible);
|
||||
this.layout_ = (LinearLayout) rootViewer.findViewById(R.id.id_layoutDevUnconn);
|
||||
onDeviceDisconnected();
|
||||
return rootViewer;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected
|
||||
public void onDeviceConnected(UsbCommunication comm) {
|
||||
if (this.imgViewer_ != null) {
|
||||
this.imgViewer_.setVisibility(0);
|
||||
}
|
||||
if (imgViewerVisible_ != null) {
|
||||
boolean hasPermission = VisibleCamera.isCameraPermission();
|
||||
if (MagApplication.magParameter.dispMode == 1) {
|
||||
imgViewerVisible_.setVisibility(4);
|
||||
} else if (hasPermission) {
|
||||
imgViewerVisible_.setVisibility(0);
|
||||
}
|
||||
}
|
||||
if (this.layout_ != null) {
|
||||
this.layout_.setVisibility(4);
|
||||
}
|
||||
if (comm != null && this.imgViewer_ != null) {
|
||||
this.imgViewer_.initData(MagApplication.magParameter.basePara1.fpaWidth, MagApplication.magParameter.basePara1.fpaHeight);
|
||||
comm.setImageViewer(this.imgViewer_);
|
||||
}
|
||||
}
|
||||
|
||||
public void startLoading() {
|
||||
this.layout_.setVisibility(4);
|
||||
this.progBarLoading_.setVisibility(0);
|
||||
this.progBarLoading_.setProgress(0.0f);
|
||||
this.tvTipInfo_.setVisibility(0);
|
||||
this.tvTipInfo_.setText("");
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
StatService.onPageStart(getActivity(), "主页面中");
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPageEnd(getActivity(), "主页面中");
|
||||
}
|
||||
|
||||
public void stopLoading(boolean succ) {
|
||||
this.progBarLoading_.setVisibility(8);
|
||||
this.tvTipInfo_.setVisibility(8);
|
||||
if (!succ) {
|
||||
this.layout_.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected
|
||||
public void onDeviceDisconnected() {
|
||||
getResources();
|
||||
if (this.layout_ != null) {
|
||||
this.layout_.setVisibility(0);
|
||||
}
|
||||
if (this.imgViewAnim_ != null) {
|
||||
this.imgViewAnim_.clearAnimation();
|
||||
this.imgViewAnim_.invalidate();
|
||||
this.imgViewAnim_.setVisibility(4);
|
||||
}
|
||||
if (this.imgViewer_ != null) {
|
||||
this.imgViewer_.setVisibility(4);
|
||||
}
|
||||
if (imgViewerVisible_ != null) {
|
||||
imgViewerVisible_.setVisibility(4);
|
||||
}
|
||||
if (this.progBarLoading_ != null) {
|
||||
this.progBarLoading_.setVisibility(8);
|
||||
}
|
||||
if (this.tvTipInfo_ != null) {
|
||||
this.tvTipInfo_.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.UsbCommunication.IProgressCallback
|
||||
public void progressCancel(int id) {
|
||||
getActivity().setRequestedOrientation(10);
|
||||
switch (id) {
|
||||
case 0:
|
||||
stopLoading(false);
|
||||
UsbConnection.getInstance().notifyObervers(0);
|
||||
break;
|
||||
}
|
||||
Toast.makeText(getContext(), R.string.tipForFail, 1).show();
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.UsbCommunication.IProgressCallback
|
||||
public void progressFinished(int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
stopLoading(true);
|
||||
UsbConnection.getInstance().notifyObervers(1);
|
||||
getActivity().setRequestedOrientation(10);
|
||||
break;
|
||||
case 1:
|
||||
stopLoading(true);
|
||||
getActivity().setRequestedOrientation(10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.UsbCommunication.IProgressCallback
|
||||
public void progressChanged(int id, int progress) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
case 1:
|
||||
this.progBarLoading_.setProgress(progress);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.UsbCommunication.IProgressCallback
|
||||
public void progressStart(int id) {
|
||||
getActivity().setRequestedOrientation(14);
|
||||
switch (id) {
|
||||
case 0:
|
||||
startLoading();
|
||||
this.tvTipInfo_.setText(R.string.tipForNewMobile);
|
||||
break;
|
||||
case 1:
|
||||
startLoading();
|
||||
this.tvTipInfo_.setText(R.string.tipForDeviceInit);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainTop.DelegateDisplayModeChanged
|
||||
public boolean onDisplayModeChanged(int oldMode, int newMode) {
|
||||
boolean hasPermission = VisibleCamera.isCameraPermission();
|
||||
if (newMode == 0 && hasPermission) {
|
||||
imgViewerVisible_.setVisibility(0);
|
||||
} else {
|
||||
imgViewerVisible_.setVisibility(8);
|
||||
if (!hasPermission) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ImageViewer getImageViewer() {
|
||||
return this.imgViewer_;
|
||||
}
|
||||
|
||||
public boolean startRecording() {
|
||||
this.imgViewAnim_.clearAnimation();
|
||||
this.imgViewAnim_.invalidate();
|
||||
this.imgViewAnim_.setVisibility(4);
|
||||
if (!(this.imgViewer_ instanceof DelegateCapture) || this.imgViewer_.getVisibility() != 0) {
|
||||
return false;
|
||||
}
|
||||
String type = "";
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
type = getResources().getString(R.string.c1);
|
||||
break;
|
||||
case 1:
|
||||
type = getResources().getString(R.string.c3);
|
||||
break;
|
||||
case 2:
|
||||
type = getResources().getString(R.string.c3p);
|
||||
break;
|
||||
case 3:
|
||||
type = getResources().getString(R.string.core160);
|
||||
break;
|
||||
case 5:
|
||||
type = getResources().getString(R.string.c1pro);
|
||||
break;
|
||||
case 6:
|
||||
type = getResources().getString(R.string.c1prolite);
|
||||
break;
|
||||
}
|
||||
this.recordingFileName_ = MagApplication.magParameter.mediaDir + File.separator + type + new SimpleDateFormat("yyyyMMddHHmmssSSS", Locale.US).format(new Date()) + ".mp4";
|
||||
if (!this.imgViewer_.onStartRecording(this.recordingFileName_)) {
|
||||
Logging.warn("Fail to start recording");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void stopRecording() {
|
||||
this.imgViewer_.onStopRecording();
|
||||
FragmentMainBottom fragmentMainBottom = ((MainActivity) getActivity()).getFragmentMainBottom();
|
||||
if (fragmentMainBottom instanceof DelegateCapture) {
|
||||
fragmentMainBottom.onCaptureFinished(this.recordingFileName_);
|
||||
GlobalFunc.notifyMediaSync(getContext(), new File(this.recordingFileName_));
|
||||
}
|
||||
this.recordingFileName_ = "";
|
||||
}
|
||||
|
||||
public boolean capturePhoto() {
|
||||
if (MagApplication.magParameter.mediaDir.isEmpty()) {
|
||||
Logging.error("Media not mounted");
|
||||
return false;
|
||||
}
|
||||
String type = "";
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
type = getResources().getString(R.string.c1);
|
||||
break;
|
||||
case 1:
|
||||
type = getResources().getString(R.string.c3);
|
||||
break;
|
||||
case 2:
|
||||
type = getResources().getString(R.string.c3p);
|
||||
break;
|
||||
case 3:
|
||||
type = getResources().getString(R.string.core160);
|
||||
break;
|
||||
case 5:
|
||||
type = getResources().getString(R.string.c1pro);
|
||||
break;
|
||||
case 6:
|
||||
type = getResources().getString(R.string.c1prolite);
|
||||
break;
|
||||
}
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + type + new SimpleDateFormat("yyyyMMddHHmmssSSS", Locale.US).format(new Date()) + ".jpg";
|
||||
if ((this.imgViewer_ instanceof DelegateCapture) && this.imgViewer_.getVisibility() == 0) {
|
||||
this.bmpCaptured_ = this.imgViewer_.onCapture();
|
||||
if (MagApplication.magParameter.basePara1.devType == 2) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.saveDDT(pathName.replace(".jpg", ".ddt"));
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
}
|
||||
if (this.bmpCaptured_ == null) {
|
||||
Logging.error("Capture photo fail because of ir bmp is null");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(pathName);
|
||||
this.bmpCaptured_.compress(Bitmap.CompressFormat.JPEG, 100, out);
|
||||
out.close();
|
||||
GlobalFunc.notifyMediaSync(getContext(), new File(pathName));
|
||||
FragmentMainBottom fragmentMainBottom = ((MainActivity) getActivity()).getFragmentMainBottom();
|
||||
if (fragmentMainBottom instanceof DelegateCapture) {
|
||||
fragmentMainBottom.onCaptureFinished(pathName);
|
||||
}
|
||||
Animation anim = AnimationUtils.loadAnimation(getActivity(), R.anim.photo_capture);
|
||||
anim.setFillAfter(true);
|
||||
anim.setAnimationListener(new Animation.AnimationListener() { // from class: cn.com.magnity.magnitycx.FragmentMainCenter.1
|
||||
@Override // android.view.animation.Animation.AnimationListener
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override // android.view.animation.Animation.AnimationListener
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
FragmentMainCenter.this.imgViewAnim_.clearAnimation();
|
||||
FragmentMainCenter.this.imgViewAnim_.invalidate();
|
||||
}
|
||||
|
||||
@Override // android.view.animation.Animation.AnimationListener
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
this.imgViewAnim_.startAnimation(anim);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
Logging.error("Capture photo fail (" + e.getMessage() + ")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbCommunication;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentMainTop extends Fragment implements DelegateDeviceConnected, PopupMenu.OnMenuItemClickListener, ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
private ImageButton btnCross_;
|
||||
private ImageButton btnLaserOn_;
|
||||
private ImageButton btnMode_;
|
||||
private ImageButton btnMore_;
|
||||
private ImageButton btnTraceMaxMin_;
|
||||
private ImageButton btnZoom_;
|
||||
private MainTopClickListener clickListener_;
|
||||
private PopupWindow popupWindowMore_;
|
||||
private UsbCommunication usbComm_;
|
||||
|
||||
public interface DelegateDisplayModeChanged {
|
||||
boolean onDisplayModeChanged(int i, int i2);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.clickListener_ = new MainTopClickListener();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_main_top, container, false);
|
||||
this.btnMode_ = (ImageButton) rootView.findViewById(R.id.id_mode);
|
||||
this.btnCross_ = (ImageButton) rootView.findViewById(R.id.id_cross);
|
||||
this.btnLaserOn_ = (ImageButton) rootView.findViewById(R.id.id_laser);
|
||||
this.btnMore_ = (ImageButton) rootView.findViewById(R.id.id_more);
|
||||
this.btnTraceMaxMin_ = (ImageButton) rootView.findViewById(R.id.id_trace_max_min);
|
||||
this.btnZoom_ = (ImageButton) rootView.findViewById(R.id.id_zoom);
|
||||
this.btnMode_.setOnClickListener(this.clickListener_);
|
||||
this.btnCross_.setOnClickListener(this.clickListener_);
|
||||
this.btnLaserOn_.setOnClickListener(this.clickListener_);
|
||||
this.btnMore_.setOnClickListener(this.clickListener_);
|
||||
this.btnTraceMaxMin_.setOnClickListener(this.clickListener_);
|
||||
this.btnZoom_.setOnClickListener(this.clickListener_);
|
||||
if (MagApplication.magParameter.dispMode == 1) {
|
||||
this.btnMode_.setImageResource(R.mipmap.disp_mode_ironly);
|
||||
} else {
|
||||
this.btnMode_.setImageResource(R.mipmap.disp_mode_pip);
|
||||
}
|
||||
if (MagApplication.magParameter.isShowCross) {
|
||||
this.btnCross_.setImageResource(R.mipmap.center_cross_on);
|
||||
} else {
|
||||
this.btnCross_.setImageResource(R.mipmap.center_cross_off);
|
||||
}
|
||||
if (MagApplication.magParameter.isTraceMaxMin) {
|
||||
this.btnTraceMaxMin_.setImageResource(R.mipmap.trace_max_min_on);
|
||||
} else {
|
||||
this.btnTraceMaxMin_.setImageResource(R.mipmap.trace_max_min_off);
|
||||
}
|
||||
int ratio = MagApplication.magParameter.imageEX;
|
||||
if (ratio == 0) {
|
||||
this.btnZoom_.setImageResource(R.mipmap.zoom_1x);
|
||||
} else if (ratio == 1) {
|
||||
this.btnZoom_.setImageResource(R.mipmap.zoom_2x);
|
||||
} else if (ratio == 2) {
|
||||
this.btnZoom_.setImageResource(R.mipmap.zoom_4x);
|
||||
}
|
||||
initPopupWindowMore();
|
||||
onDeviceDisconnected();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initPopupWindowMore() {
|
||||
View moreView = LayoutInflater.from(getActivity()).inflate(R.layout.popup_window_more, (ViewGroup) null);
|
||||
View viewItem = moreView.findViewById(R.id.id_menu_item_setting);
|
||||
viewItem.setOnClickListener(this.clickListener_);
|
||||
ImageView viewLogo = (ImageView) viewItem.findViewById(R.id.id_item_menu_logo);
|
||||
viewLogo.setImageResource(R.mipmap.settings);
|
||||
TextView txtView = (TextView) viewItem.findViewById(R.id.id_item_menu_text);
|
||||
txtView.setText(R.string.labelSetting);
|
||||
View viewItem2 = moreView.findViewById(R.id.id_menu_item_help);
|
||||
viewItem2.setOnClickListener(this.clickListener_);
|
||||
ImageView viewLogo2 = (ImageView) viewItem2.findViewById(R.id.id_item_menu_logo);
|
||||
viewLogo2.setImageResource(R.mipmap.help);
|
||||
TextView txtView2 = (TextView) viewItem2.findViewById(R.id.id_item_menu_text);
|
||||
txtView2.setText(R.string.labelHelp);
|
||||
this.popupWindowMore_ = new PopupWindow(moreView, -2, -2);
|
||||
this.popupWindowMore_.setOutsideTouchable(true);
|
||||
this.popupWindowMore_.setFocusable(true);
|
||||
this.popupWindowMore_.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.liveBackground)));
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected
|
||||
public void onDeviceConnected(UsbCommunication comm) {
|
||||
this.usbComm_ = comm;
|
||||
if (this.btnMode_ != null) {
|
||||
this.btnMode_.setVisibility(0);
|
||||
}
|
||||
if (this.btnZoom_ != null) {
|
||||
this.btnZoom_.setVisibility(0);
|
||||
}
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
case 3:
|
||||
case 5:
|
||||
case 6:
|
||||
if (this.btnCross_ != null) {
|
||||
this.btnCross_.setVisibility(0);
|
||||
}
|
||||
if (this.btnTraceMaxMin_ != null) {
|
||||
this.btnTraceMaxMin_.setVisibility(0);
|
||||
}
|
||||
if (this.btnZoom_ != null) {
|
||||
this.btnZoom_.setVisibility(8);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (this.btnCross_ != null) {
|
||||
this.btnCross_.setVisibility(8);
|
||||
}
|
||||
if (this.btnTraceMaxMin_ != null) {
|
||||
this.btnTraceMaxMin_.setVisibility(8);
|
||||
}
|
||||
if (this.btnLaserOn_ != null) {
|
||||
this.btnLaserOn_.setImageResource(R.mipmap.laser_off);
|
||||
this.btnLaserOn_.setVisibility(0);
|
||||
}
|
||||
if (this.btnZoom_ != null) {
|
||||
this.btnZoom_.setVisibility(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this.btnCross_ != null) {
|
||||
this.btnCross_.setVisibility(0);
|
||||
}
|
||||
if (this.btnTraceMaxMin_ != null) {
|
||||
this.btnTraceMaxMin_.setVisibility(8);
|
||||
}
|
||||
if (this.btnLaserOn_ != null) {
|
||||
this.btnLaserOn_.setVisibility(0);
|
||||
}
|
||||
if (this.btnZoom_ != null) {
|
||||
this.btnZoom_.setVisibility(0);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateDeviceConnected
|
||||
public void onDeviceDisconnected() {
|
||||
this.usbComm_ = null;
|
||||
if (this.btnMode_ != null) {
|
||||
this.btnMode_.setVisibility(4);
|
||||
}
|
||||
if (this.btnCross_ != null) {
|
||||
this.btnCross_.setVisibility(4);
|
||||
}
|
||||
if (this.btnTraceMaxMin_ != null) {
|
||||
this.btnTraceMaxMin_.setVisibility(8);
|
||||
}
|
||||
if (this.btnLaserOn_ != null) {
|
||||
this.btnLaserOn_.setVisibility(8);
|
||||
}
|
||||
if (this.btnZoom_ != null) {
|
||||
this.btnZoom_.setVisibility(8);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideButtonsWhenRecordingStart() {
|
||||
this.btnMode_.setVisibility(4);
|
||||
this.btnMore_.setVisibility(4);
|
||||
}
|
||||
|
||||
public void showButtonsWhenRecordingFinish() {
|
||||
this.btnMode_.setVisibility(0);
|
||||
this.btnMore_.setVisibility(0);
|
||||
}
|
||||
|
||||
@Override // android.widget.PopupMenu.OnMenuItemClickListener
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setIconsVisible(Menu menu, boolean flag) {
|
||||
if (menu != null) {
|
||||
try {
|
||||
Method method = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
|
||||
if (method != null) {
|
||||
method.setAccessible(true);
|
||||
method.invoke(menu, Boolean.valueOf(flag));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void exchangeLogo(final ImageButton btn, final int resIdOn, final int resIdOff, final boolean on) {
|
||||
Animation anim;
|
||||
if (getResources().getConfiguration().orientation == 2) {
|
||||
anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_right_out);
|
||||
} else {
|
||||
anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_bottom_out);
|
||||
}
|
||||
anim.setDuration(200L);
|
||||
anim.setAnimationListener(new Animation.AnimationListener() { // from class: cn.com.magnity.magnitycx.FragmentMainTop.1
|
||||
@Override // android.view.animation.Animation.AnimationListener
|
||||
public void onAnimationStart(Animation animation) {
|
||||
}
|
||||
|
||||
@Override // android.view.animation.Animation.AnimationListener
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
Animation anim2;
|
||||
if (on) {
|
||||
btn.setImageResource(resIdOn);
|
||||
} else {
|
||||
btn.setImageResource(resIdOff);
|
||||
}
|
||||
if (FragmentMainTop.this.getResources().getConfiguration().orientation == 2) {
|
||||
anim2 = AnimationUtils.loadAnimation(FragmentMainTop.this.getActivity(), R.anim.slide_left_in);
|
||||
} else {
|
||||
anim2 = AnimationUtils.loadAnimation(FragmentMainTop.this.getActivity(), R.anim.slide_top_in);
|
||||
}
|
||||
anim2.setDuration(200L);
|
||||
btn.startAnimation(anim2);
|
||||
}
|
||||
|
||||
@Override // android.view.animation.Animation.AnimationListener
|
||||
public void onAnimationRepeat(Animation animation) {
|
||||
}
|
||||
});
|
||||
btn.startAnimation(anim);
|
||||
}
|
||||
|
||||
public void openLaser() {
|
||||
if (!this.usbComm_.setLaserState(1)) {
|
||||
Logging.error("Fail to set laser off");
|
||||
} else {
|
||||
exchangeLogo(this.btnLaserOn_, R.mipmap.laser_on, R.mipmap.laser_off, true);
|
||||
MagApplication.magParameter.isLaserOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeLaser() {
|
||||
if (!this.usbComm_.setLaserState(0)) {
|
||||
Logging.error("Fail to set laser off");
|
||||
} else {
|
||||
exchangeLogo(this.btnLaserOn_, R.mipmap.laser_on, R.mipmap.laser_off, false);
|
||||
MagApplication.magParameter.isLaserOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
private class MainTopClickListener implements View.OnClickListener {
|
||||
private MainTopClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
int dispMode;
|
||||
switch (v.getId()) {
|
||||
case R.id.id_mode /* 2131624136 */:
|
||||
int dispMode2 = MagApplication.magParameter.dispMode;
|
||||
if (dispMode2 == 0) {
|
||||
dispMode = 1;
|
||||
StatService.onEvent(FragmentMainTop.this.getContext(), MagParameter.EVENT_DISABLE_VISWND_ID, MagParameter.EVENT_DISABLE_VISWND);
|
||||
} else {
|
||||
dispMode = 0;
|
||||
StatService.onEvent(FragmentMainTop.this.getContext(), MagParameter.EVENT_ENABLE_VISWND_ID, MagParameter.EVENT_ENABLE_VISWND);
|
||||
}
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnMode_, R.mipmap.disp_mode_pip, R.mipmap.disp_mode_ironly, dispMode == 0);
|
||||
FragmentMainCenter fragment = ((MainActivity) FragmentMainTop.this.getActivity()).getFragmentMainCenter();
|
||||
if (fragment instanceof DelegateDisplayModeChanged) {
|
||||
boolean ret = fragment.onDisplayModeChanged(0, dispMode);
|
||||
if (!ret) {
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnMode_, R.mipmap.disp_mode_pip, R.mipmap.disp_mode_ironly, dispMode != 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_DISPMODE, dispMode);
|
||||
MagApplication.magParameter.dispMode = dispMode;
|
||||
int num = MagApplication.magParameter.onceTipVisibleMove;
|
||||
if (dispMode == 0) {
|
||||
int num2 = num - 1;
|
||||
if (num != 0) {
|
||||
MagApplication.magParameter.onceTipVisibleMove = num2;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_ONCETIPVISIBLEMOVE, num2);
|
||||
Toast.makeText(FragmentMainTop.this.getContext(), R.string.onceTipVisibleMove, 1).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case R.id.id_cross /* 2131624137 */:
|
||||
MagApplication.magParameter.isShowCross = !MagApplication.magParameter.isShowCross;
|
||||
if (MagApplication.magParameter.isShowCross) {
|
||||
StatService.onEvent(FragmentMainTop.this.getContext(), MagParameter.EVENT_ENABLE_CENTER_TEMP_ID, MagParameter.EVENT_ENABLE_CENTER_TEMP);
|
||||
} else {
|
||||
StatService.onEvent(FragmentMainTop.this.getContext(), MagParameter.EVENT_DISABLE_CENTER_TEMP_ID, MagParameter.EVENT_DISABLE_CENTER_TEMP);
|
||||
}
|
||||
SharedPreferencesManager.putBooleanWithCommit(MagParameter.KEY_SHOWCROSS, MagApplication.magParameter.isShowCross);
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnCross_, R.mipmap.center_cross_on, R.mipmap.center_cross_off, MagApplication.magParameter.isShowCross);
|
||||
break;
|
||||
case R.id.id_zoom /* 2131624138 */:
|
||||
int ratio = MagApplication.magParameter.imageEX;
|
||||
if (ratio == 0) {
|
||||
MagApplication.magParameter.imageEX = 1;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EXMODE, MagApplication.magParameter.imageEX);
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnZoom_, R.mipmap.zoom_2x, R.mipmap.zoom_1x, true);
|
||||
} else if (ratio == 1) {
|
||||
MagApplication.magParameter.imageEX = 2;
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnZoom_, R.mipmap.zoom_4x, R.mipmap.zoom_2x, true);
|
||||
} else if (ratio == 2) {
|
||||
MagApplication.magParameter.imageEX = 0;
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnZoom_, R.mipmap.zoom_1x, R.mipmap.zoom_4x, true);
|
||||
}
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EXMODE, MagApplication.magParameter.imageEX);
|
||||
DeviceController.setEX(MagApplication.magParameter.imageEX, MagApplication.magParameter.basePara1.fpaWidth / 2, MagApplication.magParameter.basePara1.fpaHeight / 2);
|
||||
break;
|
||||
case R.id.id_trace_max_min /* 2131624139 */:
|
||||
MagApplication.magParameter.isTraceMaxMin = !MagApplication.magParameter.isTraceMaxMin;
|
||||
SharedPreferencesManager.putBooleanWithCommit(MagParameter.KEY_TRACEMAXMIN, MagApplication.magParameter.isTraceMaxMin);
|
||||
FragmentMainTop.this.exchangeLogo(FragmentMainTop.this.btnTraceMaxMin_, R.mipmap.trace_max_min_on, R.mipmap.trace_max_min_off, MagApplication.magParameter.isTraceMaxMin);
|
||||
if ((MagApplication.magParameter.basePara1.devType == 0 || MagApplication.magParameter.basePara1.devType == 5 || MagApplication.magParameter.basePara1.devType == 6 || MagApplication.magParameter.basePara1.devType == 3) && MagApplication.magParameter.maxMinTrace == -1 && MagApplication.magParameter.isTraceMaxMin) {
|
||||
MagApplication.magParameter.maxMinTrace = 0;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_MAXMINTRACE, MagApplication.magParameter.maxMinTrace);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R.id.id_laser /* 2131624140 */:
|
||||
if (MagApplication.magParameter.isLaserOn) {
|
||||
StatService.onEvent(FragmentMainTop.this.getContext(), MagParameter.EVENT_DISABLE_LASER_ID, MagParameter.EVENT_DISABLE_LASER);
|
||||
FragmentMainTop.this.closeLaser();
|
||||
break;
|
||||
} else {
|
||||
QueryDialogFragment dlgMediaDel = QueryDialogFragment.newInstance(R.layout.dialog_fragment_query_open_laser);
|
||||
StatService.onEvent(FragmentMainTop.this.getContext(), MagParameter.EVENT_ENABLE_LASER_ID, MagParameter.EVENT_ENABLE_LASER);
|
||||
dlgMediaDel.show(FragmentMainTop.this.getActivity().getSupportFragmentManager(), "openLaser");
|
||||
break;
|
||||
}
|
||||
case R.id.id_more /* 2131624141 */:
|
||||
Intent intent = new Intent(FragmentMainTop.this.getActivity(), (Class<?>) SettingActivity.class);
|
||||
FragmentMainTop.this.startActivity(intent);
|
||||
break;
|
||||
case R.id.id_menu_item_setting /* 2131624220 */:
|
||||
Intent intent2 = new Intent(FragmentMainTop.this.getActivity(), (Class<?>) SettingActivity.class);
|
||||
FragmentMainTop.this.startActivity(intent2);
|
||||
FragmentMainTop.this.popupWindowMore_.dismiss();
|
||||
break;
|
||||
case R.id.id_menu_item_help /* 2131624221 */:
|
||||
Intent intent3 = new Intent(FragmentMainTop.this.getActivity(), (Class<?>) SupportActivity.class);
|
||||
FragmentMainTop.this.startActivity(intent3);
|
||||
FragmentMainTop.this.popupWindowMore_.dismiss();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,411 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.MediaActivity;
|
||||
import cn.com.magnity.magnitycx.QueryDialogFragment;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateMediaStatusChanged;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentMedia extends Fragment implements MediaActivity.DelegateBackPressed, QueryDialogFragment.DelegateQueryResult, AbsListView.OnScrollListener {
|
||||
private static final int MODE_NORMAL = 0;
|
||||
private static final int MODE_SELECTION = 1;
|
||||
private Button btnDelete_;
|
||||
private Button btnSelectAll_;
|
||||
private Button btnSocialShare_;
|
||||
private ArrayList<String> fileNames_;
|
||||
private int firstVisiblePos_;
|
||||
private GridView gridView_;
|
||||
private int index_;
|
||||
private Map mapSelStatus_;
|
||||
private MediaGridViewAdapter mediaGridViewAdapter_;
|
||||
private MediaItemClickListener mediaItemClickListener_;
|
||||
private MediaItemLongClickListener mediaItemLongClickListener_;
|
||||
private MediaMenuClickListener mediaMenuClickListener_;
|
||||
private ViewGroup menu_;
|
||||
private int mode_ = 0;
|
||||
private int visibleItemCount_;
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
this.fileNames_ = new ArrayList<>();
|
||||
this.mediaMenuClickListener_ = new MediaMenuClickListener();
|
||||
this.mediaItemClickListener_ = new MediaItemClickListener();
|
||||
this.mediaItemLongClickListener_ = new MediaItemLongClickListener();
|
||||
this.mapSelStatus_ = new HashMap();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_media, (ViewGroup) null);
|
||||
initViews(rootView);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initViews(View rootView) {
|
||||
this.menu_ = (ViewGroup) rootView.findViewById(R.id.id_media_menu);
|
||||
if (this.mode_ == 0) {
|
||||
this.menu_.setVisibility(8);
|
||||
} else if (this.mode_ == 1) {
|
||||
this.menu_.setVisibility(0);
|
||||
}
|
||||
this.btnSocialShare_ = (Button) rootView.findViewById(R.id.id_btn_social_share);
|
||||
this.btnSocialShare_.setOnClickListener(this.mediaMenuClickListener_);
|
||||
this.btnDelete_ = (Button) rootView.findViewById(R.id.id_btn_delete);
|
||||
this.btnDelete_.setOnClickListener(this.mediaMenuClickListener_);
|
||||
this.btnSelectAll_ = (Button) rootView.findViewById(R.id.id_btn_select_all);
|
||||
this.btnSelectAll_.setOnClickListener(this.mediaMenuClickListener_);
|
||||
this.gridView_ = (GridView) rootView.findViewById(R.id.id_photowall);
|
||||
this.gridView_.setOnScrollListener(this);
|
||||
this.gridView_.setOnItemClickListener(this.mediaItemClickListener_);
|
||||
this.gridView_.setOnItemLongClickListener(this.mediaItemLongClickListener_);
|
||||
setAdapter();
|
||||
}
|
||||
|
||||
private void setAdapter() {
|
||||
updateFileList();
|
||||
this.mediaGridViewAdapter_ = new MediaGridViewAdapter(getActivity(), this.gridView_, this.fileNames_, this.mapSelStatus_);
|
||||
this.mediaGridViewAdapter_.setMode(this.mode_);
|
||||
this.gridView_.setAdapter((ListAdapter) this.mediaGridViewAdapter_);
|
||||
}
|
||||
|
||||
private void updateFileList() {
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
GlobalFunc.updateFileList(this.fileNames_);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateGridView() {
|
||||
this.mediaGridViewAdapter_.notifyDataSetChanged();
|
||||
this.gridView_.setSelection(this.index_);
|
||||
this.gridView_.invalidateViews();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateFileList();
|
||||
updateGridView();
|
||||
StatService.onPageStart(getActivity(), "媒体");
|
||||
if (this.mode_ == 0) {
|
||||
getActivity().setTitle(String.format(getResources().getString(R.string.mediaTitle), Integer.valueOf(this.fileNames_.size())));
|
||||
} else {
|
||||
getActivity().setTitle(String.format(getResources().getString(R.string.mediaSelectedNum), Integer.valueOf(getSelectedItemCount())));
|
||||
}
|
||||
int num = MagApplication.magParameter.onceTipMediaLongClick;
|
||||
int num2 = num - 1;
|
||||
if (num != 0) {
|
||||
MagApplication.magParameter.onceTipMediaLongClick = num2;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_ONCETIPMEDIALONGCLICK, num2);
|
||||
Toast.makeText(getContext(), R.string.onceTipMediaLongClick, 1).show();
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getSelectedItemCount() {
|
||||
int num = 0;
|
||||
for (Object value : this.mapSelStatus_.values()) {
|
||||
if (((Boolean) value).booleanValue()) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onPause() {
|
||||
this.index_ = this.gridView_.getFirstVisiblePosition();
|
||||
StatService.onPageEnd(getActivity(), "媒体");
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.mediaGridViewAdapter_.cancelAllTasks();
|
||||
}
|
||||
|
||||
@Override // android.widget.AbsListView.OnScrollListener
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
}
|
||||
|
||||
@Override // android.widget.AbsListView.OnScrollListener
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
this.firstVisiblePos_ = firstVisibleItem;
|
||||
this.visibleItemCount_ = visibleItemCount;
|
||||
if (this.visibleItemCount_ > 0) {
|
||||
this.mediaGridViewAdapter_.loadBitmap(this.firstVisiblePos_, this.visibleItemCount_);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.MediaActivity.DelegateBackPressed
|
||||
public boolean onActivityBackPressed() {
|
||||
if (this.mode_ == 0) {
|
||||
return true;
|
||||
}
|
||||
this.mode_ = 0;
|
||||
unselectAllFiles();
|
||||
this.mediaGridViewAdapter_.cancelAllTasks();
|
||||
this.menu_.setVisibility(8);
|
||||
if (!this.mapSelStatus_.isEmpty()) {
|
||||
this.mapSelStatus_.clear();
|
||||
}
|
||||
if (getActivity() instanceof DelegateMediaStatusChanged) {
|
||||
((DelegateMediaStatusChanged) getActivity()).onModeChanged(1, 0, this.fileNames_.size());
|
||||
}
|
||||
this.mediaGridViewAdapter_.setMode(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
getActivity().setTitle(Integer.toString(this.fileNames_.size()) + getResources().getString(R.string.mediaTitle));
|
||||
updateGridView();
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.QueryDialogFragment.DelegateQueryResult
|
||||
public void onQueryResult(int result) {
|
||||
if (result == 1) {
|
||||
deleteSelectedFiles();
|
||||
updateButtons();
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteSelectedFiles() {
|
||||
Iterator iter = this.mapSelStatus_.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) iter.next();
|
||||
boolean val = ((Boolean) entry.getValue()).booleanValue();
|
||||
if (val) {
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + ((String) entry.getKey());
|
||||
File file = new File(pathName);
|
||||
if (file != null && file.isFile()) {
|
||||
if (file.delete()) {
|
||||
iter.remove();
|
||||
}
|
||||
File file2 = new File(pathName.replace(".jpg", ".ddt"));
|
||||
if (file2 != null && file2.isFile()) {
|
||||
file2.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateFileList();
|
||||
updateGridView();
|
||||
if (this.fileNames_.isEmpty()) {
|
||||
onActivityBackPressed();
|
||||
} else if (getActivity() instanceof DelegateMediaStatusChanged) {
|
||||
((DelegateMediaStatusChanged) getActivity()).onSelChanged(0, this.fileNames_.size());
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void socialShare() {
|
||||
Intent intent;
|
||||
boolean hasVideo = false;
|
||||
ArrayList<Uri> lst = new ArrayList<>();
|
||||
for (Map.Entry entry : this.mapSelStatus_.entrySet()) {
|
||||
boolean val = ((Boolean) entry.getValue()).booleanValue();
|
||||
if (val) {
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + ((String) entry.getKey());
|
||||
File f = new File(pathName);
|
||||
if (f != null && f.isFile()) {
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
int type = GlobalFunc.guessMediaTypeBySuffix(pathName);
|
||||
if (type == 0) {
|
||||
lst.add(FileProvider.getUriForFile(getContext(), "cn.com.magnity.magnitycx.fileprovider", f));
|
||||
} else if (type == 1) {
|
||||
lst.add(FileProvider.getUriForFile(getContext(), "cn.com.magnity.magnitycx.fileprovider", f));
|
||||
hasVideo = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lst.size() > 1) {
|
||||
intent = new Intent("android.intent.action.SEND_MULTIPLE");
|
||||
intent.putParcelableArrayListExtra("android.intent.extra.STREAM", lst);
|
||||
} else if (lst.size() == 1) {
|
||||
intent = new Intent("android.intent.action.SEND");
|
||||
intent.putExtra("android.intent.extra.STREAM", lst.get(0));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
intent.setType(hasVideo ? "video/*" : "image/*");
|
||||
intent.addFlags(1);
|
||||
startActivity(Intent.createChooser(intent, getResources().getString(R.string.mediaSocialShare)));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void selectAllFiles() {
|
||||
Iterator<String> it = this.fileNames_.iterator();
|
||||
while (it.hasNext()) {
|
||||
String name = it.next();
|
||||
this.mapSelStatus_.put(name, true);
|
||||
}
|
||||
if (getActivity() instanceof DelegateMediaStatusChanged) {
|
||||
int num = this.fileNames_.size();
|
||||
((DelegateMediaStatusChanged) getActivity()).onSelChanged(num, num);
|
||||
}
|
||||
updateGridView();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void unselectAllFiles() {
|
||||
Iterator<String> it = this.fileNames_.iterator();
|
||||
while (it.hasNext()) {
|
||||
String name = it.next();
|
||||
this.mapSelStatus_.put(name, false);
|
||||
}
|
||||
if (getActivity() instanceof DelegateMediaStatusChanged) {
|
||||
((DelegateMediaStatusChanged) getActivity()).onSelChanged(0, this.fileNames_.size());
|
||||
}
|
||||
updateGridView();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean isAllItemSelected() {
|
||||
return this.fileNames_.size() == this.mapSelStatus_.size() && !this.mapSelStatus_.containsValue(false);
|
||||
}
|
||||
|
||||
private boolean isNoItemSelected() {
|
||||
return !this.mapSelStatus_.containsValue(true);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateButtons() {
|
||||
if (isNoItemSelected()) {
|
||||
this.btnSocialShare_.setEnabled(false);
|
||||
this.btnDelete_.setEnabled(false);
|
||||
this.btnSelectAll_.setText(R.string.mediaSelectAll);
|
||||
Drawable drawable = getResources().getDrawable(R.drawable.button_unselect_all_select);
|
||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
|
||||
this.btnSelectAll_.setCompoundDrawables(null, drawable, null, null);
|
||||
return;
|
||||
}
|
||||
this.btnSocialShare_.setEnabled(true);
|
||||
this.btnDelete_.setEnabled(true);
|
||||
if (isAllItemSelected()) {
|
||||
this.btnSelectAll_.setText(R.string.mediaUnselectAll);
|
||||
Drawable drawable2 = getResources().getDrawable(R.drawable.button_select_all_select);
|
||||
drawable2.setBounds(0, 0, drawable2.getMinimumWidth(), drawable2.getMinimumHeight());
|
||||
this.btnSelectAll_.setCompoundDrawables(null, drawable2, null, null);
|
||||
return;
|
||||
}
|
||||
this.btnSelectAll_.setText(R.string.mediaSelectAll);
|
||||
Drawable drawable3 = getResources().getDrawable(R.drawable.button_unselect_all_select);
|
||||
drawable3.setBounds(0, 0, drawable3.getMinimumWidth(), drawable3.getMinimumHeight());
|
||||
this.btnSelectAll_.setCompoundDrawables(null, drawable3, null, null);
|
||||
}
|
||||
|
||||
private class MediaMenuClickListener implements View.OnClickListener {
|
||||
private MediaMenuClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_btn_social_share /* 2131624072 */:
|
||||
FragmentMedia.this.socialShare();
|
||||
break;
|
||||
case R.id.id_btn_delete /* 2131624143 */:
|
||||
QueryDialogFragment dlg = QueryDialogFragment.newInstance(R.layout.dialog_fragment_query_delete_media);
|
||||
if (dlg != null) {
|
||||
dlg.show(FragmentMedia.this.getActivity().getSupportFragmentManager(), "deleteMedia");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case R.id.id_btn_select_all /* 2131624144 */:
|
||||
if (FragmentMedia.this.isAllItemSelected()) {
|
||||
FragmentMedia.this.unselectAllFiles();
|
||||
} else {
|
||||
FragmentMedia.this.selectAllFiles();
|
||||
}
|
||||
FragmentMedia.this.updateButtons();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MediaItemClickListener implements AdapterView.OnItemClickListener {
|
||||
private MediaItemClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (FragmentMedia.this.mode_ != 0) {
|
||||
String name = (String) FragmentMedia.this.fileNames_.get(position);
|
||||
ImageView v = (ImageView) view.findViewById(R.id.id_photo_selected);
|
||||
ImageView vimg = (ImageView) view.findViewById(R.id.id_wallphoto);
|
||||
Object val = FragmentMedia.this.mapSelStatus_.get(name);
|
||||
if (val == null || !((Boolean) val).booleanValue()) {
|
||||
v.setImageResource(R.mipmap.media_selected);
|
||||
vimg.setAlpha(0.6f);
|
||||
FragmentMedia.this.mapSelStatus_.put(name, true);
|
||||
} else {
|
||||
v.setImageResource(R.mipmap.media_unselected);
|
||||
vimg.setAlpha(1.0f);
|
||||
FragmentMedia.this.mapSelStatus_.put(name, false);
|
||||
}
|
||||
if (FragmentMedia.this.getActivity() instanceof DelegateMediaStatusChanged) {
|
||||
((DelegateMediaStatusChanged) FragmentMedia.this.getActivity()).onSelChanged(FragmentMedia.this.getSelectedItemCount(), FragmentMedia.this.fileNames_.size());
|
||||
}
|
||||
FragmentMedia.this.updateButtons();
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(FragmentMedia.this.getActivity(), (Class<?>) MediaSingleActivity.class);
|
||||
intent.putExtra(MediaSingleActivity.MEDIAWINDOWFLAG, 1);
|
||||
intent.putExtra(MediaSingleActivity.MEDIAINDEX, position);
|
||||
intent.putStringArrayListExtra(MediaSingleActivity.MEDIANAMELIST, FragmentMedia.this.fileNames_);
|
||||
FragmentMedia.this.startActivityForResult(intent, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private class MediaItemLongClickListener implements AdapterView.OnItemLongClickListener {
|
||||
private MediaItemLongClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.widget.AdapterView.OnItemLongClickListener
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (FragmentMedia.this.mode_ != 1) {
|
||||
String name = (String) FragmentMedia.this.fileNames_.get(position);
|
||||
FragmentMedia.this.mapSelStatus_.put(name, true);
|
||||
FragmentMedia.this.updateButtons();
|
||||
FragmentMedia.this.menu_.setVisibility(0);
|
||||
FragmentMedia.this.mode_ = 1;
|
||||
if (FragmentMedia.this.getActivity() instanceof DelegateMediaStatusChanged) {
|
||||
((DelegateMediaStatusChanged) FragmentMedia.this.getActivity()).onModeChanged(0, 1, FragmentMedia.this.fileNames_.size());
|
||||
}
|
||||
FragmentMedia.this.mediaGridViewAdapter_.setMode(1);
|
||||
FragmentMedia.this.updateGridView();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,559 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateOptionSelected;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.ExtPara;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.MsgBus;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbCommunication;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbConnection;
|
||||
import com.baidu.mobstat.StatService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentSetting extends Fragment implements DelegateOptionSelected {
|
||||
private View rootView_;
|
||||
private SettingClickListner settingClickListner_;
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.settingClickListner_ = new SettingClickListner();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
this.rootView_ = inflater.inflate(R.layout.fragment_setting, (ViewGroup) null);
|
||||
initUi(this.rootView_);
|
||||
return this.rootView_;
|
||||
}
|
||||
|
||||
/* JADX WARN: Can't fix incorrect switch cases order, some code will duplicate */
|
||||
private void initUi(View rootView) {
|
||||
int id;
|
||||
int id2;
|
||||
int id3;
|
||||
int id4;
|
||||
int id5;
|
||||
int devType = MagApplication.magParameter.basePara1.devType;
|
||||
setText1_(rootView, R.id.id_setting_subheader_visible, R.string.settingsVisible);
|
||||
switch (MagApplication.magParameter.visWndSize) {
|
||||
case 0:
|
||||
id = R.string.settingsVisibleSizeSmall;
|
||||
break;
|
||||
case 1:
|
||||
id = R.string.settingsVisibleSizeMedium;
|
||||
break;
|
||||
case 2:
|
||||
id = R.string.settingsVisibleSizeLarge;
|
||||
break;
|
||||
default:
|
||||
id = R.string.settingsVisibleSizeSmall;
|
||||
break;
|
||||
}
|
||||
setTextIcon(rootView, R.id.id_setting_item_visiblesize, R.string.settingsVisibleSize, id, R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
setText1_(rootView, R.id.id_setting_subheader_maxmintrace, R.string.settingsTempTrace);
|
||||
switch (MagApplication.magParameter.maxMinTrace) {
|
||||
case -1:
|
||||
id2 = R.string.settingsNoneTrace;
|
||||
break;
|
||||
case 0:
|
||||
id2 = R.string.settingsMaxTrace;
|
||||
break;
|
||||
case 1:
|
||||
id2 = R.string.settingsMinTrace;
|
||||
break;
|
||||
case 2:
|
||||
id2 = R.string.settingsMaxMinTrace;
|
||||
break;
|
||||
default:
|
||||
id2 = R.string.settingsMaxTrace;
|
||||
break;
|
||||
}
|
||||
setTextIcon(rootView, R.id.id_setting_item_maxmintrace, R.string.settingsTraceTarget, id2, R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
if (UsbConnection.getInstance().isConnected()) {
|
||||
switch (devType) {
|
||||
case 0:
|
||||
case 5:
|
||||
case 6:
|
||||
StatService.onEvent(getContext(), MagParameter.EVENT_C1_ID, MagParameter.EVENT_C1);
|
||||
rootView.findViewById(R.id.trace_divider3).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider4).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_roitrace).setVisibility(8);
|
||||
break;
|
||||
case 1:
|
||||
StatService.onEvent(getContext(), MagParameter.EVENT_C3_ID, MagParameter.EVENT_C3);
|
||||
rootView.findViewById(R.id.trace_divider1).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider2).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider3).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider4).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_subheader_maxmintrace).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_maxmintrace).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_roitrace).setVisibility(8);
|
||||
break;
|
||||
case 2:
|
||||
StatService.onEvent(getContext(), MagParameter.EVENT_C3_ID, MagParameter.EVENT_C3);
|
||||
setTextIcon(rootView, R.id.id_setting_item_roitrace, R.string.settingsTraceROI, "", MagApplication.magParameter.isTraceRoi ? R.mipmap.media_selected : R.mipmap.media_unselected).setOnClickListener(this.settingClickListner_);
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
default:
|
||||
rootView.findViewById(R.id.trace_divider3).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider4).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_roitrace).setVisibility(8);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
rootView.findViewById(R.id.trace_divider1).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider2).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider3).setVisibility(8);
|
||||
rootView.findViewById(R.id.trace_divider4).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_subheader_maxmintrace).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_maxmintrace).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_roitrace).setVisibility(8);
|
||||
}
|
||||
setText1_(rootView, R.id.id_setting_subheader_imageflip, R.string.settingsImageFlip);
|
||||
int imageFlip = MagApplication.magParameter.imageFlip;
|
||||
setTextIcon(rootView, R.id.id_setting_item_imageHorflip, R.string.settingsImageFlipHor, "", (imageFlip & 1) != 0 ? R.mipmap.media_selected : R.mipmap.media_unselected).setOnClickListener(this.settingClickListner_);
|
||||
setTextIcon(rootView, R.id.id_setting_item_imageVerflip, R.string.settingsImageFlipVer, "", (imageFlip & 2) != 0 ? R.mipmap.media_selected : R.mipmap.media_unselected).setOnClickListener(this.settingClickListner_);
|
||||
if ((UsbConnection.getInstance().isConnected() && devType == 2) || devType == 1) {
|
||||
switch (MagApplication.magParameter.imageEX) {
|
||||
case 1:
|
||||
id5 = R.string.settingsEX2;
|
||||
break;
|
||||
case 2:
|
||||
id5 = R.string.settingsEX4;
|
||||
break;
|
||||
case 3:
|
||||
id5 = R.string.settingsEX8;
|
||||
break;
|
||||
case 4:
|
||||
id5 = R.string.settingsEX16;
|
||||
break;
|
||||
default:
|
||||
id5 = R.string.settingsEX1;
|
||||
break;
|
||||
}
|
||||
setTextIcon(rootView, R.id.id_setting_item_imageEX, R.string.settingsImageEX, id5, R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
} else {
|
||||
rootView.findViewById(R.id.id_imageEX_divider).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_imageEX).setVisibility(8);
|
||||
}
|
||||
if (UsbConnection.getInstance().isConnected() && devType == 2) {
|
||||
setText1_(rootView, R.id.id_setting_subheader_emissivity, R.string.settingsTemperature);
|
||||
switch (MagApplication.magParameter.emissivity) {
|
||||
case 70:
|
||||
id4 = R.string.settingsEM4;
|
||||
break;
|
||||
case 80:
|
||||
id4 = R.string.settingsEM3;
|
||||
break;
|
||||
case 90:
|
||||
id4 = R.string.settingsEM2;
|
||||
break;
|
||||
case 100:
|
||||
id4 = R.string.settingsEM1;
|
||||
break;
|
||||
default:
|
||||
id4 = R.string.settingsEM1;
|
||||
break;
|
||||
}
|
||||
setTextIcon(rootView, R.id.id_setting_item_emissivity, R.string.settingsEmissivity, id4, R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
} else {
|
||||
rootView.findViewById(R.id.id_emissivity_divider1).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_subheader_emissivity).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_emissivity_divider2).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_emissivity).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_emissivity_divider3).setVisibility(8);
|
||||
}
|
||||
if (UsbConnection.getInstance().isConnected() && (devType == 1 || devType == 2)) {
|
||||
setText1_(rootView, R.id.id_setting_subheader_fps, R.string.settingsFps);
|
||||
switch (MagApplication.magParameter.fpsMode) {
|
||||
case 1:
|
||||
id3 = R.string.settingsFpsLow;
|
||||
break;
|
||||
default:
|
||||
id3 = R.string.settingsFpsHigh;
|
||||
break;
|
||||
}
|
||||
setTextIcon(rootView, R.id.id_setting_item_fps, R.string.settingsFps, id3, R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
} else {
|
||||
rootView.findViewById(R.id.id_fps_divider1).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_subheader_fps).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_fps_divider2).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_fps).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_fps_divider3).setVisibility(8);
|
||||
}
|
||||
if (UsbConnection.getInstance().isConnected() && devType == 1) {
|
||||
setText1_(rootView, R.id.id_setting_subheader_moving_cross, R.string.settingsMovingCross);
|
||||
setTextIcon(rootView, R.id.id_setting_item_moving_cross, R.string.settingsMovingCrossOn, "", MagApplication.magParameter.isShowMovingCross ? R.mipmap.media_selected : R.mipmap.media_unselected).setOnClickListener(this.settingClickListner_);
|
||||
} else {
|
||||
rootView.findViewById(R.id.id_moving_cross_divider1).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_subheader_moving_cross).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_moving_cross_divider2).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_setting_item_moving_cross).setVisibility(8);
|
||||
rootView.findViewById(R.id.id_moving_cross_divider3).setVisibility(8);
|
||||
}
|
||||
setText1_(rootView, R.id.id_setting_subheader_about, R.string.settingsAbout);
|
||||
setTextIcon(rootView, R.id.id_setting_item_aboutProduct, R.string.settingsAboutProduct, "", R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
setTextIcon(rootView, R.id.id_setting_item_aboutAbout, R.string.settingsAboutAbout, "", R.mipmap.expand_more).setOnClickListener(this.settingClickListner_);
|
||||
}
|
||||
|
||||
private void updateVisibleUi(int opt) {
|
||||
int id;
|
||||
switch (opt) {
|
||||
case 0:
|
||||
MagApplication.magParameter.visWndSize = 0;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_VISWNDSIZE, 0);
|
||||
id = R.string.settingsVisibleSizeSmall;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
MagApplication.magParameter.visWndSize = 1;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_VISWNDSIZE, 1);
|
||||
id = R.string.settingsVisibleSizeMedium;
|
||||
break;
|
||||
case 2:
|
||||
MagApplication.magParameter.visWndSize = 2;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_VISWNDSIZE, 2);
|
||||
id = R.string.settingsVisibleSizeLarge;
|
||||
break;
|
||||
}
|
||||
View item = this.rootView_.findViewById(R.id.id_setting_item_visiblesize);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView.setText(id);
|
||||
if (MagApplication.magParameter.dispMode == 0) {
|
||||
FragmentMainCenter.imgViewerVisible_.setVisibility(4);
|
||||
FragmentMainCenter.imgViewerVisible_.setVisibility(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTempTraceUi(int opt) {
|
||||
int id;
|
||||
switch (opt) {
|
||||
case 0:
|
||||
MagApplication.magParameter.maxMinTrace = -1;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_MAXMINTRACE, -1);
|
||||
id = R.string.settingsNoneTrace;
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
MagApplication.magParameter.maxMinTrace = 0;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_MAXMINTRACE, 0);
|
||||
id = R.string.settingsMaxTrace;
|
||||
break;
|
||||
case 2:
|
||||
MagApplication.magParameter.maxMinTrace = 1;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_MAXMINTRACE, 1);
|
||||
id = R.string.settingsMinTrace;
|
||||
break;
|
||||
case 3:
|
||||
MagApplication.magParameter.maxMinTrace = 2;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_MAXMINTRACE, 2);
|
||||
id = R.string.settingsMaxMinTrace;
|
||||
break;
|
||||
}
|
||||
View item = this.rootView_.findViewById(R.id.id_setting_item_maxmintrace);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView.setText(id);
|
||||
}
|
||||
|
||||
private void updateImageEX(int opt) {
|
||||
int id;
|
||||
switch (opt) {
|
||||
case 1:
|
||||
id = R.string.settingsEX2;
|
||||
break;
|
||||
case 2:
|
||||
id = R.string.settingsEX4;
|
||||
break;
|
||||
case 3:
|
||||
id = R.string.settingsEX8;
|
||||
break;
|
||||
case 4:
|
||||
id = R.string.settingsEX16;
|
||||
break;
|
||||
default:
|
||||
id = R.string.settingsEX1;
|
||||
break;
|
||||
}
|
||||
if (DeviceController.isProcessImage()) {
|
||||
View item = this.rootView_.findViewById(R.id.id_setting_item_imageEX);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView.setText(id);
|
||||
MagApplication.magParameter.imageEX = opt;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EXMODE, 0);
|
||||
DeviceController.setEX(opt, MagApplication.magParameter.basePara1.fpaWidth / 2, MagApplication.magParameter.basePara1.fpaHeight / 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateEmissivity(int opt) {
|
||||
int id;
|
||||
switch (opt) {
|
||||
case 1:
|
||||
MagApplication.magParameter.emissivity = 90;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EMISSIVITY, 90);
|
||||
id = R.string.settingsEM2;
|
||||
break;
|
||||
case 2:
|
||||
MagApplication.magParameter.emissivity = 80;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EMISSIVITY, 80);
|
||||
id = R.string.settingsEM3;
|
||||
break;
|
||||
case 3:
|
||||
MagApplication.magParameter.emissivity = 70;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EMISSIVITY, 70);
|
||||
id = R.string.settingsEM4;
|
||||
break;
|
||||
default:
|
||||
MagApplication.magParameter.emissivity = 100;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_EMISSIVITY, 100);
|
||||
id = R.string.settingsEM1;
|
||||
break;
|
||||
}
|
||||
DeviceController.Lock();
|
||||
ExtPara param = new ExtPara();
|
||||
DeviceController.getExtParameter(param);
|
||||
DeviceController.setEmissivity(MagApplication.magParameter.emissivity, param.intCurrentEnvTemperature);
|
||||
DeviceController.Unlock();
|
||||
View item = this.rootView_.findViewById(R.id.id_setting_item_emissivity);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView.setText(id);
|
||||
}
|
||||
|
||||
private void updateFpsUi(int opt) {
|
||||
int id;
|
||||
switch (opt) {
|
||||
case 1:
|
||||
MagApplication.magParameter.fpsMode = 1;
|
||||
id = R.string.settingsFpsLow;
|
||||
StatService.onEvent(getContext(), MagParameter.EVENT_FRAME_RATE_LOW_ID, MagParameter.EVENT_FRAME_RATE_LOW);
|
||||
break;
|
||||
default:
|
||||
MagApplication.magParameter.fpsMode = 0;
|
||||
id = R.string.settingsFpsHigh;
|
||||
StatService.onEvent(getContext(), MagParameter.EVENT_FRAME_RATE_HIGH_ID, MagParameter.EVENT_FRAME_RATE_HIGH);
|
||||
break;
|
||||
}
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_FPSMODE, MagApplication.magParameter.fpsMode);
|
||||
View item = this.rootView_.findViewById(R.id.id_setting_item_fps);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView.setText(id);
|
||||
MsgBus.getInstance().postEmptytMsg(UsbCommunication.MSG_SET_BASEPARAMETER);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateRoiTraceParameter(int itemId, int stringId) {
|
||||
boolean isTraceRoi = !MagApplication.magParameter.isTraceRoi;
|
||||
MagApplication.magParameter.isTraceRoi = isTraceRoi;
|
||||
SharedPreferencesManager.putBooleanWithCommit(MagParameter.KEY_TRACEROI, isTraceRoi);
|
||||
setTextIcon(this.rootView_, itemId, stringId, "", isTraceRoi ? R.mipmap.media_selected : R.mipmap.media_unselected);
|
||||
if (isTraceRoi) {
|
||||
Toast.makeText(getContext(), R.string.tipTraceRoi, 1).show();
|
||||
StatService.onEvent(getContext(), MagParameter.EVENT_ROIT_TRACE_ID, MagParameter.EVENT_ROIT_TRACE);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateFlipParameter(int mode, int itemId, int stringId) {
|
||||
int imageFlip;
|
||||
boolean selected;
|
||||
int imageFlip2 = MagApplication.magParameter.imageFlip;
|
||||
if ((imageFlip2 & mode) == 0) {
|
||||
imageFlip = imageFlip2 | mode;
|
||||
selected = true;
|
||||
} else {
|
||||
imageFlip = imageFlip2 & (mode ^ (-1));
|
||||
selected = false;
|
||||
}
|
||||
MagApplication.magParameter.imageFlip = imageFlip;
|
||||
SharedPreferencesManager.putIntWithCommit(MagParameter.KEY_FLIPMODE, imageFlip);
|
||||
setTextIcon(this.rootView_, itemId, stringId, "", selected ? R.mipmap.media_selected : R.mipmap.media_unselected);
|
||||
ExtPara param = new ExtPara();
|
||||
DeviceController.Lock();
|
||||
DeviceController.getExtParameter(param);
|
||||
param.dwFlip = imageFlip;
|
||||
DeviceController.setExtParameter(param);
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void updateMovingCrossValue(int itemId, int stringId) {
|
||||
boolean selected = !MagApplication.magParameter.isShowMovingCross;
|
||||
MagApplication.magParameter.isShowMovingCross = selected;
|
||||
SharedPreferencesManager.putBooleanWithCommit(MagParameter.KEY_SHOWMOVINGCROSS, selected);
|
||||
setTextIcon(this.rootView_, itemId, stringId, "", selected ? R.mipmap.media_selected : R.mipmap.media_unselected);
|
||||
}
|
||||
|
||||
private View setText1_(View rootView, int itemId, int stringId) {
|
||||
View item = rootView.findViewById(itemId);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text);
|
||||
txtView.setText(stringId);
|
||||
return item;
|
||||
}
|
||||
|
||||
private View setTextIcon(View rootView, int itemId, int stringId1, int stringId2, int iconId) {
|
||||
View item = rootView.findViewById(itemId);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text);
|
||||
txtView.setText(stringId1);
|
||||
TextView txtView2 = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView2.setText(stringId2);
|
||||
ImageView iv = (ImageView) item.findViewById(R.id.id_setting_icon);
|
||||
iv.setImageResource(iconId);
|
||||
return item;
|
||||
}
|
||||
|
||||
private View setTextIcon(View rootView, int itemId, int stringId1, String text, int iconId) {
|
||||
View item = rootView.findViewById(itemId);
|
||||
TextView txtView = (TextView) item.findViewById(R.id.id_setting_item_text);
|
||||
txtView.setText(stringId1);
|
||||
TextView txtView2 = (TextView) item.findViewById(R.id.id_setting_item_text2);
|
||||
txtView2.setText(text);
|
||||
ImageView iv = (ImageView) item.findViewById(R.id.id_setting_icon);
|
||||
iv.setImageResource(iconId);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateOptionSelected
|
||||
public void onOptionSelected(int itemId, int opt) {
|
||||
switch (itemId) {
|
||||
case R.id.id_setting_item_visiblesize /* 2131624149 */:
|
||||
updateVisibleUi(opt);
|
||||
break;
|
||||
case R.id.id_setting_item_maxmintrace /* 2131624153 */:
|
||||
updateTempTraceUi(opt);
|
||||
break;
|
||||
case R.id.id_setting_item_imageEX /* 2131624160 */:
|
||||
updateImageEX(opt);
|
||||
break;
|
||||
case R.id.id_setting_item_emissivity /* 2131624165 */:
|
||||
updateEmissivity(opt);
|
||||
break;
|
||||
case R.id.id_setting_item_fps /* 2131624170 */:
|
||||
updateFpsUi(opt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private class SettingClickListner implements View.OnClickListener {
|
||||
private SettingClickListner() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
int index;
|
||||
int index2;
|
||||
int index3;
|
||||
switch (v.getId()) {
|
||||
case R.id.id_setting_item_aboutProduct /* 2131624146 */:
|
||||
Intent intent = new Intent(FragmentSetting.this.getActivity(), (Class<?>) AboutProductActivity.class);
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_CLICK_PRODUCT_ID, MagParameter.EVENT_CLICK_PRODUCT);
|
||||
FragmentSetting.this.startActivity(intent);
|
||||
break;
|
||||
case R.id.id_setting_item_aboutAbout /* 2131624147 */:
|
||||
Intent intent2 = new Intent(FragmentSetting.this.getActivity(), (Class<?>) AboutAboutActivity.class);
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_CLICK_ABOUT_ID, MagParameter.EVENT_CLICK_ABOUT);
|
||||
FragmentSetting.this.startActivity(intent2);
|
||||
break;
|
||||
case R.id.id_setting_item_visiblesize /* 2131624149 */:
|
||||
switch (MagApplication.magParameter.visWndSize) {
|
||||
case 0:
|
||||
index3 = 0;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_VISWND_SMALL_ID, MagParameter.EVENT_VISWND_SMALL);
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
index3 = 1;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_VISWND_MIDDLE_ID, MagParameter.EVENT_VISWND_MIDDLE);
|
||||
break;
|
||||
case 2:
|
||||
index3 = 2;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_VISWND_LARGE_ID, MagParameter.EVENT_VISWND_LARGE);
|
||||
break;
|
||||
}
|
||||
DialogFragment dlg = DialogOption.newInstance(R.string.visibleSizeOptionText, R.id.id_setting_item_visiblesize, new int[]{R.string.settingsVisibleSizeSmall, R.string.settingsVisibleSizeMedium, R.string.settingsVisibleSizeLarge}, index3, FragmentSetting.this, 0);
|
||||
dlg.show(FragmentSetting.this.getActivity().getSupportFragmentManager(), "dialogOptionVisible");
|
||||
break;
|
||||
case R.id.id_setting_item_maxmintrace /* 2131624153 */:
|
||||
switch (MagApplication.magParameter.maxMinTrace) {
|
||||
case -1:
|
||||
index2 = 0;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_TRACE_NONE_ID, MagParameter.EVENT_TRACE_NONE);
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
index2 = 1;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_TRACE_MAX_ID, MagParameter.EVENT_TRACE_MAX);
|
||||
break;
|
||||
case 1:
|
||||
index2 = 2;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_TRACE_MIN_ID, MagParameter.EVENT_TRACE_MIN);
|
||||
break;
|
||||
case 2:
|
||||
index2 = 3;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_TRACE_MAXMIN_ID, MagParameter.EVENT_TRACE_MAXMIN);
|
||||
break;
|
||||
}
|
||||
DialogFragment dlg2 = DialogOption.newInstance(R.string.settingsTraceTarget, R.id.id_setting_item_maxmintrace, new int[]{R.string.settingsNoneTrace, R.string.settingsMaxTrace, R.string.settingsMinTrace, R.string.settingsMaxMinTrace}, index2, FragmentSetting.this, 0);
|
||||
dlg2.show(FragmentSetting.this.getActivity().getSupportFragmentManager(), "dialogOptionMaxMinTrace");
|
||||
break;
|
||||
case R.id.id_setting_item_roitrace /* 2131624155 */:
|
||||
FragmentSetting.this.updateRoiTraceParameter(R.id.id_setting_item_roitrace, R.string.settingsTraceROI);
|
||||
break;
|
||||
case R.id.id_setting_item_imageHorflip /* 2131624158 */:
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_FLIP_HORIZONTAL_ID, MagParameter.EVENT_FLIP_HORIZONTAL);
|
||||
FragmentSetting.this.updateFlipParameter(1, R.id.id_setting_item_imageHorflip, R.string.settingsImageFlipHor);
|
||||
break;
|
||||
case R.id.id_setting_item_imageVerflip /* 2131624159 */:
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_FLIP_VERTICAL_ID, MagParameter.EVENT_FLIP_VERTICAL);
|
||||
FragmentSetting.this.updateFlipParameter(2, R.id.id_setting_item_imageVerflip, R.string.settingsImageFlipVer);
|
||||
break;
|
||||
case R.id.id_setting_item_imageEX /* 2131624160 */:
|
||||
DialogFragment dlg3 = DialogOption.newInstance(R.string.settingsImageEX, R.id.id_setting_item_imageEX, new int[]{R.string.settingsEX1, R.string.settingsEX2, R.string.settingsEX4, R.string.settingsEX8, R.string.settingsEX16}, DeviceController.getEX(), FragmentSetting.this, 0);
|
||||
dlg3.show(FragmentSetting.this.getActivity().getSupportFragmentManager(), "dialogOptionImageEx");
|
||||
break;
|
||||
case R.id.id_setting_item_emissivity /* 2131624165 */:
|
||||
switch (MagApplication.magParameter.emissivity) {
|
||||
case 70:
|
||||
index = 3;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_EMISSIVITY_LIGHT_ID, MagParameter.EVENT_EMISSIVITY_LIGHT);
|
||||
break;
|
||||
case 80:
|
||||
index = 2;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_EMISSIVITY_HALF_ID, MagParameter.EVENT_EMISSIVITY_HALF);
|
||||
break;
|
||||
case 90:
|
||||
index = 1;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_EMISSIVITY_DARK_ID, MagParameter.EVENT_EMISSIVITY_DARK);
|
||||
break;
|
||||
default:
|
||||
index = 0;
|
||||
StatService.onEvent(FragmentSetting.this.getContext(), MagParameter.EVENT_EMISSIVITY_NONE_ID, MagParameter.EVENT_EMISSIVITY_NONE);
|
||||
break;
|
||||
}
|
||||
DialogFragment dlg4 = DialogOption.newInstance(R.string.settingsEmissivity, R.id.id_setting_item_emissivity, new int[]{R.string.settingsEM1, R.string.settingsEM2, R.string.settingsEM3, R.string.settingsEM4}, index, FragmentSetting.this, 0);
|
||||
dlg4.show(FragmentSetting.this.getActivity().getSupportFragmentManager(), "dialogOptionEmissivity");
|
||||
break;
|
||||
case R.id.id_setting_item_fps /* 2131624170 */:
|
||||
DialogFragment dlg5 = DialogOption.newInstance(R.string.settingsFps, R.id.id_setting_item_fps, new int[]{R.string.settingsFpsHigh, R.string.settingsFpsLow}, MagApplication.magParameter.fpsMode, FragmentSetting.this, R.string.settingsFpsTip);
|
||||
dlg5.show(FragmentSetting.this.getActivity().getSupportFragmentManager(), "dialogOptionFps");
|
||||
break;
|
||||
case R.id.id_setting_item_moving_cross /* 2131624175 */:
|
||||
FragmentSetting.this.updateMovingCrossValue(R.id.id_setting_item_moving_cross, R.string.settingsMovingCrossOn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentSupport extends Fragment {
|
||||
private SupportClickListener settingClickListener_;
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.settingClickListener_ = new SupportClickListener();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_support, (ViewGroup) null);
|
||||
View view = rootView.findViewById(R.id.id_product);
|
||||
view.setOnClickListener(this.settingClickListener_);
|
||||
ImageView icon = (ImageView) view.findViewById(R.id.id_icon);
|
||||
icon.setImageResource(R.mipmap.help);
|
||||
TextView text = (TextView) view.findViewById(R.id.id_text);
|
||||
text.setText(R.string.labelProductInfo);
|
||||
View view2 = rootView.findViewById(R.id.id_about);
|
||||
view2.setOnClickListener(this.settingClickListener_);
|
||||
ImageView icon2 = (ImageView) view2.findViewById(R.id.id_icon);
|
||||
icon2.setImageResource(R.mipmap.about);
|
||||
TextView text2 = (TextView) view2.findViewById(R.id.id_text);
|
||||
text2.setText(R.string.labelAbout);
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getActivity().setTitle(R.string.labelHelp);
|
||||
}
|
||||
|
||||
private class SupportClickListener implements View.OnClickListener {
|
||||
private SupportClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_product /* 2131624177 */:
|
||||
((SupportActivity) FragmentSupport.this.getActivity()).showHelp();
|
||||
break;
|
||||
case R.id.id_about /* 2131624178 */:
|
||||
((SupportActivity) FragmentSupport.this.getActivity()).showAbout();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbConnection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentSupportAbout extends Fragment {
|
||||
private PackageInfo packInfo_;
|
||||
private SettingClickListener settingClickListener_;
|
||||
private TextView tvCompanyCaption_;
|
||||
private TextView tvCompany_;
|
||||
private TextView tvHWVersionCaption_;
|
||||
private TextView tvHWVersion_;
|
||||
private TextView tvProductTypeCaption_;
|
||||
private TextView tvProductType_;
|
||||
private TextView tvRightCaption_;
|
||||
private TextView tvRight_;
|
||||
private TextView tvSWVersionCaption_;
|
||||
private TextView tvSWVersion_;
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
this.settingClickListener_ = new SettingClickListener();
|
||||
PackageManager packageManager = getActivity().getPackageManager();
|
||||
try {
|
||||
this.packInfo_ = packageManager.getPackageInfo(getActivity().getPackageName(), 0);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
this.packInfo_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View rootView = inflater.inflate(R.layout.fragment_support_about, container, false);
|
||||
View view = rootView.findViewById(R.id.id_productType);
|
||||
this.tvProductTypeCaption_ = (TextView) view.findViewById(R.id.id_text1);
|
||||
this.tvProductTypeCaption_.setText(R.string.productType);
|
||||
this.tvProductType_ = (TextView) view.findViewById(R.id.id_text2);
|
||||
if (UsbConnection.getInstance().isConnected()) {
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
this.tvProductType_.setText(R.string.c1);
|
||||
break;
|
||||
case 1:
|
||||
this.tvProductType_.setText(R.string.c3);
|
||||
break;
|
||||
case 2:
|
||||
this.tvProductType_.setText(R.string.c3p);
|
||||
break;
|
||||
case 3:
|
||||
this.tvProductType_.setText(R.string.core160);
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
this.tvProductType_.setText("");
|
||||
break;
|
||||
case 5:
|
||||
this.tvProductType_.setText(R.string.c1pro);
|
||||
break;
|
||||
case 6:
|
||||
this.tvProductType_.setText(R.string.c1prolite);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
this.tvProductType_.setText("");
|
||||
}
|
||||
View view2 = rootView.findViewById(R.id.id_swVersion);
|
||||
this.tvSWVersionCaption_ = (TextView) view2.findViewById(R.id.id_text1);
|
||||
this.tvSWVersionCaption_.setText(R.string.swVersion);
|
||||
this.tvSWVersion_ = (TextView) view2.findViewById(R.id.id_text2);
|
||||
if (this.packInfo_ != null) {
|
||||
this.tvSWVersion_.setText(this.packInfo_.versionName);
|
||||
}
|
||||
View view3 = rootView.findViewById(R.id.id_right);
|
||||
this.tvRightCaption_ = (TextView) view3.findViewById(R.id.id_text1);
|
||||
this.tvRightCaption_.setText(R.string.right);
|
||||
this.tvRight_ = (TextView) view3.findViewById(R.id.id_text2);
|
||||
this.tvRight_.setText(R.string.juge);
|
||||
View view4 = rootView.findViewById(R.id.id_hwVersion);
|
||||
this.tvHWVersionCaption_ = (TextView) view4.findViewById(R.id.id_text1);
|
||||
this.tvHWVersionCaption_.setText(R.string.hwVersion);
|
||||
this.tvHWVersion_ = (TextView) view4.findViewById(R.id.id_text2);
|
||||
if (UsbConnection.getInstance().isConnected()) {
|
||||
this.tvHWVersion_.setText(Integer.toString(MagApplication.magParameter.basePara1.hwVersion));
|
||||
} else {
|
||||
this.tvHWVersion_.setText("");
|
||||
}
|
||||
View view5 = rootView.findViewById(R.id.id_company);
|
||||
this.tvCompanyCaption_ = (TextView) view5.findViewById(R.id.id_text1);
|
||||
this.tvCompanyCaption_.setText(R.string.company);
|
||||
this.tvCompany_ = (TextView) view5.findViewById(R.id.id_text2);
|
||||
this.tvCompany_.setText("http://www.magnity.com.cn");
|
||||
this.tvCompany_.setAutoLinkMask(15);
|
||||
this.tvCompany_.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getActivity().setTitle(R.string.labelAbout);
|
||||
}
|
||||
|
||||
private class SettingClickListener implements View.OnClickListener {
|
||||
private SettingClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
v.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FragmentSupportHelp extends Fragment {
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
@Nullable
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_support_help, (ViewGroup) null);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.Fragment
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getActivity().setTitle(R.string.labelProductInfo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,959 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PaintFlagsDrawFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import cn.com.magnity.magnitycx.FragmentMainCenter;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import cn.com.magnity.magnitycx.sdk.State;
|
||||
import cn.com.magnity.magnitycx.sdk.TimerHelper;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbCommunication;
|
||||
import cn.com.magnity.magnitycx.sdk.WaitCondition;
|
||||
import com.baidu.mobstat.Config;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImageViewer extends SurfaceView implements SurfaceHolder.Callback, UsbCommunication.DelegateNewFrame, FragmentMainCenter.DelegateCapture {
|
||||
private static final int MAX_ROI_NUM = 1;
|
||||
private int aimOrientation_;
|
||||
private int aimX_;
|
||||
private int aimY_;
|
||||
private Bitmap bmpIr_;
|
||||
private Canvas cachedCanvas_;
|
||||
private Bitmap cachedbmp_;
|
||||
private WaitCondition condRecording_;
|
||||
private int dx_;
|
||||
private int dy_;
|
||||
private volatile int fpaHeight_;
|
||||
private volatile int fpaWidth_;
|
||||
private int frameIndex_;
|
||||
private int height_;
|
||||
private SurfaceHolder holder_;
|
||||
private volatile int imageStableCounter_;
|
||||
private boolean isAimDrag_;
|
||||
private volatile boolean isExitThreadRecording_;
|
||||
private volatile boolean isExitThreadRender_;
|
||||
private volatile boolean isTempStable_;
|
||||
private ArrayList<ROIInfo> listRoi_;
|
||||
private Matrix matrixVGA_;
|
||||
private Matrix matrix_;
|
||||
private Paint paintROIVGA_;
|
||||
private Paint paintROI_;
|
||||
private Paint paintVGA_;
|
||||
private Paint paint_;
|
||||
private PaintFlagsDrawFilter pfd_;
|
||||
private AtomicLong recordingTimeElapsed_;
|
||||
private volatile ThreadLocalParam threadLocalParam_;
|
||||
private ThreadRecording threadRecording_;
|
||||
private ThreadRender threadRender_;
|
||||
private TimerHelper timerHelper_;
|
||||
private WaitCondition waitCondition_;
|
||||
private int width_;
|
||||
private static volatile Lock lock_ = new ReentrantLock();
|
||||
private static volatile long[] ticks_ = new long[20];
|
||||
private static Object syncNotifyNewFrame_ = new Object();
|
||||
private static ArrayList<ImageViewer> imgViewerList_ = new ArrayList<>();
|
||||
|
||||
private class ThreadLocalParam implements Cloneable {
|
||||
int centerTemp;
|
||||
State state;
|
||||
|
||||
private ThreadLocalParam() {
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
ThreadLocalParam param = (ThreadLocalParam) super.clone();
|
||||
if (this.state != null) {
|
||||
param.state = (State) this.state.clone();
|
||||
}
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
||||
private class OSDParam {
|
||||
private Bitmap crossLogo_;
|
||||
private Bitmap laserLogo_;
|
||||
private Bitmap maxTrace_;
|
||||
private Bitmap minTrace_;
|
||||
private Bitmap moveingCrossLogo_;
|
||||
private Bitmap waterMark_;
|
||||
|
||||
private OSDParam() {
|
||||
}
|
||||
|
||||
public Bitmap getCrossLogo() {
|
||||
return this.crossLogo_;
|
||||
}
|
||||
|
||||
public Bitmap getWaterMark() {
|
||||
return this.waterMark_;
|
||||
}
|
||||
|
||||
public Bitmap getMinTrace() {
|
||||
return this.minTrace_;
|
||||
}
|
||||
|
||||
public Bitmap getMaxTrace() {
|
||||
return this.maxTrace_;
|
||||
}
|
||||
|
||||
public Bitmap getMovingCrossLogo() {
|
||||
return this.moveingCrossLogo_;
|
||||
}
|
||||
|
||||
public Bitmap getLaserLogo() {
|
||||
return this.laserLogo_;
|
||||
}
|
||||
|
||||
public void setCrossLogo(int id) {
|
||||
this.crossLogo_ = BitmapFactory.decodeResource(ImageViewer.this.getResources(), id);
|
||||
}
|
||||
|
||||
public void setWaterMark(int id) {
|
||||
this.waterMark_ = BitmapFactory.decodeResource(ImageViewer.this.getResources(), id);
|
||||
}
|
||||
|
||||
public void setMinTrace(int id) {
|
||||
this.minTrace_ = BitmapFactory.decodeResource(ImageViewer.this.getResources(), id);
|
||||
}
|
||||
|
||||
public void setMaxTrace(int id) {
|
||||
this.maxTrace_ = BitmapFactory.decodeResource(ImageViewer.this.getResources(), id);
|
||||
}
|
||||
|
||||
public void setMovingCrossLogo(int id) {
|
||||
this.moveingCrossLogo_ = BitmapFactory.decodeResource(ImageViewer.this.getResources(), id);
|
||||
}
|
||||
|
||||
public void setLaserLogo(int id) {
|
||||
this.laserLogo_ = BitmapFactory.decodeResource(ImageViewer.this.getResources(), id);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void reset() {
|
||||
if (this.crossLogo_ != null && !this.crossLogo_.isRecycled()) {
|
||||
this.crossLogo_.recycle();
|
||||
this.crossLogo_ = null;
|
||||
}
|
||||
if (this.waterMark_ != null && !this.waterMark_.isRecycled()) {
|
||||
this.waterMark_.recycle();
|
||||
this.waterMark_ = null;
|
||||
}
|
||||
if (this.minTrace_ != null && !this.minTrace_.isRecycled()) {
|
||||
this.minTrace_.recycle();
|
||||
this.minTrace_ = null;
|
||||
}
|
||||
if (this.maxTrace_ != null && !this.maxTrace_.isRecycled()) {
|
||||
this.maxTrace_.recycle();
|
||||
this.maxTrace_ = null;
|
||||
}
|
||||
if (this.moveingCrossLogo_ != null && !this.moveingCrossLogo_.isRecycled()) {
|
||||
this.moveingCrossLogo_.recycle();
|
||||
this.moveingCrossLogo_ = null;
|
||||
}
|
||||
if (this.laserLogo_ != null && !this.laserLogo_.isRecycled()) {
|
||||
this.laserLogo_.recycle();
|
||||
this.laserLogo_ = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTempStableFlag(boolean isStable) {
|
||||
this.isTempStable_ = isStable;
|
||||
}
|
||||
|
||||
public boolean getTempStableFlag() {
|
||||
return this.isTempStable_;
|
||||
}
|
||||
|
||||
public void setImageStableCounter(int counter) {
|
||||
this.imageStableCounter_ = counter;
|
||||
}
|
||||
|
||||
public int getImageStableCounter() {
|
||||
return this.imageStableCounter_;
|
||||
}
|
||||
|
||||
public ImageViewer(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.waitCondition_ = new WaitCondition();
|
||||
this.condRecording_ = new WaitCondition();
|
||||
this.threadLocalParam_ = new ThreadLocalParam();
|
||||
this.paint_ = new Paint(1);
|
||||
this.matrix_ = new Matrix();
|
||||
this.matrixVGA_ = new Matrix();
|
||||
this.paintVGA_ = new Paint(1);
|
||||
this.paintROI_ = new Paint(1);
|
||||
this.paintROIVGA_ = new Paint(1);
|
||||
this.listRoi_ = new ArrayList<>();
|
||||
this.recordingTimeElapsed_ = new AtomicLong(0L);
|
||||
this.holder_ = getHolder();
|
||||
this.holder_.setFormat(-2);
|
||||
this.holder_.addCallback(this);
|
||||
this.timerHelper_ = new TimerHelper() { // from class: cn.com.magnity.magnitycx.ImageViewer.1
|
||||
@Override // cn.com.magnity.magnitycx.sdk.TimerHelper
|
||||
public void run() {
|
||||
ImageViewer.this.recordingTimeElapsed_.getAndIncrement();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void invalidate_() {
|
||||
synchronized (this.waitCondition_.cond) {
|
||||
this.waitCondition_.notified = true;
|
||||
this.waitCondition_.cond.notify();
|
||||
}
|
||||
}
|
||||
|
||||
private void recordingOneFrame() {
|
||||
synchronized (this.condRecording_.cond) {
|
||||
this.condRecording_.notified = true;
|
||||
this.condRecording_.cond.notify();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUiTemps(int fpaWidth, int fpaHeight) {
|
||||
int pos;
|
||||
switch (DeviceController.getPreviewOrientation()) {
|
||||
case 0:
|
||||
case 180:
|
||||
pos = ((fpaHeight + 1) * fpaWidth) / 2;
|
||||
break;
|
||||
default:
|
||||
pos = ((fpaWidth + 1) * fpaHeight) / 2;
|
||||
break;
|
||||
}
|
||||
this.threadLocalParam_.centerTemp = DeviceController.getTemperature(pos, 1, false);
|
||||
this.threadLocalParam_.state = DeviceController.getState();
|
||||
ROIInfo.lock();
|
||||
try {
|
||||
Iterator<ROIInfo> it = this.listRoi_.iterator();
|
||||
while (it.hasNext()) {
|
||||
ROIInfo roiInfo = it.next();
|
||||
switch (roiInfo.getType()) {
|
||||
case 1:
|
||||
int[] info = new int[5];
|
||||
if (roiInfo.isBigEnouth() && DeviceController.getRectTemperatureInfo(roiInfo.getBeginPointX(), roiInfo.getBeginPointY(), roiInfo.getEndPointX(), roiInfo.getEndPointY(), info, false)) {
|
||||
roiInfo.setTempInfo(info[0], info[1], info[2], info[3], info[4]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
ROIInfo.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void initData(int fpaWidth, int fpaHeight) {
|
||||
this.fpaWidth_ = fpaWidth;
|
||||
this.fpaHeight_ = fpaHeight;
|
||||
if (this.bmpIr_ == null) {
|
||||
this.bmpIr_ = Bitmap.createBitmap(fpaWidth, fpaHeight, Bitmap.Config.ARGB_8888);
|
||||
} else if (this.bmpIr_.getWidth() != fpaWidth || this.bmpIr_.getHeight() != fpaHeight) {
|
||||
if (!this.bmpIr_.isRecycled()) {
|
||||
this.bmpIr_.recycle();
|
||||
}
|
||||
this.bmpIr_ = Bitmap.createBitmap(fpaWidth, fpaHeight, Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.UsbCommunication.DelegateNewFrame
|
||||
public void onNewFrameReceived(int fpaTemp, int camTemp) {
|
||||
DeviceController.Lock();
|
||||
if (!DeviceController.getOutputBMPData(this.bmpIr_, this.fpaWidth_ * this.fpaHeight_ * 4)) {
|
||||
DeviceController.Unlock();
|
||||
return;
|
||||
}
|
||||
int i = this.frameIndex_;
|
||||
this.frameIndex_ = i + 1;
|
||||
if ((i & 7) == 0) {
|
||||
updateUiTemps(this.fpaWidth_, this.fpaHeight_);
|
||||
}
|
||||
DeviceController.Unlock();
|
||||
if (DeviceController.isRecording()) {
|
||||
recordingOneFrame();
|
||||
}
|
||||
invalidate_();
|
||||
}
|
||||
|
||||
private void calculateScreenFit() {
|
||||
int width;
|
||||
int height;
|
||||
int width2 = getWidth();
|
||||
int height2 = getHeight();
|
||||
if (getResources().getConfiguration().orientation == 1) {
|
||||
if (width2 * 4 > height2 * 3) {
|
||||
height = (height2 / 12) * 12;
|
||||
width = (height * 3) / 4;
|
||||
} else {
|
||||
width = (width2 / 12) * 12;
|
||||
height = (width * 4) / 3;
|
||||
}
|
||||
} else if (width2 * 3 > height2 * 4) {
|
||||
height = (height2 / 12) * 12;
|
||||
width = (height * 4) / 3;
|
||||
} else {
|
||||
width = (width2 / 12) * 12;
|
||||
height = (width * 3) / 4;
|
||||
}
|
||||
this.dx_ = (getWidth() - width) / 2;
|
||||
this.dy_ = (getHeight() - height) / 2;
|
||||
this.width_ = width;
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
if (this.cachedbmp_ == null) {
|
||||
switch (DeviceController.getPreviewOrientation()) {
|
||||
case 0:
|
||||
case 180:
|
||||
this.cachedbmp_ = Bitmap.createBitmap(640, 480, Bitmap.Config.ARGB_8888);
|
||||
break;
|
||||
case 90:
|
||||
case 270:
|
||||
this.cachedbmp_ = Bitmap.createBitmap(480, 640, Bitmap.Config.ARGB_8888);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.cachedCanvas_ == null) {
|
||||
this.cachedCanvas_ = new Canvas();
|
||||
this.cachedCanvas_.setBitmap(this.cachedbmp_);
|
||||
}
|
||||
Canvas canvas = this.holder_.lockCanvas();
|
||||
if (canvas != null) {
|
||||
this.paint_.setTextSize(getResources().getDimensionPixelSize(R.dimen.liveTemperatureTextSize));
|
||||
this.paint_.setTypeface(Typeface.SANS_SERIF);
|
||||
this.paint_.setTextAlign(Paint.Align.LEFT);
|
||||
this.paint_.setColor(getResources().getColor(R.color.liveBackground));
|
||||
canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), this.paint_);
|
||||
this.holder_.unlockCanvasAndPost(canvas);
|
||||
this.paint_.setColor(getResources().getColor(R.color.textColor));
|
||||
this.paint_.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
this.paint_.setStrokeWidth(2.0f);
|
||||
this.paint_.setShadowLayer(12.0f, 0.0f, 0.0f, getResources().getColor(R.color.black));
|
||||
this.paintVGA_.setTextSize(getResources().getDimensionPixelSize(R.dimen.recordingTemperatureTextSize));
|
||||
this.paintVGA_.setTypeface(Typeface.SANS_SERIF);
|
||||
this.paintVGA_.setTextAlign(Paint.Align.LEFT);
|
||||
this.paintVGA_.setColor(getResources().getColor(R.color.textColor));
|
||||
this.paintVGA_.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
this.paintVGA_.setStrokeWidth(1.0f);
|
||||
this.paintVGA_.setShadowLayer(6.0f, 0.0f, 0.0f, getResources().getColor(R.color.black));
|
||||
this.paintROI_.setColor(getResources().getColor(R.color.roiColor));
|
||||
this.paintROI_.setStyle(Paint.Style.STROKE);
|
||||
this.paintROI_.setStrokeWidth(4.0f);
|
||||
this.paintROI_.setShadowLayer(6.0f, 0.0f, 0.0f, getResources().getColor(R.color.black));
|
||||
this.paintROIVGA_.setColor(getResources().getColor(R.color.roiColor));
|
||||
this.paintROIVGA_.setStyle(Paint.Style.STROKE);
|
||||
this.paintROIVGA_.setStrokeWidth(2.0f);
|
||||
this.paintROIVGA_.setShadowLayer(2.0f, 0.0f, 0.0f, getResources().getColor(R.color.black));
|
||||
}
|
||||
this.pfd_ = new PaintFlagsDrawFilter(0, 3);
|
||||
synchronized (syncNotifyNewFrame_) {
|
||||
imgViewerList_.add(this);
|
||||
}
|
||||
calculateScreenFit();
|
||||
this.aimOrientation_ = getResources().getConfiguration().orientation;
|
||||
if (this.aimOrientation_ == 1) {
|
||||
this.aimX_ = SharedPreferencesManager.getInt("aimX_portrait", getWidth() / 2);
|
||||
this.aimY_ = SharedPreferencesManager.getInt("aimY_portrait", getHeight() / 2);
|
||||
} else {
|
||||
this.aimX_ = SharedPreferencesManager.getInt("aimX_landscape", getWidth() / 2);
|
||||
this.aimY_ = SharedPreferencesManager.getInt("aimY_landscape", getHeight() / 2);
|
||||
}
|
||||
DeviceController.setColorbarSize(100, 20);
|
||||
DeviceController.setColorPalette(SharedPreferencesManager.getInt("paletteIndex", 2));
|
||||
this.threadRender_ = new ThreadRender();
|
||||
this.isExitThreadRender_ = false;
|
||||
this.waitCondition_.notified = false;
|
||||
this.threadRender_.start();
|
||||
this.threadRecording_ = new ThreadRecording();
|
||||
this.isExitThreadRecording_ = false;
|
||||
this.condRecording_.notified = false;
|
||||
this.threadRecording_.start();
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
calculateScreenFit();
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
if (this.aimOrientation_ == 1) {
|
||||
SharedPreferencesManager.putInt("aimX_portrait", this.aimX_);
|
||||
SharedPreferencesManager.putIntWithCommit("aimY_portrait", this.aimY_);
|
||||
} else {
|
||||
SharedPreferencesManager.putInt("aimX_landscape", this.aimX_);
|
||||
SharedPreferencesManager.putIntWithCommit("aimY_landscape", this.aimY_);
|
||||
}
|
||||
this.isExitThreadRender_ = true;
|
||||
synchronized (this.waitCondition_.cond) {
|
||||
this.waitCondition_.notified = true;
|
||||
this.waitCondition_.cond.notify();
|
||||
}
|
||||
try {
|
||||
this.threadRender_.join();
|
||||
this.threadRender_ = null;
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
this.isExitThreadRecording_ = true;
|
||||
synchronized (this.condRecording_.cond) {
|
||||
this.condRecording_.notified = true;
|
||||
this.condRecording_.cond.notify();
|
||||
}
|
||||
try {
|
||||
this.threadRecording_.join();
|
||||
this.threadRecording_ = null;
|
||||
} catch (InterruptedException e2) {
|
||||
}
|
||||
synchronized (syncNotifyNewFrame_) {
|
||||
imgViewerList_.remove(this);
|
||||
}
|
||||
this.cachedCanvas_ = null;
|
||||
if (!this.cachedbmp_.isRecycled()) {
|
||||
this.cachedbmp_.recycle();
|
||||
this.cachedbmp_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public boolean onStartRecording(String pathName) {
|
||||
boolean ret = DeviceController.startRecording(pathName, this.cachedbmp_.getWidth(), this.cachedbmp_.getHeight(), 2048, 20, 5);
|
||||
this.recordingTimeElapsed_.set(0L);
|
||||
this.timerHelper_.start(1000L, 1000L);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public void onStopRecording() {
|
||||
this.timerHelper_.stop();
|
||||
if (DeviceController.isRecording()) {
|
||||
DeviceController.stopRecording();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public Bitmap onCapture() {
|
||||
OSDParam osdParam = new OSDParam();
|
||||
osdParam.setCrossLogo(R.mipmap.cross_capture);
|
||||
osdParam.setWaterMark(R.mipmap.water_mark);
|
||||
osdParam.setMinTrace(R.mipmap.min_trace_capture);
|
||||
osdParam.setMaxTrace(R.mipmap.max_trace_capture);
|
||||
DeviceController.Lock();
|
||||
updateUiTemps(this.fpaWidth_, this.fpaHeight_);
|
||||
DeviceController.Unlock();
|
||||
drawImage(this.cachedCanvas_, this.paintVGA_, this.paintROIVGA_, this.matrixVGA_, 0, 0, this.cachedbmp_.getWidth(), this.cachedbmp_.getHeight(), osdParam);
|
||||
return this.cachedbmp_;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.FragmentMainCenter.DelegateCapture
|
||||
public void onCaptureFinished(String pathName) {
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean z = false;
|
||||
if (!DeviceController.isProcessImage()) {
|
||||
return false;
|
||||
}
|
||||
switch (event.getActionMasked()) {
|
||||
case 0:
|
||||
if (MagApplication.magParameter.isTraceRoi) {
|
||||
int[] coor = DeviceController.screenXY2ClientXY(((int) event.getX()) - this.dx_, ((int) event.getY()) - this.dy_, this.width_, this.height_);
|
||||
boolean isPointInROI = false;
|
||||
ROIInfo.lock();
|
||||
try {
|
||||
Iterator<ROIInfo> it = this.listRoi_.iterator();
|
||||
while (true) {
|
||||
if (it.hasNext()) {
|
||||
if (it.next().isPointIn(coor[0], coor[1])) {
|
||||
it.remove();
|
||||
isPointInROI = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isPointInROI && this.listRoi_.size() > 0) {
|
||||
this.listRoi_.remove(0);
|
||||
}
|
||||
ROIInfo.unlock();
|
||||
ROIInfo roiInfo = new ROIInfo(1);
|
||||
roiInfo.setBeginPoint(coor[0], coor[1]);
|
||||
roiInfo.setEndPoint(coor[0], coor[1]);
|
||||
ROIInfo.lock();
|
||||
try {
|
||||
this.listRoi_.add(roiInfo);
|
||||
return true;
|
||||
} finally {
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
if (MagApplication.magParameter.basePara1.devType != 1 || !MagApplication.magParameter.isShowMovingCross || event.getX() <= this.aimX_ - 48 || event.getX() >= this.aimX_ + 48 || event.getY() <= this.aimY_ - 48 || event.getY() >= this.aimY_ + 48) {
|
||||
return false;
|
||||
}
|
||||
this.isAimDrag_ = true;
|
||||
return true;
|
||||
case 1:
|
||||
if (MagApplication.magParameter.isTraceRoi) {
|
||||
int num = this.listRoi_.size();
|
||||
if (num < 1) {
|
||||
return false;
|
||||
}
|
||||
ROIInfo roiInfo2 = this.listRoi_.get(num - 1);
|
||||
int[] coor2 = DeviceController.screenXY2ClientXY(((int) event.getX()) - this.dx_, ((int) event.getY()) - this.dy_, this.width_, this.height_);
|
||||
ROIInfo.lock();
|
||||
try {
|
||||
roiInfo2.setEndPoint(coor2[0], coor2[1]);
|
||||
if (!roiInfo2.isBigEnouth()) {
|
||||
this.listRoi_.remove(num - 1);
|
||||
} else {
|
||||
roiInfo2.setFinished();
|
||||
ROIInfo.unlock();
|
||||
invalidate_();
|
||||
z = true;
|
||||
}
|
||||
return z;
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
if (!this.isAimDrag_) {
|
||||
return false;
|
||||
}
|
||||
this.isAimDrag_ = false;
|
||||
invalidate_();
|
||||
return true;
|
||||
case 2:
|
||||
if (MagApplication.magParameter.isTraceRoi) {
|
||||
int num2 = this.listRoi_.size();
|
||||
if (num2 < 1) {
|
||||
return false;
|
||||
}
|
||||
ROIInfo roiInfo3 = this.listRoi_.get(num2 - 1);
|
||||
int[] coor3 = DeviceController.screenXY2ClientXY(((int) event.getX()) - this.dx_, ((int) event.getY()) - this.dy_, this.width_, this.height_);
|
||||
if (!roiInfo3.isFinished()) {
|
||||
ROIInfo.lock();
|
||||
try {
|
||||
roiInfo3.setEndPoint(coor3[0], coor3[1]);
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!this.isAimDrag_) {
|
||||
return false;
|
||||
}
|
||||
this.aimX_ = (int) event.getX();
|
||||
this.aimY_ = (int) event.getY();
|
||||
if (this.aimX_ < this.dx_) {
|
||||
this.aimX_ = this.dx_;
|
||||
} else if (this.aimX_ > this.dx_ + this.width_) {
|
||||
this.aimX_ = this.dx_ + this.width_;
|
||||
}
|
||||
if (this.aimY_ < this.dy_) {
|
||||
this.aimY_ = this.dy_;
|
||||
} else if (this.aimY_ > this.dy_ + this.height_) {
|
||||
this.aimY_ = this.dy_ + this.height_;
|
||||
}
|
||||
invalidate_();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void doDraw(OSDParam param) {
|
||||
Bitmap crossLogo;
|
||||
Canvas canvas = this.holder_.lockCanvas();
|
||||
if (canvas != null) {
|
||||
drawImage(canvas, this.paint_, this.paintROI_, this.matrix_, this.dx_, this.dy_, this.width_, this.height_, param);
|
||||
drawMarginBackground(canvas, this.paint_, this.dx_, this.dy_, this.width_, this.height_);
|
||||
if (DeviceController.isRecording()) {
|
||||
drawRecordingTime(canvas, this.paint_, this.dx_, this.dy_, this.width_, this.height_, this.recordingTimeElapsed_.get());
|
||||
}
|
||||
if (MagApplication.magParameter.basePara1.devType == 1 && (crossLogo = param.getMovingCrossLogo()) != null && MagApplication.magParameter.isShowMovingCross) {
|
||||
canvas.drawBitmap(crossLogo, this.aimX_ - (crossLogo.getWidth() / 2), this.aimY_ - (crossLogo.getHeight() / 2), (Paint) null);
|
||||
}
|
||||
this.holder_.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawFps(Canvas canvas, Paint paint, int dx, int dy, int width, int height, int recvFps, int showFps) {
|
||||
Paint p = new Paint();
|
||||
p.setColor(-16711936);
|
||||
p.setTextSize(20.0f);
|
||||
String s = String.format("接收帧率:%s", Integer.valueOf(recvFps));
|
||||
Rect rect = new Rect();
|
||||
p.getTextBounds(s, 0, s.length(), rect);
|
||||
canvas.drawText(s, dx + 2, rect.height() + dy + 2, p);
|
||||
canvas.drawText(String.format("显示帧率:%s", Integer.valueOf(showFps)), dx + 2, ((rect.height() + 2) * 2) + dy, p);
|
||||
}
|
||||
|
||||
private void drawRecordingTime(Canvas canvas, Paint paint, int dx, int dy, int width, int height, long seconds) {
|
||||
long hour = seconds / 3600;
|
||||
long min = (seconds - (3600 * hour)) / 60;
|
||||
long sec = (seconds - (3600 * hour)) - (60 * min);
|
||||
String hms = String.format("%02d", Long.valueOf(hour)) + Config.TRACE_TODAY_VISIT_SPLIT + String.format("%02d", Long.valueOf(min)) + Config.TRACE_TODAY_VISIT_SPLIT + String.format("%02d", Long.valueOf(sec));
|
||||
float oldFontSize = paint.getTextSize();
|
||||
paint.setTextSize(getResources().getDimensionPixelSize(R.dimen.recordingTimeTextSize));
|
||||
int oldFontColor = paint.getColor();
|
||||
paint.setColor(getResources().getColor(R.color.highlightText));
|
||||
Rect rect = new Rect();
|
||||
paint.getTextBounds(hms + "8", 0, hms.length() + 1, rect);
|
||||
canvas.drawText(hms, ((getWidth() - rect.width()) / 2) + dx, (dy + height) - 20, paint);
|
||||
paint.setTextSize(oldFontSize);
|
||||
paint.setColor(oldFontColor);
|
||||
}
|
||||
|
||||
private void drawMarginBackground(Canvas canvas, Paint paint, int dx, int dy, int width, int height) {
|
||||
int oldColor = paint.getColor();
|
||||
paint.setColor(getResources().getColor(R.color.black));
|
||||
canvas.drawRect(0.0f, 0.0f, dx, getHeight(), paint);
|
||||
canvas.drawRect(0.0f, 0.0f, getWidth(), dy, paint);
|
||||
canvas.drawRect(dx + width, 0.0f, getWidth(), getHeight(), paint);
|
||||
canvas.drawRect(0.0f, dy + height, getWidth(), getHeight(), paint);
|
||||
paint.setColor(oldColor);
|
||||
}
|
||||
|
||||
private void drawROIs(Canvas canvas, Paint paint, Paint paintROI, Rect rect, int dx, int dy, int width, int height, OSDParam osdParam) {
|
||||
String format;
|
||||
int[] coor;
|
||||
Bitmap maxTrace = osdParam.getMaxTrace();
|
||||
Bitmap minTrace = osdParam.getMinTrace();
|
||||
int traceType = MagApplication.magParameter.maxMinTrace;
|
||||
if (this.isTempStable_) {
|
||||
format = "%.1f℃";
|
||||
} else {
|
||||
format = "~%.1f℃";
|
||||
}
|
||||
int pad = maxTrace.getWidth() / 6;
|
||||
ROIInfo.lock();
|
||||
try {
|
||||
Iterator<ROIInfo> it = this.listRoi_.iterator();
|
||||
while (it.hasNext()) {
|
||||
ROIInfo roiInfo = it.next();
|
||||
switch (roiInfo.getType()) {
|
||||
case 1:
|
||||
int[] coor2 = DeviceController.clientXY2ScreenXY(roiInfo.getBeginPointX(), roiInfo.getBeginPointY(), width, height);
|
||||
int[] coor22 = DeviceController.clientXY2ScreenXY(roiInfo.getEndPointX(), roiInfo.getEndPointY(), width, height);
|
||||
canvas.drawRect(coor2[0] + dx, coor2[1] + dy, coor22[0] + dx, coor22[1] + dy, paintROI);
|
||||
if (roiInfo.isBigEnouth() && roiInfo.isTempValid()) {
|
||||
if ((traceType == 0 || traceType == 2 || traceType == -1) && (coor = DeviceController.clientPos2ScreenXY(roiInfo.getMaxPos(), width, height)) != null) {
|
||||
canvas.drawBitmap(maxTrace, (coor[0] - (maxTrace.getWidth() / 2)) + dx, (coor[1] - (maxTrace.getHeight() / 2)) + dy, paint);
|
||||
String str = String.format(format, Float.valueOf(roiInfo.getMaxTemp() * 0.001f));
|
||||
paint.getTextBounds(str, 0, str.length(), rect);
|
||||
int cx = rect.width();
|
||||
int cy = rect.height();
|
||||
int x = coor[0] + pad;
|
||||
int y = coor[1] + cy + pad;
|
||||
if (x > width - cx) {
|
||||
x = (coor[0] - pad) - cx;
|
||||
}
|
||||
if (y > height) {
|
||||
y = (coor[1] - pad) - cy;
|
||||
}
|
||||
canvas.drawText(str, x + dx, y + dy, paint);
|
||||
}
|
||||
if (traceType != 1 && traceType != 2) {
|
||||
break;
|
||||
} else {
|
||||
int[] coor3 = DeviceController.clientPos2ScreenXY(roiInfo.getMinPos(), width, height);
|
||||
if (coor3 == null) {
|
||||
break;
|
||||
} else {
|
||||
canvas.drawBitmap(minTrace, (coor3[0] - (minTrace.getWidth() / 2)) + dx, (coor3[1] - (minTrace.getHeight() / 2)) + dy, paint);
|
||||
String str2 = String.format(format, Float.valueOf(roiInfo.getMinTemp() * 0.001f));
|
||||
paint.getTextBounds(str2, 0, str2.length(), rect);
|
||||
int cx2 = rect.width();
|
||||
int cy2 = rect.height();
|
||||
int x2 = coor3[0] + pad;
|
||||
int y2 = coor3[1] + cy2 + pad;
|
||||
if (x2 > width - cx2) {
|
||||
x2 = (coor3[0] - pad) - cx2;
|
||||
}
|
||||
if (y2 > height) {
|
||||
y2 = (coor3[1] - pad) - cy2;
|
||||
}
|
||||
canvas.drawText(str2, x2 + dx, y2 + dy, paint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
ROIInfo.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void drawMaxMin(Canvas canvas, Paint paint, State state, Rect rect, int dx, int dy, int width, int height, OSDParam osdParam) {
|
||||
String format;
|
||||
int[] coor;
|
||||
int[] coor2;
|
||||
Bitmap maxTrace = osdParam.getMaxTrace();
|
||||
Bitmap minTrace = osdParam.getMinTrace();
|
||||
if (this.isTempStable_) {
|
||||
format = "%.1f℃";
|
||||
} else {
|
||||
format = "~%.1f℃";
|
||||
}
|
||||
if (maxTrace != null && minTrace != null) {
|
||||
int pad = maxTrace.getWidth() / 6;
|
||||
int traceType = MagApplication.magParameter.maxMinTrace;
|
||||
if ((traceType == 0 || traceType == 2) && (coor = DeviceController.clientXY2ScreenXY(state.intMaxX, state.intMaxY, width, height)) != null) {
|
||||
canvas.drawBitmap(maxTrace, (coor[0] - (maxTrace.getWidth() / 2)) + dx, (coor[1] - (maxTrace.getHeight() / 2)) + dy, paint);
|
||||
String str = String.format(format, Float.valueOf(state.intMaxTemperature * 0.001f));
|
||||
paint.getTextBounds(str, 0, str.length(), rect);
|
||||
int cx = rect.width();
|
||||
int cy = rect.height();
|
||||
int x = coor[0] + pad;
|
||||
int y = coor[1] + cy + pad;
|
||||
if (x > width - cx) {
|
||||
x = (coor[0] - pad) - cx;
|
||||
}
|
||||
if (y > height) {
|
||||
y = (coor[1] - pad) - cy;
|
||||
}
|
||||
canvas.drawText(str, x + dx, y + dy, paint);
|
||||
}
|
||||
if ((traceType == 1 || traceType == 2) && (coor2 = DeviceController.clientXY2ScreenXY(state.intMinX, state.intMinY, width, height)) != null) {
|
||||
canvas.drawBitmap(minTrace, (coor2[0] - (minTrace.getWidth() / 2)) + dx, (coor2[1] - (minTrace.getHeight() / 2)) + dy, paint);
|
||||
String str2 = String.format(format, Float.valueOf(state.intMinTemperature * 0.001f));
|
||||
paint.getTextBounds(str2, 0, str2.length(), rect);
|
||||
int cx2 = rect.width();
|
||||
int cy2 = rect.height();
|
||||
int x2 = coor2[0] + pad;
|
||||
int y2 = coor2[1] + cy2 + pad;
|
||||
if (x2 > width - cx2) {
|
||||
x2 = (coor2[0] - pad) - cx2;
|
||||
}
|
||||
if (y2 > height) {
|
||||
y2 = (coor2[1] - pad) - cy2;
|
||||
}
|
||||
canvas.drawText(str2, x2 + dx, y2 + dy, paint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void drawImage(Canvas canvas, Paint paint, Paint paintROI, Matrix matrix, int dx, int dy, int width, int height, OSDParam osdParam) {
|
||||
Bitmap laserLogo;
|
||||
Bitmap crossLogo;
|
||||
String str;
|
||||
matrix.reset();
|
||||
Rect rect = new Rect();
|
||||
ThreadLocalParam param = null;
|
||||
switch (DeviceController.getPreviewOrientation()) {
|
||||
case 0:
|
||||
float ratioX = width / this.fpaWidth_;
|
||||
float ratioY = height / this.fpaHeight_;
|
||||
matrix.postScale(ratioX, ratioY, 0.0f, 0.0f);
|
||||
matrix.postTranslate(dx, dy);
|
||||
break;
|
||||
case 90:
|
||||
float ratioX2 = width / this.fpaHeight_;
|
||||
float ratioY2 = height / this.fpaWidth_;
|
||||
matrix.postRotate(90.0f);
|
||||
matrix.postTranslate(this.fpaHeight_ + dx, dy);
|
||||
matrix.postScale(ratioX2, ratioY2, dx, dy);
|
||||
break;
|
||||
case 180:
|
||||
float ratioX3 = width / this.fpaWidth_;
|
||||
float ratioY3 = height / this.fpaHeight_;
|
||||
matrix.postRotate(180.0f, this.fpaWidth_ / 2, this.fpaHeight_ / 2);
|
||||
matrix.postTranslate(dx, dy);
|
||||
matrix.postScale(ratioX3, ratioY3, dx, dy);
|
||||
break;
|
||||
case 270:
|
||||
float ratioX4 = width / this.fpaHeight_;
|
||||
float ratioY4 = height / this.fpaWidth_;
|
||||
matrix.postRotate(-90.0f);
|
||||
matrix.postTranslate(dx, this.fpaWidth_ + dy);
|
||||
matrix.postScale(ratioX4, ratioY4, dx, dy);
|
||||
break;
|
||||
}
|
||||
canvas.setDrawFilter(this.pfd_);
|
||||
DeviceController.Lock();
|
||||
canvas.drawBitmap(this.bmpIr_, matrix, null);
|
||||
try {
|
||||
param = (ThreadLocalParam) this.threadLocalParam_.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} finally {
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
DeviceController.Unlock();
|
||||
MagParameter magParameter = MagApplication.magParameter;
|
||||
if (magParameter.isShowCross && (crossLogo = osdParam.getCrossLogo()) != null) {
|
||||
canvas.drawBitmap(crossLogo, ((width - crossLogo.getWidth()) / 2) + dx, ((height - crossLogo.getHeight()) / 2) + dy, (Paint) null);
|
||||
if (this.isTempStable_) {
|
||||
str = String.format("%.1f℃", Float.valueOf(param.centerTemp * 0.001f));
|
||||
} else {
|
||||
str = String.format("~%.1f℃", Float.valueOf(param.centerTemp * 0.001f));
|
||||
}
|
||||
paint.getTextBounds(str, 0, str.length(), rect);
|
||||
int offset = crossLogo.getWidth() / 6;
|
||||
canvas.drawText(str, (width / 2) + dx + offset, (height / 2) + dy + rect.height() + offset, paint);
|
||||
}
|
||||
if (magParameter.isLaserOn && (laserLogo = osdParam.getLaserLogo()) != null) {
|
||||
int laserPos = magParameter.basePara2.laserPos;
|
||||
int x = laserPos & 255;
|
||||
int y = laserPos >> 16;
|
||||
switch (magParameter.imageEX) {
|
||||
case 1:
|
||||
x = ((x - (this.fpaWidth_ / 2)) * 2) + (this.fpaWidth_ / 2);
|
||||
y = ((y - (this.fpaHeight_ / 2)) * 2) + (this.fpaHeight_ / 2);
|
||||
break;
|
||||
case 2:
|
||||
x = ((x - (this.fpaWidth_ / 2)) * 4) + (this.fpaWidth_ / 2);
|
||||
y = ((y - (this.fpaHeight_ / 2)) * 4) + (this.fpaHeight_ / 2);
|
||||
break;
|
||||
case 3:
|
||||
x = ((x - (this.fpaWidth_ / 2)) * 8) + (this.fpaWidth_ / 2);
|
||||
y = ((y - (this.fpaHeight_ / 2)) * 8) + (this.fpaHeight_ / 2);
|
||||
break;
|
||||
case 4:
|
||||
x = ((x - (this.fpaWidth_ / 2)) * 16) + (this.fpaWidth_ / 2);
|
||||
y = ((y - (this.fpaHeight_ / 2)) * 16) + (this.fpaHeight_ / 2);
|
||||
break;
|
||||
}
|
||||
int[] screenCoor = DeviceController.sensorXY2ScreenXY(x, y, width, height);
|
||||
if ((magParameter.imageFlip & 1) != 0) {
|
||||
screenCoor[0] = (width - 1) - screenCoor[0];
|
||||
}
|
||||
if ((magParameter.imageFlip & 2) != 0) {
|
||||
screenCoor[1] = (height - 1) - screenCoor[1];
|
||||
}
|
||||
canvas.drawBitmap(laserLogo, (screenCoor[0] - (laserLogo.getWidth() / 2)) + dx, (screenCoor[1] - (laserLogo.getHeight() / 2)) + dy, (Paint) null);
|
||||
}
|
||||
if (magParameter.maxMinTrace != -1 && magParameter.isTraceMaxMin && param.state != null) {
|
||||
drawMaxMin(canvas, paint, param.state, rect, dx, dy, width, height, osdParam);
|
||||
}
|
||||
if (magParameter.isTraceRoi) {
|
||||
drawROIs(canvas, paint, paintROI, rect, dx, dy, width, height, osdParam);
|
||||
}
|
||||
Bitmap waterMark = osdParam.getWaterMark();
|
||||
if (waterMark != null) {
|
||||
canvas.drawBitmap(waterMark, ((dx + width) - waterMark.getWidth()) - 8, dy + 8, (Paint) null);
|
||||
}
|
||||
if (MagApplication.isShowFps && this.frameIndex_ > 20) {
|
||||
drawFps(canvas, paint, dx, dy, width, height, UsbCommunication.getReceivedFps(), getShowFps());
|
||||
}
|
||||
}
|
||||
|
||||
private class ThreadRecording extends Thread {
|
||||
private ThreadRecording() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Logging.trace("Enter ThreadRecording.");
|
||||
OSDParam osdParam = new OSDParam();
|
||||
osdParam.setCrossLogo(R.mipmap.cross_capture);
|
||||
osdParam.setWaterMark(R.mipmap.water_mark);
|
||||
osdParam.setMinTrace(R.mipmap.min_trace_capture);
|
||||
osdParam.setMaxTrace(R.mipmap.max_trace_capture);
|
||||
while (!ImageViewer.this.isExitThreadRecording_) {
|
||||
synchronized (ImageViewer.this.condRecording_.cond) {
|
||||
while (!ImageViewer.this.condRecording_.notified) {
|
||||
try {
|
||||
ImageViewer.this.condRecording_.cond.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
ImageViewer.this.condRecording_.notified = false;
|
||||
}
|
||||
if (ImageViewer.this.isExitThreadRecording_) {
|
||||
break;
|
||||
} else if (DeviceController.isRecording()) {
|
||||
ImageViewer.this.drawImage(ImageViewer.this.cachedCanvas_, ImageViewer.this.paintVGA_, ImageViewer.this.paintROIVGA_, ImageViewer.this.matrixVGA_, 0, 0, ImageViewer.this.cachedbmp_.getWidth(), ImageViewer.this.cachedbmp_.getHeight(), osdParam);
|
||||
DeviceController.doRecording(ImageViewer.this.cachedbmp_);
|
||||
}
|
||||
}
|
||||
osdParam.reset();
|
||||
Logging.trace("Leave ThreadRecording.");
|
||||
}
|
||||
}
|
||||
|
||||
private class ThreadRender extends Thread {
|
||||
private ThreadRender() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Logging.trace("Enter ThreadRender.");
|
||||
OSDParam osdParam = new OSDParam();
|
||||
osdParam.setCrossLogo(R.mipmap.cross);
|
||||
osdParam.setMinTrace(R.mipmap.min_trace);
|
||||
osdParam.setMaxTrace(R.mipmap.max_trace);
|
||||
osdParam.setLaserLogo(R.mipmap.laser);
|
||||
osdParam.setMovingCrossLogo(R.mipmap.moving_cross);
|
||||
int frameIndex = -1;
|
||||
long t1 = 0;
|
||||
while (!ImageViewer.this.isExitThreadRender_) {
|
||||
synchronized (ImageViewer.this.waitCondition_.cond) {
|
||||
while (!ImageViewer.this.waitCondition_.notified) {
|
||||
try {
|
||||
ImageViewer.this.waitCondition_.cond.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
ImageViewer.this.waitCondition_.notified = false;
|
||||
}
|
||||
if (ImageViewer.this.isExitThreadRender_) {
|
||||
break;
|
||||
}
|
||||
if (DeviceController.isOutputDataReady()) {
|
||||
ImageViewer.this.doDraw(osdParam);
|
||||
if (MagApplication.isShowFps) {
|
||||
if (t1 == 0) {
|
||||
t1 = System.currentTimeMillis();
|
||||
} else {
|
||||
long t = System.currentTimeMillis();
|
||||
ImageViewer.lock_.lock();
|
||||
ImageViewer.ticks_[frameIndex % ImageViewer.ticks_.length] = t - t1;
|
||||
ImageViewer.lock_.unlock();
|
||||
t1 = t;
|
||||
}
|
||||
}
|
||||
frameIndex++;
|
||||
} else {
|
||||
Logging.trace("draw not ready.");
|
||||
}
|
||||
}
|
||||
osdParam.reset();
|
||||
Logging.trace("Leave ThreadRender.");
|
||||
}
|
||||
}
|
||||
|
||||
private static int getShowFps() {
|
||||
long[] ticks = new long[ticks_.length];
|
||||
lock_.lock();
|
||||
System.arraycopy(ticks_, 0, ticks, 0, ticks_.length);
|
||||
lock_.unlock();
|
||||
int sum = 0;
|
||||
for (int i = ticks.length - 1; i != -1; i--) {
|
||||
sum = (int) (sum + ticks[i]);
|
||||
}
|
||||
return (ticks_.length * 1000) / sum;
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
import android.widget.RelativeLayout;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.SharedPreferencesManager;
|
||||
import cn.com.magnity.magnitycx.sdk.VisibleCamera;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImageViewerVisible extends SurfaceView implements SurfaceHolder.Callback {
|
||||
private SurfaceHolder holder_;
|
||||
private int leftMargin_;
|
||||
private int mouseDownX_;
|
||||
private int mouseDownY_;
|
||||
private int topMargin_;
|
||||
|
||||
public ImageViewerVisible(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
this.holder_ = null;
|
||||
this.holder_ = getHolder();
|
||||
this.holder_.addCallback(this);
|
||||
this.holder_.setFormat(-2);
|
||||
this.holder_.setType(3);
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
int width;
|
||||
int height;
|
||||
this.leftMargin_ = MagApplication.magParameter.visWndLeftMargin;
|
||||
this.topMargin_ = MagApplication.magParameter.visWndTopMargin;
|
||||
switch (MagApplication.magParameter.visWndSize) {
|
||||
case 0:
|
||||
width = ((MagApplication.magParameter.portraitScreenWidth / 4) / 12) * 12;
|
||||
break;
|
||||
case 1:
|
||||
width = ((MagApplication.magParameter.portraitScreenWidth / 3) / 12) * 12;
|
||||
break;
|
||||
case 2:
|
||||
width = ((MagApplication.magParameter.portraitScreenWidth / 2) / 12) * 12;
|
||||
break;
|
||||
default:
|
||||
width = ((MagApplication.magParameter.portraitScreenWidth / 4) / 12) * 12;
|
||||
break;
|
||||
}
|
||||
if (getResources().getConfiguration().orientation == 2) {
|
||||
height = width;
|
||||
width = (height * 4) / 3;
|
||||
VisibleCamera.initCamera(MagApplication.magParameter.visCameraId, this.holder_, height);
|
||||
} else {
|
||||
height = (width * 4) / 3;
|
||||
VisibleCamera.initCamera(MagApplication.magParameter.visCameraId, this.holder_, width);
|
||||
}
|
||||
Point outSize = new Point();
|
||||
MagApplication.windowManager.getDefaultDisplay().getSize(outSize);
|
||||
RelativeLayout layout = (RelativeLayout) getParent();
|
||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
lp.width = width;
|
||||
lp.height = height;
|
||||
if (this.leftMargin_ < 0 || this.leftMargin_ > outSize.x - lp.width) {
|
||||
this.leftMargin_ = outSize.x - lp.width;
|
||||
}
|
||||
if (this.topMargin_ < 0) {
|
||||
this.topMargin_ = 0;
|
||||
} else if (this.topMargin_ > layout.getHeight() - lp.height) {
|
||||
this.topMargin_ = layout.getHeight() - lp.height;
|
||||
}
|
||||
lp.leftMargin = this.leftMargin_;
|
||||
lp.topMargin = this.topMargin_;
|
||||
setLayoutParams(lp);
|
||||
Canvas canvas = this.holder_.lockCanvas();
|
||||
if (canvas != null) {
|
||||
Paint pint = new Paint();
|
||||
pint.setColor(getResources().getColor(R.color.black));
|
||||
canvas.drawRect(0.0f, 0.0f, lp.width, lp.height, pint);
|
||||
this.holder_.unlockCanvasAndPost(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
}
|
||||
|
||||
@Override // android.view.SurfaceHolder.Callback
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
MagApplication.magParameter.visWndLeftMargin = params.leftMargin;
|
||||
MagApplication.magParameter.visWndTopMargin = params.topMargin;
|
||||
SharedPreferencesManager.putInt(MagParameter.KEY_VISWNDLEFTMARGIN, params.leftMargin);
|
||||
SharedPreferencesManager.putInt(MagParameter.KEY_VISWNDTOPMARGIN, params.topMargin);
|
||||
SharedPreferencesManager.commit();
|
||||
VisibleCamera.deinitCamera();
|
||||
}
|
||||
|
||||
@Override // android.view.View
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case 0:
|
||||
this.mouseDownX_ = (int) event.getRawX();
|
||||
this.mouseDownY_ = (int) event.getRawY();
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
this.leftMargin_ = params.leftMargin;
|
||||
this.topMargin_ = params.topMargin;
|
||||
break;
|
||||
case 2:
|
||||
RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
params2.leftMargin = (this.leftMargin_ + ((int) event.getRawX())) - this.mouseDownX_;
|
||||
params2.topMargin = (this.topMargin_ + ((int) event.getRawY())) - this.mouseDownY_;
|
||||
RelativeLayout layout = (RelativeLayout) getParent();
|
||||
if (params2.leftMargin < 0) {
|
||||
params2.leftMargin = 0;
|
||||
} else if (params2.leftMargin > layout.getWidth() - params2.width) {
|
||||
params2.leftMargin = layout.getWidth() - params2.width;
|
||||
}
|
||||
if (params2.topMargin < 0) {
|
||||
params2.topMargin = 0;
|
||||
} else if (params2.topMargin > layout.getHeight() - params2.height) {
|
||||
params2.topMargin = layout.getHeight() - params2.height;
|
||||
}
|
||||
setLayoutParams(params2);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import cn.com.magnity.magnitycx.sdk.MagParameter;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbConnection;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MagApplication extends Application {
|
||||
public static GlobalFunc globalFunc;
|
||||
private static MagApplication instance_;
|
||||
public static MagParameter magParameter;
|
||||
public static WindowManager windowManager;
|
||||
private int counter_;
|
||||
private Handler handler_ = new Handler();
|
||||
private Runnable runnable_ = new Runnable() { // from class: cn.com.magnity.magnitycx.MagApplication.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
UsbConnection.getInstance().deinit(true);
|
||||
UsbConnection.getInstance().setCallbackReceiver(null);
|
||||
}
|
||||
};
|
||||
private static boolean handlerProhibited_ = false;
|
||||
public static boolean isShowFps = false;
|
||||
|
||||
static /* synthetic */ int access$008(MagApplication x0) {
|
||||
int i = x0.counter_;
|
||||
x0.counter_ = i + 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
static /* synthetic */ int access$010(MagApplication x0) {
|
||||
int i = x0.counter_;
|
||||
x0.counter_ = i - 1;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static void setUsbDeinitAllowed(boolean flag) {
|
||||
handlerProhibited_ = !flag;
|
||||
}
|
||||
|
||||
public static MagApplication getInstance() {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
@Override // android.app.Application
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
instance_ = this;
|
||||
magParameter = new MagParameter(this);
|
||||
globalFunc = new GlobalFunc();
|
||||
windowManager = (WindowManager) getSystemService("window");
|
||||
DisplayMetrics metric = new DisplayMetrics();
|
||||
try {
|
||||
windowManager.getDefaultDisplay().getMetrics(metric);
|
||||
} catch (Exception e) {
|
||||
int i = 0 + 1;
|
||||
}
|
||||
switch (getResources().getConfiguration().orientation) {
|
||||
case 1:
|
||||
magParameter.portraitScreenWidth = metric.widthPixels;
|
||||
magParameter.portraitScreenHeight = metric.heightPixels;
|
||||
break;
|
||||
case 2:
|
||||
magParameter.portraitScreenWidth = metric.heightPixels;
|
||||
magParameter.portraitScreenHeight = metric.widthPixels;
|
||||
break;
|
||||
}
|
||||
registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() { // from class: cn.com.magnity.magnitycx.MagApplication.2
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStarted(Activity activity) {
|
||||
MagApplication.access$008(MagApplication.this);
|
||||
if (MagApplication.this.counter_ == 1) {
|
||||
MagApplication.this.handler_.removeCallbacks(MagApplication.this.runnable_);
|
||||
boolean unused = MagApplication.handlerProhibited_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityResumed(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityPaused(Activity activity) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityStopped(Activity activity) {
|
||||
MagApplication.access$010(MagApplication.this);
|
||||
if (MagApplication.this.counter_ == 0 && !MagApplication.handlerProhibited_) {
|
||||
MagApplication.this.handler_.postDelayed(MagApplication.this.runnable_, 500L);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
|
||||
}
|
||||
|
||||
@Override // android.app.Application.ActivityLifecycleCallbacks
|
||||
public void onActivityDestroyed(Activity activity) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.graphics.RectF;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.OrientationEventListener;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import cn.com.magnity.magnitycx.QueryDialogFragment;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import cn.com.magnity.magnitycx.sdk.UsbConnection;
|
||||
import cn.com.magnity.magnitycx.upgrade.UpgradeManager;
|
||||
import cn.com.magnity.magnitycx.util.ActivityUtils;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MainActivity extends AppCompatActivity implements QueryDialogFragment.DelegateQueryResult {
|
||||
private FragmentMainBottom fragmentBottom_;
|
||||
private FragmentMainCenter fragmentCenter_;
|
||||
private FragmentMainTop fragmentTop_;
|
||||
private GestureDetectorCompat gestureDetector_;
|
||||
private boolean mIsLoggingInitSucc;
|
||||
OrientationEventListener orientationListener_;
|
||||
private UpgradeManager upgradeManager_;
|
||||
|
||||
public interface DelegateFling {
|
||||
void afterFling(int i);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onPageStart(getApplicationContext(), "");
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ActivityUtils.requestRuntimePermission(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.ACCESS_FINE_LOCATION", "android.permission.CAMERA"}, 0);
|
||||
this.mIsLoggingInitSucc = Logging.init(Level.INFO);
|
||||
Logging.info("App start");
|
||||
Logging.trace("Main activity created");
|
||||
setContentView(R.layout.activity_main);
|
||||
disableRotationAnimation();
|
||||
overridePendingTransition(0, 0);
|
||||
getWindow().setFormat(-3);
|
||||
StatService.setDebugOn(false);
|
||||
this.orientationListener_ = new OrientationEventListener(this, 2) { // from class: cn.com.magnity.magnitycx.MainActivity.1
|
||||
@Override // android.view.OrientationEventListener
|
||||
public void onOrientationChanged(int orientation) {
|
||||
if (orientation != -1) {
|
||||
int degree = 0;
|
||||
switch (MagApplication.windowManager.getDefaultDisplay().getRotation()) {
|
||||
case 0:
|
||||
degree = 90;
|
||||
break;
|
||||
case 1:
|
||||
degree = 0;
|
||||
break;
|
||||
case 2:
|
||||
degree = 270;
|
||||
break;
|
||||
case 3:
|
||||
degree = 180;
|
||||
break;
|
||||
}
|
||||
if (degree != DeviceController.getPreviewOrientation()) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.setPreviewOrientation(degree);
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (this.orientationListener_.canDetectOrientation()) {
|
||||
this.orientationListener_.enable();
|
||||
} else {
|
||||
this.orientationListener_.disable();
|
||||
int degree = 0;
|
||||
switch (MagApplication.windowManager.getDefaultDisplay().getRotation()) {
|
||||
case 0:
|
||||
degree = 90;
|
||||
break;
|
||||
case 1:
|
||||
degree = 0;
|
||||
break;
|
||||
case 2:
|
||||
degree = 270;
|
||||
break;
|
||||
case 3:
|
||||
degree = 180;
|
||||
break;
|
||||
}
|
||||
DeviceController.Lock();
|
||||
DeviceController.setPreviewOrientation(degree);
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
this.gestureDetector_ = new GestureDetectorCompat(this, new MyGestureListener());
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
this.fragmentTop_ = (FragmentMainTop) fm.findFragmentById(R.id.fragment_container_main_top);
|
||||
if (this.fragmentTop_ == null) {
|
||||
this.fragmentTop_ = new FragmentMainTop();
|
||||
fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).add(R.id.fragment_container_main_top, this.fragmentTop_).commit();
|
||||
}
|
||||
this.fragmentCenter_ = (FragmentMainCenter) fm.findFragmentById(R.id.fragment_container_main_center);
|
||||
if (this.fragmentCenter_ == null) {
|
||||
this.fragmentCenter_ = new FragmentMainCenter();
|
||||
fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).add(R.id.fragment_container_main_center, this.fragmentCenter_).commit();
|
||||
}
|
||||
this.fragmentBottom_ = (FragmentMainBottom) fm.findFragmentById(R.id.fragment_container_main_bottom);
|
||||
if (this.fragmentBottom_ == null) {
|
||||
this.fragmentBottom_ = new FragmentMainBottom();
|
||||
fm.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).add(R.id.fragment_container_main_bottom, this.fragmentBottom_).commit();
|
||||
}
|
||||
UsbConnection usbConn = UsbConnection.getInstance();
|
||||
usbConn.registerObserver(this.fragmentTop_);
|
||||
usbConn.registerObserver(this.fragmentCenter_);
|
||||
usbConn.registerObserver(this.fragmentBottom_);
|
||||
if (savedInstanceState == null) {
|
||||
this.upgradeManager_ = new UpgradeManager(this);
|
||||
this.upgradeManager_.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
UsbConnection usbConn = UsbConnection.getInstance();
|
||||
if (usbConn != null) {
|
||||
usbConn.setCallbackReceiver(this.fragmentCenter_);
|
||||
if (!usbConn.isConnected()) {
|
||||
usbConn.init();
|
||||
} else {
|
||||
usbConn.notifyObervers(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
UsbConnection usbConn = UsbConnection.getInstance();
|
||||
if (usbConn != null) {
|
||||
usbConn.setCallbackReceiver(null);
|
||||
usbConn.deinit(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
Logging.trace("Main activity destroyed");
|
||||
super.onDestroy();
|
||||
this.orientationListener_.disable();
|
||||
UsbConnection usbConn = UsbConnection.getInstance();
|
||||
usbConn.unregisterAll();
|
||||
if (this.upgradeManager_ != null) {
|
||||
this.upgradeManager_.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity, android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
for (int i = 0; i < permissions.length; i++) {
|
||||
String permission = permissions[i];
|
||||
int result = grantResults[i];
|
||||
if (result == 0) {
|
||||
switch (permission) {
|
||||
case "android.permission.WRITE_EXTERNAL_STORAGE":
|
||||
if (this.mIsLoggingInitSucc) {
|
||||
break;
|
||||
} else {
|
||||
this.mIsLoggingInitSucc = Logging.init(Level.INFO);
|
||||
if (this.mIsLoggingInitSucc) {
|
||||
Logging.info("App start");
|
||||
break;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
|
||||
private void disableRotationAnimation() {
|
||||
Window localWindow = getWindow();
|
||||
WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
|
||||
localLayoutParams.rotationAnimation = 2;
|
||||
localWindow.setAttributes(localLayoutParams);
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.QueryDialogFragment.DelegateQueryResult
|
||||
public void onQueryResult(int result) {
|
||||
if (result == 1) {
|
||||
this.fragmentTop_.openLaser();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPageEnd(getApplicationContext(), "��ҳ��");
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.Window.Callback
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
if (this.gestureDetector_ != null && !MagApplication.magParameter.isTraceRoi) {
|
||||
this.gestureDetector_.onTouchEvent(ev);
|
||||
}
|
||||
return super.dispatchTouchEvent(ev);
|
||||
}
|
||||
|
||||
public FragmentMainTop getFragmentMainTop() {
|
||||
return this.fragmentTop_;
|
||||
}
|
||||
|
||||
public FragmentMainCenter getFragmentMainCenter() {
|
||||
return this.fragmentCenter_;
|
||||
}
|
||||
|
||||
public FragmentMainBottom getFragmentMainBottom() {
|
||||
return this.fragmentBottom_;
|
||||
}
|
||||
|
||||
public RectF getRect(int index) {
|
||||
RectF rt = new RectF();
|
||||
LinearLayout layout = null;
|
||||
switch (index) {
|
||||
case 0:
|
||||
layout = (LinearLayout) findViewById(R.id.fragment_container_main_top);
|
||||
break;
|
||||
case 1:
|
||||
layout = (LinearLayout) findViewById(R.id.fragment_container_main_center);
|
||||
break;
|
||||
case 2:
|
||||
layout = (LinearLayout) findViewById(R.id.fragment_container_main_bottom);
|
||||
break;
|
||||
}
|
||||
rt.left = layout.getX();
|
||||
rt.top = layout.getY();
|
||||
rt.right = rt.left + layout.getWidth();
|
||||
rt.bottom = rt.top + layout.getHeight();
|
||||
return rt;
|
||||
}
|
||||
|
||||
private class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
|
||||
private MyGestureListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnDoubleTapListener
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
return super.onDoubleTap(e);
|
||||
}
|
||||
|
||||
@Override // android.view.GestureDetector.SimpleOnGestureListener, android.view.GestureDetector.OnGestureListener
|
||||
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
MainActivity.this.getWindow().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
int resw = outMetrics.widthPixels;
|
||||
int resh = outMetrics.heightPixels;
|
||||
if (resw >= resh) {
|
||||
resw = resh;
|
||||
}
|
||||
int cmp = resw / 4;
|
||||
if (MainActivity.this.getResources().getConfiguration().orientation == 1) {
|
||||
float dist = e2.getX() - e1.getX();
|
||||
if (dist > cmp) {
|
||||
MainActivity.this.fragmentBottom_.afterFling(0);
|
||||
} else if (dist < (-cmp)) {
|
||||
MainActivity.this.fragmentBottom_.afterFling(1);
|
||||
}
|
||||
} else {
|
||||
float dist2 = e2.getY() - e1.getY();
|
||||
if (dist2 > cmp) {
|
||||
MainActivity.this.fragmentBottom_.afterFling(1);
|
||||
} else if (dist2 < cmp) {
|
||||
MainActivity.this.fragmentBottom_.afterFling(0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
import cn.com.magnity.magnitycx.QueryDialogFragment;
|
||||
import cn.com.magnity.magnitycx.sdk.DelegateMediaStatusChanged;
|
||||
import com.baidu.mobstat.StatService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MediaActivity extends AppCompatActivity implements QueryDialogFragment.DelegateQueryResult, DelegateMediaStatusChanged {
|
||||
private Fragment fragment_;
|
||||
|
||||
public interface DelegateBackPressed {
|
||||
boolean onActivityBackPressed();
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_media);
|
||||
cancelDefaultAnimation();
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
this.fragment_ = fm.findFragmentById(R.id.id_space_fragment_media);
|
||||
if (this.fragment_ == null) {
|
||||
this.fragment_ = new FragmentMedia();
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.id_space_fragment_media, this.fragment_).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
cancelDefaultAnimation();
|
||||
StatService.onPageEnd(getApplicationContext(), "媒体页面");
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private void cancelDefaultAnimation() {
|
||||
TypedArray activityStyle = getTheme().obtainStyledAttributes(new int[]{android.R.attr.windowAnimationStyle});
|
||||
int windowAnimationStyleResId = activityStyle.getResourceId(0, 0);
|
||||
activityStyle.recycle();
|
||||
TypedArray activityStyle2 = getTheme().obtainStyledAttributes(windowAnimationStyleResId, new int[]{android.R.attr.activityCloseEnterAnimation, android.R.attr.activityCloseExitAnimation});
|
||||
int activityCloseEnterAnimation = activityStyle2.getResourceId(0, 0);
|
||||
int activityCloseExitAnimation = activityStyle2.getResourceId(1, 0);
|
||||
activityStyle2.recycle();
|
||||
overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onPageStart(getApplicationContext(), "媒体页面");
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.QueryDialogFragment.DelegateQueryResult
|
||||
public void onQueryResult(int result) {
|
||||
if (this.fragment_ instanceof QueryDialogFragment.DelegateQueryResult) {
|
||||
((QueryDialogFragment.DelegateQueryResult) this.fragment_).onQueryResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateMediaStatusChanged
|
||||
public void onSelChanged(int newSelCount, int count) {
|
||||
setTitle(String.format(getResources().getString(R.string.mediaSelectedNum), Integer.valueOf(newSelCount)));
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DelegateMediaStatusChanged
|
||||
public void onModeChanged(int oldMode, int newMode, int count) {
|
||||
if (newMode == 0) {
|
||||
getSupportActionBar().setHomeAsUpIndicator((Drawable) null);
|
||||
setTitle(String.format(getResources().getString(R.string.mediaTitle), Integer.valueOf(count)));
|
||||
} else if (newMode == 1) {
|
||||
getSupportActionBar().setHomeAsUpIndicator(R.mipmap.media_cancel_sel_mode);
|
||||
setTitle(String.format(getResources().getString(R.string.mediaSelectedNum), 1));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
public void onBackPressed() {
|
||||
if (!(this.fragment_ instanceof DelegateBackPressed) || ((DelegateBackPressed) this.fragment_).onActivityBackPressed()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import cn.com.magnity.magnitycx.sdk.BitmapUtilities;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import cn.com.magnity.magnitycx.sdk.LruCacheManager;
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MediaGridViewAdapter extends BaseAdapter {
|
||||
private static final int SAMPLESIZE = 2;
|
||||
private Context context_;
|
||||
private ArrayList<String> fileNames_;
|
||||
private WeakReference<GridView> gridView_;
|
||||
private LayoutInflater layoutInflater_;
|
||||
private Map mapSelStatus_;
|
||||
private int mode_;
|
||||
private LruCacheManager lruCacheManager_ = LruCacheManager.getInstance();
|
||||
private Map mapTask_ = new HashMap();
|
||||
|
||||
public MediaGridViewAdapter(Context context, GridView gridView, ArrayList<String> fileNames, Map mapSelStatus) {
|
||||
this.layoutInflater_ = LayoutInflater.from(context);
|
||||
this.context_ = context;
|
||||
this.gridView_ = new WeakReference<>(gridView);
|
||||
this.fileNames_ = fileNames;
|
||||
this.mapSelStatus_ = mapSelStatus;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public int getCount() {
|
||||
return this.fileNames_.size();
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public Object getItem(int position) {
|
||||
return this.fileNames_.get(position);
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public long getItemId(int position) {
|
||||
return this.fileNames_.get(position).hashCode();
|
||||
}
|
||||
|
||||
public void setMode(int mode) {
|
||||
this.mode_ = mode;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View rootView;
|
||||
if (convertView == null) {
|
||||
rootView = this.layoutInflater_.inflate(R.layout.item_gridview, (ViewGroup) null);
|
||||
} else {
|
||||
rootView = convertView;
|
||||
}
|
||||
String name = this.fileNames_.get(position);
|
||||
ImageView imgView = (ImageView) rootView.findViewById(R.id.id_wallphoto);
|
||||
imgView.setTag(name);
|
||||
ImageView logoView = (ImageView) rootView.findViewById(R.id.id_photo_video);
|
||||
loadCachedBitmapIfExist(imgView, logoView, name);
|
||||
ImageView viewSelLogo = (ImageView) rootView.findViewById(R.id.id_photo_selected);
|
||||
if (this.mode_ == 1) {
|
||||
Object obj = this.mapSelStatus_.get(name);
|
||||
if (obj == null || !((Boolean) obj).booleanValue()) {
|
||||
viewSelLogo.setImageResource(R.mipmap.media_unselected);
|
||||
imgView.setAlpha(1.0f);
|
||||
} else {
|
||||
viewSelLogo.setImageResource(R.mipmap.media_selected);
|
||||
imgView.setAlpha(0.6f);
|
||||
}
|
||||
viewSelLogo.setVisibility(0);
|
||||
} else {
|
||||
viewSelLogo.setVisibility(4);
|
||||
imgView.setAlpha(1.0f);
|
||||
}
|
||||
return rootView;
|
||||
}
|
||||
|
||||
public void loadBitmap(int firstVisiblePos, int visibleCount) {
|
||||
GridView gridView = this.gridView_.get();
|
||||
if (gridView != null) {
|
||||
Iterator iter = this.mapTask_.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) iter.next();
|
||||
int pos = this.fileNames_.indexOf((String) entry.getKey());
|
||||
if (pos < firstVisiblePos) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
for (int i = firstVisiblePos; i < firstVisiblePos + visibleCount; i++) {
|
||||
String name = this.fileNames_.get(i);
|
||||
Bitmap bitmap = this.lruCacheManager_.get(name);
|
||||
if (bitmap != null) {
|
||||
ImageView imageView = (ImageView) gridView.findViewWithTag(name);
|
||||
if (imageView != null && bitmap != null) {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
} else if (((AsyncLoadImageTask) this.mapTask_.get(name)) == null) {
|
||||
int size = gridView.getColumnWidth();
|
||||
AsyncLoadImageTask task = new AsyncLoadImageTask(size, size);
|
||||
this.mapTask_.put(name, task);
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadCachedBitmapIfExist(ImageView imgView, ImageView logoView, String name) {
|
||||
Bitmap bitmap = this.lruCacheManager_.get(name);
|
||||
if (bitmap != null) {
|
||||
imgView.setImageBitmap(bitmap);
|
||||
} else {
|
||||
imgView.setImageResource(R.mipmap.empty_photo);
|
||||
}
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
if (GlobalFunc.guessMediaTypeBySuffix(name) == 1) {
|
||||
logoView.setVisibility(0);
|
||||
} else {
|
||||
logoView.setVisibility(4);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelAllTasks() {
|
||||
for (Map.Entry entry : this.mapTask_.entrySet()) {
|
||||
AsyncLoadImageTask task = (AsyncLoadImageTask) entry.getValue();
|
||||
if (task != null) {
|
||||
task.cancel(false);
|
||||
}
|
||||
}
|
||||
this.mapTask_.clear();
|
||||
}
|
||||
|
||||
private class AsyncLoadImageTask extends AsyncTask<String, Void, Bitmap> {
|
||||
private int height_;
|
||||
private String name_;
|
||||
private int width_;
|
||||
|
||||
public AsyncLoadImageTask(int width, int height) {
|
||||
this.width_ = width;
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public Bitmap doInBackground(String... params) {
|
||||
this.name_ = params[0];
|
||||
Bitmap bitmap = BitmapUtilities.getBitmapThumbnail(MagApplication.magParameter.mediaDir + File.separator + this.name_, this.width_, this.height_);
|
||||
if (bitmap != null) {
|
||||
MediaGridViewAdapter.this.lruCacheManager_.put(this.name_, bitmap);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.os.AsyncTask
|
||||
public void onPostExecute(Bitmap bitmap) {
|
||||
ImageView imageView;
|
||||
super.onPostExecute((AsyncLoadImageTask) bitmap);
|
||||
if (!isCancelled()) {
|
||||
GridView gridView = (GridView) MediaGridViewAdapter.this.gridView_.get();
|
||||
if (gridView != null && (imageView = (ImageView) gridView.findViewWithTag(this.name_)) != null && bitmap != null) {
|
||||
imageView.setImageBitmap(bitmap);
|
||||
}
|
||||
MediaGridViewAdapter.this.mapTask_.remove(this.name_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.ImageView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MediaImageView extends ImageView {
|
||||
public MediaImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override // android.widget.ImageView, android.view.View
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
setMeasuredDimension(widthMeasureSpec, widthMeasureSpec);
|
||||
}
|
||||
}
|
||||
+445
@@ -0,0 +1,445 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.ExifInterface;
|
||||
import android.media.MediaMetadataRetriever;
|
||||
import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import android.support.v4.media.session.PlaybackStateCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Toast;
|
||||
import cn.com.magnity.magnitycx.QueryDialogFragment;
|
||||
import cn.com.magnity.magnitycx.sdk.BitmapUtilities;
|
||||
import cn.com.magnity.magnitycx.sdk.GlobalFunc;
|
||||
import com.baidu.mobstat.StatService;
|
||||
import java.io.File;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MediaSingleActivity extends AppCompatActivity implements QueryDialogFragment.DelegateQueryResult {
|
||||
public static final String MEDIAINDEX = "mediaIndex";
|
||||
public static final String MEDIANAMELIST = "mediaNameList";
|
||||
public static final String MEDIAWINDOWFLAG = "mediaWindowFlag";
|
||||
private Button btnDel_;
|
||||
private Button btnInfo_;
|
||||
private Button btnShare_;
|
||||
private int currentIndex_;
|
||||
private ArrayList<String> fileNames_;
|
||||
private boolean isVideo_;
|
||||
private MagClickListener magClickListener_;
|
||||
private int mediaWindowFlag_;
|
||||
private ViewPager viewPager_;
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_media_single);
|
||||
if (savedInstanceState != null) {
|
||||
this.mediaWindowFlag_ = savedInstanceState.getInt(MEDIAWINDOWFLAG);
|
||||
this.currentIndex_ = savedInstanceState.getInt(MEDIAINDEX);
|
||||
this.fileNames_ = savedInstanceState.getStringArrayList(MEDIANAMELIST);
|
||||
} else {
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
this.mediaWindowFlag_ = intent.getIntExtra(MEDIAWINDOWFLAG, 0);
|
||||
this.currentIndex_ = intent.getIntExtra(MEDIAINDEX, 0);
|
||||
this.fileNames_ = intent.getStringArrayListExtra(MEDIANAMELIST);
|
||||
} else {
|
||||
this.mediaWindowFlag_ = 0;
|
||||
this.currentIndex_ = 0;
|
||||
this.fileNames_ = new ArrayList<>();
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
GlobalFunc.updateFileList(this.fileNames_);
|
||||
}
|
||||
}
|
||||
setTitle(getResources().getString(R.string.mediaHouse) + " " + Integer.toString(this.currentIndex_ + 1) + "/" + this.fileNames_.size());
|
||||
this.btnShare_ = (Button) findViewById(R.id.id_btn_social_share);
|
||||
this.btnInfo_ = (Button) findViewById(R.id.id_btn_meida_info);
|
||||
this.btnDel_ = (Button) findViewById(R.id.id_btn_media_delete);
|
||||
this.viewPager_ = (ViewPager) findViewById(R.id.id_media_viewpager);
|
||||
this.viewPager_.setAdapter(new MediaPageAdapter());
|
||||
this.viewPager_.addOnPageChangeListener(new MediaPageListener());
|
||||
this.viewPager_.setPageMargin(30);
|
||||
this.viewPager_.setCurrentItem(this.currentIndex_);
|
||||
this.viewPager_.setPageTransformer(true, new DepthPageTransformer());
|
||||
if (this.currentIndex_ < this.fileNames_.size()) {
|
||||
GlobalFunc globalFunc2 = MagApplication.globalFunc;
|
||||
this.isVideo_ = GlobalFunc.guessMediaTypeBySuffix(this.fileNames_.get(this.currentIndex_)) == 1;
|
||||
}
|
||||
this.magClickListener_ = new MagClickListener();
|
||||
this.btnShare_.setOnClickListener(this.magClickListener_);
|
||||
this.btnInfo_.setOnClickListener(this.magClickListener_);
|
||||
this.btnDel_.setOnClickListener(this.magClickListener_);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPageEnd(getApplicationContext(), "单个媒体页面");
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
showInfoWhenFileNotExist();
|
||||
StatService.onPageStart(getApplicationContext(), "单个媒体页面");
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void showInfoWhenFileNotExist() {
|
||||
File file = new File(MagApplication.magParameter.mediaDir + File.separator + this.fileNames_.get(this.currentIndex_));
|
||||
if (file != null && !file.exists()) {
|
||||
Toast.makeText(getApplicationContext(), R.string.fileDeleted, 0).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(MEDIAWINDOWFLAG, this.mediaWindowFlag_);
|
||||
outState.putInt(MEDIAINDEX, this.currentIndex_);
|
||||
outState.putStringArrayList(MEDIANAMELIST, this.fileNames_);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.meida_single_menu, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.id_action_media_expand /* 2131624225 */:
|
||||
if (this.mediaWindowFlag_ == 1) {
|
||||
super.onBackPressed();
|
||||
break;
|
||||
} else {
|
||||
finish();
|
||||
Intent intent = new Intent(this, (Class<?>) MediaActivity.class);
|
||||
startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public Bitmap decodeBitmap(String pathName) {
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.outWidth = 0;
|
||||
opts.outHeight = 0;
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
Point outSize = new Point();
|
||||
MagApplication.windowManager.getDefaultDisplay().getSize(outSize);
|
||||
int r1 = ((opts.outWidth - 1) / outSize.x) + 1;
|
||||
int r2 = ((opts.outHeight - 1) / outSize.y) + 1;
|
||||
opts.inSampleSize = Math.max(Math.max(r1, r2), 1);
|
||||
opts.inJustDecodeBounds = false;
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(pathName, opts);
|
||||
if (bitmap == null) {
|
||||
return ThumbnailUtils.createVideoThumbnail(pathName, 1);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
private File getMediaStoragePath(Context context) {
|
||||
File file;
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ("mounted".equals(state) && (file = new File(Environment.getExternalStorageDirectory(), "magnity/Cx/media")) != null) {
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
return file;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void socialShare() {
|
||||
Uri uri;
|
||||
File f = new File(getMediaStoragePath(this), this.fileNames_.get(this.currentIndex_));
|
||||
if (f != null && f.isFile() && (uri = FileProvider.getUriForFile(this, "cn.com.magnity.magnitycx.fileprovider", f)) != null) {
|
||||
Intent intent = new Intent("android.intent.action.SEND");
|
||||
intent.setType(this.isVideo_ ? "video/*" : "image/*");
|
||||
intent.putExtra("android.intent.extra.STREAM", uri);
|
||||
intent.addFlags(1);
|
||||
startActivity(Intent.createChooser(intent, getResources().getString(R.string.mediaSocialShare)));
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> getMediaInfos() {
|
||||
File f;
|
||||
Point pt;
|
||||
ArrayList<String> infos = new ArrayList<>();
|
||||
String time = null;
|
||||
String size = null;
|
||||
String reso = null;
|
||||
String duration = null;
|
||||
String name = this.fileNames_.get(this.currentIndex_);
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + name;
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
int mediaType = GlobalFunc.guessMediaTypeBySuffix(name);
|
||||
if (mediaType == 0) {
|
||||
try {
|
||||
ExifInterface exifInterface = new ExifInterface(pathName);
|
||||
time = exifInterface.getAttribute("DateTimeDigitized");
|
||||
size = null;
|
||||
reso = null;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
} else if (mediaType == 1) {
|
||||
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
|
||||
try {
|
||||
mmr.setDataSource(pathName);
|
||||
time = null;
|
||||
size = null;
|
||||
String w = mmr.extractMetadata(18);
|
||||
String h = mmr.extractMetadata(19);
|
||||
if (w != null && h != null && w != "0" && h != "0") {
|
||||
reso = w + " x " + h;
|
||||
}
|
||||
duration = mmr.extractMetadata(9);
|
||||
if (duration != null) {
|
||||
long sec = Integer.parseInt(duration) / 1000;
|
||||
long hour = sec / 3600;
|
||||
long min = (sec - (3600 * hour)) / 60;
|
||||
duration = String.format("%02d:%02d:%02d", Long.valueOf(hour), Long.valueOf(min), Long.valueOf((sec - (3600 * hour)) - (60 * min)));
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
}
|
||||
} else {
|
||||
time = null;
|
||||
size = null;
|
||||
reso = null;
|
||||
}
|
||||
if ((time == null || size == null || reso == null) && (f = new File(pathName)) != null && f.isFile()) {
|
||||
if (time == null) {
|
||||
Date dt = new Date(f.lastModified());
|
||||
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
time = ft.format(dt);
|
||||
}
|
||||
if (size == null) {
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
long bytes = f.length();
|
||||
if (bytes < PlaybackStateCompat.ACTION_PLAY_FROM_MEDIA_ID) {
|
||||
size = df.format(bytes) + "B";
|
||||
} else if (bytes < 1048576) {
|
||||
size = df.format(bytes / 1024.0f) + "KB";
|
||||
} else {
|
||||
size = df.format(bytes / 1048576.0f) + "MB";
|
||||
}
|
||||
}
|
||||
if (reso == null && (pt = BitmapUtilities.getBitmapSize(pathName)) != null) {
|
||||
reso = pt.x + " x " + pt.y;
|
||||
}
|
||||
}
|
||||
if (mediaType == 1) {
|
||||
infos.add("1");
|
||||
} else {
|
||||
infos.add("0");
|
||||
}
|
||||
infos.add(name);
|
||||
infos.add(time);
|
||||
infos.add(size);
|
||||
infos.add(duration);
|
||||
infos.add(reso);
|
||||
infos.add(pathName);
|
||||
return infos;
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.QueryDialogFragment.DelegateQueryResult
|
||||
public void onQueryResult(int result) {
|
||||
if (result == 1) {
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + this.fileNames_.get(this.currentIndex_);
|
||||
File f = new File(pathName);
|
||||
if (f != null && f.isFile()) {
|
||||
f.delete();
|
||||
this.fileNames_.remove(this.currentIndex_);
|
||||
File f2 = new File(pathName.replace(".jpg", ".ddt"));
|
||||
if (f2 != null && f2.isFile()) {
|
||||
f2.delete();
|
||||
}
|
||||
if (this.fileNames_.isEmpty()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
this.viewPager_.setAdapter(new MediaPageAdapter());
|
||||
if (this.currentIndex_ > this.fileNames_.size() - 1) {
|
||||
this.viewPager_.setCurrentItem(this.currentIndex_ - 1);
|
||||
} else {
|
||||
this.viewPager_.setCurrentItem(this.currentIndex_);
|
||||
}
|
||||
showInfoWhenFileNotExist();
|
||||
setTitle(getResources().getString(R.string.mediaHouse) + " " + Integer.toString(this.currentIndex_ + 1) + "/" + this.fileNames_.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MagClickListener implements View.OnClickListener {
|
||||
private MagClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.id_btn_social_share /* 2131624072 */:
|
||||
MediaSingleActivity.this.socialShare();
|
||||
break;
|
||||
case R.id.id_btn_meida_info /* 2131624073 */:
|
||||
DialogFragmentMediaInfo dlgMediaInfo = DialogFragmentMediaInfo.newInstance(MediaSingleActivity.this.getMediaInfos());
|
||||
dlgMediaInfo.show(MediaSingleActivity.this.getSupportFragmentManager(), "dialogFragmentMediaInfo");
|
||||
break;
|
||||
case R.id.id_btn_media_delete /* 2131624074 */:
|
||||
QueryDialogFragment dlgMediaDel = QueryDialogFragment.newInstance(R.layout.dialog_fragment_query_delete_media);
|
||||
dlgMediaDel.show(MediaSingleActivity.this.getSupportFragmentManager(), "deleteMedia");
|
||||
break;
|
||||
case R.id.id_img_single /* 2131624185 */:
|
||||
if (MediaSingleActivity.this.isVideo_) {
|
||||
Intent intent = new Intent("android.intent.action.VIEW");
|
||||
String pathName = MagApplication.magParameter.mediaDir + File.separator + ((String) MediaSingleActivity.this.fileNames_.get(MediaSingleActivity.this.currentIndex_));
|
||||
intent.setDataAndType(Uri.parse("file:///" + pathName), "video/*");
|
||||
MagApplication.setUsbDeinitAllowed(false);
|
||||
if (intent.resolveActivity(MediaSingleActivity.this.getPackageManager()) != null) {
|
||||
MediaSingleActivity.this.startActivity(intent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class MediaPageAdapter extends PagerAdapter {
|
||||
private MediaPageAdapter() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public int getCount() {
|
||||
return MediaSingleActivity.this.fileNames_.size();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
private void releaseImageViewResouce(ImageView imageView) {
|
||||
Drawable drawable;
|
||||
if (imageView != null && (drawable = imageView.getDrawable()) != null && (drawable instanceof BitmapDrawable)) {
|
||||
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
|
||||
Bitmap bitmap = bitmapDrawable.getBitmap();
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public void destroyItem(ViewGroup container, int position, Object object) {
|
||||
View view = (View) object;
|
||||
if (view != null) {
|
||||
releaseImageViewResouce((ImageView) view.findViewById(R.id.id_img_single));
|
||||
container.removeView(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.PagerAdapter
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
View view = MediaSingleActivity.this.getLayoutInflater().inflate(R.layout.include_media_single, (ViewGroup) null);
|
||||
String name = (String) MediaSingleActivity.this.fileNames_.get(position);
|
||||
ImageView img = (ImageView) view.findViewById(R.id.id_img_single);
|
||||
img.setImageBitmap(MediaSingleActivity.this.decodeBitmap(MagApplication.magParameter.mediaDir + File.separator + ((String) MediaSingleActivity.this.fileNames_.get(position))));
|
||||
ImageView videoLogo = (ImageView) view.findViewById(R.id.id_video_play_logo);
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
int type = GlobalFunc.guessMediaTypeBySuffix(name);
|
||||
if (type == 1) {
|
||||
videoLogo.setVisibility(0);
|
||||
} else {
|
||||
videoLogo.setVisibility(4);
|
||||
}
|
||||
img.setOnClickListener(MediaSingleActivity.this.magClickListener_);
|
||||
container.addView(view);
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
private class MediaPageListener implements ViewPager.OnPageChangeListener {
|
||||
private MediaPageListener() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.OnPageChangeListener
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.OnPageChangeListener
|
||||
public void onPageSelected(int position) {
|
||||
MediaSingleActivity.this.currentIndex_ = position;
|
||||
MediaSingleActivity mediaSingleActivity = MediaSingleActivity.this;
|
||||
GlobalFunc globalFunc = MagApplication.globalFunc;
|
||||
mediaSingleActivity.isVideo_ = GlobalFunc.guessMediaTypeBySuffix((String) MediaSingleActivity.this.fileNames_.get(position)) == 1;
|
||||
MediaSingleActivity.this.setTitle(MediaSingleActivity.this.getResources().getString(R.string.mediaHouse) + " " + Integer.toString(position + 1) + "/" + MediaSingleActivity.this.fileNames_.size());
|
||||
MediaSingleActivity.this.showInfoWhenFileNotExist();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.OnPageChangeListener
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
}
|
||||
}
|
||||
|
||||
public class DepthPageTransformer implements ViewPager.PageTransformer {
|
||||
private static final float MIN_SCALE = 0.75f;
|
||||
|
||||
public DepthPageTransformer() {
|
||||
}
|
||||
|
||||
@Override // android.support.v4.view.ViewPager.PageTransformer
|
||||
public void transformPage(View view, float position) {
|
||||
int pageWidth = view.getWidth();
|
||||
if (position < -1.0f) {
|
||||
view.setAlpha(0.0f);
|
||||
return;
|
||||
}
|
||||
if (position <= 0.0f) {
|
||||
view.setAlpha(1.0f);
|
||||
view.setTranslationX(0.0f);
|
||||
view.setScaleX(1.0f);
|
||||
view.setScaleY(1.0f);
|
||||
return;
|
||||
}
|
||||
if (position <= 1.0f) {
|
||||
view.setAlpha(1.0f - position);
|
||||
view.setTranslationX(pageWidth * (-position));
|
||||
float scaleFactor = MIN_SCALE + (0.25f * (1.0f - Math.abs(position)));
|
||||
view.setScaleX(scaleFactor);
|
||||
view.setScaleY(scaleFactor);
|
||||
return;
|
||||
}
|
||||
view.setAlpha(0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class QueryDialogFragment extends DialogFragment {
|
||||
private static final String RESID = "resid";
|
||||
private MagOnClickListener magOnClickListener_;
|
||||
private int resId_;
|
||||
|
||||
public interface DelegateQueryResult {
|
||||
void onQueryResult(int i);
|
||||
}
|
||||
|
||||
public static QueryDialogFragment newInstance(int resId) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(RESID, resId);
|
||||
QueryDialogFragment dlg = new QueryDialogFragment();
|
||||
dlg.setArguments(bundle);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment, android.support.v4.app.Fragment
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle bundle = getArguments();
|
||||
if (bundle != null) {
|
||||
this.resId_ = bundle.getInt(RESID);
|
||||
}
|
||||
this.magOnClickListener_ = new MagOnClickListener();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.DialogFragment
|
||||
@NonNull
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(this.resId_, (ViewGroup) null);
|
||||
Button btnCancel = (Button) view.findViewById(R.id.id_btn_cancel);
|
||||
Button btnOk = (Button) view.findViewById(R.id.id_btn_ok);
|
||||
btnCancel.setOnClickListener(this.magOnClickListener_);
|
||||
btnOk.setOnClickListener(this.magOnClickListener_);
|
||||
builder.setView(view);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
private class MagOnClickListener implements View.OnClickListener {
|
||||
private MagOnClickListener() {
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View v) {
|
||||
int result = 0;
|
||||
switch (v.getId()) {
|
||||
case R.id.id_btn_ok /* 2131624096 */:
|
||||
result = 1;
|
||||
break;
|
||||
case R.id.id_btn_cancel /* 2131624106 */:
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
if (QueryDialogFragment.this.getActivity() instanceof DelegateQueryResult) {
|
||||
((DelegateQueryResult) QueryDialogFragment.this.getActivity()).onQueryResult(result);
|
||||
}
|
||||
QueryDialogFragment.this.dismiss();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,127 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ROIInfo {
|
||||
public static final int TYPE_POINT = 0;
|
||||
public static final int TYPE_RECT = 1;
|
||||
private static volatile Lock lock = new ReentrantLock();
|
||||
private int aveTemp_;
|
||||
private int maxTempPos_;
|
||||
private int maxTemp_;
|
||||
private int minTempPos_;
|
||||
private int minTemp_;
|
||||
public String name;
|
||||
private int type_;
|
||||
private int x0_;
|
||||
private int x1_;
|
||||
private int y0_;
|
||||
private int y1_;
|
||||
private boolean isFinished_ = false;
|
||||
private boolean isBigEnouth_ = false;
|
||||
private boolean isTempValid_ = false;
|
||||
|
||||
public ROIInfo(int type) {
|
||||
this.type_ = type;
|
||||
}
|
||||
|
||||
public void setBeginPoint(int x0, int y0) {
|
||||
this.x0_ = x0;
|
||||
this.y0_ = y0;
|
||||
this.isBigEnouth_ = false;
|
||||
this.isFinished_ = false;
|
||||
}
|
||||
|
||||
public void translate(int dx, int dy) {
|
||||
this.x0_ += dx;
|
||||
this.y0_ += dy;
|
||||
this.x1_ += dx;
|
||||
this.y1_ += dy;
|
||||
}
|
||||
|
||||
public void setEndPoint(int x1, int y1) {
|
||||
this.x1_ = x1;
|
||||
this.y1_ = y1;
|
||||
int limit = MagApplication.magParameter.basePara1.fpaWidth / 12;
|
||||
if (Math.abs(this.x1_ - this.x0_) > limit && Math.abs(this.y1_ - this.y0_) > limit) {
|
||||
this.isBigEnouth_ = true;
|
||||
} else {
|
||||
this.isBigEnouth_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTempInfo(int minTemp, int maxTemp, int aveTemp, int minPos, int maxPos) {
|
||||
this.maxTemp_ = maxTemp;
|
||||
this.minTemp_ = minTemp;
|
||||
this.aveTemp_ = aveTemp;
|
||||
this.maxTempPos_ = maxPos;
|
||||
this.minTempPos_ = minPos;
|
||||
this.isTempValid_ = true;
|
||||
}
|
||||
|
||||
public boolean isPointIn(int x, int y) {
|
||||
return x < this.x1_ && x > this.x0_ && y < this.y1_ && y > this.y0_;
|
||||
}
|
||||
|
||||
public void setFinished() {
|
||||
this.isFinished_ = true;
|
||||
}
|
||||
|
||||
public int getBeginPointX() {
|
||||
return this.x0_ > this.x1_ ? this.x1_ : this.x0_;
|
||||
}
|
||||
|
||||
public int getBeginPointY() {
|
||||
return this.y0_ > this.y1_ ? this.y1_ : this.y0_;
|
||||
}
|
||||
|
||||
public int getEndPointX() {
|
||||
return this.x0_ > this.x1_ ? this.x0_ : this.x1_;
|
||||
}
|
||||
|
||||
public int getEndPointY() {
|
||||
return this.y0_ > this.y1_ ? this.y0_ : this.y1_;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return this.type_;
|
||||
}
|
||||
|
||||
public int getMaxTemp() {
|
||||
return this.maxTemp_;
|
||||
}
|
||||
|
||||
public int getMinTemp() {
|
||||
return this.minTemp_;
|
||||
}
|
||||
|
||||
public int getMaxPos() {
|
||||
return this.maxTempPos_;
|
||||
}
|
||||
|
||||
public int getMinPos() {
|
||||
return this.minTempPos_;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return this.isFinished_;
|
||||
}
|
||||
|
||||
public boolean isBigEnouth() {
|
||||
return this.isBigEnouth_;
|
||||
}
|
||||
|
||||
public boolean isTempValid() {
|
||||
return this.isTempValid_;
|
||||
}
|
||||
|
||||
public static void lock() {
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
public static void unlock() {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
import com.baidu.mobstat.StatService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SettingActivity extends AppCompatActivity {
|
||||
FragmentSetting fragmentSetting_;
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_setting);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
setTitle(R.string.labelSetting);
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
Fragment fragment = fm.findFragmentById(R.id.id_space_fragment_setting);
|
||||
if (fragment == null) {
|
||||
this.fragmentSetting_ = new FragmentSetting();
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.id_space_fragment_setting, this.fragmentSetting_).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onPageStart(getApplicationContext(), "设置主界面");
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPageEnd(getApplicationContext(), "设置主界面");
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
import com.baidu.mobstat.StatService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StoreActivity extends AppCompatActivity {
|
||||
ViewGroup mLayout;
|
||||
WebView mWebView;
|
||||
|
||||
public static void actionStart(Context ctx, String uri) {
|
||||
Intent intent = new Intent(ctx, (Class<?>) StoreActivity.class);
|
||||
intent.putExtra("uri", uri);
|
||||
ctx.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_store);
|
||||
this.mLayout = (ViewGroup) findViewById(R.id.id_layout);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(-1, -1);
|
||||
this.mWebView = new WebView(getApplicationContext());
|
||||
WebSettings webSettings = this.mWebView.getSettings();
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setSupportZoom(true);
|
||||
webSettings.setBuiltInZoomControls(true);
|
||||
webSettings.setDisplayZoomControls(false);
|
||||
webSettings.setCacheMode(1);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setAllowFileAccess(true);
|
||||
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||
webSettings.setLoadsImagesAutomatically(true);
|
||||
webSettings.setDefaultTextEncodingName("utf-8");
|
||||
this.mWebView.setWebViewClient(new WebViewClient() { // from class: cn.com.magnity.magnitycx.StoreActivity.1
|
||||
@Override // android.webkit.WebViewClient
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
view.loadUrl(url);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // android.webkit.WebViewClient
|
||||
public void onPageCommitVisible(WebView view, String url) {
|
||||
StoreActivity.this.setTitle(StoreActivity.this.mWebView.getTitle());
|
||||
super.onPageCommitVisible(view, url);
|
||||
}
|
||||
});
|
||||
this.mWebView.setLayoutParams(params);
|
||||
this.mLayout.addView(this.mWebView);
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
if (bundle != null) {
|
||||
this.mWebView.loadUrl(bundle.getString("uri"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
this.mWebView.saveState(outState);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
super.onRestoreInstanceState(savedInstanceState);
|
||||
this.mWebView.restoreState(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
this.mWebView.getSettings().setJavaScriptEnabled(true);
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onStop() {
|
||||
this.mWebView.getSettings().setJavaScriptEnabled(false);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPageEnd(getApplicationContext(), "微商");
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onPageStart(getApplicationContext(), "微商");
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
if (this.mWebView != null) {
|
||||
this.mWebView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
|
||||
this.mWebView.clearHistory();
|
||||
this.mLayout.removeView(this.mWebView);
|
||||
this.mWebView.destroy();
|
||||
this.mWebView = null;
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode != 4 || !this.mWebView.canGoBack()) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
this.mWebView.getSettings().setCacheMode(3);
|
||||
this.mWebView.goBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.about_menu, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.id_cancel /* 2131624224 */:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package cn.com.magnity.magnitycx;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MenuItem;
|
||||
import com.baidu.mobstat.StatService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SupportActivity extends AppCompatActivity {
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.support.v4.app.BaseFragmentActivityGingerbread, android.app.Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_support);
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
Fragment fragment = fm.findFragmentById(R.id.id_space_fragment_setting);
|
||||
if (fragment == null) {
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.id_space_fragment, new FragmentSupport()).commit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPostResume() {
|
||||
super.onPostResume();
|
||||
StatService.onResume(this);
|
||||
}
|
||||
|
||||
@Override // android.support.v4.app.FragmentActivity, android.app.Activity
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
StatService.onPause(this);
|
||||
}
|
||||
|
||||
public void showHelp() {
|
||||
getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.id_space_fragment, new FragmentSupportHelp()).commit();
|
||||
}
|
||||
|
||||
public void showAbout() {
|
||||
getSupportFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.id_space_fragment, new FragmentSupportAbout()).commit();
|
||||
}
|
||||
|
||||
@Override // android.app.Activity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
super.onBackPressed();
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package cn.com.magnity.magnitycx.log;
|
||||
|
||||
import android.os.Build;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.apache.log4j.FileAppender;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Logging {
|
||||
private static Logger logger_ = null;
|
||||
|
||||
public static void trace(Object msg) {
|
||||
if (logger_ != null) {
|
||||
logger_.trace(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void debug(Object msg) {
|
||||
if (logger_ != null) {
|
||||
logger_.debug(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void info(Object msg) {
|
||||
if (logger_ != null) {
|
||||
logger_.info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void warn(Object msg) {
|
||||
if (logger_ != null) {
|
||||
logger_.warn(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(Object msg) {
|
||||
if (logger_ != null) {
|
||||
logger_.error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fatal(Object msg) {
|
||||
if (logger_ != null) {
|
||||
logger_.fatal(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean init(Level level) {
|
||||
if (MagApplication.magParameter.logDir.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
String pathName = MagApplication.magParameter.logDir + File.separator + (Build.MODEL + "-Android_" + Build.VERSION.RELEASE + "_" + Build.VERSION.SDK_INT) + ".log";
|
||||
try {
|
||||
PatternLayout patternLayout = new PatternLayout();
|
||||
patternLayout.setConversionPattern("%d{yyyy-MM-dd HH:mm:ss} -%-5.5p- %m %n");
|
||||
FileAppender fileAppender = new FileAppender(patternLayout, pathName);
|
||||
logger_ = Logger.getLogger(Logging.class);
|
||||
logger_.addAppender(fileAppender);
|
||||
logger_.setLevel(level);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
logger_ = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AsyncLoadImage {
|
||||
private static final int MSG = 305419896;
|
||||
private Handler[] handlers_;
|
||||
private String imageDir_;
|
||||
private volatile int maxTaskLen = Integer.MAX_VALUE;
|
||||
private Object receiver_;
|
||||
private volatile boolean running_;
|
||||
private volatile ArrayList<String> taskList;
|
||||
private volatile ArrayList<String> taskList_;
|
||||
private ImageLoaderThread[] threads_;
|
||||
private WaitCondition wcObj_;
|
||||
|
||||
public interface DelegateExecute {
|
||||
Object onBackToDo(Object obj);
|
||||
|
||||
void onExecuteFinished(Object obj);
|
||||
}
|
||||
|
||||
public AsyncLoadImage(String imageDir, int threadNum, Object receiver) {
|
||||
this.receiver_ = receiver;
|
||||
this.imageDir_ = imageDir;
|
||||
this.threads_ = new ImageLoaderThread[threadNum];
|
||||
ImageLoaderThread[] imageLoaderThreadArr = this.threads_;
|
||||
int length = imageLoaderThreadArr.length;
|
||||
int i = 0;
|
||||
int index = 0;
|
||||
while (i < length) {
|
||||
ImageLoaderThread imageLoaderThread = imageLoaderThreadArr[i];
|
||||
ImageLoaderThread thread = new ImageLoaderThread(index);
|
||||
thread.start();
|
||||
i++;
|
||||
index++;
|
||||
}
|
||||
this.wcObj_ = new WaitCondition();
|
||||
this.taskList_ = new ArrayList<>();
|
||||
for (Handler handler : this.handlers_) {
|
||||
new Handler() { // from class: cn.com.magnity.magnitycx.sdk.AsyncLoadImage.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case AsyncLoadImage.MSG /* 305419896 */:
|
||||
if (AsyncLoadImage.this.receiver_ instanceof DelegateExecute) {
|
||||
((DelegateExecute) AsyncLoadImage.this.receiver_).onExecuteFinished(msg.obj);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.handleMessage(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String name) {
|
||||
synchronized (this.wcObj_.cond) {
|
||||
if (!this.taskList_.contains(name)) {
|
||||
if (this.taskList_.size() > this.maxTaskLen) {
|
||||
}
|
||||
if (!this.taskList_.contains(name)) {
|
||||
this.taskList_.add(name);
|
||||
this.wcObj_.notified = true;
|
||||
this.wcObj_.cond.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTaskQueueLen(int len) {
|
||||
synchronized (this.wcObj_.cond) {
|
||||
this.maxTaskLen = len;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAll() {
|
||||
synchronized (this.wcObj_.cond) {
|
||||
this.taskList_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
this.running_ = false;
|
||||
synchronized (this.wcObj_.cond) {
|
||||
this.wcObj_.notified = true;
|
||||
this.wcObj_.cond.notifyAll();
|
||||
}
|
||||
try {
|
||||
for (ImageLoaderThread thread : this.threads_) {
|
||||
thread.join();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
private class ImageLoaderThread extends Thread {
|
||||
private int index_;
|
||||
|
||||
public ImageLoaderThread(int index) {
|
||||
this.index_ = index;
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
while (AsyncLoadImage.this.running_) {
|
||||
synchronized (AsyncLoadImage.this.wcObj_.cond) {
|
||||
while (!AsyncLoadImage.this.wcObj_.notified) {
|
||||
try {
|
||||
AsyncLoadImage.this.wcObj_.cond.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
AsyncLoadImage.this.wcObj_.notified = false;
|
||||
if (AsyncLoadImage.this.taskList_.size() > 0) {
|
||||
String name = (String) AsyncLoadImage.this.taskList_.get(0);
|
||||
AsyncLoadImage.this.taskList_.remove(0);
|
||||
if (AsyncLoadImage.this.running_) {
|
||||
if (AsyncLoadImage.this.receiver_ instanceof DelegateExecute) {
|
||||
Object object = ((DelegateExecute) AsyncLoadImage.this.receiver_).onBackToDo(name);
|
||||
Message msg = new Message();
|
||||
msg.what = AsyncLoadImage.MSG;
|
||||
msg.obj = object;
|
||||
AsyncLoadImage.this.handlers_[this.index_].sendMessage(msg);
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BasePara1 implements Cloneable {
|
||||
public int devType;
|
||||
public int fpaFlip;
|
||||
public int fpaGain;
|
||||
public int fpaHeight;
|
||||
public int fpaWidth;
|
||||
public int fps;
|
||||
public int gfid;
|
||||
public int gsk;
|
||||
public int hwVersion;
|
||||
public int interFrame;
|
||||
public int interLine;
|
||||
public int reserved1;
|
||||
public int reserved2;
|
||||
public int serialNumber;
|
||||
public int swVersion;
|
||||
|
||||
public BasePara1() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.serialNumber = 0;
|
||||
this.hwVersion = 0;
|
||||
this.devType = 0;
|
||||
this.swVersion = 0;
|
||||
this.reserved1 = 0;
|
||||
this.fpaWidth = 0;
|
||||
this.fpaHeight = 0;
|
||||
this.fps = 0;
|
||||
this.reserved2 = 0;
|
||||
this.fpaGain = 0;
|
||||
this.fpaFlip = 0;
|
||||
this.interFrame = 0;
|
||||
this.interLine = 0;
|
||||
this.gfid = 0;
|
||||
this.gsk = 0;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BasePara2 implements Cloneable {
|
||||
public float ATErrorSlope;
|
||||
public int ATZeroErrorPoint;
|
||||
public int baseLineAcc;
|
||||
public int denoiseLevel;
|
||||
public int enlargeRange;
|
||||
public int ffcTriggerFrame;
|
||||
public int ffcTriggerTemperature;
|
||||
public short fpaTempFix;
|
||||
public int laserPos;
|
||||
public int reserved1;
|
||||
public short reserved2;
|
||||
public int reserved5;
|
||||
public int reserved6;
|
||||
public int shutterCloseSpeed;
|
||||
public int shutterOpenSpeed;
|
||||
|
||||
public BasePara2() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.baseLineAcc = 0;
|
||||
this.denoiseLevel = 0;
|
||||
this.reserved1 = 0;
|
||||
this.reserved2 = (short) 0;
|
||||
this.fpaTempFix = (short) 0;
|
||||
this.shutterCloseSpeed = 0;
|
||||
this.shutterOpenSpeed = 0;
|
||||
this.ffcTriggerFrame = 0;
|
||||
this.ffcTriggerTemperature = 0;
|
||||
this.enlargeRange = 0;
|
||||
this.laserPos = 0;
|
||||
this.ATZeroErrorPoint = 0;
|
||||
this.ATErrorSlope = 0.0f;
|
||||
this.reserved5 = 0;
|
||||
this.reserved6 = 0;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Point;
|
||||
import android.media.ThumbnailUtils;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BitmapUtilities {
|
||||
public static Bitmap getBitmapThumbnail(String pathName, int width, int height) {
|
||||
Bitmap bitmap = null;
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
if (opts.outWidth > 0 && opts.outHeight > 0) {
|
||||
float r = Math.max(opts.outHeight / height, opts.outWidth / width);
|
||||
opts.inSampleSize = (int) (r + 0.5d);
|
||||
opts.inJustDecodeBounds = false;
|
||||
bitmap = BitmapFactory.decodeFile(pathName, opts);
|
||||
}
|
||||
if (bitmap == null) {
|
||||
return ThumbnailUtils.createVideoThumbnail(pathName, 1);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Bitmap getBitmapThumbnail(String pathName, int sampleSize) {
|
||||
Bitmap bitmap = null;
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
if (opts.outWidth > 0 && opts.outHeight > 0) {
|
||||
opts.inSampleSize = sampleSize;
|
||||
opts.inJustDecodeBounds = false;
|
||||
bitmap = BitmapFactory.decodeFile(pathName, opts);
|
||||
}
|
||||
if (bitmap == null) {
|
||||
return ThumbnailUtils.createVideoThumbnail(pathName, 1);
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public static Point getBitmapSize(String pathName) {
|
||||
BitmapFactory.Options opts = new BitmapFactory.Options();
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(pathName, opts);
|
||||
if (opts.outWidth <= 0 || opts.outHeight <= 0) {
|
||||
return null;
|
||||
}
|
||||
return new Point(opts.outWidth, opts.outHeight);
|
||||
}
|
||||
|
||||
public static Bitmap getBitmapThumbnail(Bitmap bmp, int width, int height) {
|
||||
Bitmap bitmap;
|
||||
if (bmp == null) {
|
||||
return null;
|
||||
}
|
||||
int bmpWidth = bmp.getWidth();
|
||||
int bmpHeight = bmp.getHeight();
|
||||
if (width > 0 && height > 0) {
|
||||
Matrix matrix = new Matrix();
|
||||
float scaleWidth = width / bmpWidth;
|
||||
float scaleHeight = height / bmpHeight;
|
||||
matrix.postScale(scaleWidth, scaleHeight);
|
||||
bitmap = Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
|
||||
} else {
|
||||
bitmap = bmp;
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CaliInfo implements Cloneable {
|
||||
public long date;
|
||||
public int reserved;
|
||||
public int size;
|
||||
|
||||
public CaliInfo() {
|
||||
reset();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.size = 0;
|
||||
this.reserved = 0;
|
||||
this.date = 0L;
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class D2PCmd {
|
||||
public static final int D2P_CaliHandledAck = 1538635104;
|
||||
public static final int D2P_CmdHandledAck = 1538635103;
|
||||
public static final int D2P_SendCaliFile = 1538635101;
|
||||
public static final int D2P_SendCaliInfo = 1538635102;
|
||||
public static final int D2P_SendFPAState = 1538635106;
|
||||
public static final int D2P_SendLifeTime = 1538635105;
|
||||
public static final int D2P_SendParameter1 = 1538635099;
|
||||
public static final int D2P_SendParameter2 = 1538635100;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateDeviceConnected {
|
||||
void onDeviceConnected(UsbCommunication usbCommunication);
|
||||
|
||||
void onDeviceDisconnected();
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateMedia {
|
||||
void onCapture();
|
||||
|
||||
void onRecordingStart();
|
||||
|
||||
void onRecordingStop();
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateMediaStatusChanged {
|
||||
void onModeChanged(int i, int i2, int i3);
|
||||
|
||||
void onSelChanged(int i, int i2);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface DelegateOptionSelected {
|
||||
void onOptionSelected(int i, int i2);
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class DeviceController {
|
||||
public static final int BITSPERPIXEL = 16;
|
||||
|
||||
public interface ShutterCallBack {
|
||||
void setShutterState(int i);
|
||||
}
|
||||
|
||||
public static native void Lock();
|
||||
|
||||
public static native void Unlock();
|
||||
|
||||
public static native int[] clientPos2ScreenXY(int i, int i2, int i3);
|
||||
|
||||
public static native int[] clientXY2ScreenXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native boolean doRecording(Bitmap bitmap);
|
||||
|
||||
public static native int getEX();
|
||||
|
||||
public static native void getExtParameter(ExtPara extPara);
|
||||
|
||||
public static native boolean getOutputBMPData(Bitmap bitmap, int i);
|
||||
|
||||
public static native boolean getOutputColorbarData(Bitmap bitmap, int i);
|
||||
|
||||
public static native int getPreviewOrientation();
|
||||
|
||||
public static native boolean getRectTemperatureInfo(int i, int i2, int i3, int i4, int[] iArr, boolean z);
|
||||
|
||||
public static native State getState();
|
||||
|
||||
public static native int getTemperature(int i, int i2, boolean z);
|
||||
|
||||
public static native boolean isOutputDataReady();
|
||||
|
||||
public static native boolean isProcessImage();
|
||||
|
||||
public static native boolean isRecording();
|
||||
|
||||
public static native boolean pushFrame(byte[] bArr, int i, int i2);
|
||||
|
||||
public static native boolean saveDDT(String str);
|
||||
|
||||
public static native int[] screenXY2ClientXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native int[] screenXY2SensorXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native int[] sensorXY2ScreenXY(int i, int i2, int i3, int i4);
|
||||
|
||||
public static native void setAutoEnlarge(int i);
|
||||
|
||||
public static native void setColorPalette(int i);
|
||||
|
||||
public static native void setColorbarSize(int i, int i2);
|
||||
|
||||
public static native void setEX(int i, int i2, int i3);
|
||||
|
||||
public static native void setEmissivity(int i, int i2);
|
||||
|
||||
public static native void setExtParameter(ExtPara extPara);
|
||||
|
||||
public static native void setPreviewOrientation(int i);
|
||||
|
||||
public static native boolean startProcess(ShutterCallBack shutterCallBack, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, String str);
|
||||
|
||||
public static native boolean startRecording(String str, int i, int i2, int i3, int i4, int i5);
|
||||
|
||||
public static native void stopProcess();
|
||||
|
||||
public static native void stopRecording();
|
||||
|
||||
public static native void triggerFFC();
|
||||
|
||||
static {
|
||||
System.loadLibrary("avutil-55");
|
||||
System.loadLibrary("avcodec-57");
|
||||
System.loadLibrary("swresample-2");
|
||||
System.loadLibrary("avformat-57");
|
||||
System.loadLibrary("swscale-4");
|
||||
System.loadLibrary("postproc-54");
|
||||
System.loadLibrary("avfilter-6");
|
||||
System.loadLibrary("avdevice-57");
|
||||
System.loadLibrary("cxsdk");
|
||||
System.loadLibrary("cxx2java");
|
||||
setColorbarSize(100, 20);
|
||||
setColorPalette(SharedPreferencesManager.getInt("paletteIndex", 2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ExtPara {
|
||||
public boolean bIsothermal;
|
||||
public int dwFlip;
|
||||
public int intAutoEnlargeRange;
|
||||
public int intBrightOffset;
|
||||
public int intContrastOffset;
|
||||
public int intCurrentEnvTemperature;
|
||||
public int intDetailRatio;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class GlobalFunc {
|
||||
public static final int MEDIA_IMAGE = 0;
|
||||
public static final int MEDIA_OTHER = -1;
|
||||
public static final int MEDIA_VIDEO = 1;
|
||||
|
||||
public static int guessMediaTypeBySuffix(String name) {
|
||||
String mimeType = getMimeType(getExtension(name));
|
||||
if (mimeType == null) {
|
||||
return -1;
|
||||
}
|
||||
if (mimeType.contains("video/")) {
|
||||
return 1;
|
||||
}
|
||||
return mimeType.contains("image/") ? 0 : -1;
|
||||
}
|
||||
|
||||
public static void updateFileList(ArrayList<String> fileNames) {
|
||||
File file = new File(MagApplication.magParameter.mediaDir);
|
||||
File[] files = file.listFiles(new FileFilter() { // from class: cn.com.magnity.magnitycx.sdk.GlobalFunc.1
|
||||
@Override // java.io.FileFilter
|
||||
public boolean accept(File pathname) {
|
||||
String name = pathname.getName().toLowerCase();
|
||||
return !name.endsWith(".ddt");
|
||||
}
|
||||
});
|
||||
if (file == null || files == null) {
|
||||
fileNames.clear();
|
||||
return;
|
||||
}
|
||||
ArrayList<FileInfo> fileInfos = new ArrayList<>();
|
||||
for (File f : files) {
|
||||
FileInfo fileInfo = new FileInfo();
|
||||
fileInfo.name = f.getName();
|
||||
fileInfo.lastModified = f.lastModified();
|
||||
fileInfos.add(fileInfo);
|
||||
}
|
||||
Collections.sort(fileInfos, new FileInfoComparator());
|
||||
fileNames.clear();
|
||||
Iterator<FileInfo> it = fileInfos.iterator();
|
||||
while (it.hasNext()) {
|
||||
fileNames.add(it.next().name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void notifyMediaSync(Context context, File file) {
|
||||
Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
|
||||
Uri uri = Uri.fromFile(file);
|
||||
intent.setData(uri);
|
||||
context.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public static int byteArrayToInt(byte[] b) {
|
||||
return (b[0] & 255) | ((b[1] & 255) << 8) | ((b[2] & 255) << 16) | ((b[3] & 255) << 24);
|
||||
}
|
||||
|
||||
public static byte[] intToByteArray(int a) {
|
||||
return new byte[]{(byte) (a & 255), (byte) ((a >> 8) & 255), (byte) ((a >> 16) & 255), (byte) ((a >> 24) & 255)};
|
||||
}
|
||||
|
||||
public static void intToByteArray(int a, byte[] out, int offset) {
|
||||
if (out.length >= offset + 4) {
|
||||
int offset2 = offset + 1;
|
||||
out[offset] = (byte) a;
|
||||
int offset3 = offset2 + 1;
|
||||
out[offset2] = (byte) (a >> 8);
|
||||
int offset4 = offset3 + 1;
|
||||
out[offset3] = (byte) (a >> 16);
|
||||
int i = offset4 + 1;
|
||||
out[offset4] = (byte) (a >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getExtension(String name) {
|
||||
int idx = name.lastIndexOf(".");
|
||||
if (idx <= 0) {
|
||||
return "";
|
||||
}
|
||||
String suffix = name.substring(idx + 1);
|
||||
return suffix;
|
||||
}
|
||||
|
||||
private static String getMimeType(String suffix) {
|
||||
if (suffix.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return MimeTypeMap.getSingleton().getMimeTypeFromExtension(suffix);
|
||||
}
|
||||
|
||||
private static class FileInfoComparator implements Comparator<FileInfo> {
|
||||
private FileInfoComparator() {
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(FileInfo lhs, FileInfo rhs) {
|
||||
if (lhs.lastModified > rhs.lastModified) {
|
||||
return -1;
|
||||
}
|
||||
if (lhs.lastModified == rhs.lastModified) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static class FileInfo {
|
||||
public long lastModified;
|
||||
public String name;
|
||||
|
||||
private FileInfo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImgHeader {
|
||||
public int frameIndex;
|
||||
public int[] reserved = new int[4];
|
||||
public int sendBytes;
|
||||
public int startCode;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ImgTail implements Serializable {
|
||||
public int camTemp;
|
||||
public int endCode;
|
||||
public int fpaTemp;
|
||||
public int frameIndex;
|
||||
public int intDrop;
|
||||
public int[] reserved = new int[2];
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.support.v4.util.LruCache;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LruCacheManager {
|
||||
private static final int CACHE_SIZE = 10485760;
|
||||
private static LruCacheManager instance_;
|
||||
private LruCache<String, Bitmap> memCache_;
|
||||
|
||||
private LruCacheManager() {
|
||||
}
|
||||
|
||||
public static LruCacheManager getInstance() {
|
||||
if (instance_ == null) {
|
||||
instance_ = new LruCacheManager();
|
||||
instance_.init();
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
int maxMemory = (int) Runtime.getRuntime().maxMemory();
|
||||
int cacheSize = CACHE_SIZE;
|
||||
if (CACHE_SIZE > maxMemory / 8) {
|
||||
cacheSize = maxMemory / 8;
|
||||
}
|
||||
this.memCache_ = new LruCache<String, Bitmap>(cacheSize) { // from class: cn.com.magnity.magnitycx.sdk.LruCacheManager.1
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.support.v4.util.LruCache
|
||||
public int sizeOf(String key, Bitmap bitmap) {
|
||||
return Build.VERSION.SDK_INT >= 12 ? bitmap.getByteCount() : bitmap.getRowBytes() * bitmap.getHeight();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // android.support.v4.util.LruCache
|
||||
public void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) {
|
||||
super.entryRemoved(evicted, (boolean) key, oldValue, newValue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public synchronized Bitmap put(String key, Bitmap value) {
|
||||
return this.memCache_.put(key, value);
|
||||
}
|
||||
|
||||
public synchronized Bitmap get(String key) {
|
||||
return this.memCache_.get(key);
|
||||
}
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import java.io.File;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MagParameter {
|
||||
public static final int DISPMODE_IRONLY = 1;
|
||||
public static final int DISPMODE_PIP = 0;
|
||||
public static final int EM_LEVEL1 = 100;
|
||||
public static final int EM_LEVEL2 = 90;
|
||||
public static final int EM_LEVEL3 = 80;
|
||||
public static final int EM_LEVEL4 = 70;
|
||||
public static final String EVENT_C1 = "c1设备启动";
|
||||
public static final String EVENT_C1_ID = "C1";
|
||||
public static final String EVENT_C3 = "c3设备启动";
|
||||
public static final String EVENT_C3_ID = "C3";
|
||||
public static final String EVENT_CLICK_ABOUT = "点击关于";
|
||||
public static final String EVENT_CLICK_ABOUT_ID = "CLICK_ABOUT";
|
||||
public static final String EVENT_CLICK_PRODUCT = "点击产品";
|
||||
public static final String EVENT_CLICK_PRODUCT_ID = "CLICK_PRODUCT";
|
||||
public static final String EVENT_CLICK_SHARE = "点击分享";
|
||||
public static final String EVENT_CLICK_SHARE_ID = "CLICK_SHARE";
|
||||
public static final String EVENT_COLOR_PALETTE = "调色板";
|
||||
public static final String EVENT_COLOR_PALETTE_ID = "COLOR_PALETTE";
|
||||
public static final String EVENT_DIABLE_MAX_TEMP = "关闭最高温测温";
|
||||
public static final String EVENT_DIABLE_MAX_TEMP_ID = "DISABLE_MAX_TEMP";
|
||||
public static final String EVENT_DISABLE_CENTER_TEMP = "关闭中心测温";
|
||||
public static final String EVENT_DISABLE_CENTER_TEMP_ID = "DISABLE_CENTER_TEMP";
|
||||
public static final String EVENT_DISABLE_LASER = "关闭激光";
|
||||
public static final String EVENT_DISABLE_LASER_ID = "DISABLE_LASER";
|
||||
public static final String EVENT_DISABLE_VISWND = "关闭可见光";
|
||||
public static final String EVENT_DISABLE_VISWND_ID = "DISABLE_VISWND";
|
||||
public static final String EVENT_EMISSIVITY_DARK = "辐射率暗光";
|
||||
public static final String EVENT_EMISSIVITY_DARK_ID = "EMISSIVITY_DARK";
|
||||
public static final String EVENT_EMISSIVITY_HALF = "辐射率半光";
|
||||
public static final String EVENT_EMISSIVITY_HALF_ID = "EMISSIVITY_HALF";
|
||||
public static final String EVENT_EMISSIVITY_LIGHT = "辐射率亮光";
|
||||
public static final String EVENT_EMISSIVITY_LIGHT_ID = "EMISSIVITY_LIGHT";
|
||||
public static final String EVENT_EMISSIVITY_NONE = "辐射率无光";
|
||||
public static final String EVENT_EMISSIVITY_NONE_ID = "EMISSIVITY_NONE";
|
||||
public static final String EVENT_ENABLE_CENTER_TEMP = "打开中心测温";
|
||||
public static final String EVENT_ENABLE_CENTER_TEMP_ID = "ENABLE_CENTER_TEMP";
|
||||
public static final String EVENT_ENABLE_LASER = "打开激光";
|
||||
public static final String EVENT_ENABLE_LASER_ID = "ENABLE_LASER";
|
||||
public static final String EVENT_ENABLE_MAX_TEMP = "打开最高温测温";
|
||||
public static final String EVENT_ENABLE_MAX_TEMP_ID = "ENABLE_MAX_TEMP";
|
||||
public static final String EVENT_ENABLE_VISWND = "打开可见光";
|
||||
public static final String EVENT_ENABLE_VISWND_ID = "ENABLE_VISWND";
|
||||
public static final String EVENT_ENTER_COMPANY_WEBSITE = "进入官网";
|
||||
public static final String EVENT_ENTER_COMPANY_WEBSITE_ID = "ENTER_COMPANY_WEBSITE";
|
||||
public static final String EVENT_ENTER_WECHAT_STORE = "进入微店";
|
||||
public static final String EVENT_ENTER_WECHAT_STORE_ID = "ENTER_WECHAT_STORE";
|
||||
public static final String EVENT_FLIP_HORIZONTAL = "水平翻转";
|
||||
public static final String EVENT_FLIP_HORIZONTAL_ID = "FLIP_HORIZONTAL";
|
||||
public static final String EVENT_FLIP_VERTICAL = "竖直翻转";
|
||||
public static final String EVENT_FLIP_VERTICAL_ID = "FLIP_VERTICAL";
|
||||
public static final String EVENT_FRAME_RATE_HIGH = "帧率高";
|
||||
public static final String EVENT_FRAME_RATE_HIGH_ID = "FRAME_RATE_HIGH";
|
||||
public static final String EVENT_FRAME_RATE_LOW = "帧率低";
|
||||
public static final String EVENT_FRAME_RATE_LOW_ID = "FRAME_RATE_LOW";
|
||||
public static final String EVENT_PHOTO = "拍照";
|
||||
public static final String EVENT_PHOTO_ID = "PHOTO";
|
||||
public static final String EVENT_ROIT_TRACE = "矩形测温";
|
||||
public static final String EVENT_ROIT_TRACE_ID = "ROIT_TRACE";
|
||||
public static final String EVENT_TRACE_MAX = "目标最高温";
|
||||
public static final String EVENT_TRACE_MAXMIN = "目标全";
|
||||
public static final String EVENT_TRACE_MAXMIN_ID = "TRACE_MAXMIN";
|
||||
public static final String EVENT_TRACE_MAX_ID = "TRACE_MAX";
|
||||
public static final String EVENT_TRACE_MIN = "目标最低温";
|
||||
public static final String EVENT_TRACE_MIN_ID = "TRACE_MIN";
|
||||
public static final String EVENT_TRACE_NONE = "目标无";
|
||||
public static final String EVENT_TRACE_NONE_ID = "TRACE_NONE";
|
||||
public static final String EVENT_VIDEO = "录像";
|
||||
public static final String EVENT_VIDEO_ID = "VIDEO";
|
||||
public static final String EVENT_VISWND_LARGE = "可见光尺寸大";
|
||||
public static final String EVENT_VISWND_LARGE_ID = "VISWND_LARGE";
|
||||
public static final String EVENT_VISWND_MIDDLE = "可见光尺寸中";
|
||||
public static final String EVENT_VISWND_MIDDLE_ID = "VISWND_MIDDLE";
|
||||
public static final String EVENT_VISWND_SMALL = "可见光尺寸小";
|
||||
public static final String EVENT_VISWND_SMALL_ID = "VISWND_SMALL";
|
||||
public static final int FLIP_HOR = 1;
|
||||
public static final int FLIP_NO = 0;
|
||||
public static final int FLIP_VER = 2;
|
||||
public static final int FPS_HIGH = 0;
|
||||
public static final int FPS_LOW = 1;
|
||||
public static final String KEY_DISPMODE = "dispMode";
|
||||
public static final String KEY_EMISSIVITY = "emissivity";
|
||||
public static final String KEY_EXMODE = "exMode";
|
||||
public static final String KEY_FLIPMODE = "flipMode";
|
||||
public static final String KEY_FPSMODE = "fpsMode";
|
||||
public static final String KEY_MAXMINTRACE = "maxMinTrace";
|
||||
public static final String KEY_ONCETIPMEDIALONGCLICK = "onceTipMediaLongClick2";
|
||||
public static final String KEY_ONCETIPVISIBLEMOVE = "onceTipVisibleMove2";
|
||||
public static final String KEY_SHOWCROSS = "isShowCross";
|
||||
public static final String KEY_SHOWMOVINGCROSS = "isShowMovingCross";
|
||||
public static final String KEY_TRACEMAXMIN = "isTraceMaxMin";
|
||||
public static final String KEY_TRACEROI = "isTraceRoi";
|
||||
public static final String KEY_VISCAMID = "visCameraId";
|
||||
public static final String KEY_VISWNDLEFTMARGIN = "visWndLeftMargin";
|
||||
public static final String KEY_VISWNDSIZE = "visWndSize";
|
||||
public static final String KEY_VISWNDTOPMARGIN = "visWndTopMargin";
|
||||
public static final int TRACE_MAX = 0;
|
||||
public static final int TRACE_MAXMIN = 2;
|
||||
public static final int TRACE_MIN = 1;
|
||||
public static final int TRACE_NONE = -1;
|
||||
public static final int TYPE_160CORE = 3;
|
||||
public static final int TYPE_C1 = 0;
|
||||
public static final int TYPE_C1Pro = 5;
|
||||
public static final int TYPE_C1ProLite = 6;
|
||||
public static final int TYPE_C3 = 1;
|
||||
public static final int TYPE_C3P = 2;
|
||||
public static final int TYPE_C6 = 4;
|
||||
public static final int VISWND_LARGE = 2;
|
||||
public static final int VISWND_MEDIUM = 1;
|
||||
public static final int VISWND_SMALL = 0;
|
||||
public BasePara1 basePara1;
|
||||
public BasePara2 basePara2;
|
||||
public CaliInfo caliInfo;
|
||||
public int dispMode;
|
||||
public int emissivity;
|
||||
public int fpsMode;
|
||||
public int imageEX;
|
||||
public int imageFlip;
|
||||
public boolean isLaserOn;
|
||||
public boolean isShowCross;
|
||||
public boolean isShowMovingCross;
|
||||
public boolean isTraceMaxMin;
|
||||
public boolean isTraceRoi;
|
||||
public int maxMinTrace;
|
||||
public int onceTipMediaLongClick;
|
||||
public int onceTipVisibleMove;
|
||||
public int portraitScreenHeight;
|
||||
public int portraitScreenWidth;
|
||||
public int visCameraId;
|
||||
public int visWndLeftMargin;
|
||||
public int visWndSize;
|
||||
public int visWndTopMargin;
|
||||
public String logDir = "";
|
||||
public String caliDir = "";
|
||||
public String mediaDir = "";
|
||||
public String otherDir = "";
|
||||
|
||||
public MagParameter(Context context) {
|
||||
SharedPreferencesManager.init(context);
|
||||
this.basePara1 = new BasePara1();
|
||||
this.basePara2 = new BasePara2();
|
||||
this.caliInfo = new CaliInfo();
|
||||
this.dispMode = SharedPreferencesManager.getInt(KEY_DISPMODE, 1);
|
||||
this.isShowCross = SharedPreferencesManager.getBoolean(KEY_SHOWCROSS, false);
|
||||
this.isShowMovingCross = SharedPreferencesManager.getBoolean(KEY_SHOWMOVINGCROSS, false);
|
||||
this.isTraceMaxMin = SharedPreferencesManager.getBoolean(KEY_TRACEMAXMIN, false);
|
||||
this.isLaserOn = false;
|
||||
this.isTraceRoi = SharedPreferencesManager.getBoolean(KEY_TRACEROI, false);
|
||||
this.visCameraId = SharedPreferencesManager.getInt(KEY_VISCAMID, 0);
|
||||
this.visWndSize = SharedPreferencesManager.getInt(KEY_VISWNDSIZE, 1);
|
||||
this.maxMinTrace = SharedPreferencesManager.getInt(KEY_MAXMINTRACE, 0);
|
||||
this.imageFlip = SharedPreferencesManager.getInt(KEY_FLIPMODE, 0);
|
||||
this.imageEX = SharedPreferencesManager.getInt(KEY_EXMODE, 0);
|
||||
this.emissivity = SharedPreferencesManager.getInt(KEY_EMISSIVITY, 100);
|
||||
this.visWndLeftMargin = SharedPreferencesManager.getInt(KEY_VISWNDLEFTMARGIN, -1);
|
||||
this.visWndTopMargin = SharedPreferencesManager.getInt(KEY_VISWNDTOPMARGIN, 0);
|
||||
this.onceTipMediaLongClick = SharedPreferencesManager.getInt(KEY_ONCETIPMEDIALONGCLICK, 3);
|
||||
this.onceTipVisibleMove = SharedPreferencesManager.getInt(KEY_ONCETIPVISIBLEMOVE, 3);
|
||||
this.fpsMode = SharedPreferencesManager.getInt(KEY_FPSMODE, 1);
|
||||
createDirs();
|
||||
}
|
||||
|
||||
private void createDirs() {
|
||||
if (Environment.getExternalStorageState().equals("mounted")) {
|
||||
String pathName = Environment.getExternalStorageDirectory().getPath() + File.separator + "magnity" + File.separator + "Cx";
|
||||
File file = new File(pathName);
|
||||
if (file.exists() || file.mkdirs()) {
|
||||
String pathName2 = pathName + File.separator;
|
||||
this.logDir = pathName2 + "log";
|
||||
File file2 = new File(this.logDir);
|
||||
if (!file2.exists()) {
|
||||
file2.mkdirs();
|
||||
}
|
||||
this.caliDir = pathName2 + "others";
|
||||
File file3 = new File(this.caliDir);
|
||||
if (!file3.exists()) {
|
||||
file3.mkdirs();
|
||||
}
|
||||
this.mediaDir = pathName2 + "media";
|
||||
File file4 = new File(this.mediaDir);
|
||||
if (!file4.exists()) {
|
||||
file4.mkdirs();
|
||||
}
|
||||
this.otherDir = pathName2 + "others";
|
||||
File file5 = new File(this.otherDir);
|
||||
if (!file5.exists()) {
|
||||
file5.mkdirs();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Size {
|
||||
private int height_;
|
||||
private int width_;
|
||||
|
||||
public Size() {
|
||||
}
|
||||
|
||||
public Size(int width, int height) {
|
||||
this.width_ = width;
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width_ = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width_;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class MsgBus {
|
||||
private static MsgBus mInstance;
|
||||
private static LocalBroadcastManager mLocalBroadcastManager;
|
||||
|
||||
public static synchronized MsgBus getInstance() {
|
||||
MsgBus msgBus;
|
||||
synchronized (MsgBus.class) {
|
||||
if (mInstance == null) {
|
||||
mInstance = new MsgBus(MagApplication.getInstance());
|
||||
}
|
||||
msgBus = mInstance;
|
||||
}
|
||||
return msgBus;
|
||||
}
|
||||
|
||||
public MsgBus(Context context) {
|
||||
mLocalBroadcastManager = LocalBroadcastManager.getInstance(context.getApplicationContext());
|
||||
}
|
||||
|
||||
public void register(BroadcastReceiver receiver, String action) {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction(action);
|
||||
mLocalBroadcastManager.registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
public void register(BroadcastReceiver receiver, String[] actions) {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
for (String msg : actions) {
|
||||
intentFilter.addAction(msg);
|
||||
}
|
||||
mLocalBroadcastManager.registerReceiver(receiver, intentFilter);
|
||||
}
|
||||
|
||||
public void unregister(BroadcastReceiver receiver) {
|
||||
mLocalBroadcastManager.unregisterReceiver(receiver);
|
||||
}
|
||||
|
||||
public void postEmptytMsg(String msg) {
|
||||
mLocalBroadcastManager.sendBroadcast(new Intent(msg));
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag, int val) {
|
||||
Intent intent = new Intent(msg);
|
||||
intent.putExtra(tag, val);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag, String val) {
|
||||
Intent intent = new Intent(msg);
|
||||
intent.putExtra(tag, val);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag, Parcelable parcel) {
|
||||
Intent intent = new Intent(msg);
|
||||
intent.putExtra(tag, parcel);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
public void postMsg(String msg, String tag1, Parcelable parcel, String tag2, int val) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(tag1, parcel);
|
||||
intent.putExtra(tag2, val);
|
||||
mLocalBroadcastManager.sendBroadcast(intent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class Observable<T> {
|
||||
protected final ArrayList<T> observers_ = new ArrayList<>();
|
||||
|
||||
public void registerObserver(T observer) {
|
||||
if (observer != null) {
|
||||
synchronized (this.observers_) {
|
||||
if (!this.observers_.contains(observer)) {
|
||||
this.observers_.add(observer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterObserver(T observer) {
|
||||
if (observer != null) {
|
||||
synchronized (this.observers_) {
|
||||
int index = this.observers_.indexOf(observer);
|
||||
if (index != -1) {
|
||||
this.observers_.remove(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterAll() {
|
||||
synchronized (this.observers_) {
|
||||
this.observers_.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class P2DCmd {
|
||||
public static final int P2D_GetCaliFile = 1807136368;
|
||||
public static final int P2D_GetCaliInfo = 1807136367;
|
||||
public static final int P2D_GetFPAState = 1807136376;
|
||||
public static final int P2D_GetLifeTime = 1807136373;
|
||||
public static final int P2D_GetParameter1 = 1807136363;
|
||||
public static final int P2D_GetParameter2 = 1807136364;
|
||||
public static final int P2D_PowerSave = 1807136375;
|
||||
public static final int P2D_SendCaliFile = 1807136369;
|
||||
public static final int P2D_SetFrameRate = 1807136377;
|
||||
public static final int P2D_SetLaserState = 1807136374;
|
||||
public static final int P2D_SetParameter1 = 1807136365;
|
||||
public static final int P2D_SetParameter2 = 1807136366;
|
||||
public static final int P2D_SetShutterState = 1807136370;
|
||||
public static final int P2D_StartTransferImg = 1807136371;
|
||||
public static final int P2D_StopTransferImg = 1807136372;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class SharedPreferencesManager {
|
||||
private static SharedPreferences.Editor editor_;
|
||||
private static SharedPreferences preferences_;
|
||||
|
||||
public static void init(Context context) {
|
||||
preferences_ = context.getApplicationContext().getSharedPreferences("magnitycx", 0);
|
||||
editor_ = preferences_.edit();
|
||||
}
|
||||
|
||||
public static boolean commit() {
|
||||
return editor_.commit();
|
||||
}
|
||||
|
||||
public static SharedPreferences.Editor putInt(String key, int value) {
|
||||
return editor_.putInt(key, value);
|
||||
}
|
||||
|
||||
public static void putIntWithCommit(String key, int value) {
|
||||
editor_.putInt(key, value);
|
||||
editor_.commit();
|
||||
}
|
||||
|
||||
public static int getInt(String key, int defValue) {
|
||||
return preferences_.getInt(key, defValue);
|
||||
}
|
||||
|
||||
public static SharedPreferences.Editor putFloat(String key, float value) {
|
||||
return editor_.putFloat(key, value);
|
||||
}
|
||||
|
||||
public static void putFloatWithCommit(String key, float value) {
|
||||
editor_.putFloat(key, value);
|
||||
editor_.commit();
|
||||
}
|
||||
|
||||
public static float getFloat(String key, float defValue) {
|
||||
return preferences_.getFloat(key, defValue);
|
||||
}
|
||||
|
||||
public static SharedPreferences.Editor putBoolean(String key, boolean value) {
|
||||
return editor_.putBoolean(key, value);
|
||||
}
|
||||
|
||||
public static void putBooleanWithCommit(String key, boolean value) {
|
||||
editor_.putBoolean(key, value);
|
||||
editor_.commit();
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String key, boolean defValue) {
|
||||
return preferences_.getBoolean(key, defValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class State implements Cloneable {
|
||||
public int intAveNETDt;
|
||||
public int intAveTemperature;
|
||||
public int[] intHistTemperature = new int[256];
|
||||
public int intMaxTemperature;
|
||||
public int intMaxX;
|
||||
public int intMaxY;
|
||||
public int intMinTemperature;
|
||||
public int intMinX;
|
||||
public int intMinY;
|
||||
public int intSTDTemperature;
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
State state = (State) super.clone();
|
||||
if (this.intHistTemperature != null) {
|
||||
state.intHistTemperature = Arrays.copyOf(this.intHistTemperature, this.intHistTemperature.length);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class TimerHelper {
|
||||
private Timer timer_ = null;
|
||||
|
||||
public abstract void run();
|
||||
|
||||
public void start(long delay, long period) {
|
||||
stop();
|
||||
this.timer_ = new Timer();
|
||||
this.timer_.schedule(new TimerTask() { // from class: cn.com.magnity.magnitycx.sdk.TimerHelper.1
|
||||
@Override // java.util.TimerTask, java.lang.Runnable
|
||||
public void run() {
|
||||
TimerHelper.this.run();
|
||||
}
|
||||
}, delay, period);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.timer_ != null) {
|
||||
this.timer_.cancel();
|
||||
this.timer_ = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+966
@@ -0,0 +1,966 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbDeviceConnection;
|
||||
import android.hardware.usb.UsbEndpoint;
|
||||
import android.hardware.usb.UsbInterface;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.media.TransportMediator;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import cn.com.magnity.magnitycx.ImageViewer;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import cn.com.magnity.magnitycx.R;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import cn.com.magnity.magnitycx.sdk.DeviceController;
|
||||
import com.baidu.mobstat.Config;
|
||||
import com.baidu.mobstat.autotrace.Common;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.apache.log4j.Priority;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UsbCommunication implements DeviceController.ShutterCallBack {
|
||||
private static final int DOWNLOAD_CALI_TIMEOUT = 5000;
|
||||
private static final int HEADER_SIZE = 28;
|
||||
private static final int IMG_END_CODE = 464630044;
|
||||
private static final int IMG_START_CODE = 464630043;
|
||||
private static final int MAX_CALI_FILE_LEN = 104857600;
|
||||
private static final int MAX_RECEIVED_LEN = 16384;
|
||||
private static final int MIN_CALI_FILE_LEN = 65536;
|
||||
public static final String MSG_SET_BASEPARAMETER = "set_baseparameter";
|
||||
public static final String MSG_TRIGGER_FFC = "trigger_ffc";
|
||||
public static final int PROGRESS_CALI_ID = 0;
|
||||
private static final int PROGRESS_CANCEL = 3;
|
||||
private static final int PROGRESS_CHANGED = 2;
|
||||
private static final int PROGRESS_FINISHED = 1;
|
||||
private static final int PROGRESS_START = 0;
|
||||
public static final int PROGRESS_WAIT_FOR_CORRECT_STREAM_ID = 1;
|
||||
private static final int QUERY_DEVICE_LIFETIME = 4;
|
||||
private static final int TAIL_SIZE = 28;
|
||||
private static final int TIMEOUT = 800;
|
||||
private static final int TIME_FOR_DEVICE_INIT = 15000;
|
||||
private static volatile Lock lock_ = new ReentrantLock();
|
||||
private static volatile long[] ticks_ = new long[20];
|
||||
private volatile int camTemp_;
|
||||
private UsbConnection conn_;
|
||||
private volatile int fpaTemp_;
|
||||
private byte[] imgExchangeBuf1_;
|
||||
private ImageViewer imgViewer_;
|
||||
private volatile boolean isExitThreadImgProcess_;
|
||||
private IProgressCallback progressCallback_;
|
||||
private ThreadCaliRecv threadCaliRecv_;
|
||||
private ThreadImgProcess threadImgProcess_;
|
||||
private ThreadImgRecv threadImgRecv_;
|
||||
private UsbDeviceConnection usbConn_;
|
||||
private UsbEndpoint usbEpCaliIn_;
|
||||
private UsbEndpoint usbEpCaliOut_;
|
||||
private UsbEndpoint usbEpCmdIn_;
|
||||
private UsbEndpoint usbEpCmdOut_;
|
||||
private UsbEndpoint usbEpImgIn_;
|
||||
private UsbInterface usbInterface_;
|
||||
private volatile boolean connected_ = false;
|
||||
private volatile boolean isExitCaliRecvThread = false;
|
||||
private WaitCondition condImgProcess_ = new WaitCondition();
|
||||
private volatile boolean isToRecvFirstCaliPacket_ = false;
|
||||
private String caliPathName_ = "";
|
||||
private Handler handler_ = new Handler() { // from class: cn.com.magnity.magnitycx.sdk.UsbCommunication.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case 0:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressStart(((Integer) msg.obj).intValue());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressFinished(((Integer) msg.obj).intValue());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressChanged(msg.arg1, msg.arg2);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (UsbCommunication.this.progressCallback_ != null) {
|
||||
UsbCommunication.this.progressCallback_.progressCancel(((Integer) msg.obj).intValue());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
int t = UsbCommunication.this.getDevLifeTime();
|
||||
if (t != -1) {
|
||||
if (MagApplication.magParameter.basePara1.devType == 0 || MagApplication.magParameter.basePara1.devType == 5 || MagApplication.magParameter.basePara1.devType == 6 || MagApplication.magParameter.basePara1.devType == 3) {
|
||||
if (t > 5000) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 4) {
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(0);
|
||||
} else {
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(4);
|
||||
}
|
||||
} else if (MagApplication.magParameter.basePara1.devType == 1 || MagApplication.magParameter.basePara1.devType == 2) {
|
||||
if (t > 26000) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 1) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(0);
|
||||
} else if (t > 19500) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 2) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(1);
|
||||
} else if (t > 13000) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 3) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(2);
|
||||
} else if (t > 6500) {
|
||||
if (UsbCommunication.this.imgViewer_.getImageStableCounter() == 4) {
|
||||
DeviceController.Lock();
|
||||
DeviceController.triggerFFC();
|
||||
DeviceController.Unlock();
|
||||
}
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(3);
|
||||
} else {
|
||||
UsbCommunication.this.imgViewer_.setImageStableCounter(4);
|
||||
}
|
||||
}
|
||||
if (t > 40000) {
|
||||
UsbCommunication.this.imgViewer_.setTempStableFlag(true);
|
||||
break;
|
||||
} else {
|
||||
UsbCommunication.this.imgViewer_.setTempStableFlag(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() { // from class: cn.com.magnity.magnitycx.sdk.UsbCommunication.2
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "set_baseparameter":
|
||||
UsbCommunication.this.setFrameRate();
|
||||
DeviceController.triggerFFC();
|
||||
break;
|
||||
case "trigger_ffc":
|
||||
DeviceController.triggerFFC();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public interface DelegateNewFrame {
|
||||
void onNewFrameReceived(int i, int i2);
|
||||
}
|
||||
|
||||
public interface IProgressCallback {
|
||||
void progressCancel(int i);
|
||||
|
||||
void progressChanged(int i, int i2);
|
||||
|
||||
void progressFinished(int i);
|
||||
|
||||
void progressStart(int i);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int getDevLifeTime() {
|
||||
int i = -1;
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetLifeTime, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get device lifetime");
|
||||
}
|
||||
byte[] data = new byte[64];
|
||||
int len = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len < 0) {
|
||||
Logging.error("Fail to get lifetime ack");
|
||||
} else if (len < 4) {
|
||||
Logging.error("Get wrong ack size(" + len + ")");
|
||||
} else if (len < 8) {
|
||||
Logging.error("Get wrong ack size(" + len + ", cmd: " + GlobalFunc.byteArrayToInt(data) + ")");
|
||||
} else {
|
||||
ByteBuffer bb = ByteBuffer.wrap(data, 0, len);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
try {
|
||||
if (bb.getInt() == 1538635105) {
|
||||
i = bb.getInt();
|
||||
} else {
|
||||
Logging.error("Get wrong cmd(expected is lifetime)");
|
||||
}
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Logging.error("Exception of get liftime");
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public void setCallbackReceiver(IProgressCallback cb) {
|
||||
this.progressCallback_ = cb;
|
||||
}
|
||||
|
||||
public UsbCommunication(UsbConnection conn, UsbManager usbMgr, UsbDevice device, IProgressCallback cb) throws Exception {
|
||||
this.conn_ = conn;
|
||||
this.progressCallback_ = cb;
|
||||
this.usbConn_ = usbMgr.openDevice(device);
|
||||
if (this.usbConn_ == null) {
|
||||
throw new Exception("Unable to open USB device");
|
||||
}
|
||||
if (device.getInterfaceCount() < 1) {
|
||||
throw new Exception("Unable to get USB interface");
|
||||
}
|
||||
this.usbInterface_ = device.getInterface(0);
|
||||
if (!this.usbConn_.claimInterface(this.usbInterface_, true)) {
|
||||
throw new Exception("Unable to claim USB interface");
|
||||
}
|
||||
if (this.usbInterface_.getEndpointCount() < 4) {
|
||||
throw new Exception("Unable to get USB endpoint (" + this.usbInterface_.getEndpointCount() + ")");
|
||||
}
|
||||
for (int i = this.usbInterface_.getEndpointCount() - 1; i != -1; i--) {
|
||||
UsbEndpoint ep = this.usbInterface_.getEndpoint(i);
|
||||
switch (ep.getAddress()) {
|
||||
case 3:
|
||||
this.usbEpCmdOut_ = ep;
|
||||
break;
|
||||
case 5:
|
||||
this.usbEpCaliOut_ = ep;
|
||||
break;
|
||||
case 129:
|
||||
this.usbEpImgIn_ = ep;
|
||||
break;
|
||||
case TransportMediator.KEYCODE_MEDIA_RECORD /* 130 */:
|
||||
this.usbEpCmdIn_ = ep;
|
||||
break;
|
||||
case 132:
|
||||
this.usbEpCaliIn_ = ep;
|
||||
break;
|
||||
default:
|
||||
Logging.warn("Unknown endpoint found.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this.usbEpCmdIn_ == null || this.usbEpCmdOut_ == null || this.usbEpCaliIn_ == null || this.usbEpCaliOut_ == null || this.usbEpImgIn_ == null) {
|
||||
Logging.warn("Some endpoint lost.");
|
||||
}
|
||||
}
|
||||
|
||||
public void setImageViewer(ImageViewer imageViewer) {
|
||||
this.imgViewer_ = imageViewer;
|
||||
}
|
||||
|
||||
public int connect() {
|
||||
if (this.connected_) {
|
||||
return 1;
|
||||
}
|
||||
MsgBus.getInstance().register(this.mReceiver, new String[]{MSG_SET_BASEPARAMETER, MSG_TRIGGER_FFC});
|
||||
byte[] data = new byte[64];
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetParameter1, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get parameter1");
|
||||
return -1;
|
||||
}
|
||||
int len = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len > 0) {
|
||||
if (parseCmd(data, len) != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (MagApplication.magParameter.basePara1.devType != 0 && MagApplication.magParameter.basePara1.devType != 5 && MagApplication.magParameter.basePara1.devType != 6 && MagApplication.magParameter.basePara1.devType != 1 && MagApplication.magParameter.basePara1.devType != 2 && MagApplication.magParameter.basePara1.devType != 3) {
|
||||
Logging.error("unknown device type " + MagApplication.magParameter.basePara1.devType);
|
||||
return -1;
|
||||
}
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetParameter2, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get parameter2");
|
||||
return -1;
|
||||
}
|
||||
int len2 = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len2 > 0) {
|
||||
if (parseCmd(data, len2) != 1) {
|
||||
return -1;
|
||||
}
|
||||
if (sendEmptyCmd(P2DCmd.P2D_GetCaliInfo, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to get remote file info");
|
||||
return -1;
|
||||
}
|
||||
int len3 = recvCmd(data, 0, data.length, TIMEOUT);
|
||||
if (len3 > 0) {
|
||||
int ret = parseCmd(data, len3);
|
||||
if (ret == 1) {
|
||||
return !startTransfer(this.caliPathName_) ? -1 : 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
Logging.error("Fail to get remote file info");
|
||||
return -1;
|
||||
}
|
||||
Logging.error("Fail to get parameter2 ack");
|
||||
return -1;
|
||||
}
|
||||
Logging.error("Fail to get parameter1 ack");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean startTransfer(String caliPathName) {
|
||||
BasePara1 para1 = MagApplication.magParameter.basePara1;
|
||||
BasePara2 para2 = MagApplication.magParameter.basePara2;
|
||||
if (!DeviceController.startProcess(this, para1.fpaWidth, para1.fpaHeight, para1.serialNumber, para1.devType, para2.shutterCloseSpeed, para2.shutterOpenSpeed, para2.ffcTriggerFrame, para2.ffcTriggerTemperature, SharedPreferencesManager.getInt("paletteIndex", 2), para2.baseLineAcc, caliPathName)) {
|
||||
Logging.error("SDK start fail");
|
||||
try {
|
||||
File f = new File(caliPathName);
|
||||
f.delete();
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DeviceController.setEX(MagApplication.magParameter.imageEX, MagApplication.magParameter.basePara1.fpaWidth / 2, MagApplication.magParameter.basePara1.fpaHeight / 2);
|
||||
ExtPara param = new ExtPara();
|
||||
DeviceController.Lock();
|
||||
DeviceController.getExtParameter(param);
|
||||
param.dwFlip = MagApplication.magParameter.imageFlip;
|
||||
DeviceController.setExtParameter(param);
|
||||
DeviceController.setAutoEnlarge(para2.enlargeRange);
|
||||
DeviceController.Unlock();
|
||||
Logging.info("****Start****");
|
||||
this.connected_ = true;
|
||||
this.threadImgRecv_ = new ThreadImgRecv();
|
||||
this.threadImgRecv_.start();
|
||||
this.threadImgProcess_ = new ThreadImgProcess();
|
||||
this.isExitThreadImgProcess_ = false;
|
||||
this.condImgProcess_.notified = false;
|
||||
this.threadImgProcess_.start();
|
||||
try {
|
||||
Thread.sleep(5L);
|
||||
} catch (InterruptedException e2) {
|
||||
}
|
||||
if (sendEmptyCmd(P2DCmd.P2D_StartTransferImg, Common.EDIT_SNAPSHOT_INTERVAL) < 0) {
|
||||
Logging.error("Fail to start remote transferring");
|
||||
DeviceController.stopProcess();
|
||||
return false;
|
||||
}
|
||||
if (para1.devType == 1) {
|
||||
MagApplication.magParameter.isTraceRoi = false;
|
||||
MagApplication.magParameter.isShowCross = false;
|
||||
MagApplication.magParameter.isTraceMaxMin = true;
|
||||
MagApplication.magParameter.maxMinTrace = -1;
|
||||
MagApplication.magParameter.emissivity = 100;
|
||||
DeviceController.Lock();
|
||||
DeviceController.setEmissivity(100, Priority.INFO_INT);
|
||||
DeviceController.Unlock();
|
||||
} else if (para1.devType == 0 || para1.devType == 5 || para1.devType == 6 || para1.devType == 3) {
|
||||
MagApplication.magParameter.isTraceRoi = false;
|
||||
MagApplication.magParameter.isShowMovingCross = false;
|
||||
MagApplication.magParameter.emissivity = 100;
|
||||
DeviceController.Lock();
|
||||
DeviceController.setEmissivity(100, Priority.INFO_INT);
|
||||
DeviceController.Unlock();
|
||||
} else if (para1.devType == 2) {
|
||||
MagApplication.magParameter.isShowMovingCross = false;
|
||||
MagApplication.magParameter.isTraceMaxMin = true;
|
||||
}
|
||||
if (para1.devType == 1 || para1.devType == 2) {
|
||||
if (MagApplication.magParameter.fpsMode == 0) {
|
||||
MagApplication.magParameter.basePara1.interFrame = 9;
|
||||
MagApplication.magParameter.basePara1.interLine = 12;
|
||||
} else {
|
||||
MagApplication.magParameter.basePara1.interFrame = 105;
|
||||
MagApplication.magParameter.basePara1.interLine = 105;
|
||||
}
|
||||
setFrameRate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void stopTransfer() {
|
||||
if (sendEmptyCmd(P2DCmd.P2D_StopTransferImg, TIMEOUT) < 0) {
|
||||
Logging.error("Fail to stop remote transferring");
|
||||
}
|
||||
this.connected_ = false;
|
||||
try {
|
||||
if (this.threadImgRecv_ != null) {
|
||||
this.threadImgRecv_.join();
|
||||
this.threadImgRecv_ = null;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
this.threadImgRecv_ = null;
|
||||
Logging.trace("Thread join interrupted1");
|
||||
}
|
||||
this.isExitThreadImgProcess_ = true;
|
||||
synchronized (this.condImgProcess_.cond) {
|
||||
this.condImgProcess_.notified = true;
|
||||
this.condImgProcess_.cond.notify();
|
||||
}
|
||||
try {
|
||||
if (this.threadImgProcess_ != null) {
|
||||
this.threadImgProcess_.join();
|
||||
this.threadImgProcess_ = null;
|
||||
}
|
||||
} catch (InterruptedException e2) {
|
||||
this.condImgProcess_ = null;
|
||||
Logging.trace("Thread join interrupted2");
|
||||
}
|
||||
DeviceController.stopProcess();
|
||||
Logging.trace("****Stop****");
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
MsgBus.getInstance().unregister(this.mReceiver);
|
||||
setLaserState(0);
|
||||
MagApplication.magParameter.isLaserOn = false;
|
||||
stopTransfer();
|
||||
this.conn_ = null;
|
||||
if (this.usbConn_ != null) {
|
||||
if (this.usbInterface_ != null) {
|
||||
this.usbConn_.releaseInterface(this.usbInterface_);
|
||||
}
|
||||
this.usbConn_.close();
|
||||
this.usbConn_ = null;
|
||||
}
|
||||
this.usbEpImgIn_ = null;
|
||||
this.usbEpCaliOut_ = null;
|
||||
this.usbEpCaliIn_ = null;
|
||||
this.usbEpCmdOut_ = null;
|
||||
this.usbEpCmdIn_ = null;
|
||||
stopCaliRecvThread();
|
||||
}
|
||||
|
||||
@Override // cn.com.magnity.magnitycx.sdk.DeviceController.ShutterCallBack
|
||||
public void setShutterState(int on) {
|
||||
setShutterState_(on);
|
||||
}
|
||||
|
||||
private void startCaliRecvThread() {
|
||||
if (this.threadCaliRecv_ == null) {
|
||||
this.threadCaliRecv_ = new ThreadCaliRecv();
|
||||
this.isExitCaliRecvThread = false;
|
||||
this.threadCaliRecv_.start();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopCaliRecvThread() {
|
||||
try {
|
||||
if (this.threadCaliRecv_ != null) {
|
||||
this.isExitCaliRecvThread = true;
|
||||
this.threadCaliRecv_.join();
|
||||
this.threadCaliRecv_ = null;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
this.threadCaliRecv_ = null;
|
||||
Logging.trace("Thread join interrupted.");
|
||||
}
|
||||
}
|
||||
|
||||
private void setShutterState_(int on) {
|
||||
byte[] buf = {(byte) P2DCmd.P2D_SetShutterState, (byte) 7059126, (byte) 27574, (byte) 107, (byte) on, (byte) (on >> 8), (byte) (on >> 16), (byte) (on >> 24)};
|
||||
sendCmd(buf, 0, buf.length, TIMEOUT);
|
||||
}
|
||||
|
||||
public boolean setLaserState(int on) {
|
||||
byte[] buf = {(byte) P2DCmd.P2D_SetLaserState, (byte) 7059126, (byte) 27574, (byte) 107, (byte) on, (byte) (on >> 8), (byte) (on >> 16), (byte) (on >> 24)};
|
||||
return sendCmd(buf, 0, buf.length, TIMEOUT) >= 0;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean setFrameRate() {
|
||||
int interFrame;
|
||||
int interLine;
|
||||
byte[] buf = new byte[12];
|
||||
if (MagApplication.magParameter.fpsMode == 0) {
|
||||
interFrame = 9;
|
||||
interLine = 12;
|
||||
} else {
|
||||
interFrame = 105;
|
||||
interLine = 105;
|
||||
}
|
||||
buf[0] = (byte) P2DCmd.P2D_SetFrameRate;
|
||||
buf[1] = (byte) 7059126;
|
||||
buf[2] = (byte) 27574;
|
||||
buf[3] = (byte) 107;
|
||||
buf[4] = (byte) interFrame;
|
||||
buf[5] = (byte) (interFrame >> 8);
|
||||
buf[6] = (byte) (interFrame >> 16);
|
||||
buf[7] = (byte) (interFrame >> 24);
|
||||
buf[8] = (byte) interLine;
|
||||
buf[9] = (byte) (interLine >> 8);
|
||||
buf[10] = (byte) (interLine >> 16);
|
||||
buf[11] = (byte) (interLine >> 24);
|
||||
return sendCmd(buf, 0, buf.length, TIMEOUT) >= 0;
|
||||
}
|
||||
|
||||
private boolean waitForCmdAck(int cmd, int timeout) {
|
||||
switch (cmd) {
|
||||
case P2DCmd.P2D_SetParameter1 /* 1807136365 */:
|
||||
case P2DCmd.P2D_SetParameter2 /* 1807136366 */:
|
||||
case P2DCmd.P2D_GetCaliFile /* 1807136368 */:
|
||||
case P2DCmd.P2D_SendCaliFile /* 1807136369 */:
|
||||
case P2DCmd.P2D_SetShutterState /* 1807136370 */:
|
||||
case P2DCmd.P2D_StartTransferImg /* 1807136371 */:
|
||||
case P2DCmd.P2D_StopTransferImg /* 1807136372 */:
|
||||
case P2DCmd.P2D_SetLaserState /* 1807136374 */:
|
||||
case P2DCmd.P2D_SetFrameRate /* 1807136377 */:
|
||||
byte[] buf = new byte[64];
|
||||
int ret = this.usbConn_.bulkTransfer(this.usbEpCmdIn_, buf, 0, buf.length, timeout);
|
||||
if (ret < 0) {
|
||||
Logging.trace("Fail to get command ack - " + Integer.toHexString(cmd));
|
||||
return false;
|
||||
}
|
||||
case P2DCmd.P2D_GetCaliInfo /* 1807136367 */:
|
||||
case P2DCmd.P2D_GetLifeTime /* 1807136373 */:
|
||||
case P2DCmd.P2D_PowerSave /* 1807136375 */:
|
||||
case P2DCmd.P2D_GetFPAState /* 1807136376 */:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized int sendCmd(byte[] data, int offset, int len, int timeout) {
|
||||
int ret;
|
||||
ret = this.usbConn_.bulkTransfer(this.usbEpCmdOut_, data, offset, len, timeout);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
} else if (!waitForCmdAck(GlobalFunc.byteArrayToInt(data), timeout)) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public synchronized int sendEmptyCmd(int data, int timeout) {
|
||||
int ret;
|
||||
ret = this.usbConn_.bulkTransfer(this.usbEpCmdOut_, GlobalFunc.intToByteArray(data), 0, 4, timeout);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
} else if (!waitForCmdAck(data, timeout)) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public synchronized int recvCmd(byte[] buffer, int offset, int len, int timeout) {
|
||||
return this.usbConn_.bulkTransfer(this.usbEpCmdIn_, buffer, offset, len, timeout);
|
||||
}
|
||||
|
||||
public int sendCali(byte[] data, int offset, int len, int timeout) {
|
||||
int ret = this.usbConn_.bulkTransfer(this.usbEpCaliOut_, data, offset, len, timeout);
|
||||
if (ret >= 0 && waitForCmdAck(GlobalFunc.byteArrayToInt(data), timeout)) {
|
||||
return ret;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public synchronized int sendEmptyCali(int data, int timeout) {
|
||||
int ret;
|
||||
ret = this.usbConn_.bulkTransfer(this.usbEpCaliOut_, GlobalFunc.intToByteArray(data), 0, 4, timeout);
|
||||
if (ret < 0) {
|
||||
ret = -1;
|
||||
} else if (!waitForCmdAck(data, timeout)) {
|
||||
ret = -1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int recvCali(byte[] buffer, int offset, int len, int timeout) {
|
||||
return this.usbConn_.bulkTransfer(this.usbEpCaliIn_, buffer, offset, len, timeout);
|
||||
}
|
||||
|
||||
public int recvImg(byte[] buffer, int offset, int len, int timeout) {
|
||||
return this.usbConn_.bulkTransfer(this.usbEpImgIn_, buffer, offset, len, timeout);
|
||||
}
|
||||
|
||||
public int getCmdInAddress() {
|
||||
return this.usbEpCmdIn_.getAddress();
|
||||
}
|
||||
|
||||
public int getCaliInAddress() {
|
||||
return this.usbEpCaliIn_.getAddress();
|
||||
}
|
||||
|
||||
public int getImgInAddress() {
|
||||
return this.usbEpImgIn_.getAddress();
|
||||
}
|
||||
|
||||
private int parseCmd(byte[] data, int len) {
|
||||
String productType;
|
||||
if (len < 4) {
|
||||
return -1;
|
||||
}
|
||||
ByteBuffer bb = ByteBuffer.wrap(data, 0, len);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
int cmd = bb.getInt();
|
||||
switch (cmd) {
|
||||
case D2PCmd.D2P_SendParameter1 /* 1538635099 */:
|
||||
Logging.trace("D2P_SendParameter1");
|
||||
BasePara1 para1 = MagApplication.magParameter.basePara1;
|
||||
try {
|
||||
para1.serialNumber = bb.getInt();
|
||||
int val = bb.getInt();
|
||||
para1.hwVersion = 16777215 & val;
|
||||
para1.devType = (val >> 24) & 255;
|
||||
para1.swVersion = bb.getInt();
|
||||
para1.reserved1 = bb.getInt();
|
||||
para1.fpaWidth = bb.getInt();
|
||||
para1.fpaHeight = bb.getInt();
|
||||
para1.fps = bb.getInt();
|
||||
para1.reserved2 = bb.getInt();
|
||||
para1.fpaGain = bb.getInt();
|
||||
para1.fpaFlip = bb.getInt();
|
||||
para1.interFrame = bb.getInt();
|
||||
para1.interLine = bb.getInt();
|
||||
para1.gfid = bb.getInt();
|
||||
para1.gsk = bb.getInt();
|
||||
if (bb.hasRemaining()) {
|
||||
Logging.warn("D2PCmd.D2P_SendParameter1 cmd size is too long");
|
||||
return -1;
|
||||
}
|
||||
Logging.trace("Serial number: " + para1.serialNumber);
|
||||
return 1;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
para1.reset();
|
||||
Logging.error("D2PCmd.D2P_SendParameter1 cmd size is not enough");
|
||||
return -1;
|
||||
}
|
||||
case D2PCmd.D2P_SendParameter2 /* 1538635100 */:
|
||||
Logging.trace("D2P_SendParameter2");
|
||||
BasePara2 para2 = MagApplication.magParameter.basePara2;
|
||||
try {
|
||||
para2.baseLineAcc = bb.getInt();
|
||||
para2.denoiseLevel = bb.getInt();
|
||||
para2.reserved1 = bb.getInt();
|
||||
para2.reserved2 = bb.getShort();
|
||||
para2.fpaTempFix = bb.getShort();
|
||||
para2.shutterCloseSpeed = bb.getInt();
|
||||
para2.shutterOpenSpeed = bb.getInt();
|
||||
para2.ffcTriggerFrame = bb.getInt();
|
||||
para2.ffcTriggerTemperature = bb.getInt();
|
||||
para2.enlargeRange = bb.getInt();
|
||||
para2.laserPos = bb.getInt();
|
||||
para2.ATZeroErrorPoint = bb.getInt();
|
||||
para2.ATErrorSlope = bb.getFloat();
|
||||
para2.reserved5 = bb.getInt();
|
||||
para2.reserved6 = bb.getInt();
|
||||
if (bb.hasRemaining()) {
|
||||
Logging.warn("D2PCmd.D2P_SendParameter2 cmd size is too long");
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
} catch (IndexOutOfBoundsException e2) {
|
||||
para2.reset();
|
||||
Logging.error("D2PCmd.D2P_SendParameter2 cmd size is not enough");
|
||||
return -1;
|
||||
}
|
||||
case D2PCmd.D2P_SendCaliFile /* 1538635101 */:
|
||||
Logging.trace("D2P_SendRemoteFile");
|
||||
this.isToRecvFirstCaliPacket_ = true;
|
||||
return 1;
|
||||
case D2PCmd.D2P_SendCaliInfo /* 1538635102 */:
|
||||
Logging.trace("D2P_SendRemoteFileInfo");
|
||||
CaliInfo caliInfo = MagApplication.magParameter.caliInfo;
|
||||
try {
|
||||
caliInfo.size = bb.getInt();
|
||||
caliInfo.reserved = bb.getInt();
|
||||
caliInfo.date = bb.getLong();
|
||||
if (bb.hasRemaining()) {
|
||||
Logging.warn("D2PCmd.D2P_SendRemoteFileInfo cmd size is too long");
|
||||
return -1;
|
||||
}
|
||||
Logging.trace("Remote file info: " + caliInfo.size + ", " + caliInfo.date);
|
||||
if (MagApplication.magParameter.caliInfo.size < 65536 || MagApplication.magParameter.caliInfo.size > MAX_CALI_FILE_LEN) {
|
||||
this.caliPathName_ = "";
|
||||
Logging.error("remoteFileInfo error(invalid size)");
|
||||
return -1;
|
||||
}
|
||||
if (MagApplication.magParameter.caliDir != null) {
|
||||
switch (MagApplication.magParameter.basePara1.devType) {
|
||||
case 0:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c1);
|
||||
break;
|
||||
case 1:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c3);
|
||||
break;
|
||||
case 2:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c3p);
|
||||
break;
|
||||
case 3:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.core160);
|
||||
break;
|
||||
case 4:
|
||||
default:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.unknownProductType);
|
||||
break;
|
||||
case 5:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c1pro);
|
||||
break;
|
||||
case 6:
|
||||
productType = MagApplication.getInstance().getResources().getString(R.string.c1prolite);
|
||||
break;
|
||||
}
|
||||
this.caliPathName_ = MagApplication.magParameter.caliDir + File.separator + productType + "." + MagApplication.magParameter.basePara1.serialNumber + "." + MagApplication.magParameter.caliInfo.date;
|
||||
File dir = new File(MagApplication.magParameter.caliDir);
|
||||
File file = new File(this.caliPathName_);
|
||||
if (!file.exists() || file.length() != MagApplication.magParameter.caliInfo.size) {
|
||||
File[] files = dir.listFiles();
|
||||
for (File f : files) {
|
||||
if (f.getName().contains(MagApplication.magParameter.basePara1.serialNumber + ".")) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
stopCaliRecvThread();
|
||||
startCaliRecvThread();
|
||||
try {
|
||||
Thread.sleep(50L);
|
||||
} catch (InterruptedException e3) {
|
||||
}
|
||||
sendEmptyCmd(P2DCmd.P2D_GetCaliFile, TIMEOUT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
} catch (IndexOutOfBoundsException e4) {
|
||||
caliInfo.reset();
|
||||
Logging.error("D2PCmd.D2P_SendRemoteFileInfo cmd size is not enough");
|
||||
return -1;
|
||||
}
|
||||
default:
|
||||
Logging.warn("Unknown command(" + cmd + ")");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private class ThreadImgRecv extends Thread {
|
||||
private ThreadImgRecv() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
int drop;
|
||||
int frameBytes = ((MagApplication.magParameter.basePara1.fpaWidth * MagApplication.magParameter.basePara1.fpaHeight) * 16) / 8;
|
||||
int imgRecvBufLength = frameBytes + 1024;
|
||||
if (UsbCommunication.this.imgExchangeBuf1_ == null || UsbCommunication.this.imgExchangeBuf1_.length < imgRecvBufLength) {
|
||||
UsbCommunication.this.imgExchangeBuf1_ = new byte[imgRecvBufLength];
|
||||
}
|
||||
Logging.trace("Enter ThreadImgReceiver");
|
||||
byte[] recvbuf = new byte[imgRecvBufLength];
|
||||
boolean headerFound = false;
|
||||
int total = 0;
|
||||
int index = 0;
|
||||
long t1 = 0;
|
||||
while (UsbCommunication.this.connected_) {
|
||||
int len = UsbCommunication.this.recvImg(recvbuf, total, recvbuf.length - total, ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION);
|
||||
if (len > 0) {
|
||||
if (!headerFound) {
|
||||
if (len >= 28) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(recvbuf, 0, 28);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
if (bb.getInt() == UsbCommunication.IMG_START_CODE) {
|
||||
headerFound = true;
|
||||
}
|
||||
}
|
||||
total = 0;
|
||||
} else if (len >= 28) {
|
||||
ByteBuffer bb2 = ByteBuffer.wrap(recvbuf, (total + len) - 28, 28);
|
||||
bb2.order(ByteOrder.LITTLE_ENDIAN);
|
||||
if (bb2.getInt() == UsbCommunication.IMG_END_CODE) {
|
||||
if ((total + len) - 28 == frameBytes) {
|
||||
int frameIndex = bb2.getInt();
|
||||
long t = System.currentTimeMillis();
|
||||
synchronized (UsbCommunication.this.condImgProcess_.cond) {
|
||||
System.arraycopy(recvbuf, 0, UsbCommunication.this.imgExchangeBuf1_, 0, recvbuf.length);
|
||||
if (MagApplication.magParameter.basePara1.devType == 0 || MagApplication.magParameter.basePara1.devType == 5 || MagApplication.magParameter.basePara1.devType == 6 || MagApplication.magParameter.basePara1.devType == 3) {
|
||||
UsbCommunication.this.fpaTemp_ = bb2.getInt();
|
||||
UsbCommunication.this.camTemp_ = UsbCommunication.this.fpaTemp_ - 500;
|
||||
drop = bb2.getInt();
|
||||
} else {
|
||||
bb2.getInt();
|
||||
drop = bb2.getInt();
|
||||
UsbCommunication.this.camTemp_ = bb2.getInt();
|
||||
UsbCommunication.this.fpaTemp_ = UsbCommunication.this.camTemp_ + 500;
|
||||
}
|
||||
if (drop == 0 || drop == 1) {
|
||||
UsbCommunication.this.condImgProcess_.notified = true;
|
||||
UsbCommunication.this.condImgProcess_.cond.notify();
|
||||
}
|
||||
}
|
||||
if (UsbCommunication.this.imgViewer_ != null && (index == 0 || !UsbCommunication.this.imgViewer_.getTempStableFlag() || UsbCommunication.this.imgViewer_.getImageStableCounter() != 0)) {
|
||||
int index2 = index + 1;
|
||||
if ((index & 15) == 0) {
|
||||
UsbCommunication.this.handler_.sendEmptyMessage(4);
|
||||
}
|
||||
index = index2;
|
||||
}
|
||||
if (MagApplication.isShowFps) {
|
||||
if (t1 != 0) {
|
||||
UsbCommunication.lock_.lock();
|
||||
UsbCommunication.ticks_[frameIndex % UsbCommunication.ticks_.length] = t - t1;
|
||||
UsbCommunication.lock_.unlock();
|
||||
}
|
||||
t1 = t;
|
||||
}
|
||||
}
|
||||
headerFound = false;
|
||||
total = 0;
|
||||
} else {
|
||||
total += len;
|
||||
}
|
||||
} else {
|
||||
total += len;
|
||||
}
|
||||
if (total > frameBytes) {
|
||||
headerFound = false;
|
||||
total = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Logging.trace("Leave ThreadImgReceiver");
|
||||
}
|
||||
}
|
||||
|
||||
public static int getReceivedFps() {
|
||||
long[] ticks = new long[ticks_.length];
|
||||
lock_.lock();
|
||||
System.arraycopy(ticks_, 0, ticks, 0, ticks_.length);
|
||||
lock_.unlock();
|
||||
int sum = 0;
|
||||
for (int i = ticks.length - 1; i != -1; i--) {
|
||||
sum = (int) (sum + ticks[i]);
|
||||
}
|
||||
return (ticks_.length * 1000) / sum;
|
||||
}
|
||||
|
||||
private class ThreadImgProcess extends Thread {
|
||||
private ThreadImgProcess() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
int fpaTemp;
|
||||
int camTemp;
|
||||
Logging.trace("Enter ThreadImgProcess");
|
||||
int frameBytes = ((MagApplication.magParameter.basePara1.fpaWidth * MagApplication.magParameter.basePara1.fpaHeight) * 16) / 8;
|
||||
byte[] imgExchangeBuf2 = new byte[frameBytes + 1024];
|
||||
while (!UsbCommunication.this.isExitThreadImgProcess_) {
|
||||
synchronized (UsbCommunication.this.condImgProcess_.cond) {
|
||||
while (!UsbCommunication.this.condImgProcess_.notified) {
|
||||
try {
|
||||
UsbCommunication.this.condImgProcess_.cond.wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
UsbCommunication.this.condImgProcess_.notified = false;
|
||||
if (imgExchangeBuf2 == null) {
|
||||
imgExchangeBuf2 = new byte[UsbCommunication.this.imgExchangeBuf1_.length];
|
||||
}
|
||||
System.arraycopy(UsbCommunication.this.imgExchangeBuf1_, 0, imgExchangeBuf2, 0, UsbCommunication.this.imgExchangeBuf1_.length);
|
||||
fpaTemp = UsbCommunication.this.fpaTemp_ + MagApplication.magParameter.basePara2.fpaTempFix;
|
||||
camTemp = UsbCommunication.this.camTemp_ + MagApplication.magParameter.basePara2.fpaTempFix;
|
||||
}
|
||||
DeviceController.Lock();
|
||||
boolean ret = DeviceController.pushFrame(imgExchangeBuf2, fpaTemp, camTemp);
|
||||
DeviceController.Unlock();
|
||||
if (UsbCommunication.this.isExitThreadImgProcess_) {
|
||||
break;
|
||||
} else if (ret && UsbCommunication.this.imgViewer_ != null) {
|
||||
UsbCommunication.this.imgViewer_.onNewFrameReceived(fpaTemp, camTemp);
|
||||
}
|
||||
}
|
||||
Logging.trace("Leave ThreadImgProcess");
|
||||
}
|
||||
}
|
||||
|
||||
private class ThreadCaliRecv extends Thread {
|
||||
private ThreadCaliRecv() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Logging.trace("Enter ThreadRemoteFileReceiver");
|
||||
byte[] recvbuf = new byte[16384];
|
||||
int totalSize = 0;
|
||||
FileOutputStream out = null;
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(0, 0));
|
||||
long t1 = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (UsbCommunication.this.isExitCaliRecvThread) {
|
||||
break;
|
||||
}
|
||||
int remain = MagApplication.magParameter.caliInfo.size - totalSize;
|
||||
UsbCommunication usbCommunication = UsbCommunication.this;
|
||||
if (remain > 16384) {
|
||||
remain = recvbuf.length;
|
||||
}
|
||||
int len = usbCommunication.recvCali(recvbuf, 0, remain, UsbCommunication.TIMEOUT);
|
||||
if (len >= 0 && !UsbCommunication.this.caliPathName_.isEmpty()) {
|
||||
if (UsbCommunication.this.isToRecvFirstCaliPacket_) {
|
||||
totalSize = 0;
|
||||
UsbCommunication.this.isToRecvFirstCaliPacket_ = false;
|
||||
}
|
||||
if (totalSize == 0) {
|
||||
try {
|
||||
FileOutputStream out2 = new FileOutputStream(UsbCommunication.this.caliPathName_);
|
||||
out = out2;
|
||||
} catch (Exception e) {
|
||||
Logging.error("Receive remote file error 1.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
}
|
||||
totalSize += len;
|
||||
if (totalSize > MagApplication.magParameter.caliInfo.size) {
|
||||
try {
|
||||
out.close();
|
||||
Logging.error("Receive remote file error 3.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
break;
|
||||
} catch (Exception e2) {
|
||||
Logging.error("Receive remote file error 2.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
out.write(recvbuf, 0, len);
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(2, 0, (totalSize * 100) / MagApplication.magParameter.caliInfo.size));
|
||||
if (totalSize == MagApplication.magParameter.caliInfo.size) {
|
||||
try {
|
||||
out.close();
|
||||
Logging.info("Receive remote file succ.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(1, 0));
|
||||
if (!UsbCommunication.this.startTransfer(UsbCommunication.this.caliPathName_)) {
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
Logging.error("SDK start fail.");
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
Logging.error("Receive remote file error 5.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
}
|
||||
} catch (Exception e4) {
|
||||
Logging.error("Receive remote file error 4.");
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
}
|
||||
}
|
||||
} else if (System.currentTimeMillis() - t1 > Config.BPLUS_DELAY_TIME) {
|
||||
UsbCommunication.this.handler_.sendMessage(UsbCommunication.this.handler_.obtainMessage(3, 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
Logging.trace("Leave ThreadRemoteFileReceiver");
|
||||
}
|
||||
}
|
||||
}
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.hardware.usb.UsbDevice;
|
||||
import android.hardware.usb.UsbManager;
|
||||
import android.telephony.TelephonyManager;
|
||||
import cn.com.magnity.magnitycx.FragmentMainCenter;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UsbConnection extends Observable<DelegateDeviceConnected> {
|
||||
private static final String ACTION_USB_PERMISSION = "cn.com.magnity.magnitycx.USB_PERMISSION";
|
||||
private static UsbConnection instance_ = new UsbConnection();
|
||||
private FragmentMainCenter fragmentMainCenter_;
|
||||
private PhoneReceiver phoneReceiver_;
|
||||
private UsbCommunication usbComm_;
|
||||
private UsbConnectionReceiver usbConnectionReceiver_;
|
||||
private UsbPermissionReceiver usbPermissionReceiver_;
|
||||
private Context context_ = MagApplication.getInstance();
|
||||
private UsbManager usbManager_ = (UsbManager) this.context_.getSystemService("usb");
|
||||
|
||||
public static UsbConnection getInstance() {
|
||||
return instance_;
|
||||
}
|
||||
|
||||
private UsbConnection() {
|
||||
}
|
||||
|
||||
public void setCallbackReceiver(FragmentMainCenter fragment) {
|
||||
this.fragmentMainCenter_ = fragment;
|
||||
if (this.usbComm_ != null) {
|
||||
this.usbComm_.setCallbackReceiver(fragment);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
if (this.phoneReceiver_ == null) {
|
||||
registerPhoneReceiver();
|
||||
}
|
||||
if (this.usbConnectionReceiver_ == null) {
|
||||
registerConnectionReceiver();
|
||||
}
|
||||
UsbDevice device = findDevice(33596, 1);
|
||||
if (device != null) {
|
||||
requestDevicePermission(device);
|
||||
}
|
||||
return device != null;
|
||||
}
|
||||
|
||||
public void deinit(boolean notifyUi) {
|
||||
if (this.usbConnectionReceiver_ != null) {
|
||||
this.context_.unregisterReceiver(this.usbConnectionReceiver_);
|
||||
this.usbConnectionReceiver_ = null;
|
||||
}
|
||||
if (this.usbPermissionReceiver_ != null) {
|
||||
this.context_.unregisterReceiver(this.usbPermissionReceiver_);
|
||||
this.usbPermissionReceiver_ = null;
|
||||
}
|
||||
disconnect(notifyUi);
|
||||
}
|
||||
|
||||
public boolean isConnected() {
|
||||
return this.usbComm_ != null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public boolean connect(UsbDevice device) {
|
||||
if (this.usbComm_ != null) {
|
||||
return true;
|
||||
}
|
||||
Logging.info("Try to connect to device");
|
||||
try {
|
||||
this.usbComm_ = new UsbCommunication(this, this.usbManager_, device, this.fragmentMainCenter_);
|
||||
int ret = this.usbComm_.connect();
|
||||
if (ret == -1) {
|
||||
Logging.error("Fail to connect to device, do clean work now");
|
||||
this.usbComm_.disconnect();
|
||||
this.usbComm_ = null;
|
||||
return false;
|
||||
}
|
||||
if (ret == 0) {
|
||||
return false;
|
||||
}
|
||||
notifyObervers(1);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
Logging.warn("Exception when connecting to device (" + ex.getMessage() + ")");
|
||||
if (this.usbComm_ != null) {
|
||||
this.usbComm_.disconnect();
|
||||
}
|
||||
this.usbComm_ = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void notifyObervers(int status) {
|
||||
synchronized (this.observers_) {
|
||||
if (status == 1) {
|
||||
for (int i = this.observers_.size() - 1; i != -1; i--) {
|
||||
((DelegateDeviceConnected) this.observers_.get(i)).onDeviceConnected(this.usbComm_);
|
||||
}
|
||||
} else if (status == 2) {
|
||||
for (int i2 = this.observers_.size() - 1; i2 != -1; i2--) {
|
||||
}
|
||||
} else if (status == 0) {
|
||||
for (int i3 = this.observers_.size() - 1; i3 != -1; i3--) {
|
||||
((DelegateDeviceConnected) this.observers_.get(i3)).onDeviceDisconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void disconnect(boolean notifyUi) {
|
||||
Logging.info("Try to disconnect to device");
|
||||
if (this.usbComm_ != null) {
|
||||
this.usbComm_.disconnect();
|
||||
this.usbComm_ = null;
|
||||
}
|
||||
if (notifyUi) {
|
||||
notifyObervers(0);
|
||||
}
|
||||
}
|
||||
|
||||
private UsbDevice findDevice(int vendorId, int productId) {
|
||||
for (UsbDevice device : this.usbManager_.getDeviceList().values()) {
|
||||
if (device.getVendorId() == vendorId && device.getProductId() == productId) {
|
||||
return device;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void registerConnectionReceiver() {
|
||||
this.usbConnectionReceiver_ = new UsbConnectionReceiver();
|
||||
IntentFilter localFilter = new IntentFilter();
|
||||
localFilter.addAction("android.hardware.usb.action.USB_DEVICE_ATTACHED");
|
||||
localFilter.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED");
|
||||
this.context_.registerReceiver(this.usbConnectionReceiver_, localFilter);
|
||||
}
|
||||
|
||||
private void registerPhoneReceiver() {
|
||||
this.phoneReceiver_ = new PhoneReceiver();
|
||||
IntentFilter localFilter = new IntentFilter();
|
||||
localFilter.addAction("android.intent.action.NEW_OUTGOING_CALL");
|
||||
localFilter.addAction("android.intent.action.PHONE_STATE");
|
||||
this.context_.registerReceiver(this.phoneReceiver_, localFilter);
|
||||
}
|
||||
|
||||
private void requestDevicePermission(UsbDevice device) {
|
||||
if (this.usbManager_.hasPermission(device)) {
|
||||
Logging.trace("Already has permission");
|
||||
connect(device);
|
||||
return;
|
||||
}
|
||||
if (this.usbPermissionReceiver_ == null) {
|
||||
this.usbPermissionReceiver_ = new UsbPermissionReceiver();
|
||||
IntentFilter localFilter = new IntentFilter(ACTION_USB_PERMISSION);
|
||||
this.context_.registerReceiver(this.usbPermissionReceiver_, localFilter);
|
||||
}
|
||||
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.context_, 0, new Intent(ACTION_USB_PERMISSION), 0);
|
||||
this.usbManager_.requestPermission(device, pendingIntent);
|
||||
Logging.trace("Request permission");
|
||||
}
|
||||
|
||||
private final class UsbConnectionReceiver extends BroadcastReceiver {
|
||||
private UsbConnectionReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "android.hardware.usb.action.USB_DEVICE_ATTACHED":
|
||||
Logging.trace("Broadcast for usb attached received");
|
||||
UsbConnection.this.disconnect(false);
|
||||
UsbConnection.this.init();
|
||||
break;
|
||||
case "android.hardware.usb.action.USB_DEVICE_DETACHED":
|
||||
Logging.trace("Broadcast for usb detached received");
|
||||
UsbConnection.this.disconnect(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class UsbPermissionReceiver extends BroadcastReceiver {
|
||||
private UsbPermissionReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "cn.com.magnity.magnitycx.USB_PERMISSION":
|
||||
Logging.trace("Broadcast for usb permission received");
|
||||
if (!intent.getBooleanExtra("permission", false)) {
|
||||
Logging.warn("Permission rejected by user");
|
||||
break;
|
||||
} else {
|
||||
UsbDevice device = (UsbDevice) intent.getParcelableExtra("device");
|
||||
if (device != null) {
|
||||
UsbConnection.this.connect(device);
|
||||
UsbConnection.this.context_.unregisterReceiver(UsbConnection.this.usbPermissionReceiver_);
|
||||
UsbConnection.this.usbPermissionReceiver_ = null;
|
||||
break;
|
||||
} else {
|
||||
Logging.warn("Failed to get device");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PhoneReceiver extends BroadcastReceiver {
|
||||
private PhoneReceiver() {
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
switch (intent.getAction()) {
|
||||
case "android.intent.action.PHONE_STATE":
|
||||
if (MagApplication.magParameter.basePara1.swVersion > 100) {
|
||||
String state = intent.getStringExtra("state");
|
||||
if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)) {
|
||||
Logging.trace("ring");
|
||||
UsbConnection.this.deinit(true);
|
||||
break;
|
||||
} else if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_IDLE)) {
|
||||
Logging.trace("hang up");
|
||||
UsbConnection.this.init();
|
||||
break;
|
||||
} else if (state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_OFFHOOK)) {
|
||||
Logging.trace("hang on");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.hardware.Camera;
|
||||
import android.view.SurfaceHolder;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VisibleCamera {
|
||||
private static Camera camera_;
|
||||
private static boolean isPreview_;
|
||||
|
||||
public static void initCamera(int id, SurfaceHolder surfaceHolder, int size) {
|
||||
if (Camera.getNumberOfCameras() >= 1) {
|
||||
if (!isPreview_) {
|
||||
camera_ = Camera.open(id);
|
||||
setPreviewOrientation(id);
|
||||
}
|
||||
if (camera_ != null && !isPreview_) {
|
||||
try {
|
||||
Camera.Parameters parameters = camera_.getParameters();
|
||||
setPreviewSize(parameters, size);
|
||||
parameters.setPictureFormat(256);
|
||||
parameters.set("jpeg-quality", 85);
|
||||
parameters.setFlashMode("auto");
|
||||
parameters.setFocusMode("continuous-picture");
|
||||
camera_.setParameters(parameters);
|
||||
camera_.setPreviewDisplay(surfaceHolder);
|
||||
camera_.startPreview();
|
||||
camera_.cancelAutoFocus();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
isPreview_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deinitCamera() {
|
||||
if (camera_ != null) {
|
||||
if (isPreview_) {
|
||||
camera_.stopPreview();
|
||||
isPreview_ = false;
|
||||
}
|
||||
camera_.release();
|
||||
camera_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPreviewSize(Camera.Parameters parameters, int size) {
|
||||
List<Camera.Size> list = parameters.getSupportedPreviewSizes();
|
||||
int num = list.size();
|
||||
for (int i = 0; i < num; i++) {
|
||||
Camera.Size s = list.get(i);
|
||||
if ((s.width <= s.height || s.width * 3 == s.height * 4) && ((s.width >= s.height || s.width * 4 == s.height * 3) && Math.min(s.width, s.height) >= size)) {
|
||||
parameters.setPreviewSize(s.width, s.height);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void setPreviewOrientation(int id) {
|
||||
int result;
|
||||
if (camera_ != null) {
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(id, info);
|
||||
int rotation = MagApplication.windowManager.getDefaultDisplay().getRotation();
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
degrees = 0;
|
||||
break;
|
||||
case 1:
|
||||
degrees = 90;
|
||||
break;
|
||||
case 2:
|
||||
degrees = 180;
|
||||
break;
|
||||
case 3:
|
||||
degrees = 270;
|
||||
break;
|
||||
}
|
||||
if (info.facing == 1) {
|
||||
int result2 = (info.orientation + degrees) % 360;
|
||||
result = (360 - result2) % 360;
|
||||
} else {
|
||||
result = ((info.orientation - degrees) + 360) % 360;
|
||||
}
|
||||
camera_.setDisplayOrientation(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isCameraPermission() {
|
||||
if (camera_ != null) {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
Camera.open().release();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+291
@@ -0,0 +1,291 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.hardware.Camera;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import android.view.SurfaceHolder;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class VisibleCameraHelper {
|
||||
private static volatile VisibleCameraHelper instance_;
|
||||
private Camera camera_;
|
||||
private final CameraSizeComparator sizeComparator = new CameraSizeComparator();
|
||||
private Camera.PictureCallback jpegCallback = new Camera.PictureCallback() { // from class: cn.com.magnity.magnitycx.sdk.VisibleCameraHelper.1
|
||||
@Override // android.hardware.Camera.PictureCallback
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
try {
|
||||
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
File myCaptureFile = new File(MagApplication.magParameter.mediaDir, "1.jpg");
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
|
||||
bm.compress(Bitmap.CompressFormat.JPEG, 100, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
camera.stopPreview();
|
||||
camera.startPreview();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public int getOrientation(Context context, Uri photoUri) {
|
||||
Cursor cursor = context.getContentResolver().query(photoUri, new String[]{"_id", "orientation"}, null, null, null);
|
||||
if (cursor == null) {
|
||||
return 0;
|
||||
}
|
||||
cursor.moveToFirst();
|
||||
int i = cursor.getInt(cursor.getColumnIndexOrThrow("orientation"));
|
||||
cursor.close();
|
||||
return i;
|
||||
}
|
||||
|
||||
public int getExifOrientation(String filepath) {
|
||||
int orientation;
|
||||
ExifInterface exif = null;
|
||||
try {
|
||||
ExifInterface exif2 = new ExifInterface(filepath);
|
||||
exif = exif2;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if (exif == null || (orientation = exif.getAttributeInt("Orientation", -1)) == -1) {
|
||||
return 0;
|
||||
}
|
||||
switch (orientation) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static VisibleCameraHelper getInstance() {
|
||||
if (instance_ == null) {
|
||||
synchronized (VisibleCameraHelper.class) {
|
||||
if (instance_ == null) {
|
||||
instance_ = new VisibleCameraHelper();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
public boolean openCamera(int id) {
|
||||
if (Camera.getNumberOfCameras() < 1) {
|
||||
return false;
|
||||
}
|
||||
if (this.camera_ != null) {
|
||||
stopPreview();
|
||||
closeCamera();
|
||||
}
|
||||
try {
|
||||
this.camera_ = Camera.open(id);
|
||||
return this.camera_ != null;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void closeCamera() {
|
||||
if (this.camera_ != null) {
|
||||
this.camera_.release();
|
||||
this.camera_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Size setPreviewSize(int expectedWidth, float rate) {
|
||||
Camera.Parameters parameters;
|
||||
if (this.camera_ == null || (parameters = this.camera_.getParameters()) == null) {
|
||||
return null;
|
||||
}
|
||||
List<Camera.Size> list = parameters.getSupportedPreviewSizes();
|
||||
Collections.sort(list, this.sizeComparator);
|
||||
Camera.Size size = null;
|
||||
int num = list.size();
|
||||
int i = 0;
|
||||
while (i < num) {
|
||||
Camera.Size size2 = list.get(i);
|
||||
size = size2;
|
||||
if (size.width > expectedWidth && equalRate(size, rate)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i == num) {
|
||||
return null;
|
||||
}
|
||||
parameters.setPreviewSize(size.width, size.height);
|
||||
this.camera_.setParameters(parameters);
|
||||
return new Size(size.width, size.height);
|
||||
}
|
||||
|
||||
public Size setPictureSize(int expectedWidth, float rate) {
|
||||
Camera.Parameters parameters;
|
||||
if (this.camera_ == null || (parameters = this.camera_.getParameters()) == null) {
|
||||
return null;
|
||||
}
|
||||
List<Camera.Size> list = parameters.getSupportedPictureSizes();
|
||||
Collections.sort(list, this.sizeComparator);
|
||||
Camera.Size size = null;
|
||||
int num = list.size();
|
||||
int i = 0;
|
||||
while (i < num) {
|
||||
Camera.Size size2 = list.get(i);
|
||||
size = size2;
|
||||
if (size.width > expectedWidth && equalRate(size, rate)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (i == num) {
|
||||
return null;
|
||||
}
|
||||
parameters.setPictureSize(size.width, size.height);
|
||||
this.camera_.setParameters(parameters);
|
||||
return new Size(size.width, size.height);
|
||||
}
|
||||
|
||||
private boolean equalRate(Camera.Size s, float rate) {
|
||||
float r = s.width / s.height;
|
||||
return ((double) Math.abs(r - rate)) <= 0.1d;
|
||||
}
|
||||
|
||||
public boolean startPreview(SurfaceHolder holder, int flashMode) {
|
||||
String mode;
|
||||
if (this.camera_ == null) {
|
||||
return false;
|
||||
}
|
||||
stopPreview();
|
||||
try {
|
||||
this.camera_.setPreviewDisplay(holder);
|
||||
Camera.Parameters parameters = this.camera_.getParameters();
|
||||
if (parameters != null) {
|
||||
switch (flashMode) {
|
||||
case 0:
|
||||
mode = "off";
|
||||
break;
|
||||
case 1:
|
||||
mode = "auto";
|
||||
break;
|
||||
case 2:
|
||||
mode = "on";
|
||||
break;
|
||||
case 3:
|
||||
mode = "red-eye";
|
||||
break;
|
||||
case 4:
|
||||
mode = "torch";
|
||||
break;
|
||||
default:
|
||||
mode = "off";
|
||||
break;
|
||||
}
|
||||
parameters.setFlashMode(mode);
|
||||
this.camera_.setParameters(parameters);
|
||||
}
|
||||
this.camera_.startPreview();
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void stopPreview() {
|
||||
if (this.camera_ != null) {
|
||||
this.camera_.stopPreview();
|
||||
}
|
||||
}
|
||||
|
||||
public int setPreviewOrientation(int cameraId) {
|
||||
int result;
|
||||
if (this.camera_ == null) {
|
||||
return 0;
|
||||
}
|
||||
Camera.CameraInfo info = new Camera.CameraInfo();
|
||||
Camera.getCameraInfo(cameraId, info);
|
||||
int rotation = MagApplication.windowManager.getDefaultDisplay().getRotation();
|
||||
int degrees = 0;
|
||||
switch (rotation) {
|
||||
case 0:
|
||||
degrees = 0;
|
||||
break;
|
||||
case 1:
|
||||
degrees = 90;
|
||||
break;
|
||||
case 2:
|
||||
degrees = 180;
|
||||
break;
|
||||
case 3:
|
||||
degrees = 270;
|
||||
break;
|
||||
}
|
||||
if (info.facing == 1) {
|
||||
int result2 = (info.orientation + degrees) % 360;
|
||||
result = (360 - result2) % 360;
|
||||
} else {
|
||||
result = ((info.orientation - degrees) + 360) % 360;
|
||||
}
|
||||
this.camera_.setDisplayOrientation(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void takePicture() {
|
||||
if (this.camera_ != null) {
|
||||
this.camera_.takePicture(null, null, this.jpegCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private class CameraSizeComparator implements Comparator<Camera.Size> {
|
||||
private CameraSizeComparator() {
|
||||
}
|
||||
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Camera.Size lhs, Camera.Size rhs) {
|
||||
if (lhs.width == rhs.width) {
|
||||
return 0;
|
||||
}
|
||||
if (lhs.width > rhs.width) {
|
||||
return 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public class Size {
|
||||
private int height_;
|
||||
private int width_;
|
||||
|
||||
public Size() {
|
||||
}
|
||||
|
||||
public Size(int width, int height) {
|
||||
this.width_ = width;
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width_ = width;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height_ = height;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width_;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height_;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.com.magnity.magnitycx.sdk;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class WaitCondition {
|
||||
public final Object cond = new Object();
|
||||
public volatile boolean notified = false;
|
||||
}
|
||||
+315
@@ -0,0 +1,315 @@
|
||||
package cn.com.magnity.magnitycx.upgrade;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.v4.content.FileProvider;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import cn.com.magnity.magnitycx.MainActivity;
|
||||
import cn.com.magnity.magnitycx.R;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
import org.apache.log4j.Priority;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class CheckVersionTask implements Runnable {
|
||||
private static final int CHECK_ERROR = -1;
|
||||
private static final int CHECK_OK = 0;
|
||||
private static final String UPGRADEINFO_DESC = "description";
|
||||
private static final String UPGRADEINFO_FORCE = "forceUpgrade";
|
||||
private static final String UPGRADEINFO_URL = "url";
|
||||
private static final String UPGRADEINFO_VERSIONCODE = "versionCode";
|
||||
private static final String UPGRADEINFO_VERSIONNAME = "versionName";
|
||||
public static final int UPGRADE_BEGIN = 1;
|
||||
private static final int UPGRADE_ERROR = -2;
|
||||
public static final int UPGRADE_FINISHED = 3;
|
||||
public static final int UPGRADE_RECEIVED_SIZE = 2;
|
||||
private Context ctx_;
|
||||
private boolean isForceUpgrade_;
|
||||
private int localVersion_;
|
||||
Handler handler_ = new Handler() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case -2:
|
||||
if (CheckVersionTask.this.progressDialog_ != null) {
|
||||
CheckVersionTask.this.progressDialog_.dismiss();
|
||||
CheckVersionTask.this.progressDialog_ = null;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(CheckVersionTask.this.ctx_);
|
||||
builder.setTitle(R.string.upgradeError);
|
||||
builder.setPositiveButton(R.string.labelOK, new DialogInterface.OnClickListener() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.1.1
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
CheckVersionTask.this.unlockScreen();
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.show();
|
||||
break;
|
||||
case -1:
|
||||
CheckVersionTask.this.unlockScreen();
|
||||
break;
|
||||
case 0:
|
||||
CheckVersionTask.this.lockScreen();
|
||||
Bundle bundle = msg.getData();
|
||||
CheckVersionTask.this.isForceUpgrade_ = bundle.getBoolean(CheckVersionTask.UPGRADEINFO_FORCE);
|
||||
CheckVersionTask.this.showUpgradeDialog(bundle.getString(CheckVersionTask.UPGRADEINFO_DESC), bundle.getString(CheckVersionTask.UPGRADEINFO_URL), bundle.getString(CheckVersionTask.UPGRADEINFO_VERSIONNAME), bundle.getInt(CheckVersionTask.UPGRADEINFO_VERSIONCODE), CheckVersionTask.this.isForceUpgrade_);
|
||||
break;
|
||||
case 1:
|
||||
CheckVersionTask.this.progressDialog_ = new ProgressDialog(CheckVersionTask.this.ctx_);
|
||||
CheckVersionTask.this.progressDialog_.setOnCancelListener(new DialogInterface.OnCancelListener() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.1.2
|
||||
@Override // android.content.DialogInterface.OnCancelListener
|
||||
public void onCancel(DialogInterface dialog2) {
|
||||
CheckVersionTask.this.stopDownloadApk();
|
||||
CheckVersionTask.this.unlockScreen();
|
||||
if (CheckVersionTask.this.isForceUpgrade_ && (CheckVersionTask.this.ctx_ instanceof MainActivity)) {
|
||||
((MainActivity) CheckVersionTask.this.ctx_).onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
CheckVersionTask.this.progressDialog_.setProgressStyle(1);
|
||||
CheckVersionTask.this.progressDialog_.setMessage(CheckVersionTask.this.ctx_.getResources().getString(R.string.upgrading));
|
||||
CheckVersionTask.this.progressDialog_.setProgressNumberFormat("%1d KB/%2d KB");
|
||||
CheckVersionTask.this.progressDialog_.setProgress(0);
|
||||
CheckVersionTask.this.progressDialog_.setMax(msg.arg1 / 1000);
|
||||
CheckVersionTask.this.progressDialog_.setCanceledOnTouchOutside(false);
|
||||
CheckVersionTask.this.progressDialog_.show();
|
||||
break;
|
||||
case 2:
|
||||
if (CheckVersionTask.this.progressDialog_ != null) {
|
||||
CheckVersionTask.this.progressDialog_.setProgress(msg.arg1 / 1000);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (CheckVersionTask.this.progressDialog_ != null) {
|
||||
CheckVersionTask.this.progressDialog_.dismiss();
|
||||
CheckVersionTask.this.progressDialog_ = null;
|
||||
}
|
||||
CheckVersionTask.this.unlockScreen();
|
||||
if (msg.obj != null && (msg.obj instanceof File)) {
|
||||
CheckVersionTask.this.installApk((File) msg.obj);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
private ProgressDialog progressDialog_ = null;
|
||||
private Thread threadUpgrading_ = null;
|
||||
|
||||
public CheckVersionTask(Context ctx, int localVersion) {
|
||||
this.ctx_ = ctx;
|
||||
this.localVersion_ = localVersion;
|
||||
}
|
||||
|
||||
public void stopDownload() {
|
||||
stopDownloadApk();
|
||||
}
|
||||
|
||||
public UpgradeInfo parseVersionInfo(String str) throws Exception {
|
||||
UpgradeInfo info = null;
|
||||
JSONObject object = new JSONObject(str);
|
||||
if (object != null && object.length() >= 1) {
|
||||
String productType = this.ctx_.getString(R.string.upgradeID);
|
||||
if (object.has(productType)) {
|
||||
JSONArray array = object.getJSONArray(productType);
|
||||
if (array.length() > 0) {
|
||||
JSONObject obj = array.getJSONObject(array.length() - 1);
|
||||
info = new UpgradeInfo();
|
||||
if (obj.has("verName")) {
|
||||
info.setVersionName(obj.getString("verName"));
|
||||
}
|
||||
if (obj.has("verCode")) {
|
||||
info.setVersionCode(obj.getInt("verCode"));
|
||||
}
|
||||
if (obj.has("apkUrl")) {
|
||||
info.setApkUrl(obj.getString("apkUrl"));
|
||||
}
|
||||
try {
|
||||
Configuration config = this.ctx_.getResources().getConfiguration();
|
||||
if (!config.locale.getLanguage().equals(Locale.CHINA.getLanguage()) || !config.locale.getCountry().equals(Locale.CHINA.getCountry())) {
|
||||
if (obj.has("description-en")) {
|
||||
info.setDescription(obj.getString("description-en"));
|
||||
}
|
||||
} else if (obj.has(UPGRADEINFO_DESC)) {
|
||||
info.setDescription(obj.getString(UPGRADEINFO_DESC));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (obj.has(UPGRADEINFO_FORCE)) {
|
||||
info.setForceUpgrade(obj.getBoolean(UPGRADEINFO_FORCE));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void lockScreen() {
|
||||
if (this.ctx_ instanceof Activity) {
|
||||
((Activity) this.ctx_).setRequestedOrientation(14);
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void unlockScreen() {
|
||||
if (this.ctx_ instanceof Activity) {
|
||||
((Activity) this.ctx_).setRequestedOrientation(10);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
String path = this.ctx_.getResources().getString(R.string.remote_url);
|
||||
try {
|
||||
String str = HttpHelper.GetRemoteVersionInfo(path, 10000, Priority.INFO_INT);
|
||||
UpgradeInfo upgradeInfo = parseVersionInfo(str);
|
||||
if (upgradeInfo == null) {
|
||||
Logging.info("Parse version info fail.");
|
||||
this.handler_.sendEmptyMessage(-1);
|
||||
} else if (upgradeInfo.getVersionCode() > this.localVersion_) {
|
||||
Logging.info("New app version is detected(" + upgradeInfo.getVersionCode() + ")");
|
||||
Message msg = new Message();
|
||||
msg.what = 0;
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(UPGRADEINFO_FORCE, upgradeInfo.isForceUpgrade());
|
||||
bundle.putString(UPGRADEINFO_DESC, upgradeInfo.getDescription());
|
||||
bundle.putString(UPGRADEINFO_URL, upgradeInfo.getApkUrl());
|
||||
bundle.putString(UPGRADEINFO_VERSIONNAME, upgradeInfo.getVersionName());
|
||||
bundle.putInt(UPGRADEINFO_VERSIONCODE, upgradeInfo.getVersionCode());
|
||||
msg.setData(bundle);
|
||||
this.handler_.sendMessage(msg);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
this.handler_.sendEmptyMessage(-1);
|
||||
Logging.error("Check upgrade error(" + ex.getMessage() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void showUpgradeDialog(String description, final String url, final String versionName, final int versionCode, boolean isForceUpgrade) {
|
||||
AlertDialog.Builder builer = new AlertDialog.Builder(this.ctx_);
|
||||
builer.setTitle(this.ctx_.getResources().getString(R.string.upgrade) + "(V" + versionName + ")");
|
||||
builer.setMessage(description);
|
||||
builer.setPositiveButton(R.string.labelOK, new DialogInterface.OnClickListener() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.2
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String path = MagApplication.magParameter.otherDir + File.separator + "MAG-Cx." + versionName + ".apk";
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
PackageManager pm = CheckVersionTask.this.ctx_.getPackageManager();
|
||||
PackageInfo packInfo = pm.getPackageArchiveInfo(path, 1);
|
||||
if (packInfo == null || packInfo.versionCode != versionCode) {
|
||||
CheckVersionTask.this.startDownloadApk(url, versionName);
|
||||
return;
|
||||
} else {
|
||||
CheckVersionTask.this.installApk(file);
|
||||
return;
|
||||
}
|
||||
}
|
||||
CheckVersionTask.this.startDownloadApk(url, versionName);
|
||||
}
|
||||
});
|
||||
if (!isForceUpgrade) {
|
||||
builer.setNegativeButton(R.string.labelCancel, new DialogInterface.OnClickListener() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.3
|
||||
@Override // android.content.DialogInterface.OnClickListener
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
CheckVersionTask.this.unlockScreen();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builer.setOnCancelListener(new DialogInterface.OnCancelListener() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.4
|
||||
@Override // android.content.DialogInterface.OnCancelListener
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
if (CheckVersionTask.this.ctx_ instanceof MainActivity) {
|
||||
((MainActivity) CheckVersionTask.this.ctx_).onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
AlertDialog dialog = builer.create();
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void startDownloadApk(final String url, final String version) {
|
||||
HttpHelper.isCancelled = false;
|
||||
this.threadUpgrading_ = new Thread() { // from class: cn.com.magnity.magnitycx.upgrade.CheckVersionTask.5
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
File file = HttpHelper.getRemoteApk(url, version, 10000, 30000, CheckVersionTask.this.handler_);
|
||||
if (file == null) {
|
||||
CheckVersionTask.this.handler_.sendEmptyMessage(-2);
|
||||
} else {
|
||||
CheckVersionTask.this.handler_.sendMessage(CheckVersionTask.this.handler_.obtainMessage(3, file));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logging.error("Upgrading error(" + ex.getMessage() + ")");
|
||||
CheckVersionTask.this.handler_.sendEmptyMessage(-2);
|
||||
}
|
||||
}
|
||||
};
|
||||
this.threadUpgrading_.start();
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void stopDownloadApk() {
|
||||
HttpHelper.isCancelled = true;
|
||||
try {
|
||||
this.threadUpgrading_.join(500L);
|
||||
this.threadUpgrading_ = null;
|
||||
} catch (Exception e) {
|
||||
this.threadUpgrading_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
private File getOthersStoragePath(Context context) {
|
||||
File file;
|
||||
String state = Environment.getExternalStorageState();
|
||||
if ("mounted".equals(state) && (file = new File(Environment.getExternalStorageDirectory(), "magnity/Cx/others")) != null) {
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
return file;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void installApk(File file) {
|
||||
Intent installIntent = new Intent("android.intent.action.VIEW");
|
||||
installIntent.setFlags(268435456);
|
||||
File usedFile = new File(getOthersStoragePath(this.ctx_), file.getName());
|
||||
if (Build.VERSION.SDK_INT >= 24) {
|
||||
installIntent.setFlags(1);
|
||||
Uri contentUri = FileProvider.getUriForFile(this.ctx_, "cn.com.magnity.magnitycx.fileprovider", usedFile);
|
||||
installIntent.setDataAndType(contentUri, "application/vnd.android.package-archive");
|
||||
} else {
|
||||
installIntent.setDataAndType(Uri.fromFile(usedFile), "application/vnd.android.package-archive");
|
||||
}
|
||||
this.ctx_.startActivity(installIntent);
|
||||
}
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
package cn.com.magnity.magnitycx.upgrade;
|
||||
|
||||
import android.os.Handler;
|
||||
import cn.com.magnity.magnitycx.MagApplication;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HttpHelper {
|
||||
public static volatile boolean isCancelled;
|
||||
|
||||
public static String GetRemoteVersionInfo(String path, int connTimeout, int readTimeout) throws Exception {
|
||||
String str;
|
||||
BufferedReader br = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
URL url = new URL(path);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(connTimeout);
|
||||
conn.setReadTimeout(readTimeout);
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept-Language", "zh-CN");
|
||||
conn.setRequestProperty("Charset", "UTF-8");
|
||||
conn.setRequestProperty("Connextion", "Keep-Alive");
|
||||
int code = conn.getResponseCode();
|
||||
if (code == 302) {
|
||||
URL url2 = new URL(conn.getHeaderField("Location"));
|
||||
conn = (HttpURLConnection) url2.openConnection();
|
||||
conn.setConnectTimeout(connTimeout);
|
||||
conn.setReadTimeout(readTimeout);
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept-Language", "zh-CN");
|
||||
conn.setRequestProperty("Charset", "UTF-8");
|
||||
conn.setRequestProperty("Connextion", "Keep-Alive");
|
||||
code = conn.getResponseCode();
|
||||
}
|
||||
if (code == 200) {
|
||||
is = conn.getInputStream();
|
||||
BufferedReader br2 = new BufferedReader(new InputStreamReader(is));
|
||||
try {
|
||||
StringBuffer stringBuffer = new StringBuffer("");
|
||||
String newLine = System.getProperty("line.separator");
|
||||
while (true) {
|
||||
String line = br2.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
stringBuffer.append(line + newLine);
|
||||
}
|
||||
if (stringBuffer.length() > 0) {
|
||||
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
|
||||
}
|
||||
br2.close();
|
||||
is.close();
|
||||
str = stringBuffer.toString();
|
||||
if (br2 != null) {
|
||||
try {
|
||||
br2.close();
|
||||
} catch (IOException e) {
|
||||
Logging.error("Fail to get remote info because of io error.");
|
||||
}
|
||||
}
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
br = br2;
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e2) {
|
||||
Logging.error("Fail to get remote info because of io error.");
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} else {
|
||||
Logging.error("Get error respond(" + code + ")");
|
||||
str = "";
|
||||
if (0 != 0) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException e3) {
|
||||
Logging.error("Fail to get remote info because of io error.");
|
||||
}
|
||||
}
|
||||
if (0 != 0) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
}
|
||||
}
|
||||
|
||||
public static File getRemoteApk(String path, String version, int connTimeout, int readTimeout, Handler handler) throws Exception {
|
||||
File file;
|
||||
FileOutputStream fos;
|
||||
int total;
|
||||
int len;
|
||||
FileOutputStream fos2 = null;
|
||||
BufferedInputStream bis = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
URL url = new URL(path);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(connTimeout);
|
||||
conn.setReadTimeout(readTimeout);
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept-Language", "zh-CN");
|
||||
conn.setRequestProperty("Charset", "UTF-8");
|
||||
conn.setRequestProperty("Connextion", "Keep-Alive");
|
||||
int code = conn.getResponseCode();
|
||||
if (code == 302) {
|
||||
URL url2 = new URL(conn.getHeaderField("Location"));
|
||||
conn = (HttpURLConnection) url2.openConnection();
|
||||
conn.setConnectTimeout(connTimeout);
|
||||
conn.setReadTimeout(readTimeout);
|
||||
conn.setRequestProperty("Accept-Encoding", "identity");
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setRequestProperty("Accept-Language", "zh-CN");
|
||||
conn.setRequestProperty("Charset", "UTF-8");
|
||||
conn.setRequestProperty("Connextion", "Keep-Alive");
|
||||
code = conn.getResponseCode();
|
||||
}
|
||||
if (code == 200) {
|
||||
int size = conn.getContentLength();
|
||||
handler.sendMessage(handler.obtainMessage(1, size, 0));
|
||||
is = conn.getInputStream();
|
||||
BufferedInputStream bis2 = new BufferedInputStream(is);
|
||||
try {
|
||||
file = new File(MagApplication.magParameter.otherDir, "MAG-Cx." + version + ".apk");
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
fos = new FileOutputStream(file);
|
||||
total = 0;
|
||||
} catch (Throwable th) {
|
||||
th = th;
|
||||
bis = bis2;
|
||||
}
|
||||
try {
|
||||
byte[] buf = new byte[1024];
|
||||
while (!isCancelled && (len = bis2.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
total += len;
|
||||
handler.sendMessage(handler.obtainMessage(2, total, 0));
|
||||
}
|
||||
fos.close();
|
||||
bis2.close();
|
||||
is.close();
|
||||
if (total != size) {
|
||||
file = null;
|
||||
}
|
||||
if (fos != null) {
|
||||
try {
|
||||
fos.close();
|
||||
} catch (IOException e) {
|
||||
Logging.error("Fail to get remote file because of io error.");
|
||||
}
|
||||
}
|
||||
if (bis2 != null) {
|
||||
bis2.close();
|
||||
}
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
th = th2;
|
||||
bis = bis2;
|
||||
fos2 = fos;
|
||||
if (fos2 != null) {
|
||||
try {
|
||||
fos2.close();
|
||||
} catch (IOException e2) {
|
||||
Logging.error("Fail to get remote file because of io error.");
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
if (bis != null) {
|
||||
bis.close();
|
||||
}
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
} else {
|
||||
Logging.error("Get error respond(" + code + ")");
|
||||
file = null;
|
||||
if (0 != 0) {
|
||||
try {
|
||||
fos2.close();
|
||||
} catch (IOException e3) {
|
||||
Logging.error("Fail to get remote file because of io error.");
|
||||
}
|
||||
}
|
||||
if (0 != 0) {
|
||||
bis.close();
|
||||
}
|
||||
if (0 != 0) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
return file;
|
||||
} catch (Throwable th3) {
|
||||
th = th3;
|
||||
}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package cn.com.magnity.magnitycx.upgrade;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UpgradeInfo {
|
||||
private String apkUrl_;
|
||||
private String description_;
|
||||
private boolean isForceUpgrade_;
|
||||
private int versionCode_;
|
||||
private String versionName_;
|
||||
|
||||
public void setVersionName(String name) {
|
||||
this.versionName_ = name;
|
||||
}
|
||||
|
||||
public String getVersionName() {
|
||||
return this.versionName_;
|
||||
}
|
||||
|
||||
public void setVersionCode(int code) {
|
||||
this.versionCode_ = code;
|
||||
}
|
||||
|
||||
public int getVersionCode() {
|
||||
return this.versionCode_;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description_ = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description_;
|
||||
}
|
||||
|
||||
public void setApkUrl(String url) {
|
||||
this.apkUrl_ = url;
|
||||
}
|
||||
|
||||
public String getApkUrl() {
|
||||
return this.apkUrl_;
|
||||
}
|
||||
|
||||
public void setForceUpgrade(boolean b) {
|
||||
this.isForceUpgrade_ = b;
|
||||
}
|
||||
|
||||
public boolean isForceUpgrade() {
|
||||
return this.isForceUpgrade_;
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package cn.com.magnity.magnitycx.upgrade;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import cn.com.magnity.magnitycx.log.Logging;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UpgradeManager {
|
||||
private Context ctx_;
|
||||
private CheckVersionTask task_;
|
||||
private Thread thread_;
|
||||
|
||||
public UpgradeManager(Context ctx) {
|
||||
this.ctx_ = ctx;
|
||||
}
|
||||
|
||||
public boolean start() {
|
||||
if (!checkNetWorkStatus(this.ctx_)) {
|
||||
return false;
|
||||
}
|
||||
this.task_ = new CheckVersionTask(this.ctx_, getLocalVersionCode(this.ctx_));
|
||||
this.thread_ = new Thread(this.task_);
|
||||
this.thread_.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (this.task_ != null) {
|
||||
this.task_.stopDownload();
|
||||
try {
|
||||
this.thread_.join(500L);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
this.thread_ = null;
|
||||
this.task_ = null;
|
||||
}
|
||||
}
|
||||
|
||||
private int getLocalVersionCode(Context ctx) {
|
||||
PackageManager packageManager = ctx.getPackageManager();
|
||||
try {
|
||||
PackageInfo packInfo = packageManager.getPackageInfo(ctx.getPackageName(), 0);
|
||||
return packInfo.versionCode;
|
||||
} catch (PackageManager.NameNotFoundException ex) {
|
||||
Logging.warn("Fail to get packet name(" + ex.getMessage() + ")");
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkNetWorkStatus(Context context) {
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager) context.getSystemService("connectivity");
|
||||
NetworkInfo netinfo = cm.getActiveNetworkInfo();
|
||||
if (netinfo != null) {
|
||||
if (netinfo.isConnected()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package cn.com.magnity.magnitycx.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ActivityUtils {
|
||||
public static boolean requestRuntimePermission(Activity activity, String[] permissionTypes, int requestCode) {
|
||||
if (permissionTypes == null) {
|
||||
return false;
|
||||
}
|
||||
ArrayList<String> permissions = new ArrayList<>();
|
||||
for (int i = 0; i < permissionTypes.length; i++) {
|
||||
String permissionType = permissionTypes[i];
|
||||
if (ContextCompat.checkSelfPermission(activity, permissionType) != 0) {
|
||||
permissions.add(permissionTypes[i]);
|
||||
}
|
||||
}
|
||||
if (permissions.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
ActivityCompat.requestPermissions(activity, (String[]) permissions.toArray(new String[permissions.size()]), requestCode);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user