Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe26c56032 |
16
.idea/encodings.xml
generated
16
.idea/encodings.xml
generated
@ -1,6 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/app/jni/Android.mk" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/jni/Application.mk" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/jni/SerialPort.c" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/jni/SerialPort.h" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/jni/gen_SerialPort_h.sh" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/libs/arm64-v8a/libserial_port.so" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/libs/armeabi/libserial_port.so" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/libs/armeabi/libserial_port.so" charset="GBK" />
|
||||||
<file url="file://$PROJECT_DIR$/app/src/main/java/com/jiebao/h518/scan/SqliteConnect.java" charset="GBK" />
|
<file url="file://$PROJECT_DIR$/app/src/main/java/com/jiebao/h518/scan/SqliteConnect.java" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-jni/Android.mk" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-jni/Application.mk" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-jni/SerialPort.c" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-jni/SerialPort.h" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-jni/gen_SerialPort_h.sh" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-libs/armeabi" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-libs/armeabi-v7a" charset="GBK" />
|
||||||
|
<file url="file://$PROJECT_DIR$/app/vguang-libs/x86" charset="GBK" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
6
.idea/render.experimental.xml
generated
Normal file
6
.idea/render.experimental.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RenderSettings">
|
||||||
|
<option name="showDecorations" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@ -11,18 +11,31 @@ android {
|
|||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 15
|
targetSdkVersion 15
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "V1.077"
|
versionName "V1.079"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
signingConfigs {
|
||||||
release {
|
release {
|
||||||
minifyEnabled false
|
storeFile file(RELEASE_STOREFILE);
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
storePassword RELEASE_STORE_PASSWORD;
|
||||||
|
keyAlias RELEASE_KEY_ALIAS
|
||||||
|
keyPassword RELEASE_KEY_PASSWORD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false //是否代码混淆
|
||||||
|
multiDexEnabled true //防止方法数量超过65536导致错误
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
//配置签名
|
||||||
|
signingConfig signingConfigs.release
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//关闭代码格式检查
|
||||||
lintOptions {
|
lintOptions {
|
||||||
abortOnError false
|
abortOnError false
|
||||||
}
|
}
|
||||||
@ -33,8 +46,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//加载动态库
|
//加载动态库
|
||||||
sourceSets{
|
sourceSets {
|
||||||
main{
|
main {
|
||||||
jniLibs.srcDir(['libs'])
|
jniLibs.srcDir(['libs'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,5 +55,5 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//加载jar包
|
//加载jar包
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
}
|
}
|
||||||
@ -18,7 +18,7 @@ LOCAL_PATH := $(call my-dir)
|
|||||||
|
|
||||||
include $(CLEAR_VARS)
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
TARGET_PLATFORM := android-8
|
TARGET_PLATFORM := android-3
|
||||||
LOCAL_MODULE := serial_port
|
LOCAL_MODULE := serial_port
|
||||||
LOCAL_SRC_FILES := SerialPort.c
|
LOCAL_SRC_FILES := SerialPort.c
|
||||||
LOCAL_LDLIBS := -llog
|
LOCAL_LDLIBS := -llog
|
||||||
|
|||||||
1
app/jni/Application.mk
Normal file
1
app/jni/Application.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
APP_ABI := armeabi armeabi-v7a x86
|
||||||
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009 Cedric Priscal
|
* Copyright 2009-2011 Cedric Priscal
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,52 +22,14 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include "SerialPort.h"
|
||||||
|
|
||||||
#include "android/log.h"
|
#include "android/log.h"
|
||||||
static const char *TAG="serial_port";
|
static const char *TAG="serial_port";
|
||||||
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##args)
|
#define LOGI(fmt, args...) __android_log_print(ANDROID_LOG_INFO, TAG, fmt, ##args)
|
||||||
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
|
#define LOGD(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, TAG, fmt, ##args)
|
||||||
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
|
#define LOGE(fmt, args...) __android_log_print(ANDROID_LOG_ERROR, TAG, fmt, ##args)
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* Class: com_android_barcode_SerialPort
|
|
||||||
* Method: open
|
|
||||||
* Signature: (Ljava/lang/String;I)I
|
|
||||||
*/
|
|
||||||
JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
|
||||||
(JNIEnv *, jclass, jstring, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: com_android_barcode_SerialPort
|
|
||||||
* Method: write
|
|
||||||
* Signature: (ILjava/lang/String;I)I
|
|
||||||
*/
|
|
||||||
JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_write
|
|
||||||
(JNIEnv *, jobject, jint, jstring, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: com_android_barcode_SerialPort
|
|
||||||
* Method: read
|
|
||||||
* Signature: (II)[B
|
|
||||||
*/
|
|
||||||
JNIEXPORT jbyteArray JNICALL Java_com_android_barcode_SerialPort_read
|
|
||||||
(JNIEnv *, jobject, jint, jint);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: com_android_barcode_SerialPort
|
|
||||||
* Method: close
|
|
||||||
* Signature: (I)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_com_android_barcode_SerialPort_close
|
|
||||||
(JNIEnv *, jobject, jint);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static speed_t getBaudrate(jint baudrate)
|
static speed_t getBaudrate(jint baudrate)
|
||||||
{
|
{
|
||||||
switch(baudrate) {
|
switch(baudrate) {
|
||||||
@ -107,15 +69,16 @@ static speed_t getBaudrate(jint baudrate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: cedric_serial_SerialPort
|
* Class: android_serialport_SerialPort
|
||||||
* Method: open
|
* Method: open
|
||||||
* Signature: (Ljava/lang/String;)V
|
* Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
|
||||||
*/
|
*/
|
||||||
JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
JNIEXPORT jobject JNICALL Java_android_1serialport_1api_SerialPort_open
|
||||||
(JNIEnv *env, jobject thiz, jstring path, jint baudrate)
|
(JNIEnv *env, jclass thiz, jstring path, jint baudrate, jint flags)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
speed_t speed;
|
speed_t speed;
|
||||||
|
jobject mFileDescriptor;
|
||||||
|
|
||||||
/* Check arguments */
|
/* Check arguments */
|
||||||
{
|
{
|
||||||
@ -123,6 +86,7 @@ JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
|||||||
if (speed == -1) {
|
if (speed == -1) {
|
||||||
/* TODO: throw an exception */
|
/* TODO: throw an exception */
|
||||||
LOGE("Invalid baudrate");
|
LOGE("Invalid baudrate");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,8 +94,8 @@ JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
|||||||
{
|
{
|
||||||
jboolean iscopy;
|
jboolean iscopy;
|
||||||
const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
|
const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
|
||||||
LOGD("Opening serial port %s", path_utf);
|
LOGD("Opening serial port %s with flags 0x%x", path_utf, O_RDWR | flags);
|
||||||
fd = open(path_utf, O_RDWR | O_SYNC);
|
fd = open(path_utf, O_RDWR | flags);
|
||||||
LOGD("open() fd = %d", fd);
|
LOGD("open() fd = %d", fd);
|
||||||
(*env)->ReleaseStringUTFChars(env, path, path_utf);
|
(*env)->ReleaseStringUTFChars(env, path, path_utf);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
@ -139,6 +103,7 @@ JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
|||||||
/* Throw an exception */
|
/* Throw an exception */
|
||||||
LOGE("Cannot open port");
|
LOGE("Cannot open port");
|
||||||
/* TODO: throw an exception */
|
/* TODO: throw an exception */
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,136 +116,52 @@ JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
|||||||
LOGE("tcgetattr() failed");
|
LOGE("tcgetattr() failed");
|
||||||
close(fd);
|
close(fd);
|
||||||
/* TODO: throw an exception */
|
/* TODO: throw an exception */
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfmakeraw(&cfg);
|
cfmakeraw(&cfg);
|
||||||
cfsetispeed(&cfg, speed);
|
cfsetispeed(&cfg, speed);
|
||||||
cfsetospeed(&cfg, speed);
|
cfsetospeed(&cfg, speed);
|
||||||
/*******************************/
|
|
||||||
cfg.c_cflag &= ~CSIZE;
|
|
||||||
cfg.c_lflag &= ~(ICANON|ECHO|ECHOE|ISIG);
|
|
||||||
cfg.c_oflag &= ~OPOST;
|
|
||||||
//'8' bit
|
|
||||||
cfg.c_cflag |= CS8;
|
|
||||||
//'N' PARENB
|
|
||||||
cfg.c_cflag &= ~PARENB;
|
|
||||||
cfg.c_iflag &= ~INPCK;
|
|
||||||
//'1' STOP
|
|
||||||
cfg.c_cflag &= ~CSTOPB;
|
|
||||||
|
|
||||||
cfg.c_cc[VTIME] = 15;
|
|
||||||
cfg.c_cc[VMIN] = 0;
|
|
||||||
tcflush(fd, TCIFLUSH);
|
|
||||||
/*********************************/
|
|
||||||
|
|
||||||
if (tcsetattr(fd, TCSANOW, &cfg))
|
if (tcsetattr(fd, TCSANOW, &cfg))
|
||||||
{
|
{
|
||||||
LOGE("tcsetattr() failed");
|
LOGE("tcsetattr() failed");
|
||||||
close(fd);
|
close(fd);
|
||||||
/* TODO: throw an exception */
|
/* TODO: throw an exception */
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Class: cedric_serial_SerialPort
|
|
||||||
* Method: write
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_write
|
|
||||||
(JNIEnv *env, jobject obj, jint fd, jstring str, jint len)
|
|
||||||
{
|
|
||||||
jboolean iscopy;
|
|
||||||
const char *buff_utf = (*env)->GetStringUTFChars(env, str, &iscopy);
|
|
||||||
int wlen = 0;
|
|
||||||
wlen = write(fd, buff_utf, len);
|
|
||||||
if(wlen > 0)
|
|
||||||
{
|
|
||||||
LOGD("Write serial port %s\n", buff_utf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGE("Write failed\n");
|
|
||||||
}
|
|
||||||
(*env)->ReleaseStringUTFChars(env, str, buff_utf);
|
|
||||||
LOGD("Write finish!\n");
|
|
||||||
return wlen;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* Class: cedric_serial_SerialPort
|
|
||||||
* Method: read
|
|
||||||
* Signature: ()V
|
|
||||||
*/
|
|
||||||
|
|
||||||
JNIEXPORT jbyteArray JNICALL Java_com_android_barcode_SerialPort_read
|
|
||||||
(JNIEnv *env, jobject obj, jint fd, jint len)
|
|
||||||
{
|
|
||||||
int reval;
|
|
||||||
int nread = 0;
|
|
||||||
char buff[len];
|
|
||||||
char result[len];
|
|
||||||
struct timeval tv;
|
|
||||||
jbyteArray jba;
|
|
||||||
fd_set rfds;
|
|
||||||
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
FD_ZERO(&rfds);
|
|
||||||
FD_SET(fd, &rfds);
|
|
||||||
tv.tv_sec = 0;
|
|
||||||
tv.tv_usec = 100000;
|
|
||||||
if ((reval = select(1 + fd, &rfds, NULL, NULL, &tv)) > 0)
|
|
||||||
{
|
|
||||||
if(FD_ISSET(fd, &rfds))
|
|
||||||
{
|
|
||||||
int temp = read(fd, buff + nread, len);
|
|
||||||
nread += temp;
|
|
||||||
LOGD("%i us is used", 100000 - tv.tv_usec);
|
|
||||||
LOGD("wo have data %d\n", temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(reval == 0 && nread != 0) //timeout means
|
|
||||||
{
|
|
||||||
// int ffd;
|
|
||||||
buff[nread]=0;
|
|
||||||
// ffd = open("/data/ndk", O_WRONLY | O_TRUNC);
|
|
||||||
// write(ffd, buff, nread);
|
|
||||||
// close(ffd);
|
|
||||||
int i, j;
|
|
||||||
for(i = 0, j = 0; i < nread; i++)
|
|
||||||
{
|
|
||||||
if(buff[i] != 0)
|
|
||||||
{
|
|
||||||
result[j] = buff[i];
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
// LOGD("0x%2x ", buff[i]);
|
|
||||||
}
|
|
||||||
//LOGD("\n");
|
|
||||||
//result[j] = 0;
|
|
||||||
jba = (*env)->NewByteArray(env, j);
|
|
||||||
(*env)->SetByteArrayRegion(env, jba, 0, j, result);
|
|
||||||
/* jba = (*env)->NewByteArray(env, nread);
|
|
||||||
(*env)->SetByteArrayRegion(env, jba, 0, nread, buff);*/
|
|
||||||
LOGD("readlength=%d\n, reallength=%d\n, all data received!\n", nread, j);
|
|
||||||
return jba;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Create a corresponding file descriptor */
|
||||||
|
{
|
||||||
|
jclass cFileDescriptor = (*env)->FindClass(env, "java/io/FileDescriptor");
|
||||||
|
jmethodID iFileDescriptor = (*env)->GetMethodID(env, cFileDescriptor, "<init>", "()V");
|
||||||
|
jfieldID descriptorID = (*env)->GetFieldID(env, cFileDescriptor, "descriptor", "I");
|
||||||
|
mFileDescriptor = (*env)->NewObject(env, cFileDescriptor, iFileDescriptor);
|
||||||
|
(*env)->SetIntField(env, mFileDescriptor, descriptorID, (jint)fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mFileDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: cedric_serial_SerialPort
|
* Class: cedric_serial_SerialPort
|
||||||
* Method: close
|
* Method: close
|
||||||
* Signature: ()V
|
* Signature: ()V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_com_android_barcode_SerialPort_close
|
JNIEXPORT void JNICALL Java_android_1serialport_1api_SerialPort_close
|
||||||
(JNIEnv *env, jobject obj, jint fd)
|
(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
close(fd);
|
jclass SerialPortClass = (*env)->GetObjectClass(env, thiz);
|
||||||
|
jclass FileDescriptorClass = (*env)->FindClass(env, "java/io/FileDescriptor");
|
||||||
|
|
||||||
|
jfieldID mFdID = (*env)->GetFieldID(env, SerialPortClass, "mFd", "Ljava/io/FileDescriptor;");
|
||||||
|
jfieldID descriptorID = (*env)->GetFieldID(env, FileDescriptorClass, "descriptor", "I");
|
||||||
|
|
||||||
|
jobject mFd = (*env)->GetObjectField(env, thiz, mFdID);
|
||||||
|
jint descriptor = (*env)->GetIntField(env, mFd, descriptorID);
|
||||||
|
|
||||||
|
LOGD("close(fd = %d)", descriptor);
|
||||||
|
close(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
29
app/jni/SerialPort.h
Normal file
29
app/jni/SerialPort.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||||
|
#include <jni.h>
|
||||||
|
/* Header for class android_serialport_api_SerialPort */
|
||||||
|
|
||||||
|
#ifndef _Included_android_serialport_api_SerialPort
|
||||||
|
#define _Included_android_serialport_api_SerialPort
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
/*
|
||||||
|
* Class: android_serialport_api_SerialPort
|
||||||
|
* Method: open
|
||||||
|
* Signature: (Ljava/lang/String;II)Ljava/io/FileDescriptor;
|
||||||
|
*/
|
||||||
|
JNIEXPORT jobject JNICALL Java_android_1serialport_1api_SerialPort_open
|
||||||
|
(JNIEnv *, jclass, jstring, jint, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_serialport_api_SerialPort
|
||||||
|
* Method: close
|
||||||
|
* Signature: ()V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_1serialport_1api_SerialPort_close
|
||||||
|
(JNIEnv *, jobject);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
3
app/jni/gen_SerialPort_h.sh
Normal file
3
app/jni/gen_SerialPort_h.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
javah -o SerialPort.h -jni -classpath ../src android_serialport_api.SerialPort
|
||||||
|
|
||||||
BIN
app/libs/armeabi/libmsc.so
Normal file
BIN
app/libs/armeabi/libmsc.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
app/libs/flytek.jar
Normal file
BIN
app/libs/flytek.jar
Normal file
Binary file not shown.
BIN
app/libs/honeywell.jar
Normal file
BIN
app/libs/honeywell.jar
Normal file
Binary file not shown.
BIN
app/libs/urobo.jar
Normal file
BIN
app/libs/urobo.jar
Normal file
Binary file not shown.
@ -1,6 +1,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.activity.chaoran">
|
package="com.example.chaoran"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="V1.079">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
@ -14,131 +16,113 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
<uses-permission android:name="android.permission.READ_SETTINGS" />
|
<uses-permission android:name="android.permission.READ_SETTINGS" />
|
||||||
|
|
||||||
<!-- 百度定位服务权限 -->
|
<!-- 百度定位服务权限 -->
|
||||||
<permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
|
<permission android:name="android.permission.BAIDU_LOCATION_SERVICE" />
|
||||||
</permission>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
</uses-permission>
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" >
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
</uses-permission>
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
</uses-permission>
|
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" >
|
|
||||||
</uses-permission>
|
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
|
|
||||||
</uses-permission>
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
|
|
||||||
</uses-permission>
|
|
||||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
|
|
||||||
tools:ignore="ProtectedPermissions">
|
|
||||||
</uses-permission>
|
|
||||||
<uses-permission android:name="android.permission.READ_LOGS"
|
|
||||||
tools:ignore="ProtectedPermissions">
|
|
||||||
</uses-permission>
|
|
||||||
|
|
||||||
<!-- 百度地图API权限 -->
|
<!-- 百度地图API权限 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
</uses-permission>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
|
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||||
</uses-permission>
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" >
|
|
||||||
</uses-permission>
|
<!-- -->
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
|
|
||||||
</uses-permission>
|
|
||||||
<uses-permission android:name="com.honeywell.decode.permission.DECODE" />
|
<uses-permission android:name="com.honeywell.decode.permission.DECODE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="map.baidu.com.BMapManagerUtil"
|
android:name="map.baidu.com.BMapManagerUtil"
|
||||||
android:icon="@drawable/ic_launcher"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:persistent="true"
|
android:persistent="true"
|
||||||
android:theme="@style/AppTheme" >
|
android:theme="@style/AppTheme"
|
||||||
<uses-library android:name="android.scanner.library" android:required="false" />
|
tools:ignore="HardcodedDebugMode">
|
||||||
|
<uses-library
|
||||||
|
android:name="android.scanner.library"
|
||||||
|
android:required="false" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.MainActivity"
|
android:name="com.example.chaoran.MainActivity"
|
||||||
android:label="@string/title_activity_main"
|
android:label="@string/title_activity_main"
|
||||||
android:screenOrientation="behind"
|
android:screenOrientation="behind"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden">
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.HOME" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.HOME" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.NetWorkSet"
|
android:name="com.example.chaoran.NetWorkSet"
|
||||||
android:label="@string/title_activity_net_work_set"
|
android:label="@string/title_activity_net_work_set"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.MenuActivity"
|
android:name="com.example.chaoran.MenuActivity"
|
||||||
android:label="@string/title_activity_menu"
|
android:label="@string/title_activity_menu"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.DjActivity"
|
android:name="com.example.chaoran.DjActivity"
|
||||||
android:label="@string/title_activity_dj"
|
android:label="@string/title_activity_dj"
|
||||||
android:screenOrientation="behind"
|
android:screenOrientation="behind"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.ParamActivity"
|
android:name="com.example.chaoran.ParamActivity"
|
||||||
android:label="@string/title_activity_param"
|
android:label="@string/title_activity_param"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.DjtqActivity"
|
android:name="com.example.chaoran.DjtqActivity"
|
||||||
android:label="@string/djtq_activity"
|
android:label="@string/djtq_activity"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.UpdatePwdActivity"
|
android:name="com.example.chaoran.UpdatePwdActivity"
|
||||||
android:label="@string/title_activity_update_pwd"
|
android:label="@string/title_activity_update_pwd"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="map.baidu.com.BDMapActivity"
|
android:name="map.baidu.com.BDMapActivity"
|
||||||
android:hardwareAccelerated="false"
|
android:hardwareAccelerated="false"
|
||||||
android:label="@string/title_activity_bdmap"
|
android:label="@string/title_activity_bdmap"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="com.baidu.mapapi.MapActivity" />
|
android:value="com.baidu.mapapi.MapActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="com.baidu.location.f"
|
android:name="com.baidu.location.f"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:process=":remote" >
|
android:process=":remote" />
|
||||||
</service>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.chaoran.lx.activity.DownDataActivity"
|
android:name="com.chaoran.lx.activity.DownDataActivity"
|
||||||
android:label="@string/title_activity_down_data"
|
android:label="@string/title_activity_down_data"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.chaoran.lx.activity.Lx_Param_Activity"
|
android:name="com.chaoran.lx.activity.Lx_Param_Activity"
|
||||||
android:label="@string/title_activity_lx__param_"
|
android:label="@string/title_activity_lx__param_"
|
||||||
android:screenOrientation="behind" >
|
android:screenOrientation="behind" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.MipcaActivityCapture"
|
android:name="com.example.chaoran.MipcaActivityCapture"
|
||||||
android:label="@string/title_activity_camera_scan"
|
android:label="@string/title_activity_camera_scan"
|
||||||
android:screenOrientation="behind"
|
android:screenOrientation="behind"
|
||||||
android:windowSoftInputMode="stateAlwaysHidden" >
|
android:windowSoftInputMode="stateAlwaysHidden" />
|
||||||
</activity>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.activity.chaoran.PdaRegActivity"
|
android:name="com.example.chaoran.PdaRegActivity"
|
||||||
android:label="@string/title_activity_pda_reg" >
|
android:label="@string/title_activity_pda_reg" />
|
||||||
</activity>
|
|
||||||
|
<activity
|
||||||
|
android:name=".VoiceSettingActivity"
|
||||||
|
android:theme="@android:style/Theme.Material.Light.NoActionBar"
|
||||||
|
android:label="@string/title_activity_voice_engine_setting"
|
||||||
|
tools:targetApi="lollipop" />
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
BIN
app/src/main/assets/tts/common.jet
Normal file
BIN
app/src/main/assets/tts/common.jet
Normal file
Binary file not shown.
BIN
app/src/main/assets/tts/xiaofeng.jet
Normal file
BIN
app/src/main/assets/tts/xiaofeng.jet
Normal file
Binary file not shown.
BIN
app/src/main/assets/tts/xiaoyan.jet
Normal file
BIN
app/src/main/assets/tts/xiaoyan.jet
Normal file
Binary file not shown.
@ -1,17 +1,19 @@
|
|||||||
package android_serialport_api;
|
package android_serialport_api;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import map.baidu.com.BMapManagerUtil;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
public class SerialPort {
|
public class SerialPort{
|
||||||
|
|
||||||
private static final String TAG = "SerialPort";
|
private static final String TAG = "SerialPort";
|
||||||
private FileDescriptor mFd;
|
private FileDescriptor mFd;
|
||||||
private FileInputStream mFileInputStream;
|
private FileInputStream mFileInputStream;
|
||||||
private FileOutputStream mFileOutputStream;
|
private FileOutputStream mFileOutputStream;
|
||||||
|
|
||||||
public SerialPort(File device, int baudrate, int bits, char event, int stop, int flags) throws SecurityException,
|
public SerialPort(File device, int baudrate, int flags) throws SecurityException,
|
||||||
IOException {
|
IOException {
|
||||||
|
|
||||||
if (!device.canRead() || !device.canWrite()) {
|
if (!device.canRead() || !device.canWrite()) {
|
||||||
@ -22,17 +24,20 @@ public class SerialPort {
|
|||||||
su.getOutputStream().write(cmd.getBytes());
|
su.getOutputStream().write(cmd.getBytes());
|
||||||
|
|
||||||
if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) {
|
if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) {
|
||||||
|
DialogUtil.builder(BMapManagerUtil.getGlobalApplicationContext(),"获取su命令权限失败","系统或许未root",15);
|
||||||
throw new SecurityException();
|
throw new SecurityException();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
DialogUtil.builder(BMapManagerUtil.getGlobalApplicationContext(),"获取root权限失败",e.toString(),15);
|
||||||
throw new SecurityException();
|
throw new SecurityException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mFd = open(device.getAbsolutePath(), baudrate, bits, event, stop, flags);
|
mFd = open(device.getAbsolutePath(), baudrate, flags);
|
||||||
Log.i("info", "open device!!");
|
Log.i("info", "open device!!");
|
||||||
if (mFd == null) {
|
if (mFd == null) {
|
||||||
Log.e(TAG, "native open returns null");
|
Log.e(TAG, "native open returns null");
|
||||||
|
DialogUtil.builder(BMapManagerUtil.getGlobalApplicationContext(),"获取文件描述符失败","native open returns null",15);
|
||||||
throw new IOException();
|
throw new IOException();
|
||||||
}
|
}
|
||||||
mFileInputStream = new FileInputStream(mFd);
|
mFileInputStream = new FileInputStream(mFd);
|
||||||
@ -50,12 +55,12 @@ public class SerialPort {
|
|||||||
return mFileOutputStream;
|
return mFileOutputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
private native static FileDescriptor open(String path, int baudrate, int bits, char event, int stop, int flags);
|
private native static FileDescriptor open(String path, int baudrate, int flags);
|
||||||
|
|
||||||
public native void close();
|
public native void close();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
System.loadLibrary("serialport");
|
System.loadLibrary("serial_port");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,10 +5,13 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
import com.chaoran.db.DBManager;
|
import com.chaoran.db.DBManager;
|
||||||
import com.chaoran.lx.activity.DownDataActivity;
|
import com.chaoran.lx.activity.DownDataActivity;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|||||||
@ -1,17 +1,23 @@
|
|||||||
package com.chaoran.component;
|
package com.chaoran.component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.GridView;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import com.activity.chaoran.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ImageAdpter extends BaseAdapter {
|
public class ImageAdpter extends BaseAdapter {
|
||||||
private List list;
|
private List list;
|
||||||
|
|||||||
@ -4,7 +4,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.chaoran.entiry.Zujian;
|
import com.chaoran.entiry.Zujian;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.example.chaoran.R;
|
||||||
import com.util.DialogUtil;
|
import com.util.DialogUtil;
|
||||||
import com.util.SysUtil;
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,20 @@
|
|||||||
package com.chaoran.db;
|
package com.chaoran.db;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.DanJuEntity;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class DBManager {
|
public class DBManager {
|
||||||
private SqlHelpUtil helper;
|
private SqlHelpUtil helper;
|
||||||
private SQLiteDatabase db;
|
private SQLiteDatabase db;
|
||||||
|
|||||||
@ -1,9 +1,21 @@
|
|||||||
package com.chaoran.entiry;
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import com.example.chaoran.MainActivity;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
public class PhotographUi extends LinearLayout {
|
public class PhotographUi extends LinearLayout {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
package com.chaoran.entiry;
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import android.widget.ImageButton;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
import com.chaoran.imp.InputInterface;
|
import com.chaoran.imp.InputInterface;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
public class SelfDateField extends RelativeLayout implements InputInterface {
|
public class SelfDateField extends RelativeLayout implements InputInterface {
|
||||||
private SelfEditText et;
|
private SelfEditText et;
|
||||||
|
|||||||
@ -2,10 +2,16 @@ package com.chaoran.entiry;
|
|||||||
|
|
||||||
import com.chaoran.imp.InputInterface;
|
import com.chaoran.imp.InputInterface;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
public class SelfTextBut extends RelativeLayout implements InputInterface {
|
public class SelfTextBut extends RelativeLayout implements InputInterface {
|
||||||
|
|||||||
25
app/src/main/java/com/chaoran/entiry/Test.java
Normal file
25
app/src/main/java/com/chaoran/entiry/Test.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Map<String, String> m=new HashMap<String, String>();
|
||||||
|
m.put("a","1");
|
||||||
|
m.put("b","2");
|
||||||
|
m.put("c","3");
|
||||||
|
Set<String> set=m.keySet();
|
||||||
|
for(String a:set){
|
||||||
|
System.out.println(a+"---");
|
||||||
|
if(a.equals("a")){
|
||||||
|
//set.remove(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Set<String> set1=m.keySet();
|
||||||
|
for(String b:set1){
|
||||||
|
System.out.println(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
package com.chaoran.entiry;
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Zujian {
|
public class Zujian {
|
||||||
|
|||||||
@ -1,19 +1,23 @@
|
|||||||
package com.chaoran.listener;
|
package com.chaoran.listener;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.View.OnKeyListener;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
import com.chaoran.entiry.SelfImage;
|
import com.chaoran.entiry.SelfImage;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
public class ImageClickListener implements OnClickListener {
|
public class ImageClickListener implements OnClickListener {
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
|
|||||||
@ -4,10 +4,11 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.chaoran.entiry.PhotographUi;
|
import com.chaoran.entiry.PhotographUi;
|
||||||
import com.activity.chaoran.DjActivity;
|
import com.example.chaoran.DjActivity;
|
||||||
import com.util.DialogUtil;
|
import com.util.DialogUtil;
|
||||||
import com.util.SysUtil;
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
|
|||||||
@ -4,13 +4,19 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.kobjects.base64.Base64;
|
||||||
|
|
||||||
import com.chaoran.component.ButAdapter;
|
import com.chaoran.component.ButAdapter;
|
||||||
import com.chaoran.db.DBManager;
|
import com.chaoran.db.DBManager;
|
||||||
import com.chaoran.lx.thread.LxDataDownThread;
|
import com.chaoran.lx.thread.LxDataDownThread;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
import com.activity.chaoran.RunYmupThread;
|
import com.example.chaoran.RunYmupThread;
|
||||||
|
import com.example.chaoran.R.id;
|
||||||
|
import com.example.chaoran.R.layout;
|
||||||
import com.util.DialogUtil;
|
import com.util.DialogUtil;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
|
||||||
|
import android.R.integer;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
|||||||
@ -10,7 +10,10 @@ import org.dom4j.DocumentException;
|
|||||||
import com.chaoran.entiry.DanJuEntity;
|
import com.chaoran.entiry.DanJuEntity;
|
||||||
import com.chaoran.entiry.Sys_DanJuFormsOptions;
|
import com.chaoran.entiry.Sys_DanJuFormsOptions;
|
||||||
import com.chaoran.thread.DownDJRun;
|
import com.chaoran.thread.DownDJRun;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.example.chaoran.R.layout;
|
||||||
|
import com.example.chaoran.R.menu;
|
||||||
import com.util.DialogUtil;
|
import com.util.DialogUtil;
|
||||||
import com.util.IoUtil;
|
import com.util.IoUtil;
|
||||||
import com.util.LxParamPageCreate;
|
import com.util.LxParamPageCreate;
|
||||||
|
|||||||
@ -1,21 +1,25 @@
|
|||||||
package com.chaoran.lx.thread;
|
package com.chaoran.lx.thread;
|
||||||
|
|
||||||
import android.app.ProgressDialog;
|
import java.io.IOException;
|
||||||
import android.os.Handler;
|
import java.util.ArrayList;
|
||||||
import android.os.Message;
|
import java.util.HashMap;
|
||||||
import android.widget.TextView;
|
import java.util.List;
|
||||||
import com.chaoran.db.DBManager;
|
|
||||||
import com.sys.SysData;
|
|
||||||
import com.util.IoUtil;
|
|
||||||
import org.kobjects.base64.Base64;
|
import org.kobjects.base64.Base64;
|
||||||
import org.ksoap2.SoapEnvelope;
|
import org.ksoap2.SoapEnvelope;
|
||||||
import org.ksoap2.serialization.SoapObject;
|
import org.ksoap2.serialization.SoapObject;
|
||||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
import org.ksoap2.transport.HttpTransportSE;
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.chaoran.db.DBManager;
|
||||||
import java.util.HashMap;
|
import com.sys.SysData;
|
||||||
import java.util.List;
|
import com.util.IoUtil;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class LxDataDownThread implements Runnable {
|
public class LxDataDownThread implements Runnable {
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
|
|||||||
@ -1,12 +1,17 @@
|
|||||||
package com.chaoran.thread;
|
package com.chaoran.thread;
|
||||||
|
|
||||||
import android.os.Handler;
|
import java.io.IOException;
|
||||||
import android.os.Message;
|
|
||||||
import com.sys.SysData;
|
|
||||||
import org.ksoap2.SoapEnvelope;
|
import org.ksoap2.SoapEnvelope;
|
||||||
import org.ksoap2.serialization.SoapObject;
|
import org.ksoap2.serialization.SoapObject;
|
||||||
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
import org.ksoap2.transport.HttpTransportSE;
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import com.sys.SysData;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
public class UpdatePwdThread implements Runnable {
|
public class UpdatePwdThread implements Runnable {
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private String userid;
|
private String userid;
|
||||||
|
|||||||
@ -32,7 +32,9 @@ public class CR5WScanControl {
|
|||||||
}
|
}
|
||||||
sleep(500);
|
sleep(500);
|
||||||
}
|
}
|
||||||
|
// init(context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
package com.cr5w.scan;
|
package com.cr5w.scan;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
public class ScanHelper {
|
public class ScanHelper {
|
||||||
/** scan settings show 0 : no; 1 : yes*/
|
/** scan settings show 0 : no; 1 : yes*/
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
package com.cr5w.scan.aht70;
|
package com.cr5w.scan.aht70;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
public class ScanHelper {
|
public class ScanHelper {
|
||||||
/** scan settings show 0 : no; 1 : yes*/
|
/** scan settings show 0 : no; 1 : yes*/
|
||||||
|
|||||||
@ -1,24 +1,18 @@
|
|||||||
package com.device.zk_r322a;
|
package com.device.zk_r322a;
|
||||||
|
|
||||||
|
import android_serialport_api.SerialPort;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
import android.gpio.GpioJNI;
|
|
||||||
import android.util.Log;
|
|
||||||
import android_serialport_api.SerialPort;
|
|
||||||
|
|
||||||
public class ZKR322AControl {
|
public class ZKR322AControl {
|
||||||
private SerialPort mSerialPort = null;
|
private SerialPort mSerialPort = null;
|
||||||
private OutputStream mOutputStream = null;
|
|
||||||
private InputStream mInputStream = null;
|
private InputStream mInputStream = null;
|
||||||
//private boolean readVal = false;
|
|
||||||
|
|
||||||
public ZKR322AControl() throws SecurityException, IOException {
|
public ZKR322AControl() throws SecurityException, IOException {
|
||||||
mSerialPort = new SerialPort(new File("/dev/ttyS4"), 115200, 8, 'N', 1,0);
|
mSerialPort = new SerialPort(new File("/dev/ttyS1"), 115200,0);
|
||||||
mOutputStream = mSerialPort.getOutputStream();
|
mInputStream = mSerialPort.getInputStream();
|
||||||
mInputStream = mSerialPort.getInputStream();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getData() {
|
public String getData() {
|
||||||
@ -37,19 +31,13 @@ public class ZKR322AControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
//readVal = true;
|
// GpioJNI.gpio_switch_scan_trig(1);
|
||||||
// GpioJNI.gpio_switch_scan_trig(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
//readVal = false;
|
// GpioJNI.gpio_switch_scan_trig(0);
|
||||||
// GpioJNI.gpio_switch_scan_trig(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//public boolean isRead() {
|
|
||||||
// return readVal;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
if (mSerialPort != null) {
|
if (mSerialPort != null) {
|
||||||
mSerialPort.close();
|
mSerialPort.close();
|
||||||
@ -58,7 +46,7 @@ public class ZKR322AControl {
|
|||||||
|
|
||||||
|
|
||||||
public void initScan() {
|
public void initScan() {
|
||||||
// GpioJNI.gpio_switch_scan_rf_ired(0);
|
// GpioJNI.gpio_switch_scan_rf_ired(0);
|
||||||
// GpioJNI.gpio_switch_scan_power(1);
|
// GpioJNI.gpio_switch_scan_power(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1981
app/src/main/java/com/example/chaoran/DjActivity.java
Normal file
1981
app/src/main/java/com/example/chaoran/DjActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
182
app/src/main/java/com/example/chaoran/DjtqActivity.java
Normal file
182
app/src/main/java/com/example/chaoran/DjtqActivity.java
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.chaoran.component.MyAdapter;
|
||||||
|
import com.chaoran.entiry.DataGrid;
|
||||||
|
import com.chaoran.entiry.Djselefa;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
import com.util.SqlUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
import org.kobjects.base64.Base64;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单据提取窗口
|
||||||
|
*/
|
||||||
|
public class DjtqActivity extends Activity {
|
||||||
|
private ListView listview;
|
||||||
|
private int cur_pos = -1;// 当前显示的一行
|
||||||
|
// private ArrayList items_text = new ArrayList();
|
||||||
|
private Djselefa djselefa;
|
||||||
|
public ProgressDialog pd;
|
||||||
|
public MyAdapter adapter;
|
||||||
|
private ArrayList listdata;
|
||||||
|
private String filedName;// 显示字段的名字
|
||||||
|
private String gzid;
|
||||||
|
private String mxTempTable;
|
||||||
|
private Intent intent;
|
||||||
|
private Handler runHandler = new Handler() {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
if (msg.what == -1) {
|
||||||
|
DialogUtil.builder(DjtqActivity.this, "错误信息", "提取方案初始化失败:"
|
||||||
|
+ msg.obj.toString(),0);
|
||||||
|
} else if (msg.what == -4) {
|
||||||
|
DialogUtil.builder(DjtqActivity.this, "错误信息", "提取方案运行失败:"
|
||||||
|
+ msg.obj.toString(),0);
|
||||||
|
} else {
|
||||||
|
if (msg.arg1 == 4) {
|
||||||
|
Object ob = msg.obj;
|
||||||
|
if (ob instanceof ArrayList) {
|
||||||
|
ArrayList list = (ArrayList) ob;
|
||||||
|
if (list.size() > 0) {
|
||||||
|
intent.putExtra("param", (HashMap) list.get(0));
|
||||||
|
setResult(2, intent);
|
||||||
|
}
|
||||||
|
clear();
|
||||||
|
} else {
|
||||||
|
DialogUtil.builder(DjtqActivity.this, "提示信息",
|
||||||
|
ob.toString(),0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
HashMap map = (HashMap) msg.obj;
|
||||||
|
DataGrid dg = (DataGrid) map.get("dg");
|
||||||
|
listdata = dg.getTableData();
|
||||||
|
if(listdata==null||listdata.size()<1){
|
||||||
|
filedName="";
|
||||||
|
}else{
|
||||||
|
filedName=SysUtil.mapFirst(listdata);
|
||||||
|
}
|
||||||
|
if (adapter == null) {
|
||||||
|
adapter = new MyAdapter(DjtqActivity.this, listdata,
|
||||||
|
filedName);
|
||||||
|
listview.setAdapter(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pd != null) {
|
||||||
|
pd.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.list);
|
||||||
|
listview = (ListView) findViewById(R.id.mxlist);
|
||||||
|
intent = getIntent();
|
||||||
|
HashMap paramMap = (HashMap) intent.getSerializableExtra("paramMap");
|
||||||
|
djselefa = (Djselefa) paramMap.get("djselefa");
|
||||||
|
pd = ProgressDialog.show(DjtqActivity.this, "正在执行提取方案", "正在下载……");
|
||||||
|
try {
|
||||||
|
new RunSearchThread(djselefa.getT_sql(), IoUtil.ob_base64(paramMap
|
||||||
|
.get("t_sqlParam")), runHandler).start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
DialogUtil.builder(this, "错误信息", "转换成Base64编码失败!",0);
|
||||||
|
}
|
||||||
|
gzid = paramMap.get("GZID").toString();
|
||||||
|
mxTempTable = paramMap.get("mxTempTable").toString();
|
||||||
|
intent.removeExtra("paramMap");
|
||||||
|
TextView tv = (TextView) findViewById(R.id.mxtitle);
|
||||||
|
tv.setText(djselefa.getFangamch());
|
||||||
|
((Button) findViewById(R.id.mxbut)).setText("提取");
|
||||||
|
listview.setChoiceMode(ListView.CHOICE_MODE_SINGLE);// 一定要设置这个属性,否则ListView不会刷新
|
||||||
|
listview.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> arg0, View arg1,
|
||||||
|
int position, long id) {
|
||||||
|
cur_pos = position;// 更新当前行
|
||||||
|
adapter.cur_pos = cur_pos;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void queryMx(View v) {
|
||||||
|
try {
|
||||||
|
if (cur_pos < 0) {
|
||||||
|
DialogUtil.builder(this, "提示信息", "请选择一行!",0);
|
||||||
|
} else {
|
||||||
|
if (mxTempTable == null || mxTempTable.length() < 0) {
|
||||||
|
DialogUtil.builder(this, "提示信息", "明细表不存在!",0);
|
||||||
|
}
|
||||||
|
HashMap item = (HashMap) listdata.get(cur_pos);
|
||||||
|
HashMap hzData = SqlUtil.regSql(djselefa.getHz_sql(), item);
|
||||||
|
HashMap mxData = SqlUtil.regSql(djselefa.getMx_sql(), item);
|
||||||
|
HashMap hm = new HashMap();
|
||||||
|
hm.put("gzid", gzid);
|
||||||
|
hm.put("mxTempTable", mxTempTable);
|
||||||
|
hm.put("hzSql", hzData.get("sql"));
|
||||||
|
hm.put("hzParam", hzData.get("param"));
|
||||||
|
hm.put("mxSql", mxData.get("sql"));
|
||||||
|
hm.put("mxParam", mxData.get("param"));
|
||||||
|
byte[] b = IoUtil.getbyte(hm);
|
||||||
|
DialogUtil.setDialog(pd, "提示信息", "正在运行提取方案");
|
||||||
|
new RunYmupThread(Base64.encode(b), runHandler, "runTqfa",0)
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
pd.dismiss();
|
||||||
|
DialogUtil.builder(DjtqActivity.this, "错误信息", "提取修改方案组织数据失败!",0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
||||||
|
&& !event.isCanceled()) {
|
||||||
|
clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onKeyUp(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clear() {
|
||||||
|
listview = null;
|
||||||
|
if (pd != null) {
|
||||||
|
pd.dismiss();
|
||||||
|
pd = null;
|
||||||
|
}
|
||||||
|
djselefa = null;
|
||||||
|
adapter = null;
|
||||||
|
if (listdata != null) {
|
||||||
|
listdata.clear();
|
||||||
|
listdata = null;
|
||||||
|
}
|
||||||
|
filedName = null;
|
||||||
|
gzid = null;
|
||||||
|
mxTempTable = null;
|
||||||
|
intent = null;
|
||||||
|
runHandler = null;
|
||||||
|
intent = null;
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
78
app/src/main/java/com/example/chaoran/ExitThread.java
Normal file
78
app/src/main/java/com/example/chaoran/ExitThread.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.sys.SysData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出线程
|
||||||
|
*/
|
||||||
|
public class ExitThread extends Thread {
|
||||||
|
public String gzid;
|
||||||
|
public String mxTempTable;
|
||||||
|
public Handler handler;
|
||||||
|
public String method;
|
||||||
|
|
||||||
|
public ExitThread(String gzid, String mxTempTable, Handler handler,
|
||||||
|
String method) {
|
||||||
|
this.gzid = gzid;
|
||||||
|
this.mxTempTable = mxTempTable;
|
||||||
|
this.handler = handler;
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
Log.v("SearchThread", "run执行");
|
||||||
|
try {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
// method = "exitDj";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("gzid", gzid);
|
||||||
|
rpc.addProperty("mxTempTable", mxTempTable);
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
if (handler != null) {
|
||||||
|
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.obj = envelope.getResponse();
|
||||||
|
if (method.equals("exitDj")) {
|
||||||
|
msg.arg1 = 4;
|
||||||
|
} else if (method.equals("queryMx")) {
|
||||||
|
msg.arg1 = 5;
|
||||||
|
}
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} else {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.obj = null;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (handler != null) {
|
||||||
|
Message msg = new Message();
|
||||||
|
if (method.equals("exitDj")) {
|
||||||
|
msg.what = -4;
|
||||||
|
} else if (method.equals("queryMx")) {
|
||||||
|
msg.what = -5;
|
||||||
|
}
|
||||||
|
msg.obj = e.toString();
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
606
app/src/main/java/com/example/chaoran/MainActivity.java
Normal file
606
app/src/main/java/com/example/chaoran/MainActivity.java
Normal file
@ -0,0 +1,606 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
import com.chaoran.db.SqlHelpUtil;
|
||||||
|
import com.chaoran.entiry.UpdataInfo;
|
||||||
|
import com.chaoran.entiry.UserList;
|
||||||
|
import com.chaoran.lx.activity.DownDataActivity;
|
||||||
|
import com.chaoran.thread.DownApk;
|
||||||
|
import com.honeywell.aidc.AidcManager;
|
||||||
|
import com.honeywell.aidc.AidcManager.CreatedCallback;
|
||||||
|
import com.honeywell.aidc.BarcodeReader;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.*;
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主活动窗口
|
||||||
|
*/
|
||||||
|
public class MainActivity extends Activity {
|
||||||
|
SqlHelpUtil db;
|
||||||
|
SQLiteDatabase sDatabase;
|
||||||
|
EditText name;
|
||||||
|
EditText pwd;
|
||||||
|
private CheckBox checkBox;
|
||||||
|
private CheckBox islxScan;
|
||||||
|
public ProgressDialog pd;
|
||||||
|
private int loginTy;// 登录类型,1为在线登录 2为离线数据下载
|
||||||
|
private TextView regts;
|
||||||
|
public String versionStr;
|
||||||
|
|
||||||
|
public static float def_pbl = 0.9f; // 屏幕比列
|
||||||
|
|
||||||
|
//Honeywell 扫描设备控制
|
||||||
|
private static BarcodeReader barcodeReader = null;
|
||||||
|
private AidcManager manager = null;
|
||||||
|
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
if (msg.what == -1) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "错误信息", "连接服务器失败,请检查网络!"
|
||||||
|
+ msg.obj,0);
|
||||||
|
} else if (msg.what == -2) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "错误信息", "用户名或密码错误!",0);
|
||||||
|
} else if (msg.what == -3) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "错误信息", "解析xml失败!",0);
|
||||||
|
} else if (msg.what == -4) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "错误信息", "检查更新失败,请检查网络!",0);
|
||||||
|
} else if (msg.what == -5) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "错误信息", "更新文件失败!",0);
|
||||||
|
} else if (msg.what == 1) {
|
||||||
|
UpdataInfo info = (UpdataInfo) msg.obj;
|
||||||
|
if (info!=null&&!info.getVersion().equals(versionStr)) {
|
||||||
|
showUpdataDialog(info);
|
||||||
|
}
|
||||||
|
} else if (msg.what == 2) {
|
||||||
|
new InstallUtil().installApk((File) msg.obj, MainActivity.this);
|
||||||
|
} else {
|
||||||
|
if (msg.obj.equals("该功能未授权")) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示信息", "该功能未授权!",0);
|
||||||
|
} else {
|
||||||
|
UserList user = (UserList) msg.obj;
|
||||||
|
if (user.getLgnname() == null) {
|
||||||
|
String udesc = user.getUdesc();
|
||||||
|
if (udesc.equals("0")) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||||
|
"PDA未注册!",0);
|
||||||
|
} else if (udesc.equals("1")) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||||
|
"PDA还未授权使用!",0);
|
||||||
|
} else if (udesc.equals("2")) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||||
|
"试用期已过!",0);
|
||||||
|
} else if (udesc.equals("3")) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||||
|
"超出最大站点数,请联系管理员",0);
|
||||||
|
} else if (udesc.equals("-1")) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示信息",
|
||||||
|
"用户名或密码错误!",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
SysData.is_lx = false;
|
||||||
|
login_end(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pd != null) {
|
||||||
|
pd.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private Handler regHandler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
if (msg.what != -1) {
|
||||||
|
if(msg.equals("-1")){
|
||||||
|
regts.setText("正式 注册");
|
||||||
|
}else{
|
||||||
|
regts.setText("软件到期时间"+msg.obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
public void login_end(UserList user) {
|
||||||
|
SysData.jigid = user.getJigid();
|
||||||
|
SysData.lgnname = user.getLgnname();
|
||||||
|
SysData.userid = String.valueOf(user.getUserid());
|
||||||
|
SysData.scale = MainActivity.this.getResources().getDisplayMetrics().density + 1;
|
||||||
|
SysData.t_scale = MainActivity.this.getResources().getDisplayMetrics().densityDpi >= 300f ? 1 : 300f * def_pbl / MainActivity.this.getResources().getDisplayMetrics().densityDpi;
|
||||||
|
SysData.exectime=Integer.parseInt(user.getUdesc() == null ? "60" : user.getUdesc());
|
||||||
|
SharedPreferences sp = MainActivity.this.getSharedPreferences(
|
||||||
|
"userTxt", MODE_PRIVATE);
|
||||||
|
if (checkBox.isChecked()) {
|
||||||
|
Editor editor = sp.edit();
|
||||||
|
editor.putString("name", name.getText().toString().trim());
|
||||||
|
editor.putString("pwd", pwd.getText().toString().trim());
|
||||||
|
editor.putBoolean("islxScan",islxScan.isChecked());
|
||||||
|
editor.commit();
|
||||||
|
} else {
|
||||||
|
sp.edit().clear().commit();
|
||||||
|
name.setText("");
|
||||||
|
pwd.setText("");
|
||||||
|
}
|
||||||
|
if (loginTy == 1) {
|
||||||
|
String islxscan="1";
|
||||||
|
if(islxScan.isChecked()){
|
||||||
|
islxscan="0";
|
||||||
|
}
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra("displaymode", user.getDisplaymode());
|
||||||
|
intent.putExtra("islxscan", islxscan);
|
||||||
|
intent.setClass(getApplicationContext(), DjActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
} else if (loginTy == 2) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setClass(getApplicationContext(), DownDataActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
SysData.no = name.getText().toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
System.setProperty("http.keepAlive", "false");
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
SharedPreferences sp = getSharedPreferences("userTxt", MODE_PRIVATE);
|
||||||
|
name = (EditText) findViewById(R.id.name);
|
||||||
|
pwd = (EditText) findViewById(R.id.pwd);
|
||||||
|
regts=(TextView) findViewById(R.id.regts);
|
||||||
|
checkBox = (CheckBox) findViewById(R.id.cb);
|
||||||
|
islxScan=(CheckBox)findViewById(R.id.lxs);
|
||||||
|
if (!sp.contains("name")) {
|
||||||
|
checkBox.setChecked(false);
|
||||||
|
} else {
|
||||||
|
name.setText(sp.getString("name", ""));
|
||||||
|
pwd.setText(sp.getString("pwd", ""));
|
||||||
|
islxScan.setChecked(sp.getBoolean("islxScan", true));
|
||||||
|
}
|
||||||
|
TextView version = (TextView) findViewById(R.id.version);
|
||||||
|
versionStr=getVersionName();
|
||||||
|
version.setText("版本".concat(versionStr));
|
||||||
|
SysData.clientid = SysUtil.getLocalMacAddress(MainActivity.this);
|
||||||
|
db = new SqlHelpUtil(getApplicationContext());
|
||||||
|
sDatabase = db.getWritableDatabase();
|
||||||
|
String selectStr = "select col1,col2,col3 from systable where desc='network'";
|
||||||
|
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
SysData.url = "http://".concat(select_cursor.getString(0))
|
||||||
|
.concat(":").concat(select_cursor.getString(1)).concat("/")
|
||||||
|
.concat(select_cursor.getString(2));
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
selectStr = "select col1 from systable where desc='pdaState'";
|
||||||
|
select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
SysData.isreg = select_cursor.getString(0);
|
||||||
|
System.out.println(SysData.isreg+"---------------------");
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
if (SysData.url != null) {
|
||||||
|
new Thread(new CheckVersionTask()).start();
|
||||||
|
new Thread(queryZcrq).start();
|
||||||
|
}
|
||||||
|
BufferedReader br = null;
|
||||||
|
BufferedWriter bw = null;
|
||||||
|
File file = new File(getFilesDir().getAbsolutePath() + "/cr_pda_config");
|
||||||
|
try {
|
||||||
|
if (!file.exists())
|
||||||
|
file.createNewFile();
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
InputStreamReader isr = new InputStreamReader(fis);
|
||||||
|
br = new BufferedReader(isr);
|
||||||
|
String s = br.readLine();
|
||||||
|
if (s == null || s.trim().length() < 1)
|
||||||
|
throw new Exception("Update config data.");
|
||||||
|
def_pbl = Float.parseFloat(s);
|
||||||
|
if (def_pbl < 0.1 || def_pbl > 10.0)
|
||||||
|
throw new Exception("请填写 0.1~10.0 之间的浮点数!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
def_pbl = 0.9f;
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
OutputStreamWriter osw = new OutputStreamWriter(fos);
|
||||||
|
bw = new BufferedWriter(osw);
|
||||||
|
bw.append(Float.toString(def_pbl));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (br != null) {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bw != null) {
|
||||||
|
try {
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("scanpal eda50".equals(android.os.Build.MODEL.toLowerCase())) {
|
||||||
|
AidcManager.create(this, new CreatedCallback() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreated(AidcManager aidcManager) {
|
||||||
|
manager = aidcManager;
|
||||||
|
barcodeReader = manager.createBarcodeReader();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BarcodeReader getBarcodeObject() {
|
||||||
|
return barcodeReader;
|
||||||
|
}
|
||||||
|
|
||||||
|
Runnable downloadRun = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
login(name.getText().toString().trim(), pwd.getText().toString()
|
||||||
|
.trim());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Runnable queryZcrq = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
String method = "regEndRq";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
Message message = new Message();
|
||||||
|
message.obj = envelope.getResponse().toString();
|
||||||
|
regHandler.sendMessage(message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message message = new Message();
|
||||||
|
message.what = -1;
|
||||||
|
message.obj = e.toString();
|
||||||
|
regHandler.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_main, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 获取当前程序的版本号
|
||||||
|
*/
|
||||||
|
private String getVersionName() {
|
||||||
|
// 获取packagemanager的实例
|
||||||
|
PackageManager packageManager = getPackageManager();
|
||||||
|
// getPackageName()是你当前类的包名,0代表是获取版本信息
|
||||||
|
PackageInfo packInfo = null;
|
||||||
|
try {
|
||||||
|
packInfo = packageManager.getPackageInfo(getPackageName(), 0);
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "错误信息", "获取版本号失败!",0);
|
||||||
|
}
|
||||||
|
return packInfo.versionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置按钮监听
|
||||||
|
public void onset(View v) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setClass(this, NetWorkSet.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onopentest(View v) {
|
||||||
|
DialogUtil.builder(this, "测试标题","测试内容!open" + v.getLeft(), 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onclosetest(View v) {
|
||||||
|
DialogUtil.builder(this, "测试标题","测试内容!close" + v.getLeft(), 18);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置按钮监听
|
||||||
|
public void onRotation(View v) {
|
||||||
|
int i = MainActivity.this.getRequestedOrientation();
|
||||||
|
// name.setText(i+"--"+ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT+"--"+ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
if (i == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||||
|
MainActivity.this
|
||||||
|
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
}
|
||||||
|
// 纵屏反方向
|
||||||
|
else if (i == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || i == 3) {
|
||||||
|
MainActivity.this
|
||||||
|
.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNull() {
|
||||||
|
if (name.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(this, "错误信息", "用户名不能为空!",0);
|
||||||
|
name.requestFocus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (pwd.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(this, "错误信息", "密码不能为空!",0);
|
||||||
|
pwd.requestFocus();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置按钮监听
|
||||||
|
public void onsub(View v) {
|
||||||
|
loginTy = 1;
|
||||||
|
start_login();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start_login() {
|
||||||
|
if (!isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!SysUtil.isNetworkConnected(MainActivity.this)) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "提示", "网络没连接!请检查网络",0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (name.getText().toString().trim().equals("crtech")
|
||||||
|
&& pwd.getText().toString().trim().equals("crtech")) {
|
||||||
|
Intent pdaIntent = new Intent();
|
||||||
|
pdaIntent.setClass(this, PdaRegActivity.class);
|
||||||
|
startActivity(pdaIntent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SysData.url == null || SysData.url.trim().length() < 1) {
|
||||||
|
DialogUtil.builder(this, "错误信息", "请设置URL!",0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (SysData.clientid.trim().length() < 1) {
|
||||||
|
DialogUtil.builder(this, "错误信息", "mac地址为空,请检查网络!",0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pd == null) {
|
||||||
|
pd = ProgressDialog.show(this, "提示", "正在登录……");
|
||||||
|
} else {
|
||||||
|
DialogUtil.setDialog(pd, "提示", "正在登录……");
|
||||||
|
}
|
||||||
|
|
||||||
|
new Thread(downloadRun).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void login(String name, String pwd) {
|
||||||
|
try {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
String method = "login";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("name", name);
|
||||||
|
rpc.addProperty("pwd", pwd);
|
||||||
|
rpc.addProperty("mac", SysData.clientid);
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
if (envelope.getResponse() != null) {
|
||||||
|
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
.getResponse().toString());
|
||||||
|
Message message = new Message();
|
||||||
|
message.obj = IoUtil.byte_obj(bb);
|
||||||
|
handler.sendMessage(message);
|
||||||
|
} else {
|
||||||
|
Message message = new Message();
|
||||||
|
message.what = -2;
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message message = new Message();
|
||||||
|
message.what = -1;
|
||||||
|
message.obj = e.toString();
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
|
if (event.KEYCODE_BACK == keyCode) {
|
||||||
|
if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onKeyDown(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (db != null) {
|
||||||
|
db.close();
|
||||||
|
sDatabase.close();
|
||||||
|
}
|
||||||
|
if (barcodeReader != null) {
|
||||||
|
// close BarcodeReader to clean up resources.
|
||||||
|
barcodeReader.close();
|
||||||
|
barcodeReader = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (manager != null) {
|
||||||
|
// close AidcManager to disconnect from the scanner service.
|
||||||
|
// once closed, the object can no longer be used.
|
||||||
|
manager.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showUpdataDialog(final UpdataInfo info) {
|
||||||
|
Builder builer = new Builder(this);
|
||||||
|
builer.setTitle("版本升级");
|
||||||
|
builer.setMessage(info.getDescription());
|
||||||
|
// 当点确定按钮时从服务器上下载 新的apk 然后安装
|
||||||
|
builer.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
downLoadApk(SysData.url.concat(info.getUrl()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 当点取消按钮时进行登录
|
||||||
|
builer.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builer.create();
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void downLoadApk(String url) {
|
||||||
|
ProgressDialog pd = new ProgressDialog(this);
|
||||||
|
pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||||
|
pd.setMessage("正在下载更新");
|
||||||
|
pd.show();
|
||||||
|
new Thread(new DownApk(pd, url, this.getApplicationContext(), handler))
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CheckVersionTask implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
InputStream is = null;
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
try {
|
||||||
|
String path = SysData.url + "/apk.xml";
|
||||||
|
URL url = new URL(path);
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setConnectTimeout(5000);
|
||||||
|
if (conn.getResponseCode() == 200) {
|
||||||
|
is = conn.getInputStream();
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = 1;
|
||||||
|
msg.obj = Dom4jUtil.parserXml(is,versionStr);
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = -4;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (is != null)
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
super.onOptionsItemSelected(item);
|
||||||
|
switch (item.getItemId())// 得到被点击的item的itemId
|
||||||
|
{
|
||||||
|
case R.id.lxdatadown:
|
||||||
|
loginTy = 2;
|
||||||
|
start_login();
|
||||||
|
break;
|
||||||
|
case R.id.lxlogin:
|
||||||
|
if (!isNull()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
DBManager dbManager = new DBManager(this);
|
||||||
|
if (dbManager.existsTable("userlist".toUpperCase()) < 1) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "信息提示", "请下载用户资料表!",0);
|
||||||
|
} else {
|
||||||
|
String sql = "select jigid,lgnname,userid from userlist where username='"
|
||||||
|
+ name.getText().toString().trim()
|
||||||
|
+ "' and pass='"
|
||||||
|
+ pwd.getText().toString().trim() + "'";
|
||||||
|
Cursor cur = dbManager.query(sql);
|
||||||
|
if (cur.getCount() == 0) {
|
||||||
|
DialogUtil.builder(MainActivity.this, "信息提示", "用户账号错误!",0);
|
||||||
|
} else {
|
||||||
|
SysData.is_lx = true;
|
||||||
|
UserList user = new UserList();
|
||||||
|
if (cur.moveToFirst()) {
|
||||||
|
user.setJigid(cur.getString(0));
|
||||||
|
user.setLgnname(cur.getString(1));
|
||||||
|
user.setUserid(cur.getInt(2));
|
||||||
|
user.setDisplaymode("grid");
|
||||||
|
loginTy = 1;
|
||||||
|
login_end(user);
|
||||||
|
}
|
||||||
|
if (dbManager.existsTable("TEMP_BI_DJHZ".toUpperCase()) < 1) {
|
||||||
|
dbManager
|
||||||
|
.exeSql("create table TEMP_BI_DJHZ(FIELDNAME varchar(200),FIELDVALUE VARCHAR(8000))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
cur = null;
|
||||||
|
}
|
||||||
|
dbManager.closeDB();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 该方法解决屏幕旋转程序崩溃,需要对应 AndroidManifest.xml 文件 android:configChanges="orientation|screenSize|keyboardHidden" 配置
|
||||||
|
*/
|
||||||
|
public void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
Toast.makeText(this, "转换横屏", Toast.LENGTH_SHORT).show();
|
||||||
|
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||||
|
Toast.makeText(this, "转换竖屏", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
119
app/src/main/java/com/example/chaoran/MenuActivity.java
Normal file
119
app/src/main/java/com/example/chaoran/MenuActivity.java
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.SimpleAdapter;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 菜单窗口
|
||||||
|
*/
|
||||||
|
public class MenuActivity extends Activity {
|
||||||
|
private ListView listView;
|
||||||
|
private List mData;
|
||||||
|
SimpleAdapter adapter;
|
||||||
|
Runnable downloadRun = new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
purview();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
public void purview(){
|
||||||
|
try {
|
||||||
|
String url = SysData.url+"/ChaoRanBI/webservice/ServiceInterface?wsdl";
|
||||||
|
System.out.println(url);
|
||||||
|
String method = "selectAndroidPurview";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("userid",SysData.userid);
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||||
|
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
.getResponse().toString());
|
||||||
|
ByteArrayInputStream bin = new ByteArrayInputStream(bb);
|
||||||
|
ObjectInputStream oin = new ObjectInputStream(bin);
|
||||||
|
List list= (List) oin.readObject();
|
||||||
|
// for(int i=0;i<list.size();i++){
|
||||||
|
// mData.add(list.get(i));
|
||||||
|
// }
|
||||||
|
mData.addAll(list);
|
||||||
|
System.out.println(mData.size()+"----------");
|
||||||
|
Message message = new Message();
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
new Thread(downloadRun).start();
|
||||||
|
System.out.println("--------------------------------------");
|
||||||
|
// for(int i=0;i<9;i++){
|
||||||
|
// Map m=new HashMap();
|
||||||
|
// m.put("mname","第"+i+"个选项");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
mData=new ArrayList();
|
||||||
|
adapter = new SimpleAdapter(this,mData,R.layout.activity_menu,
|
||||||
|
new String[]{"mname"},
|
||||||
|
new int[]{R.id.title});
|
||||||
|
listView=new ListView(this);
|
||||||
|
|
||||||
|
listView.setAdapter(adapter);
|
||||||
|
OnItemClickListener lis1 = new OnItemClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
|
||||||
|
long arg3) {
|
||||||
|
Map map=(Map)mData.get(arg2);
|
||||||
|
// System.out.println(map.get("gn_no"));
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtra("formlx", map.get("gn_no").toString());
|
||||||
|
intent.setClass(getApplicationContext(), DjActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
listView.setOnItemClickListener(lis1);
|
||||||
|
setContentView(listView);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_menu, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
229
app/src/main/java/com/example/chaoran/MipcaActivityCapture.java
Normal file
229
app/src/main/java/com/example/chaoran/MipcaActivityCapture.java
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
|
import android.media.MediaPlayer.OnCompletionListener;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Vibrator;
|
||||||
|
import android.view.SurfaceHolder;
|
||||||
|
import android.view.SurfaceHolder.Callback;
|
||||||
|
import android.view.SurfaceView;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.google.zxing.BarcodeFormat;
|
||||||
|
import com.google.zxing.Result;
|
||||||
|
import com.mining.app.zxing.camera.CameraManager;
|
||||||
|
import com.mining.app.zxing.decoding.CaptureActivityHandler;
|
||||||
|
import com.mining.app.zxing.decoding.InactivityTimer;
|
||||||
|
import com.mining.app.zxing.view.ViewfinderView;
|
||||||
|
/**
|
||||||
|
* 摄像头扫描条码
|
||||||
|
*/
|
||||||
|
public class MipcaActivityCapture extends Activity implements Callback {
|
||||||
|
|
||||||
|
private CaptureActivityHandler handler;
|
||||||
|
private ViewfinderView viewfinderView;
|
||||||
|
private boolean hasSurface;
|
||||||
|
private Vector<BarcodeFormat> decodeFormats;
|
||||||
|
private String characterSet;
|
||||||
|
private InactivityTimer inactivityTimer;
|
||||||
|
private MediaPlayer mediaPlayer;
|
||||||
|
private boolean playBeep;
|
||||||
|
private static final float BEEP_VOLUME = 0.10f;
|
||||||
|
private boolean vibrate;
|
||||||
|
private String uiId;
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.camerascansctivity);
|
||||||
|
//ViewUtil.addTopView(getApplicationContext(), this, R.string.scan_card);
|
||||||
|
CameraManager.init(getApplication());
|
||||||
|
viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
|
||||||
|
Intent intent = getIntent();
|
||||||
|
uiId = intent.getStringExtra("uiId");
|
||||||
|
Button mButtonBack = (Button) findViewById(R.id.button_back);
|
||||||
|
mButtonBack.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
MipcaActivityCapture.this.finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
hasSurface = false;
|
||||||
|
inactivityTimer = new InactivityTimer(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
|
||||||
|
SurfaceHolder surfaceHolder = surfaceView.getHolder();
|
||||||
|
if (hasSurface) {
|
||||||
|
initCamera(surfaceHolder);
|
||||||
|
} else {
|
||||||
|
surfaceHolder.addCallback(this);
|
||||||
|
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
|
||||||
|
}
|
||||||
|
decodeFormats = null;
|
||||||
|
characterSet = null;
|
||||||
|
|
||||||
|
playBeep = true;
|
||||||
|
AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||||
|
if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
|
||||||
|
playBeep = false;
|
||||||
|
}
|
||||||
|
initBeepSound();
|
||||||
|
vibrate = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (handler != null) {
|
||||||
|
handler.quitSynchronously();
|
||||||
|
handler = null;
|
||||||
|
}
|
||||||
|
CameraManager.get().closeDriver();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
inactivityTimer.shutdown();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理扫描结果
|
||||||
|
* @param result
|
||||||
|
* @param barcode
|
||||||
|
*/
|
||||||
|
public void handleDecode(Result result, Bitmap barcode) {
|
||||||
|
inactivityTimer.onActivity();
|
||||||
|
playBeepSoundAndVibrate();
|
||||||
|
String resultString = result.getText();
|
||||||
|
if (resultString.equals("")) {
|
||||||
|
Toast.makeText(MipcaActivityCapture.this, "Scan failed!", Toast.LENGTH_SHORT).show();
|
||||||
|
}else {
|
||||||
|
Intent resultIntent = new Intent();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString("tm", resultString);
|
||||||
|
bundle.putString("uiId",uiId);
|
||||||
|
System.out.println(resultString+"==============-"+uiId+"--------------------------------------------------------");
|
||||||
|
// bundle.putParcelable("bitmap", barcode);
|
||||||
|
resultIntent.putExtras(bundle);
|
||||||
|
this.setResult(4, resultIntent);
|
||||||
|
}
|
||||||
|
MipcaActivityCapture.this.finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCamera(SurfaceHolder surfaceHolder) {
|
||||||
|
try {
|
||||||
|
CameraManager.get().openDriver(surfaceHolder);
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
return;
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (handler == null) {
|
||||||
|
handler = new CaptureActivityHandler(this, decodeFormats,
|
||||||
|
characterSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceChanged(SurfaceHolder holder, int format, int width,
|
||||||
|
int height) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceCreated(SurfaceHolder holder) {
|
||||||
|
if (!hasSurface) {
|
||||||
|
hasSurface = true;
|
||||||
|
initCamera(holder);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
|
hasSurface = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewfinderView getViewfinderView() {
|
||||||
|
return viewfinderView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Handler getHandler() {
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawViewfinder() {
|
||||||
|
viewfinderView.drawViewfinder();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initBeepSound() {
|
||||||
|
if (playBeep && mediaPlayer == null) {
|
||||||
|
// The volume on STREAM_SYSTEM is not adjustable, and users found it
|
||||||
|
// too loud,
|
||||||
|
// so we now play on the music stream.
|
||||||
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
mediaPlayer = new MediaPlayer();
|
||||||
|
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||||
|
mediaPlayer.setOnCompletionListener(beepListener);
|
||||||
|
|
||||||
|
AssetFileDescriptor file = getResources().openRawResourceFd(
|
||||||
|
R.raw.beep);
|
||||||
|
try {
|
||||||
|
mediaPlayer.setDataSource(file.getFileDescriptor(),
|
||||||
|
file.getStartOffset(), file.getLength());
|
||||||
|
file.close();
|
||||||
|
mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
|
||||||
|
mediaPlayer.prepare();
|
||||||
|
} catch (IOException e) {
|
||||||
|
mediaPlayer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final long VIBRATE_DURATION = 200L;
|
||||||
|
|
||||||
|
private void playBeepSoundAndVibrate() {
|
||||||
|
if (playBeep && mediaPlayer != null) {
|
||||||
|
mediaPlayer.start();
|
||||||
|
}
|
||||||
|
// if (vibrate) {
|
||||||
|
// Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
|
||||||
|
// vibrator.vibrate(VIBRATE_DURATION);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the beep has finished playing, rewind to queue up another one.
|
||||||
|
*/
|
||||||
|
private final OnCompletionListener beepListener = new OnCompletionListener() {
|
||||||
|
public void onCompletion(MediaPlayer mediaPlayer) {
|
||||||
|
mediaPlayer.seekTo(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
244
app/src/main/java/com/example/chaoran/NetWorkSet.java
Normal file
244
app/src/main/java/com/example/chaoran/NetWorkSet.java
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.kobjects.base64.Base64;
|
||||||
|
|
||||||
|
import com.chaoran.db.SqlHelpUtil;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.provider.Settings.Secure;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网络相关窗口
|
||||||
|
*/
|
||||||
|
@SuppressLint("NewApi")
|
||||||
|
public class NetWorkSet extends Activity {
|
||||||
|
private EditText ip;
|
||||||
|
private EditText port;
|
||||||
|
private EditText itemName;
|
||||||
|
private EditText bz;
|
||||||
|
private SqlHelpUtil db;
|
||||||
|
private SQLiteDatabase sDatabase;
|
||||||
|
private TextView supportDevices;
|
||||||
|
|
||||||
|
private Handler regHandler = new Handler() {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
if (msg.obj.equals("0")) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "提示信息", "注册成功!", 0);
|
||||||
|
} else if (msg.obj.equals("1")) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "提示信息", "该PDA已注册!", 0);
|
||||||
|
} else {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "提示信息", "注册失败!" + msg.obj.toString(), 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
//
|
||||||
|
BufferedReader br = null;
|
||||||
|
BufferedWriter bw = null;
|
||||||
|
File file = new File(getFilesDir().getAbsolutePath() + "/cr_pda_config");
|
||||||
|
try {
|
||||||
|
if (!file.exists()) {
|
||||||
|
file.createNewFile();
|
||||||
|
//DialogUtil.builder(NetWorkSet.this, "错误信息", "文件不存在!", 0);
|
||||||
|
}
|
||||||
|
FileInputStream fis = new FileInputStream(file);
|
||||||
|
InputStreamReader isr = new InputStreamReader(fis);
|
||||||
|
br = new BufferedReader(isr);
|
||||||
|
String s = br.readLine();
|
||||||
|
if (s == null || s.trim().length() < 1)
|
||||||
|
throw new Exception("Update config data.");
|
||||||
|
MainActivity.def_pbl = Float.parseFloat(s);
|
||||||
|
if (MainActivity.def_pbl < 0.1 || MainActivity.def_pbl > 10.0)
|
||||||
|
throw new Exception("请填写 0.1~10.0 之间的浮点数!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "错误信息", e.getMessage(), 0);
|
||||||
|
MainActivity.def_pbl = 0.9f;
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
OutputStreamWriter osw = new OutputStreamWriter(fos);
|
||||||
|
bw = new BufferedWriter(osw);
|
||||||
|
bw.append(Float.toString(MainActivity.def_pbl));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (br != null) {
|
||||||
|
try {
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (bw != null) {
|
||||||
|
try {
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setContentView(R.layout.activity_net_work_set);
|
||||||
|
ip = (EditText) findViewById(R.id.ip);
|
||||||
|
port = (EditText) findViewById(R.id.port);
|
||||||
|
itemName = (EditText) findViewById(R.id.itemName);
|
||||||
|
bz = (EditText) findViewById(R.id.bz);
|
||||||
|
TextView mactv = (TextView) findViewById(R.id.mac);
|
||||||
|
mactv.setText("mac:" + SysUtil.getLocalMacAddress(NetWorkSet.this));
|
||||||
|
TextView androidIDtv = (TextView) findViewById(R.id.androidID);
|
||||||
|
androidIDtv.setText("sn:" + SysUtil.getSn());
|
||||||
|
EditText te = (EditText) findViewById(R.id.itemName91);
|
||||||
|
te.setText(Float.toString(MainActivity.def_pbl));
|
||||||
|
// MainActivity.this.getResources().getDisplayMetrics().densityDpi
|
||||||
|
TextView modeltv = (TextView) findViewById(R.id.model);
|
||||||
|
modeltv.setText("型号:" + android.os.Build.MODEL.toLowerCase());
|
||||||
|
//
|
||||||
|
TextView phoneDpi = (TextView) findViewById(R.id.phoneDpi);
|
||||||
|
phoneDpi.setText("密度:" + getResources().getDisplayMetrics().densityDpi);
|
||||||
|
//
|
||||||
|
db = new SqlHelpUtil(getApplicationContext());
|
||||||
|
sDatabase = db.getWritableDatabase();
|
||||||
|
System.out.println(sDatabase.getMaximumSize() + "--------------------------");
|
||||||
|
String selectStr = "select col1,col2,col3 from systable where desc='network'";
|
||||||
|
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
ip.setText(select_cursor.getString(0));
|
||||||
|
port.setText(select_cursor.getString(1));
|
||||||
|
itemName.setText(select_cursor.getString(2));
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_net_work_set, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onsub(View v) {
|
||||||
|
EditText te = (EditText) findViewById(R.id.itemName91);
|
||||||
|
try {
|
||||||
|
MainActivity.def_pbl = Float.parseFloat(te.getText().toString());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写 0.1~10.0 之间的浮点数!", 0);
|
||||||
|
MainActivity.def_pbl = 0.9f;
|
||||||
|
} finally {
|
||||||
|
if (MainActivity.def_pbl < 0.1 || MainActivity.def_pbl > 10.0) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写 0.1~10.0 之间的浮点数!", 0);
|
||||||
|
MainActivity.def_pbl = 0.9f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BufferedWriter bw = null;
|
||||||
|
File file = new File(getFilesDir().getAbsolutePath() + "/cr_pda_config");
|
||||||
|
|
||||||
|
try {
|
||||||
|
FileOutputStream fos = new FileOutputStream(file);
|
||||||
|
OutputStreamWriter osw = new OutputStreamWriter(fos);
|
||||||
|
bw = new BufferedWriter(osw);
|
||||||
|
bw.append(Float.toString(MainActivity.def_pbl));
|
||||||
|
} catch (IOException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (bw != null) {
|
||||||
|
try {
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// DialogUtil.builder(NetWorkSet.this, "错误信息", "请检查网络!" +
|
||||||
|
// MainActivity.def_pbl,0);
|
||||||
|
if (ip.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写IP!", 0);
|
||||||
|
ip.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (port.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写端口!", 0);
|
||||||
|
port.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (itemName.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "错误信息", "请填写工程名!", 0);
|
||||||
|
itemName.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String selectStr = "select col1 from systable where desc='network'";
|
||||||
|
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
String ipValue = ip.getText().toString().trim();
|
||||||
|
String portValue = port.getText().toString().trim();
|
||||||
|
String itemNameValue = itemName.getText().toString().trim();
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
sDatabase.execSQL("update systable set col1='" + ipValue + "',col2='" + portValue + "',col3='" + itemNameValue + "' where desc='network'");
|
||||||
|
} else {
|
||||||
|
sDatabase.execSQL("insert into systable (col1,col2,col3,desc) values('" + ipValue + "','" + portValue + "','" + itemNameValue + "','network')");
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
SysData.url = "http://".concat(ipValue).concat(":").concat(portValue).concat("/").concat(itemNameValue);
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "提示", "设置成功!", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onback(View v) {
|
||||||
|
// Intent intent = this.getIntent();
|
||||||
|
// setResult(0, intent);
|
||||||
|
finish();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pdaRegister(View v) throws Exception {
|
||||||
|
String mac = SysData.clientid;
|
||||||
|
if (mac == null || mac.length() < 1) {
|
||||||
|
DialogUtil.builder(NetWorkSet.this, "提示", "mac地址为空,请检查网络", 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HashMap map = new HashMap();
|
||||||
|
map.put("mac", mac);
|
||||||
|
map.put("bz", bz.getText().toString().trim());
|
||||||
|
byte[] b = IoUtil.getbyte(map);
|
||||||
|
String paramString = Base64.encode(b);
|
||||||
|
new RunYmupThread(paramString, regHandler, "pdaRegister", 0).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (db != null) {
|
||||||
|
db.close();
|
||||||
|
sDatabase.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
108
app/src/main/java/com/example/chaoran/ParamActivity.java
Normal file
108
app/src/main/java/com/example/chaoran/ParamActivity.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.chaoran.component.MyAdapter;
|
||||||
|
import com.chaoran.entiry.DataGrid;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数窗口
|
||||||
|
*/
|
||||||
|
public class ParamActivity extends Activity {
|
||||||
|
private ListView listView;
|
||||||
|
private List listdata;
|
||||||
|
private TextView tv;
|
||||||
|
private MyAdapter mxAdapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_param);
|
||||||
|
listView = (ListView) findViewById(R.id.list);
|
||||||
|
tv = (TextView) findViewById(R.id.tvtitle);
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
DataGrid dg = (DataGrid) intent.getSerializableExtra("dg");
|
||||||
|
listdata = dg.getTableData();
|
||||||
|
// SimpleAdapter mxAdapter = new SimpleAdapter(this,listdata,
|
||||||
|
// R.layout.activity_menu,
|
||||||
|
// new String[] {dg.getTableHead().get(0).get("columnName").toString()},
|
||||||
|
// new int[] { R.id.title });
|
||||||
|
|
||||||
|
mxAdapter = new MyAdapter(this, (ArrayList) listdata, dg.getTableHead()
|
||||||
|
.get(0).get("columnName").toString());
|
||||||
|
tv.setText(dg.getTableHead().get(0).get("columnChineseName").toString());
|
||||||
|
listView.setAdapter(mxAdapter);
|
||||||
|
// listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);//
|
||||||
|
// 一定要设置这个属性,否则ListView不会刷新
|
||||||
|
OnItemClickListener lis1 = new OnItemClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
|
||||||
|
long arg3) {
|
||||||
|
// mxAdapter.cur_pos=arg2;
|
||||||
|
arg1.setBackgroundColor(Color.GREEN);
|
||||||
|
Serializable map = (Serializable) listdata.get(arg2);
|
||||||
|
// Intent int =getIntent();
|
||||||
|
// intent.putExtra("param",map);
|
||||||
|
intent.putExtra("param", map);
|
||||||
|
intent.putExtra("audioFld",
|
||||||
|
intent.getSerializableExtra("audioFld"));
|
||||||
|
setResult(1, intent);
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
listView.setOnItemClickListener(lis1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onback(View v) {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.isTracking()
|
||||||
|
&& !event.isCanceled()) {
|
||||||
|
clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||||
|
if (mxAdapter.cur_pos < listdata.size()) {
|
||||||
|
mxAdapter.cur_pos++;
|
||||||
|
listView.setSelection(mxAdapter.cur_pos);
|
||||||
|
mxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||||
|
if (mxAdapter.cur_pos >0) {
|
||||||
|
mxAdapter.cur_pos--;
|
||||||
|
listView.setSelection(mxAdapter.cur_pos);
|
||||||
|
mxAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onKeyUp(keyCode, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clear() {
|
||||||
|
listView = null;
|
||||||
|
tv = null;
|
||||||
|
if (listdata != null) {
|
||||||
|
listdata.clear();
|
||||||
|
listdata = null;
|
||||||
|
mxAdapter.clear();
|
||||||
|
mxAdapter = null;
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
189
app/src/main/java/com/example/chaoran/PdaRegActivity.java
Normal file
189
app/src/main/java/com/example/chaoran/PdaRegActivity.java
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import com.chaoran.db.SqlHelpUtil;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pda注册窗口
|
||||||
|
*/
|
||||||
|
public class PdaRegActivity extends Activity {
|
||||||
|
private EditText ip;
|
||||||
|
private EditText port;
|
||||||
|
private EditText itemName;
|
||||||
|
private SqlHelpUtil db;
|
||||||
|
private SQLiteDatabase sDatabase;
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
if (msg.what == -1) {
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "错误信息", "连接服务器失败,请检查网络!"
|
||||||
|
+ msg.obj,0);
|
||||||
|
} else if (msg.what == -2) {
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "错误信息", "返回值为空!",0);
|
||||||
|
} else{
|
||||||
|
String retunVal=msg.obj.toString();
|
||||||
|
if(retunVal.equals("-1")){
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "提示信息", "序列号还未注册!",0);
|
||||||
|
}else if(!retunVal.equals("Y")){
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "提示信息", "序列号还未启用!",0);
|
||||||
|
}else{
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "提示信息", "操作成功!",0);
|
||||||
|
String selectStr = "select col1 from systable where desc='pdaState'";
|
||||||
|
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
sDatabase.execSQL("update systable set col1='Y' where desc='pdaState'");
|
||||||
|
} else {
|
||||||
|
sDatabase
|
||||||
|
.execSQL("insert into systable (col1,desc) values('Y','pdaState')");
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
SysData.isreg="Y";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_pda_reg);
|
||||||
|
ip = (EditText) findViewById(R.id.ip);
|
||||||
|
port = (EditText) findViewById(R.id.port);
|
||||||
|
itemName = (EditText) findViewById(R.id.itemName);
|
||||||
|
db = new SqlHelpUtil(getApplicationContext());
|
||||||
|
sDatabase = db.getWritableDatabase();
|
||||||
|
String selectStr = "select col1,col2,col3 from systable where desc='pdaRegServer'";
|
||||||
|
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
ip.setText(select_cursor.getString(0));
|
||||||
|
port.setText(select_cursor.getString(1));
|
||||||
|
itemName.setText(select_cursor.getString(2));
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onsub(View v) {
|
||||||
|
if (ip.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "错误信息", "请填写服务器IP!",0);
|
||||||
|
ip.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (port.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "错误信息", "请填写服务器端口!",0);
|
||||||
|
port.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (itemName.getText().toString().trim().equals("")) {
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "错误信息", "请填写工程名!",0);
|
||||||
|
itemName.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String selectStr = "select col1 from systable where desc='pdaRegServer'";
|
||||||
|
Cursor select_cursor = sDatabase.rawQuery(selectStr, null);
|
||||||
|
String ipValue = ip.getText().toString().trim();
|
||||||
|
String portValue = port.getText().toString().trim();
|
||||||
|
String itemNameValue = itemName.getText().toString().trim();
|
||||||
|
if (select_cursor.moveToFirst()) {
|
||||||
|
sDatabase.execSQL("update systable set col1='" + ipValue
|
||||||
|
+ "',col2='" + portValue + "',col3='" + itemNameValue
|
||||||
|
+ "' where desc='pdaRegServer'");
|
||||||
|
} else {
|
||||||
|
sDatabase
|
||||||
|
.execSQL("insert into systable (col1,col2,col3,desc) values('"
|
||||||
|
+ ipValue
|
||||||
|
+ "','"
|
||||||
|
+ portValue
|
||||||
|
+ "','"
|
||||||
|
+ itemNameValue + "','pdaRegServer')");
|
||||||
|
}
|
||||||
|
select_cursor.close();
|
||||||
|
SysData.url = "http://".concat(ipValue).concat(":").concat(portValue)
|
||||||
|
.concat("/").concat(itemNameValue);
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "提示", "保存成功,请点下面的PDA注册按钮进行注册!",0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
getMenuInflater().inflate(R.menu.activity_pda_reg, menu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onback(View v) {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (db != null) {
|
||||||
|
db.close();
|
||||||
|
sDatabase.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pdaRegister(View v) throws Exception {
|
||||||
|
String sn = SysUtil.getSn();
|
||||||
|
if (sn == null || sn.length() < 1) {
|
||||||
|
DialogUtil.builder(PdaRegActivity.this, "提示", "序列号为空,请联系供应商",0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new Thread(new PdaRegValidate()).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PdaRegValidate implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
String ipValue = ip.getText().toString().trim();
|
||||||
|
String portValue = port.getText().toString().trim();
|
||||||
|
String itemNameValue = itemName.getText().toString().trim();
|
||||||
|
String url = "http://".concat(ipValue).concat(":")
|
||||||
|
.concat(portValue).concat("/").concat(itemNameValue);
|
||||||
|
url = url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
System.out.println(url);
|
||||||
|
String method = "pdaZcValidate";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
System.out.println(SysUtil.getSn());
|
||||||
|
rpc.addProperty("sn", SysUtil.getSn());
|
||||||
|
try {
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
if (envelope.getResponse() != null) {
|
||||||
|
String s=envelope.getResponse().toString();
|
||||||
|
Message message = new Message();
|
||||||
|
message.obj = s;
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}else{
|
||||||
|
Message message = new Message();
|
||||||
|
message.what = -2;
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Message message = new Message();
|
||||||
|
message.what = -1;
|
||||||
|
message.obj = e.toString();
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
87
app/src/main/java/com/example/chaoran/RunSearchThread.java
Normal file
87
app/src/main/java/com/example/chaoran/RunSearchThread.java
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.chaoran.entiry.DataGrid;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/*运行检索方案线程*/
|
||||||
|
public class RunSearchThread extends Thread {
|
||||||
|
private String sql;
|
||||||
|
private String param;
|
||||||
|
private Handler handler;
|
||||||
|
private String return_one;// 是否单行返回
|
||||||
|
private String audioFld;// 声音播放字段
|
||||||
|
|
||||||
|
public RunSearchThread(String sql, String param, Handler handler,
|
||||||
|
String return_one, String audioFld) {
|
||||||
|
this.sql = sql;
|
||||||
|
this.param = param;
|
||||||
|
this.handler = handler;
|
||||||
|
this.return_one = return_one;
|
||||||
|
this.audioFld = audioFld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RunSearchThread(String sql, String param, Handler handler) {
|
||||||
|
this.sql = sql;
|
||||||
|
this.param = param;
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
Log.v("RunSearchThread", "run执行");
|
||||||
|
try {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
String method = "runSearch";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("sql", sql);
|
||||||
|
rpc.addProperty("base64Param", param);
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url,SysData.timeout);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
.getResponse().toString());
|
||||||
|
Object ob = IoUtil.byte_obj(bb);
|
||||||
|
if (ob instanceof DataGrid) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||||
|
DataGrid dg = (DataGrid) ob;
|
||||||
|
Map map = new HashMap();
|
||||||
|
if (return_one != null) {
|
||||||
|
map.put("return_one", return_one);
|
||||||
|
}
|
||||||
|
if (audioFld != null) {
|
||||||
|
map.put("audioFld", audioFld);
|
||||||
|
}
|
||||||
|
map.put("dg", dg);
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.obj = map;
|
||||||
|
msg.arg1 = 1;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} else {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.obj = ob.toString();
|
||||||
|
msg.what = -1;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = -1;
|
||||||
|
msg.obj = e.toString();
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
96
app/src/main/java/com/example/chaoran/RunYmupThread.java
Normal file
96
app/src/main/java/com/example/chaoran/RunYmupThread.java
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
public class RunYmupThread extends Thread {
|
||||||
|
private String param;
|
||||||
|
private Handler handler;
|
||||||
|
private String methodName;
|
||||||
|
private int urlTy;// 0表示访问ServiceInterface,1表示访问offLineInventoryInterface
|
||||||
|
|
||||||
|
public RunYmupThread(String param, Handler handler, String methodName,
|
||||||
|
int urlTy) {
|
||||||
|
this.param = param;
|
||||||
|
this.handler = handler;
|
||||||
|
this.methodName = methodName;
|
||||||
|
this.urlTy = urlTy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
Log.v("SearchThread", "run执行");
|
||||||
|
try {
|
||||||
|
String url = null;
|
||||||
|
if (urlTy == 0) {
|
||||||
|
url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
} else if (urlTy == 1) {
|
||||||
|
url = SysData.url
|
||||||
|
+ "/webservice/offLineInventoryInterface?wsdl";
|
||||||
|
}
|
||||||
|
String method = methodName;
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
if (param != null) {
|
||||||
|
rpc.addProperty("param", param);
|
||||||
|
}
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url, SysData.timeout);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||||
|
// byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
// .getResponse().toString());
|
||||||
|
// Map map= (Map)IoUtil.byte_obj(bb);
|
||||||
|
// Message msg = new Message();
|
||||||
|
// msg.obj = map;
|
||||||
|
// msg.arg1=2;
|
||||||
|
// handler.sendMessage(msg);
|
||||||
|
Message msg = new Message();
|
||||||
|
if (methodName.equals("saveDj")) {
|
||||||
|
msg.arg1 = 3;
|
||||||
|
msg.obj = envelope.getResponse().toString();
|
||||||
|
} else if (methodName.equals("pdaRegister")) {
|
||||||
|
msg.obj = envelope.getResponse().toString();
|
||||||
|
} else {
|
||||||
|
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
.getResponse().toString());
|
||||||
|
msg.obj = IoUtil.byte_obj(bb);
|
||||||
|
if (methodName.equals("runYmup")) {
|
||||||
|
msg.arg1 = 2;
|
||||||
|
} else if (methodName.equals("runTqfa")) {
|
||||||
|
msg.arg1 = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} else {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.obj = null;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message msg = new Message();
|
||||||
|
if (methodName.equals("runYmup")) {
|
||||||
|
msg.what = -2;
|
||||||
|
} else if (methodName.equals("saveDj")) {
|
||||||
|
msg.what = -3;
|
||||||
|
} else if (methodName.equals("runTqfa")) {
|
||||||
|
msg.what = -4;
|
||||||
|
}else{
|
||||||
|
msg.what = -1;
|
||||||
|
}
|
||||||
|
msg.obj = e.toString();
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
app/src/main/java/com/example/chaoran/SearchThread.java
Normal file
69
app/src/main/java/com/example/chaoran/SearchThread.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
import com.sys.SysData;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索线程
|
||||||
|
*/
|
||||||
|
public class SearchThread extends Thread {
|
||||||
|
private String fangalx;
|
||||||
|
private String functionname;
|
||||||
|
private Handler handler;
|
||||||
|
private int type;// 0 表示检索方案 1表示 页面修改方案,2表示提取方案
|
||||||
|
|
||||||
|
public SearchThread(String fangalx, String functionname, Handler handler,
|
||||||
|
int type) {
|
||||||
|
this.fangalx = fangalx;
|
||||||
|
this.functionname = functionname;
|
||||||
|
this.handler = handler;
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
super.run();
|
||||||
|
Log.v("SearchThread", "run执行");
|
||||||
|
try {
|
||||||
|
String url = SysData.url
|
||||||
|
+ "/webservice/ServiceInterface?wsdl";
|
||||||
|
String method = null;
|
||||||
|
if (type == 0) {
|
||||||
|
method = "queryZdysql";
|
||||||
|
} else if(type==1) {
|
||||||
|
method = "selectYmupSql";
|
||||||
|
}else if(type==2) {
|
||||||
|
method = "selectDjtqFun";
|
||||||
|
}
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("fangalx", fangalx);
|
||||||
|
rpc.addProperty("functionname", functionname);
|
||||||
|
HttpTransportSE ht = new HttpTransportSE(url,SysData.timeout);
|
||||||
|
ht.debug = true;
|
||||||
|
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
|
||||||
|
SoapEnvelope.VER11);
|
||||||
|
envelope.bodyOut = rpc;
|
||||||
|
envelope.dotNet = true;
|
||||||
|
envelope.setOutputSoapObject(rpc);
|
||||||
|
ht.call("", envelope);
|
||||||
|
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.obj = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
.getResponse().toString());
|
||||||
|
msg.arg1 = type;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = -1;
|
||||||
|
msg.obj = e.toString();
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
83
app/src/main/java/com/example/chaoran/UpdatePwdActivity.java
Normal file
83
app/src/main/java/com/example/chaoran/UpdatePwdActivity.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import com.chaoran.thread.UpdatePwdThread;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新密码窗口
|
||||||
|
*/
|
||||||
|
public class UpdatePwdActivity extends Activity {
|
||||||
|
private EditText newPwd;
|
||||||
|
private EditText CfNewPwd;
|
||||||
|
public ProgressDialog pd;
|
||||||
|
private Handler handler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
if (pd != null) {
|
||||||
|
pd.dismiss();
|
||||||
|
}
|
||||||
|
if (msg.what == -1) {
|
||||||
|
DialogUtil.builder(UpdatePwdActivity.this, "错误信息", msg.obj.toString(),0);
|
||||||
|
}else{
|
||||||
|
if(msg.obj.equals("0")){
|
||||||
|
DialogUtil.builder(UpdatePwdActivity.this, "提示信息","修改密码成功",0);
|
||||||
|
}else{
|
||||||
|
DialogUtil.builder(UpdatePwdActivity.this, "错误信息","修改密码失败".concat( msg.obj.toString()),0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstaneceState) {
|
||||||
|
super.onCreate(savedInstaneceState);
|
||||||
|
setContentView(R.layout.activity_update_pwd);
|
||||||
|
((EditText)findViewById(R.id.name)).setText(SysData.lgnname);
|
||||||
|
newPwd=(EditText)findViewById(R.id.newpwd);
|
||||||
|
CfNewPwd=(EditText)findViewById(R.id.cfnewpwd);
|
||||||
|
newPwd.requestFocus();
|
||||||
|
}
|
||||||
|
public void onsub(View v) {
|
||||||
|
String newPwdValue=newPwd.getText().toString().trim();
|
||||||
|
if(newPwdValue.equals("")){
|
||||||
|
DialogUtil.builder(this, "错误信息", "请填写新密码!",0);
|
||||||
|
newPwd.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String CfNewPwdValue=CfNewPwd.getText().toString().trim();
|
||||||
|
if(CfNewPwdValue.equals("")){
|
||||||
|
DialogUtil.builder(this, "错误信息", "请填写重复密码!",0);
|
||||||
|
CfNewPwd.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!CfNewPwdValue.equals(newPwdValue)){
|
||||||
|
DialogUtil.builder(this, "错误信息", "新密码和重复密码不一致!",0);
|
||||||
|
newPwd.requestFocus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pd == null) {
|
||||||
|
pd = ProgressDialog.show(this, "提示", "正在操作……");
|
||||||
|
} else {
|
||||||
|
DialogUtil.setDialog(pd, "提示", "正在操作……");
|
||||||
|
}
|
||||||
|
new Thread(new UpdatePwdThread(handler,SysData.userid,newPwdValue)).start();
|
||||||
|
}
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (pd != null) {
|
||||||
|
pd=null;
|
||||||
|
}
|
||||||
|
handler=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
139
app/src/main/java/com/example/chaoran/VoiceSettingActivity.java
Normal file
139
app/src/main/java/com/example/chaoran/VoiceSettingActivity.java
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
/*
|
||||||
|
**********************************************
|
||||||
|
* DATE PERSON REASON
|
||||||
|
* 2021-02-05 FXY Created
|
||||||
|
**********************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.*;
|
||||||
|
import com.vioce.TekVoiceEngine;
|
||||||
|
import com.vioce.VoiceEngine;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 播报语音设置
|
||||||
|
*/
|
||||||
|
public class VoiceSettingActivity extends Activity {
|
||||||
|
|
||||||
|
private EditText testText;
|
||||||
|
private RadioButton voiceF, voiceY;
|
||||||
|
private SeekBar voiceSize, voiceSpeed, voiceIndicate;
|
||||||
|
private Button save, cancel;
|
||||||
|
private SharedPreferences sharedPreferences;
|
||||||
|
private RadioGroup voiceMemberGroup;
|
||||||
|
|
||||||
|
private VoiceEngine voiceEngine;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_voice);
|
||||||
|
initView();
|
||||||
|
initData();
|
||||||
|
initListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
|
testText = findViewById(R.id.voice_test_text);
|
||||||
|
voiceF = findViewById(R.id.voice_member_xiaofeng);
|
||||||
|
voiceY = findViewById(R.id.voice_member_xiaoyan);
|
||||||
|
voiceSize = findViewById(R.id.voice_size);
|
||||||
|
voiceSpeed = findViewById(R.id.voice_speed);
|
||||||
|
voiceIndicate = findViewById(R.id.voice_indicate);
|
||||||
|
save = findViewById(R.id.save_voice_setting);
|
||||||
|
cancel = findViewById(R.id.cancel_voice_setting);
|
||||||
|
voiceMemberGroup = findViewById(R.id.voice_member_group);
|
||||||
|
voiceEngine = new TekVoiceEngine(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initData() {
|
||||||
|
sharedPreferences = getSharedPreferences("voiceEngine", MODE_PRIVATE);
|
||||||
|
//设置测试文本
|
||||||
|
testText.setText(sharedPreferences.getString("testText", testText.getText().toString()));
|
||||||
|
//设置播报人员
|
||||||
|
String voiceMember = sharedPreferences.getString("voiceMember", "xiaofeng");
|
||||||
|
if (voiceMember.equals("xiaofeng")) {
|
||||||
|
voiceF.setChecked(true);
|
||||||
|
voiceY.setChecked(false);
|
||||||
|
} else {
|
||||||
|
voiceY.setChecked(true);
|
||||||
|
voiceF.setChecked(false);
|
||||||
|
}
|
||||||
|
//设置功能选项
|
||||||
|
voiceSize.setProgress(sharedPreferences.getInt("voiceSize", 100));
|
||||||
|
voiceSpeed.setProgress(sharedPreferences.getInt("voiceSpeed", 80));
|
||||||
|
voiceIndicate.setProgress(sharedPreferences.getInt("voiceIndicate", 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initListener() {
|
||||||
|
SeekBar.OnSeekBarChangeListener seekBarChangeListener = new SeekBar.OnSeekBarChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
|
//停止播放
|
||||||
|
voiceEngine.stopSpeaking();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
//播放语音
|
||||||
|
voiceEngine.setParam(voiceF.isChecked() ? "xiaofeng" : "xiaoyan", voiceSize.getProgress(), voiceIndicate.getProgress(), voiceSpeed.getProgress());
|
||||||
|
voiceEngine.startSpeaking(testText.getText().toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
voiceSize.setOnSeekBarChangeListener(seekBarChangeListener);
|
||||||
|
voiceIndicate.setOnSeekBarChangeListener(seekBarChangeListener);
|
||||||
|
voiceSpeed.setOnSeekBarChangeListener(seekBarChangeListener);
|
||||||
|
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||||
|
save.setOnClickListener(a -> {
|
||||||
|
editor.putInt("voiceSize", voiceSize.getProgress());
|
||||||
|
editor.putInt("voiceIndicate", voiceIndicate.getProgress());
|
||||||
|
editor.putInt("voiceSpeed", voiceSpeed.getProgress());
|
||||||
|
editor.putString("testText", testText.getText().toString());
|
||||||
|
editor.putString("voiceMember", voiceF.isChecked() ? "xiaofeng" : "xiaoyan");
|
||||||
|
editor.commit();
|
||||||
|
voiceEngine.stopSpeaking();
|
||||||
|
voiceEngine.destroy();
|
||||||
|
Toast.makeText(this, "语音配置保存成功!", Toast.LENGTH_SHORT).show();
|
||||||
|
this.finish();
|
||||||
|
});
|
||||||
|
cancel.setOnClickListener(a -> {
|
||||||
|
voiceEngine.stopSpeaking();
|
||||||
|
voiceEngine.destroy();
|
||||||
|
this.finish();
|
||||||
|
});
|
||||||
|
|
||||||
|
voiceMemberGroup.setOnCheckedChangeListener((a, b) -> {
|
||||||
|
//播放语音
|
||||||
|
voiceEngine.setParam(voiceF.isChecked() ? "xiaofeng" : "xiaoyan", voiceSize.getProgress(), voiceIndicate.getProgress(), voiceSpeed.getProgress());
|
||||||
|
voiceEngine.startSpeaking(testText.getText().toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
//初始化加载一次
|
||||||
|
voiceEngine.setParam(voiceF.isChecked() ? "xiaofeng" : "xiaoyan", voiceSize.getProgress(), voiceIndicate.getProgress(), voiceSpeed.getProgress());
|
||||||
|
voiceEngine.startSpeaking(testText.getText().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
voiceEngine.stopSpeaking();
|
||||||
|
voiceEngine.destroy();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -10,7 +10,7 @@ import android.util.Log;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,17 @@
|
|||||||
package com.jiebao.h518.scan;
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import com.jiebao.h518.scan.BeepManager;
|
||||||
import android.util.Log;
|
|
||||||
import com.motorolasolutions.adc.decoder.BarCodeReader;
|
import com.motorolasolutions.adc.decoder.BarCodeReader;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.media.SoundPool;
|
||||||
|
import android.media.ToneGenerator;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.SlidingDrawer;
|
||||||
|
|
||||||
|
|
||||||
public class DiemensionalCodeControler implements BarCodeReader.DecodeCallback {
|
public class DiemensionalCodeControler implements BarCodeReader.DecodeCallback {
|
||||||
public interface DiemensionalScanListener{
|
public interface DiemensionalScanListener{
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public class NewScanControler {
|
|||||||
private InputStream mInputStream;
|
private InputStream mInputStream;
|
||||||
|
|
||||||
public NewScanControler() throws SecurityException, IOException {
|
public NewScanControler() throws SecurityException, IOException {
|
||||||
mSerialPort = new SerialPort(new File("/dev/ttySAC1"), 9600, 8, 'N', 1,
|
mSerialPort = new SerialPort(new File("/dev/ttySAC1"), 9600,
|
||||||
0);
|
0);
|
||||||
mOutputStream = mSerialPort.getOutputStream();
|
mOutputStream = mSerialPort.getOutputStream();
|
||||||
mInputStream = mSerialPort.getInputStream();
|
mInputStream = mSerialPort.getInputStream();
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
package com.jiebao.h518.scan;
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|||||||
@ -27,8 +27,8 @@ import android.os.Handler;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.activity.chaoran.MipcaActivityCapture;
|
import com.example.chaoran.MipcaActivityCapture;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.Result;
|
import com.google.zxing.Result;
|
||||||
import com.mining.app.zxing.camera.CameraManager;
|
import com.mining.app.zxing.camera.CameraManager;
|
||||||
|
|||||||
@ -23,8 +23,8 @@ import android.os.Looper;
|
|||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.activity.chaoran.MipcaActivityCapture;
|
import com.example.chaoran.MipcaActivityCapture;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
import com.google.zxing.BinaryBitmap;
|
import com.google.zxing.BinaryBitmap;
|
||||||
import com.google.zxing.DecodeHintType;
|
import com.google.zxing.DecodeHintType;
|
||||||
import com.google.zxing.MultiFormatReader;
|
import com.google.zxing.MultiFormatReader;
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import java.util.concurrent.CountDownLatch;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
|
||||||
import com.activity.chaoran.MipcaActivityCapture;
|
import com.example.chaoran.MipcaActivityCapture;
|
||||||
import com.google.zxing.BarcodeFormat;
|
import com.google.zxing.BarcodeFormat;
|
||||||
import com.google.zxing.DecodeHintType;
|
import com.google.zxing.DecodeHintType;
|
||||||
import com.google.zxing.ResultPointCallback;
|
import com.google.zxing.ResultPointCallback;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import android.graphics.Typeface;
|
|||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
import com.google.zxing.ResultPoint;
|
import com.google.zxing.ResultPoint;
|
||||||
import com.mining.app.zxing.camera.CameraManager;
|
import com.mining.app.zxing.camera.CameraManager;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
package com.util;
|
package com.util;
|
||||||
|
|
||||||
import com.chaoran.entiry.SelfEditText;
|
import com.chaoran.entiry.SelfEditText;
|
||||||
import com.activity.chaoran.DjActivity;
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.example.chaoran.MainActivity;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
@ -11,6 +12,9 @@ import android.content.DialogInterface.OnClickListener;
|
|||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
import android.text.style.AbsoluteSizeSpan;
|
import android.text.style.AbsoluteSizeSpan;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
public class DialogUtil {
|
public class DialogUtil {
|
||||||
// 错误消息对话框
|
// 错误消息对话框
|
||||||
@ -31,6 +35,7 @@ public class DialogUtil {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
if (DjActivity.cr5wScanControl != null && "DjActivity".equals(context.getClass().getSimpleName())) {
|
if (DjActivity.cr5wScanControl != null && "DjActivity".equals(context.getClass().getSimpleName())) {
|
||||||
DjActivity.cr5wScanControl.setIsOpen(true);
|
DjActivity.cr5wScanControl.setIsOpen(true);
|
||||||
DjActivity.cr5wScanControl.start(context);
|
DjActivity.cr5wScanControl.start(context);
|
||||||
@ -38,6 +43,7 @@ public class DialogUtil {
|
|||||||
DjActivity.nr510ScanControl.start(context);
|
DjActivity.nr510ScanControl.start(context);
|
||||||
} else if (DjActivity.barcodeReader != null && "DjActivity".equals(context.getClass().getSimpleName())) {
|
} else if (DjActivity.barcodeReader != null && "DjActivity".equals(context.getClass().getSimpleName())) {
|
||||||
try {
|
try {
|
||||||
|
// DjActivity.triggerState = true;
|
||||||
DjActivity.barcodeReader.light(true); //turn on/off backlight
|
DjActivity.barcodeReader.light(true); //turn on/off backlight
|
||||||
DjActivity.barcodeReader.aim(true); //开关瞄准线
|
DjActivity.barcodeReader.aim(true); //开关瞄准线
|
||||||
DjActivity.barcodeReader.decode(true); //开关解码功能
|
DjActivity.barcodeReader.decode(true); //开关解码功能
|
||||||
@ -55,9 +61,8 @@ public class DialogUtil {
|
|||||||
});
|
});
|
||||||
builder.create();
|
builder.create();
|
||||||
builder.show();
|
builder.show();
|
||||||
|
if (DjActivity.cr5wScanControl != null && "DjActivity".equals(context.getClass().getSimpleName()))
|
||||||
// if (DjActivity.cr5wScanControl != null && "DjActivity".equals(context.getClass().getSimpleName()))
|
DjActivity.cr5wScanControl.setIsOpen(false);
|
||||||
// DjActivity.cr5wScanControl.setIsOpen(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void builderCancel(Context context, String title,
|
public static void builderCancel(Context context, String title,
|
||||||
|
|||||||
@ -2,26 +2,30 @@ package com.util;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.text.DateFormat;
|
||||||
|
|
||||||
import map.baidu.com.BDMapActivity;
|
import map.baidu.com.BDMapActivity;
|
||||||
|
|
||||||
import org.kobjects.base64.Base64;
|
import org.kobjects.base64.Base64;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.chaoran.imp.InputInterface;
|
import com.chaoran.imp.InputInterface;
|
||||||
import com.activity.chaoran.DjActivity;
|
import com.example.chaoran.DjActivity;
|
||||||
import com.activity.chaoran.ExitThread;
|
import com.example.chaoran.ExitThread;
|
||||||
import com.activity.chaoran.MipcaActivityCapture;
|
import com.example.chaoran.MipcaActivityCapture;
|
||||||
import com.activity.chaoran.RunYmupThread;
|
import com.example.chaoran.NetWorkSet;
|
||||||
|
import com.example.chaoran.RunYmupThread;
|
||||||
import com.sys.SysData;
|
import com.sys.SysData;
|
||||||
|
|
||||||
public class DjMenuFun {
|
public class DjMenuFun {
|
||||||
|
|||||||
@ -153,11 +153,6 @@ public class DjUtil {
|
|||||||
for (String s : set) {
|
for (String s : set) {
|
||||||
view = layout.findViewWithTag(s);
|
view = layout.findViewWithTag(s);
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
// if (view instanceof SelfEditText) {
|
|
||||||
// ((SelfEditText) view).setText(map.get(s).toString().trim());
|
|
||||||
// } else if (view instanceof TextView) {
|
|
||||||
// ((TextView) view).setText(map.get(s).toString().trim());
|
|
||||||
// }
|
|
||||||
setText(view, map.get(s).toString().trim(), imgHandler, -1, -1);
|
setText(view, map.get(s).toString().trim(), imgHandler, -1, -1);
|
||||||
list.add(s);
|
list.add(s);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.util;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -22,12 +23,19 @@ import com.chaoran.entiry.SelfTextBut;
|
|||||||
import com.chaoran.entiry.UpdataInfo;
|
import com.chaoran.entiry.UpdataInfo;
|
||||||
import com.chaoran.imp.InputInterface;
|
import com.chaoran.imp.InputInterface;
|
||||||
import com.chaoran.thread.ImageUrl;
|
import com.chaoran.thread.ImageUrl;
|
||||||
import com.activity.chaoran.DjActivity;
|
import com.example.chaoran.DjActivity;
|
||||||
import com.sys.SysData;
|
import com.sys.SysData;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.os.Build.VERSION;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public class IoUtil {
|
|||||||
if (bin != null) {
|
if (bin != null) {
|
||||||
bin.close();
|
bin.close();
|
||||||
}
|
}
|
||||||
System.out.println("流关闭---");
|
System.out.println("留关闭---");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,12 +17,16 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.chaoran.component.AntLine;
|
import com.chaoran.component.AntLine;
|
||||||
import com.chaoran.component.SelfHRule;
|
import com.chaoran.component.SelfHRule;
|
||||||
|
import com.chaoran.entiry.PhotographUi;
|
||||||
import com.chaoran.entiry.SelfButton;
|
import com.chaoran.entiry.SelfButton;
|
||||||
import com.chaoran.entiry.SelfCheckBox;
|
import com.chaoran.entiry.SelfCheckBox;
|
||||||
import com.chaoran.entiry.SelfDateField;
|
import com.chaoran.entiry.SelfDateField;
|
||||||
import com.chaoran.entiry.SelfEditText;
|
import com.chaoran.entiry.SelfEditText;
|
||||||
|
import com.chaoran.entiry.SelfImage;
|
||||||
import com.chaoran.entiry.SelfTextBut;
|
import com.chaoran.entiry.SelfTextBut;
|
||||||
import com.chaoran.imp.InputInterface;
|
import com.chaoran.imp.InputInterface;
|
||||||
|
import com.chaoran.thread.ImageUrl;
|
||||||
|
import com.example.chaoran.DjActivity;
|
||||||
import com.sys.SysData;
|
import com.sys.SysData;
|
||||||
|
|
||||||
public class LxParamPageCreate {
|
public class LxParamPageCreate {
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package com.util;
|
package com.util;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@ -11,7 +10,6 @@ import android.os.PowerManager.WakeLock;
|
|||||||
public class WakeLockUtil {
|
public class WakeLockUtil {
|
||||||
private static WifiLock wifiLock;
|
private static WifiLock wifiLock;
|
||||||
|
|
||||||
@SuppressLint("InvalidWakeLockTag")
|
|
||||||
public static void acquireWakeLock(Activity activity, WakeLock wakeLock) {
|
public static void acquireWakeLock(Activity activity, WakeLock wakeLock) {
|
||||||
if (wakeLock == null) {
|
if (wakeLock == null) {
|
||||||
PowerManager pm = (PowerManager) activity
|
PowerManager pm = (PowerManager) activity
|
||||||
@ -20,7 +18,7 @@ public class WakeLockUtil {
|
|||||||
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "crtech");
|
| PowerManager.ACQUIRE_CAUSES_WAKEUP, "crtech");
|
||||||
}
|
}
|
||||||
if (wifiLock == null) {
|
if (wifiLock == null) {
|
||||||
WifiManager manager = (WifiManager) activity.getApplicationContext()
|
WifiManager manager = (WifiManager) activity
|
||||||
.getSystemService(Context.WIFI_SERVICE);
|
.getSystemService(Context.WIFI_SERVICE);
|
||||||
wifiLock = manager.createWifiLock("SwiFTP");
|
wifiLock = manager.createWifiLock("SwiFTP");
|
||||||
wifiLock.setReferenceCounted(false);
|
wifiLock.setReferenceCounted(false);
|
||||||
|
|||||||
219
app/src/main/java/com/vioce/TekVoiceEngine.java
Normal file
219
app/src/main/java/com/vioce/TekVoiceEngine.java
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
package com.vioce;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.iflytek.cloud.*;
|
||||||
|
import com.iflytek.cloud.util.ResourceUtil;
|
||||||
|
import com.iflytek.cloud.util.ResourceUtil.RESOURCE_TYPE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
**********************************************
|
||||||
|
* DATE PERSON REASON
|
||||||
|
* 2021-02-05 FXY Created
|
||||||
|
**********************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class TekVoiceEngine implements VoiceEngine {
|
||||||
|
private static String TAG = "TekVoiceEngine";
|
||||||
|
// 语音合成对象
|
||||||
|
private SpeechSynthesizer mTts;
|
||||||
|
|
||||||
|
//缓冲进度
|
||||||
|
private int mPercentForBuffering = 0;
|
||||||
|
|
||||||
|
//播放进度
|
||||||
|
private int mPercentForPlaying = 0;
|
||||||
|
|
||||||
|
private Toast mToast;
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public TekVoiceEngine(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
// 初始化合成对象
|
||||||
|
mTts = SpeechSynthesizer.createSynthesizer(context, mTtsInitListener);
|
||||||
|
//设置合成引擎的参数
|
||||||
|
loadParam();
|
||||||
|
//初始化对话框
|
||||||
|
mToast = Toast.makeText(context, "", Toast.LENGTH_SHORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startSpeaking(String text) {
|
||||||
|
if (null == mTts) {
|
||||||
|
this.showTip("创建对象失败,请确认 libmsc.so 放置正确,\n 且有调用 createUtility 进行初始化");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mTts.isSpeaking())
|
||||||
|
stopSpeaking();
|
||||||
|
|
||||||
|
int code = mTts.startSpeaking(text, mTtsListener);
|
||||||
|
if (code != ErrorCode.SUCCESS) {
|
||||||
|
showTip("语音合成失败,错误码: " + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopSpeaking() {
|
||||||
|
mTts.stopSpeaking();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化监听
|
||||||
|
*/
|
||||||
|
private InitListener mTtsInitListener = code -> {
|
||||||
|
Log.d(TAG, "InitListener init() code = " + code);
|
||||||
|
if (code != ErrorCode.SUCCESS) {
|
||||||
|
showTip("初始化失败,错误码:" + code + ",请点击网址https://www.xfyun.cn/document/error-code查询解决方案");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 合成回调监听。
|
||||||
|
*/
|
||||||
|
private SynthesizerListener mTtsListener = new SynthesizerListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakBegin() {
|
||||||
|
Log.d(TAG, "开始播放:" + System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakPaused() {
|
||||||
|
showTip("暂停播放");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakResumed() {
|
||||||
|
showTip("继续播放");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBufferProgress(int percent, int beginPos, int endPos,
|
||||||
|
String info) {
|
||||||
|
// 合成进度
|
||||||
|
mPercentForBuffering = percent;
|
||||||
|
showTip(String.format(context.getString(R.string.tts_toast_format),
|
||||||
|
mPercentForBuffering, mPercentForPlaying));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSpeakProgress(int percent, int beginPos, int endPos) {
|
||||||
|
// 播放进度
|
||||||
|
mPercentForPlaying = percent;
|
||||||
|
showTip(String.format(context.getString(R.string.tts_toast_format),
|
||||||
|
mPercentForBuffering, mPercentForPlaying));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCompleted(SpeechError error) {
|
||||||
|
if (error == null) {
|
||||||
|
showTip("播放完成");
|
||||||
|
} else if (error != null) {
|
||||||
|
showTip(error.getPlainDescription(true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(int eventType, int arg1, int arg2, Bundle obj) {
|
||||||
|
// 以下代码用于获取与云端的会话id,当业务出错时将会话id提供给技术支持人员,可用于查询会话日志,定位出错原因
|
||||||
|
// 若使用本地能力,会话id为null
|
||||||
|
if (SpeechEvent.EVENT_SESSION_ID == eventType) {
|
||||||
|
String sid = obj.getString(SpeechEvent.KEY_EVENT_AUDIO_URL);
|
||||||
|
Log.d(TAG, "session id =" + sid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public void loadParam() {
|
||||||
|
|
||||||
|
// 装载参数之前,先清空参数
|
||||||
|
mTts.setParameter(SpeechConstant.PARAMS, null);
|
||||||
|
|
||||||
|
SharedPreferences sharedPreferences = context.getSharedPreferences("voiceEngine", Context.MODE_PRIVATE);
|
||||||
|
|
||||||
|
//设置使用本地引擎
|
||||||
|
mTts.setParameter(SpeechConstant.ENGINE_TYPE, SpeechConstant.TYPE_LOCAL);
|
||||||
|
|
||||||
|
//设置发音人资源路径
|
||||||
|
String voicerLocal = sharedPreferences.getString("voiceMember", "xiaofeng");
|
||||||
|
mTts.setParameter(ResourceUtil.TTS_RES_PATH, getResourcePath(voicerLocal));
|
||||||
|
|
||||||
|
//设置发音人
|
||||||
|
mTts.setParameter(SpeechConstant.VOICE_NAME, voicerLocal);
|
||||||
|
|
||||||
|
//设置合成语速
|
||||||
|
mTts.setParameter(SpeechConstant.SPEED, String.valueOf(sharedPreferences.getInt("voiceSpeed", 80)));
|
||||||
|
|
||||||
|
//设置合成音调
|
||||||
|
mTts.setParameter(SpeechConstant.PITCH, String.valueOf(sharedPreferences.getInt("voiceIndicate", 50)));
|
||||||
|
|
||||||
|
//设置合成音量
|
||||||
|
mTts.setParameter(SpeechConstant.VOLUME, String.valueOf(sharedPreferences.getInt("voiceSize", 100)));
|
||||||
|
|
||||||
|
//设置播放器音频流类型
|
||||||
|
mTts.setParameter(SpeechConstant.STREAM_TYPE, "3");
|
||||||
|
|
||||||
|
// 设置播放合成音频打断音乐播放,默认为true
|
||||||
|
mTts.setParameter(SpeechConstant.KEY_REQUEST_FOCUS, "true");
|
||||||
|
|
||||||
|
// 设置音频保存路径,保存音频格式支持pcm、wav,设置路径为sd卡请注意WRITE_EXTERNAL_STORAGE权限
|
||||||
|
mTts.setParameter(SpeechConstant.AUDIO_FORMAT, "wav");
|
||||||
|
|
||||||
|
mTts.setParameter(SpeechConstant.TTS_AUDIO_PATH, Environment.getExternalStorageDirectory() + "/msc/tts.wav");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setParam(String voiceMember, Integer voiceSize, Integer voiceIndicate, Integer voiceSpeed) {
|
||||||
|
if (null != voiceMember) {
|
||||||
|
//设置发音人资源路径
|
||||||
|
mTts.setParameter(ResourceUtil.TTS_RES_PATH, getResourcePath(voiceMember));
|
||||||
|
//设置发音人
|
||||||
|
mTts.setParameter(SpeechConstant.VOICE_NAME, voiceMember);
|
||||||
|
}
|
||||||
|
if (null != voiceSize) {
|
||||||
|
//设置合成音量
|
||||||
|
mTts.setParameter(SpeechConstant.VOLUME, String.valueOf(voiceSize));
|
||||||
|
}
|
||||||
|
if (null != voiceIndicate) {
|
||||||
|
//设置合成音调
|
||||||
|
mTts.setParameter(SpeechConstant.PITCH, String.valueOf(voiceIndicate));
|
||||||
|
}
|
||||||
|
if (null != voiceSpeed) {
|
||||||
|
//设置合成语速
|
||||||
|
mTts.setParameter(SpeechConstant.SPEED, String.valueOf(voiceSpeed));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void showTip(String str) {
|
||||||
|
mToast.setText(str);
|
||||||
|
mToast.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取发音人资源路径
|
||||||
|
private String getResourcePath(String voiceMember) {
|
||||||
|
StringBuffer tempBuffer = new StringBuffer();
|
||||||
|
String type = "tts";
|
||||||
|
//合成通用资源
|
||||||
|
tempBuffer.append(ResourceUtil.generateResourcePath(context, RESOURCE_TYPE.assets, type.concat("/common.jet")));
|
||||||
|
tempBuffer.append(";");
|
||||||
|
tempBuffer.append(ResourceUtil.generateResourcePath(context, RESOURCE_TYPE.assets, type.concat("/").concat(voiceMember).concat(".jet")));
|
||||||
|
return tempBuffer.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
if (null != mTts) {
|
||||||
|
mTts.stopSpeaking();
|
||||||
|
// 退出时释放连接
|
||||||
|
mTts.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/src/main/java/com/vioce/VoiceEngine.java
Normal file
27
app/src/main/java/com/vioce/VoiceEngine.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.vioce;
|
||||||
|
|
||||||
|
/*
|
||||||
|
**********************************************
|
||||||
|
* DATE PERSON REASON
|
||||||
|
* 2021-02-05 FXY Created
|
||||||
|
**********************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public interface VoiceEngine {
|
||||||
|
|
||||||
|
//开始说话
|
||||||
|
public void startSpeaking(String text);
|
||||||
|
|
||||||
|
//停止说话
|
||||||
|
public void stopSpeaking();
|
||||||
|
|
||||||
|
//销毁资源
|
||||||
|
public void destroy();
|
||||||
|
|
||||||
|
//装载参数,从配置文件中装载参数
|
||||||
|
public void loadParam();
|
||||||
|
|
||||||
|
//设置参数
|
||||||
|
public void setParam(String voiceMember, Integer voiceSize, Integer voiceIndicate, Integer voiceSpeed);
|
||||||
|
}
|
||||||
@ -9,7 +9,7 @@ import android.widget.ZoomControls;
|
|||||||
import com.baidu.location.BDLocation;
|
import com.baidu.location.BDLocation;
|
||||||
import com.baidu.location.BDLocationListener;
|
import com.baidu.location.BDLocationListener;
|
||||||
import com.baidu.mapapi.*;
|
import com.baidu.mapapi.*;
|
||||||
import com.activity.chaoran.R;
|
import com.example.chaoran.R;
|
||||||
import com.util.DialogUtil;
|
import com.util.DialogUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|||||||
@ -1,61 +1,72 @@
|
|||||||
package map.baidu.com;
|
package map.baidu.com;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.Context;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
import com.baidu.mapapi.BMapManager;
|
import com.baidu.mapapi.BMapManager;
|
||||||
import com.baidu.mapapi.MKEvent;
|
import com.baidu.mapapi.MKEvent;
|
||||||
import com.baidu.mapapi.MKGeneralListener;
|
import com.baidu.mapapi.MKGeneralListener;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.iflytek.cloud.SpeechConstant;
|
||||||
|
import com.iflytek.cloud.SpeechUtility;
|
||||||
|
|
||||||
public class BMapManagerUtil extends Application {
|
public class BMapManagerUtil extends Application {
|
||||||
private static BMapManagerUtil bMapManagerUtil;
|
private static BMapManagerUtil bMapManagerUtil;
|
||||||
// 百度MapAPI的管理类
|
// 百度MapAPI的管理类
|
||||||
public BMapManager mBMapMan = null;
|
public BMapManager mBMapMan = null;
|
||||||
|
|
||||||
// 授权Key
|
// 授权Key
|
||||||
// TODO: 请输入您的Key,
|
// 申请地址:http://dev.baidu.com/wiki/static/imap/key/
|
||||||
// 申请地址:http://dev.baidu.com/wiki/static/imap/key/
|
public String mStrKey = "F49D31823069482466999FADEE70C34C80055379";
|
||||||
public String mStrKey = "F49D31823069482466999FADEE70C34C80055379";
|
|
||||||
private boolean m_bKeyRight = true; // 授权Key正确,验证通过
|
|
||||||
|
|
||||||
// 常用事件监听,用来处理通常的网络错误,授权验证错误等
|
// 常用事件监听,用来处理通常的网络错误,授权验证错误等
|
||||||
static class MyGeneralListener implements MKGeneralListener {
|
static class MyGeneralListener implements MKGeneralListener {
|
||||||
@Override
|
@Override
|
||||||
public void onGetNetworkState(int iError) {
|
public void onGetNetworkState(int iError) {
|
||||||
Toast.makeText(bMapManagerUtil.getApplicationContext(), "您的网络出错啦!",
|
Toast.makeText(bMapManagerUtil.getApplicationContext(), "您的网络出错啦!",
|
||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGetPermissionState(int iError) {
|
public void onGetPermissionState(int iError) {
|
||||||
if (iError == MKEvent.ERROR_PERMISSION_DENIED) {
|
if (iError == MKEvent.ERROR_PERMISSION_DENIED) {
|
||||||
// 授权Key错误:
|
// 授权Key错误:
|
||||||
Toast.makeText(bMapManagerUtil.getApplicationContext(),
|
Toast.makeText(bMapManagerUtil.getApplicationContext(),
|
||||||
"请在BMapApiDemoApp.java文件输入正确的授权Key!", Toast.LENGTH_LONG)
|
"请在BMapApiDemoApp.java文件输入正确的授权Key!", Toast.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
bMapManagerUtil.m_bKeyRight = false;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
@Override
|
||||||
|
public void onCreate() {
|
||||||
|
bMapManagerUtil = this;
|
||||||
|
mBMapMan = new BMapManager(this);
|
||||||
|
mBMapMan.init(this.mStrKey, new MyGeneralListener());
|
||||||
|
|
||||||
@Override
|
//讯飞离线语音配置
|
||||||
public void onCreate() {
|
StringBuffer param = new StringBuffer();
|
||||||
bMapManagerUtil = this;
|
param.append("appid=" + getString(R.string.app_id));
|
||||||
mBMapMan = new BMapManager(this);
|
param.append(",");
|
||||||
mBMapMan.init(this.mStrKey, new MyGeneralListener());
|
// 设置使用v5+
|
||||||
super.onCreate();
|
param.append(SpeechConstant.ENGINE_MODE + "=" + SpeechConstant.MODE_MSC);
|
||||||
}
|
SpeechUtility.createUtility(this, param.toString());
|
||||||
|
super.onCreate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// 建议在您app的退出之前调用mapadpi的destroy()函数,避免重复初始化带来的时间消耗
|
||||||
|
public void onTerminate() {
|
||||||
|
if (mBMapMan != null) {
|
||||||
|
mBMapMan.destroy();
|
||||||
|
mBMapMan = null;
|
||||||
|
}
|
||||||
|
super.onTerminate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Context getGlobalApplicationContext() {
|
||||||
|
return bMapManagerUtil.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
// 建议在您app的退出之前调用mapadpi的destroy()函数,避免重复初始化带来的时间消耗
|
|
||||||
public void onTerminate() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
if (mBMapMan != null) {
|
|
||||||
mBMapMan.destroy();
|
|
||||||
mBMapMan = null;
|
|
||||||
}
|
|
||||||
super.onTerminate();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,206 +1,213 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="6dip"
|
android:layout_gravity="center">
|
||||||
android:text="网络设置"
|
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:textSize="20dip" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<TextView
|
||||||
android:id="@+id/ipline"
|
android:id="@+id/title"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/title"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="主机IP:"
|
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:textSize="20dip" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/ip"
|
|
||||||
android:layout_width="200dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="请输入IP地址"
|
|
||||||
android:singleLine="true" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/portline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/ipline"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text3"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="端 口:"
|
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:textSize="20dip" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/port"
|
|
||||||
android:layout_width="200dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="请输入端口"
|
|
||||||
android:singleLine="true" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/objectline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/portline"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text4"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="6dip"
|
android:paddingTop="6dip"
|
||||||
android:text="工程名:"
|
android:text="网络设置"
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:textSize="20dip" />
|
android:textSize="20dip" />
|
||||||
|
|
||||||
<EditText
|
<LinearLayout
|
||||||
android:id="@+id/itemName"
|
android:id="@+id/ipline"
|
||||||
android:layout_width="200dip"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:hint="请输入工程名"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:text="ChaoRanBI_PDA" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/fblline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/objectline"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text91"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="6dip"
|
android:layout_below="@+id/title"
|
||||||
android:text="屏比率:"
|
android:layout_centerHorizontal="true"
|
||||||
android:textColor="@android:color/black"
|
android:orientation="horizontal">
|
||||||
android:textSize="20dip" />
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="主机IP:"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20dip" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/itemName91"
|
android:id="@+id/ip"
|
||||||
android:layout_width="200dip"
|
android:layout_width="200dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="范围 0.1~10.0"
|
android:hint="请输入IP地址"
|
||||||
android:singleLine="true"
|
android:singleLine="true" />
|
||||||
android:text="0.9" />
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/gnline"
|
android:id="@+id/portline"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignRight="@id/ipline"
|
android:layout_below="@+id/ipline"
|
||||||
android:layout_below="@+id/fblline"
|
android:layout_centerHorizontal="true"
|
||||||
android:layout_centerHorizontal="true"
|
android:orientation="horizontal">
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="端 口:"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20dip" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/port"
|
||||||
|
android:layout_width="200dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="请输入端口"
|
||||||
|
android:singleLine="true" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/objectline"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/portline"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text4"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="6dip"
|
||||||
|
android:text="工程名:"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20dip" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/itemName"
|
||||||
|
android:layout_width="200dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="请输入工程名"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="ChaoRanBI_PDA" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/fblline"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/objectline"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text91"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="6dip"
|
||||||
|
android:text="屏比率:"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20dip" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/itemName91"
|
||||||
|
android:layout_width="200dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="范围 0.1~10.0"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="0.9" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/gnline"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignRight="@id/ipline"
|
||||||
|
android:layout_below="@+id/fblline"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn1"
|
android:id="@+id/btn1"
|
||||||
android:layout_width="100dip"
|
android:layout_width="100dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:onClick="onsub"
|
android:onClick="onsub"
|
||||||
android:text="确定" />
|
android:text="确定" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn2"
|
android:id="@+id/btn2"
|
||||||
android:layout_width="100dip"
|
android:layout_width="100dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:onClick="onback"
|
android:onClick="onback"
|
||||||
android:text="返回" />
|
android:text="返回" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.chaoran.component.AntLine
|
<com.chaoran.component.AntLine
|
||||||
android:id="@+id/line"
|
android:id="@+id/line"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="6dip"
|
android:layout_height="6dip"
|
||||||
android:layout_below="@+id/gnline" />
|
android:layout_below="@+id/gnline" />
|
||||||
<TextView
|
|
||||||
android:id="@+id/zc"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/line"
|
|
||||||
android:text="客户端注册 "
|
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:textSize="20dip" />
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/bzline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/zc"
|
|
||||||
android:layout_centerHorizontal="true"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text5"
|
android:id="@+id/zc"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="6dip"
|
android:layout_below="@+id/line"
|
||||||
android:text="注册备注:"
|
android:text="客户端注册 "
|
||||||
android:textColor="@android:color/black"
|
android:textColor="@android:color/black"
|
||||||
android:textSize="20dip" />
|
android:textSize="20dip" />
|
||||||
|
|
||||||
<EditText
|
<LinearLayout
|
||||||
android:id="@+id/bz"
|
android:id="@+id/bzline"
|
||||||
android:layout_width="200dip"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="备注信息"
|
android:layout_below="@+id/zc"
|
||||||
android:singleLine="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:text="" />
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text5"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="6dip"
|
||||||
|
android:text="注册备注:"
|
||||||
|
android:textColor="@android:color/black"
|
||||||
|
android:textSize="20dip" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/bz"
|
||||||
|
android:layout_width="200dip"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="备注信息"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/zubut"
|
android:id="@+id/zubut"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/bzline"
|
android:layout_below="@+id/bzline"
|
||||||
android:onClick="pdaRegister"
|
android:onClick="pdaRegister"
|
||||||
android:text="注册" />
|
android:text="注册" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/mac"
|
android:id="@+id/mac"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/zubut" />
|
android:layout_below="@+id/zubut" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/androidID"
|
android:id="@+id/androidID"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/mac" />
|
android:layout_below="@+id/mac" />
|
||||||
<TextView
|
|
||||||
android:id="@+id/model"
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/model"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_below="@+id/androidID" />
|
android:layout_height="wrap_content"
|
||||||
<TextView
|
android:layout_below="@+id/androidID" />
|
||||||
android:id="@+id/phoneDpi"
|
|
||||||
android:layout_width="match_parent"
|
<TextView
|
||||||
android:layout_height="wrap_content"
|
android:id="@+id/phoneDpi"
|
||||||
android:layout_below="@+id/model" />
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/model" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
147
app/src/main/res/layout/activity_voice.xml
Normal file
147
app/src/main/res/layout/activity_voice.xml
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:weightSum="3"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="left"
|
||||||
|
android:text="这是一段测试文本,可以进行编辑!"
|
||||||
|
android:id="@+id/voice_test_text"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:stretchColumns="0,3"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:id="@+id/table">
|
||||||
|
|
||||||
|
|
||||||
|
<TableRow android:layout_marginBottom="50px">
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="15px"
|
||||||
|
android:paddingBottom="15px"
|
||||||
|
android:text="播报人员:" />
|
||||||
|
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:id="@+id/voice_member_group"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="小峰"
|
||||||
|
android:id="@+id/voice_member_xiaofeng" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="小燕"
|
||||||
|
android:layout_marginLeft="150px"
|
||||||
|
android:id="@+id/voice_member_xiaoyan" />
|
||||||
|
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow android:layout_marginBottom="50px">
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="播报音量:" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/voice_size"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:max="100"
|
||||||
|
android:min="0"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow android:layout_marginBottom="50px">
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="播报音调:" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:max="100"
|
||||||
|
android:min="0"
|
||||||
|
android:id="@+id/voice_indicate" />
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow android:layout_marginBottom="50px">
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="播报音速:" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:max="200"
|
||||||
|
android:min="100"
|
||||||
|
android:id="@+id/voice_speed" />
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/save_voice_setting"
|
||||||
|
android:text="保 存" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/cancel_voice_setting"
|
||||||
|
android:layout_marginLeft="10px"
|
||||||
|
android:text="取 消" />
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@ -1,5 +1,12 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<item android:id="@+id/updatePwd"
|
<item
|
||||||
android:title="修改密码"
|
android:id="@+id/updatePwd"
|
||||||
android:orderInCategory="100" />
|
android:title="修改密码"
|
||||||
|
android:orderInCategory="100" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/voice_setting"
|
||||||
|
android:title="语音设置"
|
||||||
|
android:orderInCategory="200" />
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">ChaoRan</string>
|
<string name="app_name">ChaoRan</string>
|
||||||
<string name="hello_world">Hello world!</string>
|
|
||||||
<string name="menu_settings">Settings</string>
|
<string name="menu_settings">Settings</string>
|
||||||
<string name="title_activity_main">超然系统</string>
|
<string name="title_activity_main">超然系统</string>
|
||||||
<string name="title_activity_net_work_set">网络设置</string>
|
<string name="title_activity_net_work_set">网络设置</string>
|
||||||
@ -21,14 +19,20 @@
|
|||||||
<string name="title_activity_param">检索方案窗口</string>
|
<string name="title_activity_param">检索方案窗口</string>
|
||||||
<string name="djtq_activity">提取方案窗口</string>
|
<string name="djtq_activity">提取方案窗口</string>
|
||||||
<string name="title_activity_update_pwd">密码修改界面</string>
|
<string name="title_activity_update_pwd">密码修改界面</string>
|
||||||
<string name="title_activity_bdmap">BDMapActivity</string>
|
<string name="title_activity_bdmap">地图展示</string>
|
||||||
<string name="main_menu_value_1">离线数据下载</string>
|
<string name="main_menu_value_1">离线数据下载</string>
|
||||||
<string name="main_menu_value_2">离线登录</string>
|
<string name="main_menu_value_2">离线登录</string>
|
||||||
<string name="title_activity_down_data">数据下载页面</string>
|
<string name="title_activity_down_data">数据下载页面</string>
|
||||||
<string name="title_activity_lx__param_">参数页面</string>
|
<string name="title_activity_lx__param_">参数页面</string>
|
||||||
<string name="title_activity_camera_scan">条码扫描</string>
|
<string name="title_activity_camera_scan">条码扫描</string>
|
||||||
<string name="scan_text">将二维码放入框内,即可自动扫描</string>
|
<string name="scan_text">将二维码放入框内,即可自动扫描</string>
|
||||||
<string name="title_activity_pda_reg">PdaRegActivity</string>
|
<string name="title_activity_pda_reg">注册界面</string>
|
||||||
<string name="title_activity_seuic_scan">SeuicScan</string>
|
<string name="title_activity_seuic_scan">SeuicScan</string>
|
||||||
|
<string name="title_activity_voice_engine_setting">语音设置界面</string>
|
||||||
|
|
||||||
|
<!-- 讯飞离线语音appid-->
|
||||||
|
<string name="app_id">601c9ec6</string>
|
||||||
|
|
||||||
|
<!-- 讯飞离线语音弹出框格式-->
|
||||||
|
<string name="tts_toast_format" formatted="false">缓冲进度为%d%%,播放进度为%d%%</string>
|
||||||
</resources>
|
</resources>
|
||||||
@ -17,3 +17,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
|||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
# Automatically convert third-party libraries to use AndroidX
|
# Automatically convert third-party libraries to use AndroidX
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
RELEASE_STOREFILE=E:/AndroidStudioProject/signKey.jks
|
||||||
|
RELEASE_STORE_PASSWORD=123456
|
||||||
|
RELEASE_KEY_ALIAS=fxy
|
||||||
|
RELEASE_KEY_PASSWORD=123456
|
||||||
Reference in New Issue
Block a user