修改eclipse项目为as项目
This commit is contained in:
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea/caches
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/navEditor.xml
|
||||||
|
/.idea/assetWizardSettings.xml
|
||||||
|
.DS_Store
|
||||||
|
/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
local.properties
|
||||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
ChaoRan-PDA-Client
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="1.8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/encodings.xml
generated
Normal file
6
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/app/src/main/java/com/jiebao/h518/scan/SqliteConnect.java" charset="GBK" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
22
.idea/gradle.xml
generated
Normal file
22
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="PLATFORM" />
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleHome" value="$PROJECT_DIR$/../../gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
<option value="$PROJECT_DIR$/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="resolveModulePerSourceSet" value="false" />
|
||||||
|
<option name="useQualifiedModuleNames" value="true" />
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
35
.idea/jarRepositories.xml
generated
Normal file
35
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven4" />
|
||||||
|
<option name="name" value="maven4" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/gradle-plugin/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven3" />
|
||||||
|
<option name="name" value="maven3" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/google/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven2" />
|
||||||
|
<option name="name" value="maven2" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/jcenter/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
19
.idea/misc.xml
generated
Normal file
19
.idea/misc.xml
generated
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="MavenImportPreferences">
|
||||||
|
<option name="generalSettings">
|
||||||
|
<MavenGeneralSettings>
|
||||||
|
<option name="localRepository" value="E:\maven\mvnRespo" />
|
||||||
|
<option name="mavenHome" value="$PROJECT_DIR$/../../apache-maven-3.2.5" />
|
||||||
|
<option name="userSettingsFile" value="E:\apache-maven-3.2.5\settings - aliyun.xml" />
|
||||||
|
</MavenGeneralSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" interpreter_name="PHP-5.6.25" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
38
app/build.gradle
Normal file
38
app/build.gradle
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
plugins {
|
||||||
|
id 'com.android.application'
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 29
|
||||||
|
buildToolsVersion "30.0.2"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.chaoran"
|
||||||
|
minSdkVersion 8
|
||||||
|
targetSdkVersion 15
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
}
|
||||||
26
app/jni/Android.mk
Normal file
26
app/jni/Android.mk
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#
|
||||||
|
# Copyright 2009 Cedric Priscal
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
LOCAL_PATH := $(call my-dir)
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
TARGET_PLATFORM := android-8
|
||||||
|
LOCAL_MODULE := serial_port
|
||||||
|
LOCAL_SRC_FILES := SerialPort.c
|
||||||
|
LOCAL_LDLIBS := -llog
|
||||||
|
|
||||||
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
286
app/jni/SerialPort.c
Normal file
286
app/jni/SerialPort.c
Normal file
@ -0,0 +1,286 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 Cedric Priscal
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include "android/log.h"
|
||||||
|
static const char *TAG="serial_port";
|
||||||
|
#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 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)
|
||||||
|
{
|
||||||
|
switch(baudrate) {
|
||||||
|
case 0: return B0;
|
||||||
|
case 50: return B50;
|
||||||
|
case 75: return B75;
|
||||||
|
case 110: return B110;
|
||||||
|
case 134: return B134;
|
||||||
|
case 150: return B150;
|
||||||
|
case 200: return B200;
|
||||||
|
case 300: return B300;
|
||||||
|
case 600: return B600;
|
||||||
|
case 1200: return B1200;
|
||||||
|
case 1800: return B1800;
|
||||||
|
case 2400: return B2400;
|
||||||
|
case 4800: return B4800;
|
||||||
|
case 9600: return B9600;
|
||||||
|
case 19200: return B19200;
|
||||||
|
case 38400: return B38400;
|
||||||
|
case 57600: return B57600;
|
||||||
|
case 115200: return B115200;
|
||||||
|
case 230400: return B230400;
|
||||||
|
case 460800: return B460800;
|
||||||
|
case 500000: return B500000;
|
||||||
|
case 576000: return B576000;
|
||||||
|
case 921600: return B921600;
|
||||||
|
case 1000000: return B1000000;
|
||||||
|
case 1152000: return B1152000;
|
||||||
|
case 1500000: return B1500000;
|
||||||
|
case 2000000: return B2000000;
|
||||||
|
case 2500000: return B2500000;
|
||||||
|
case 3000000: return B3000000;
|
||||||
|
case 3500000: return B3500000;
|
||||||
|
case 4000000: return B4000000;
|
||||||
|
default: return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: cedric_serial_SerialPort
|
||||||
|
* Method: open
|
||||||
|
* Signature: (Ljava/lang/String;)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_com_android_barcode_SerialPort_open
|
||||||
|
(JNIEnv *env, jobject thiz, jstring path, jint baudrate)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
speed_t speed;
|
||||||
|
|
||||||
|
/* Check arguments */
|
||||||
|
{
|
||||||
|
speed = getBaudrate(baudrate);
|
||||||
|
if (speed == -1) {
|
||||||
|
/* TODO: throw an exception */
|
||||||
|
LOGE("Invalid baudrate");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Opening device */
|
||||||
|
{
|
||||||
|
jboolean iscopy;
|
||||||
|
const char *path_utf = (*env)->GetStringUTFChars(env, path, &iscopy);
|
||||||
|
LOGD("Opening serial port %s", path_utf);
|
||||||
|
fd = open(path_utf, O_RDWR | O_SYNC);
|
||||||
|
LOGD("open() fd = %d", fd);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, path, path_utf);
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
/* Throw an exception */
|
||||||
|
LOGE("Cannot open port");
|
||||||
|
/* TODO: throw an exception */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Configure device */
|
||||||
|
{
|
||||||
|
struct termios cfg;
|
||||||
|
LOGD("Configuring serial port");
|
||||||
|
if (tcgetattr(fd, &cfg))
|
||||||
|
{
|
||||||
|
LOGE("tcgetattr() failed");
|
||||||
|
close(fd);
|
||||||
|
/* TODO: throw an exception */
|
||||||
|
}
|
||||||
|
|
||||||
|
cfmakeraw(&cfg);
|
||||||
|
cfsetispeed(&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))
|
||||||
|
{
|
||||||
|
LOGE("tcsetattr() failed");
|
||||||
|
close(fd);
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Class: cedric_serial_SerialPort
|
||||||
|
* Method: close
|
||||||
|
* Signature: ()V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_com_android_barcode_SerialPort_close
|
||||||
|
(JNIEnv *env, jobject obj, jint fd)
|
||||||
|
{
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
BIN
app/libs/android-support-v4.jar
Normal file
BIN
app/libs/android-support-v4.jar
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libBMapApiEngine_v1_3_3.so
Normal file
BIN
app/libs/armeabi/libBMapApiEngine_v1_3_3.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libIAL.so
Normal file
BIN
app/libs/armeabi/libIAL.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libSDL.so
Normal file
BIN
app/libs/armeabi/libSDL.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libbarcodereader.so
Normal file
BIN
app/libs/armeabi/libbarcodereader.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libjni_gpio.so
Normal file
BIN
app/libs/armeabi/libjni_gpio.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/liblocSDK3.so
Normal file
BIN
app/libs/armeabi/liblocSDK3.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/librfidtestnew.so
Normal file
BIN
app/libs/armeabi/librfidtestnew.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libserial_port.so
Normal file
BIN
app/libs/armeabi/libserial_port.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libserialport.so
Normal file
BIN
app/libs/armeabi/libserialport.so
Normal file
Binary file not shown.
BIN
app/libs/armeabi/libtiny-tools.so
Normal file
BIN
app/libs/armeabi/libtiny-tools.so
Normal file
Binary file not shown.
BIN
app/libs/baidumapapi.jar
Normal file
BIN
app/libs/baidumapapi.jar
Normal file
Binary file not shown.
BIN
app/libs/classes.jar
Normal file
BIN
app/libs/classes.jar
Normal file
Binary file not shown.
BIN
app/libs/dom4j-1.6.1.jar
Normal file
BIN
app/libs/dom4j-1.6.1.jar
Normal file
Binary file not shown.
BIN
app/libs/flex-messaging-core.jar
Normal file
BIN
app/libs/flex-messaging-core.jar
Normal file
Binary file not shown.
BIN
app/libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar
Normal file
BIN
app/libs/ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar
Normal file
Binary file not shown.
BIN
app/libs/locSDK_3.3.jar
Normal file
BIN
app/libs/locSDK_3.3.jar
Normal file
Binary file not shown.
BIN
app/libs/scan.jar
Normal file
BIN
app/libs/scan.jar
Normal file
Binary file not shown.
BIN
app/libs/zxing.jar
Normal file
BIN
app/libs/zxing.jar
Normal file
Binary file not shown.
21
app/proguard-rules.pro
vendored
Normal file
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
158
app/src/main/AndroidManifest.xml
Normal file
158
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.example.chaoran"
|
||||||
|
android:versionCode="1"
|
||||||
|
android:versionName="V1.077" >
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||||
|
<!-- <uses-permission android:name="android.permission.DEVICE_POWER" /> -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.WRITE_SETTINGS" />-->
|
||||||
|
<uses-permission android:name="android.permission.READ_SETTINGS" />
|
||||||
|
|
||||||
|
<!-- 百度定位服务权限 -->
|
||||||
|
<permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
|
||||||
|
</permission>
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
|
||||||
|
</uses-permission>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" >
|
||||||
|
</uses-permission>
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
|
||||||
|
</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" >-->
|
||||||
|
<!-- </uses-permission>-->
|
||||||
|
<!-- <uses-permission android:name="android.permission.READ_LOGS" >-->
|
||||||
|
<!-- </uses-permission>-->
|
||||||
|
|
||||||
|
<!-- 百度地图API权限 -->
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
|
||||||
|
</uses-permission>
|
||||||
|
<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="com.honeywell.decode.permission.DECODE" />
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name="map.baidu.com.BMapManagerUtil"
|
||||||
|
android:icon="@drawable/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:persistent="true"
|
||||||
|
android:theme="@style/AppTheme" >
|
||||||
|
<!-- <uses-library android:name="com.sprint.hardware.twinCamDevice" android:required="false"/> -->
|
||||||
|
<uses-library android:name="android.scanner.library" android:required="false" />
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.MainActivity"
|
||||||
|
android:label="@string/title_activity_main"
|
||||||
|
android:screenOrientation="behind"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden">
|
||||||
|
<intent-filter>
|
||||||
|
<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.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.NetWorkSet"
|
||||||
|
android:label="@string/title_activity_net_work_set"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.MenuActivity"
|
||||||
|
android:label="@string/title_activity_menu"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.DjActivity"
|
||||||
|
android:label="@string/title_activity_dj"
|
||||||
|
android:screenOrientation="behind"
|
||||||
|
android:launchMode="singleTask">
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.ParamActivity"
|
||||||
|
android:label="@string/title_activity_param"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.DjtqActivity"
|
||||||
|
android:label="@string/djtq_activity"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.UpdatePwdActivity"
|
||||||
|
android:label="@string/title_activity_update_pwd"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<!-- android:hardwareAccelerated="false" android:hardwareAccelerated="false" 硬件加速3.0以上才有 -->
|
||||||
|
<activity
|
||||||
|
android:name="map.baidu.com.BDMapActivity"
|
||||||
|
android:hardwareAccelerated="false"
|
||||||
|
android:label="@string/title_activity_bdmap"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value="com.baidu.mapapi.MapActivity" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name="com.baidu.location.f"
|
||||||
|
android:enabled="true"
|
||||||
|
android:process=":remote" >
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.baidu.location.service_v2.9"></action>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-->
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name="com.chaoran.lx.activity.DownDataActivity"
|
||||||
|
android:label="@string/title_activity_down_data"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.chaoran.lx.activity.Lx_Param_Activity"
|
||||||
|
android:label="@string/title_activity_lx__param_"
|
||||||
|
android:screenOrientation="behind" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.MipcaActivityCapture"
|
||||||
|
android:label="@string/title_activity_camera_scan"
|
||||||
|
android:screenOrientation="behind"
|
||||||
|
android:windowSoftInputMode="stateAlwaysHidden" >
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name="com.example.chaoran.PdaRegActivity"
|
||||||
|
android:label="@string/title_activity_pda_reg" >
|
||||||
|
</activity>
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
65
app/src/main/java/android/gpio/GpioJNI.java
Normal file
65
app/src/main/java/android/gpio/GpioJNI.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package android.gpio;
|
||||||
|
|
||||||
|
public class GpioJNI {
|
||||||
|
|
||||||
|
static public native void gpio_switch_gps_bluetooth(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_gps_bluetooth();
|
||||||
|
|
||||||
|
static public native void gpio_switch_gps_power(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_gps_power();
|
||||||
|
|
||||||
|
static public native void gpio_switch_rs485_rs232(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_rs485_rs232();
|
||||||
|
|
||||||
|
static public native void gpio_switch_rs485_power(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_rs485_power();
|
||||||
|
|
||||||
|
static public native void gpio_switch_rs232_power(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_rs232_power();
|
||||||
|
|
||||||
|
static public native void gpio_switch_scan_rf_ired(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_scan_rf_ired();
|
||||||
|
|
||||||
|
static public native void gpio_switch_rf_power(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_rf_power();
|
||||||
|
|
||||||
|
static public native void gpio_switch_scan_power(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_scan_power();
|
||||||
|
|
||||||
|
static public native void gpio_switch_scan_powerdown(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_scan_powerdown();
|
||||||
|
|
||||||
|
static public native void gpio_switch_scan_trig(int flag);// <20>?<3F><><EFBFBD>?<3F><>出光扫描
|
||||||
|
|
||||||
|
static public native int gpio_get_scan_trig();
|
||||||
|
|
||||||
|
static public native void gpio_switch_scan_reset(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_scan_reset();
|
||||||
|
|
||||||
|
static public native void gpio_switch_rf_reset(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_rf_reset();
|
||||||
|
|
||||||
|
static public native void gpio_switch_ired(int flag);
|
||||||
|
|
||||||
|
static public native int gpio_get_ired();
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("jni_gpio");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
61
app/src/main/java/android_serialport_api/SerialPort.java
Normal file
61
app/src/main/java/android_serialport_api/SerialPort.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package android_serialport_api;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class SerialPort {
|
||||||
|
|
||||||
|
private static final String TAG = "SerialPort";
|
||||||
|
private FileDescriptor mFd;
|
||||||
|
private FileInputStream mFileInputStream;
|
||||||
|
private FileOutputStream mFileOutputStream;
|
||||||
|
|
||||||
|
public SerialPort(File device, int baudrate, int bits, char event, int stop, int flags) throws SecurityException,
|
||||||
|
IOException {
|
||||||
|
|
||||||
|
if (!device.canRead() || !device.canWrite()) {
|
||||||
|
try {
|
||||||
|
Process su;
|
||||||
|
su = Runtime.getRuntime().exec("/system/bin/su");
|
||||||
|
String cmd = "chmod 777 " + device.getAbsolutePath() + "\n" + "exit\n";
|
||||||
|
su.getOutputStream().write(cmd.getBytes());
|
||||||
|
|
||||||
|
if ((su.waitFor() != 0) || !device.canRead() || !device.canWrite()) {
|
||||||
|
throw new SecurityException();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new SecurityException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mFd = open(device.getAbsolutePath(), baudrate, bits, event, stop, flags);
|
||||||
|
Log.i("info", "open device!!");
|
||||||
|
if (mFd == null) {
|
||||||
|
Log.e(TAG, "native open returns null");
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
mFileInputStream = new FileInputStream(mFd);
|
||||||
|
mFileOutputStream = new FileOutputStream(mFd);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getInputStream() {
|
||||||
|
|
||||||
|
return mFileInputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutputStream getOutputStream() {
|
||||||
|
|
||||||
|
return mFileOutputStream;
|
||||||
|
}
|
||||||
|
|
||||||
|
private native static FileDescriptor open(String path, int baudrate, int bits, char event, int stop, int flags);
|
||||||
|
|
||||||
|
public native void close();
|
||||||
|
|
||||||
|
static {
|
||||||
|
|
||||||
|
System.loadLibrary("serialport");
|
||||||
|
}
|
||||||
|
}
|
||||||
52
app/src/main/java/com/chaoran/component/AntLine.java
Normal file
52
app/src/main/java/com/chaoran/component/AntLine.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package com.chaoran.component;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class AntLine extends View {
|
||||||
|
private Paint mPaint;
|
||||||
|
private int color;
|
||||||
|
private int size=6;
|
||||||
|
public int getSize() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
public void setSize(int size) {
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
public AntLine(Context context) {
|
||||||
|
super(context);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
public AntLine(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
private void init(){
|
||||||
|
color=Color.GREEN;
|
||||||
|
mPaint = new Paint();
|
||||||
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
|
// mPaint.setStrokeWidth(6);
|
||||||
|
// mPaint.setColor(Color.RED);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
mPaint.setColor(color);
|
||||||
|
mPaint.setStrokeWidth(size);
|
||||||
|
int wz=size/2;//计算画笔离边的宽度
|
||||||
|
Rect r=new Rect(wz,wz, this.getWidth()-wz,this.getHeight()-wz);
|
||||||
|
canvas.drawRect(r, mPaint);
|
||||||
|
}
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
public void setColor(int color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
101
app/src/main/java/com/chaoran/component/ButAdapter.java
Normal file
101
app/src/main/java/com/chaoran/component/ButAdapter.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package com.chaoran.component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
import com.chaoran.lx.activity.DownDataActivity;
|
||||||
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class ButAdapter extends BaseAdapter {
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
public ArrayList list;
|
||||||
|
// private String filedName;
|
||||||
|
private DownDataActivity context;
|
||||||
|
private ProgressDialog pd;
|
||||||
|
private DBManager dbManager;
|
||||||
|
// private Handler handler;
|
||||||
|
private String tableName;
|
||||||
|
private String showFilde;
|
||||||
|
public ButAdapter(DownDataActivity context, ArrayList list,
|
||||||
|
ProgressDialog pd, DBManager dbManager, String tableName,String showFilde) {
|
||||||
|
inflater = (LayoutInflater) context
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
this.list = list;
|
||||||
|
this.context = context;
|
||||||
|
this.pd = pd;
|
||||||
|
this.dbManager = dbManager;
|
||||||
|
// this.handler = handler;
|
||||||
|
this.tableName = tableName;
|
||||||
|
this.showFilde=showFilde;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return this.list != null ? this.list.size() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return this.list.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
final HashMap map = (HashMap) list.get(position);
|
||||||
|
if (convertView == null) {
|
||||||
|
convertView = inflater.inflate(R.layout.butadapter_list_child,
|
||||||
|
null, false);
|
||||||
|
}
|
||||||
|
final TextView tablename = (TextView) convertView
|
||||||
|
.findViewById(R.id.tablename);
|
||||||
|
String table = map.get(tableName).toString();
|
||||||
|
Object ob=map.get(showFilde);
|
||||||
|
String lb ="";
|
||||||
|
if(ob!=null){
|
||||||
|
lb=ob.toString();
|
||||||
|
}
|
||||||
|
if (dbManager.existsTable(table.toUpperCase()) > 0) {
|
||||||
|
lb = lb.concat("(").concat(String.valueOf(dbManager.rsCount(table)))
|
||||||
|
.concat(")");
|
||||||
|
}
|
||||||
|
tablename.setText(lb);
|
||||||
|
Button button = (Button) convertView.findViewById(R.id.downbut);
|
||||||
|
button.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
context.downData(map, tablename);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clean() {
|
||||||
|
inflater = null;
|
||||||
|
context = null;
|
||||||
|
list = null;
|
||||||
|
// filedName=null;
|
||||||
|
pd = null;
|
||||||
|
// handler = null;
|
||||||
|
dbManager = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
82
app/src/main/java/com/chaoran/component/ImageAdpter.java
Normal file
82
app/src/main/java/com/chaoran/component/ImageAdpter.java
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
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.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.GridView;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class ImageAdpter extends BaseAdapter {
|
||||||
|
private List list;
|
||||||
|
private Activity context;
|
||||||
|
|
||||||
|
public ImageAdpter(List menuData, Activity context) {
|
||||||
|
this.list = menuData;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return list.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int id) {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
LayoutInflater li = context.getLayoutInflater();
|
||||||
|
View view = li.inflate(R.layout.imageadpter, null);
|
||||||
|
ImageView iv = (ImageView) view.findViewById(R.id.gridimg);
|
||||||
|
// 设置View的height和width:这样保证无论image原来的尺寸,每个图像将重新适合这个指定的尺寸。
|
||||||
|
// iv.setLayoutParams(new RelativeLayout.LayoutParams(85, 85));
|
||||||
|
// /*
|
||||||
|
// * ImageView.ScaleType.CENTER 但不执行缩放比例
|
||||||
|
// * ImageView.ScaleType.CENTER_CROP
|
||||||
|
// * 按比例统一缩放图片(保持图片的尺寸比例)便于图片的两维(宽度和高度)等于或大于相应的视图维度
|
||||||
|
// * ImageView.ScaleType.CENTER_INSIDE
|
||||||
|
// * 按比例统一缩放图片(保持图片的尺寸比例)便于图片的两维(宽度和高度)等于或小于相应的视图维度
|
||||||
|
// */
|
||||||
|
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||||
|
// iv.setPadding(8, 8, 8, 8);
|
||||||
|
Map map = (Map) list.get(position);
|
||||||
|
if (map.containsKey("img")&&map.get("img") != null) {
|
||||||
|
|
||||||
|
byte[] byt = (byte[]) map.get("img");
|
||||||
|
iv.setImageBitmap(BitmapFactory.decodeByteArray(byt, 0, byt.length));
|
||||||
|
}else{
|
||||||
|
iv.setImageResource(R.drawable.logo);
|
||||||
|
}
|
||||||
|
((TextView) view.findViewById(R.id.gridtitle)).setText(map.get("mname")
|
||||||
|
.toString());
|
||||||
|
// ImageView iv=(ImageView)view.findViewById(R.id.imageView1);
|
||||||
|
// iv.setImageResource(images[position]);
|
||||||
|
// TextView tv=(TextView)view.findViewById(R.id.ItemText);
|
||||||
|
// tv.setText(texts[position]);
|
||||||
|
// tv.setTextColor(Color.BLUE);
|
||||||
|
// tv.setTextSize(20);
|
||||||
|
// return view;
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
100
app/src/main/java/com/chaoran/component/MyAdapter.java
Normal file
100
app/src/main/java/com/chaoran/component/MyAdapter.java
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
package com.chaoran.component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.Zujian;
|
||||||
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.BaseAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class MyAdapter extends BaseAdapter {
|
||||||
|
private LayoutInflater inflater;
|
||||||
|
private ArrayList list;
|
||||||
|
public int cur_pos = -1;
|
||||||
|
private String filedName;
|
||||||
|
private Context context;
|
||||||
|
public MyAdapter(Context context, ArrayList list, String filedName) {
|
||||||
|
inflater = (LayoutInflater) context
|
||||||
|
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
this.list = list;
|
||||||
|
this.filedName = filedName;
|
||||||
|
this.context=context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCount() {
|
||||||
|
return this.list != null ? this.list.size() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getItem(int position) {
|
||||||
|
return this.list.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getItemId(int position) {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
public void clear(){
|
||||||
|
inflater=null;
|
||||||
|
if(list!=null){
|
||||||
|
list.clear();
|
||||||
|
list=null;
|
||||||
|
context=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
Zujian zj = null;
|
||||||
|
if (convertView == null) {
|
||||||
|
// System.out.println("创建新的对象-------------------------------");
|
||||||
|
zj = new Zujian();
|
||||||
|
convertView = inflater.inflate(R.layout.list_child, null, false);
|
||||||
|
zj.tv = (TextView) convertView.findViewById(R.id.list_child_text);// 显示文字
|
||||||
|
convertView.setTag(zj);
|
||||||
|
} else {
|
||||||
|
zj = (Zujian) convertView.getTag();
|
||||||
|
}
|
||||||
|
HashMap map = (HashMap) list.get(position);
|
||||||
|
zj.tv.setText(map.get(filedName).toString());
|
||||||
|
if (position == cur_pos) {// 如果当前的行就是ListView中选中的一行,就更改显示样式
|
||||||
|
convertView.setBackgroundColor(Color.LTGRAY);// 更改整行的背景色
|
||||||
|
zj.tv.setTextColor(Color.RED);// 更改字体颜色
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
int bcolor = Color.WHITE;
|
||||||
|
if (map.containsKey("__BCOLOR")) {
|
||||||
|
String colorValue = ((String) map.get("__BCOLOR"));
|
||||||
|
if (colorValue != null && colorValue.trim().length() > 0) {
|
||||||
|
bcolor = SysUtil.toColor(Integer.decode(colorValue
|
||||||
|
.trim()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
convertView.setBackgroundColor(bcolor);// 更改整行的背景色
|
||||||
|
int fcolor = Color.BLACK;
|
||||||
|
if (map.containsKey("__FCOLOR")) {
|
||||||
|
String fcolorValue = ((String) map.get("__FCOLOR"));
|
||||||
|
if (fcolorValue != null && fcolorValue.trim().length() > 0) {
|
||||||
|
fcolor = SysUtil.toColor(Integer.decode(fcolorValue
|
||||||
|
.trim()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zj.tv.setTextColor(fcolor);// 更改字体颜色
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
DialogUtil.builder(context, "错误信息",exception.toString(),0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return convertView;
|
||||||
|
}
|
||||||
|
}
|
||||||
41
app/src/main/java/com/chaoran/component/SelfHRule.java
Normal file
41
app/src/main/java/com/chaoran/component/SelfHRule.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package com.chaoran.component;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class SelfHRule extends View {
|
||||||
|
private Paint mPaint;
|
||||||
|
private int color;
|
||||||
|
public SelfHRule(Context context) {
|
||||||
|
super(context);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
public SelfHRule(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
private void init(){
|
||||||
|
color=Color.GRAY;
|
||||||
|
mPaint = new Paint();
|
||||||
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
|
// mPaint.setColor(Color.RED);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
mPaint.setColor(color);
|
||||||
|
Rect r=new Rect(0,0, this.getWidth(),this.getHeight());
|
||||||
|
canvas.drawRect(r, mPaint);
|
||||||
|
}
|
||||||
|
public int getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
public void setColor(int color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
211
app/src/main/java/com/chaoran/db/DBManager.java
Normal file
211
app/src/main/java/com/chaoran/db/DBManager.java
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
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.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
|
||||||
|
public class DBManager {
|
||||||
|
private SqlHelpUtil helper;
|
||||||
|
private SQLiteDatabase db;
|
||||||
|
|
||||||
|
public DBManager(Context context) {
|
||||||
|
helper = new SqlHelpUtil(context);
|
||||||
|
// 因为getWritableDatabase内部调用了mContext.openOrCreateDatabase(mName, 0,
|
||||||
|
// mFactory);
|
||||||
|
// 所以要确保context已初始化,我们可以把实例化DBManager的步骤放在Activity的onCreate里
|
||||||
|
db = helper.getWritableDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 判断表是否创建SELECT COUNT(*) as TabCount FROM sqlite_master where type='table'
|
||||||
|
* and name='T1'
|
||||||
|
*/
|
||||||
|
public int existsTable(String tableName) {
|
||||||
|
String sql = "SELECT COUNT(*) FROM sqlite_master where type='table' and name='"
|
||||||
|
+ tableName + "' ";
|
||||||
|
Cursor cursor = db.rawQuery(sql, null);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
int count = cursor.getInt(0);
|
||||||
|
cursor.close();
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int rsCount(String tableName) {
|
||||||
|
String sql = "SELECT COUNT(*) FROM " + tableName + ";";
|
||||||
|
Cursor cursor = db.rawQuery(sql, null);
|
||||||
|
int count=0;
|
||||||
|
if(cursor.moveToFirst()){
|
||||||
|
count = cursor.getInt(0);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
public void batchSave(String sql,Map map){
|
||||||
|
Set<String> set = map.keySet();
|
||||||
|
db.beginTransaction();
|
||||||
|
for (String s : set) {
|
||||||
|
System.out.println(s+"--=============-"+map.get(s));
|
||||||
|
db.execSQL(sql.toString(), new Object[]{s,map.get(s)});
|
||||||
|
}
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
|
public void batchSave(List<HashMap> list, String tableName) {
|
||||||
|
HashMap map = (HashMap) list.get(0);
|
||||||
|
Set<String> set = map.keySet();
|
||||||
|
ArrayList<String> keys = new ArrayList<String>();
|
||||||
|
StringBuilder sql = new StringBuilder("insert into ");
|
||||||
|
sql.append(tableName).append("(");
|
||||||
|
StringBuilder column = new StringBuilder();
|
||||||
|
StringBuilder value = new StringBuilder();
|
||||||
|
for (String key : set) {
|
||||||
|
if(key.toUpperCase().equals("ROWNUMBER")){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
keys.add(key);
|
||||||
|
if (column.length() > 0) {
|
||||||
|
column.append(",");
|
||||||
|
value.append(",");
|
||||||
|
}
|
||||||
|
column.append(key);
|
||||||
|
value.append("?");
|
||||||
|
}
|
||||||
|
sql.append(column.toString()).append(") values (").append(value)
|
||||||
|
.append(")");
|
||||||
|
int len = keys.size();
|
||||||
|
System.out.println(sql.toString());
|
||||||
|
String runSql=sql.toString();
|
||||||
|
try {
|
||||||
|
db.beginTransaction();
|
||||||
|
int listLen = list.size();
|
||||||
|
Object param[] = new Object[len];
|
||||||
|
for (HashMap hmp : list) {
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
Object tempObject=hmp.get(keys.get(i));
|
||||||
|
// System.out.println(keys.get(i)+"---"+tempObject);
|
||||||
|
// if(tempObject instanceof byte[]){
|
||||||
|
// System.out.println("length---"+((byte[])tempObject).length);
|
||||||
|
// ByteArrayInputStream bin = new ByteArrayInputStream((byte[])tempObject);
|
||||||
|
// try {
|
||||||
|
// ObjectInputStream oin = new ObjectInputStream(bin);
|
||||||
|
// DanJuEntity danJuEntity=(DanJuEntity) oin.readObject();
|
||||||
|
// System.out.println(danJuEntity.pageNr + "--------");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if(tempObject==null){
|
||||||
|
param[i]="";
|
||||||
|
}else{
|
||||||
|
param[i] = tempObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db.execSQL(runSql, param);
|
||||||
|
}
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
db.endTransaction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exeSql(String sql) {
|
||||||
|
db.execSQL(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void exeSql(String sql, Object object[]) {
|
||||||
|
db.execSQL(sql, object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Cursor query(String sql) {
|
||||||
|
System.out.println(sql);
|
||||||
|
return db.rawQuery(sql, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add persons
|
||||||
|
*
|
||||||
|
* @param persons
|
||||||
|
*/
|
||||||
|
// public void add(List<Person> persons) {
|
||||||
|
// db.beginTransaction(); //开始事务
|
||||||
|
// try {
|
||||||
|
// for (Person person : persons) {
|
||||||
|
// db.execSQL("INSERT INTO person VALUES(null, ?, ?, ?)", new
|
||||||
|
// Object[]{person.name, person.age, person.info});
|
||||||
|
// }
|
||||||
|
// db.setTransactionSuccessful(); //设置事务成功完成
|
||||||
|
// } finally {
|
||||||
|
// db.endTransaction(); //结束事务
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * update person's age
|
||||||
|
// * @param person
|
||||||
|
// */
|
||||||
|
// public void updateAge(Person person) {
|
||||||
|
// ContentValues cv = new ContentValues();
|
||||||
|
// cv.put("age", person.age);
|
||||||
|
// db.update("person", cv, "name = ?", new String[]{person.name});
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * delete old person
|
||||||
|
// * @param person
|
||||||
|
// */
|
||||||
|
// public void deleteOldPerson(Person person) {
|
||||||
|
// db.delete("person", "age >= ?", new
|
||||||
|
// String[]{String.valueOf(person.age)});
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * query all persons, return list
|
||||||
|
// * @return List<Person>
|
||||||
|
// */
|
||||||
|
// public List<Person> query() {
|
||||||
|
// ArrayList<Person> persons = new ArrayList<Person>();
|
||||||
|
// Cursor c = queryTheCursor();
|
||||||
|
// while (c.moveToNext()) {
|
||||||
|
// Person person = new Person();
|
||||||
|
// person._id = c.getInt(c.getColumnIndex("_id"));
|
||||||
|
// person.name = c.getString(c.getColumnIndex("name"));
|
||||||
|
// person.age = c.getInt(c.getColumnIndex("age"));
|
||||||
|
// person.info = c.getString(c.getColumnIndex("info"));
|
||||||
|
// persons.add(person);
|
||||||
|
// }
|
||||||
|
// c.close();
|
||||||
|
// return persons;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * query all persons, return cursor
|
||||||
|
// * @return Cursor
|
||||||
|
// */
|
||||||
|
// public Cursor queryTheCursor() {
|
||||||
|
// Cursor c = db.rawQuery("SELECT * FROM person", null);
|
||||||
|
// return c;
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* close database
|
||||||
|
*/
|
||||||
|
public void closeDB() {
|
||||||
|
db.close();
|
||||||
|
helper.close();
|
||||||
|
db = null;
|
||||||
|
helper = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/src/main/java/com/chaoran/db/SqlHelpUtil.java
Normal file
35
app/src/main/java/com/chaoran/db/SqlHelpUtil.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package com.chaoran.db;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class SqlHelpUtil extends SQLiteOpenHelper {
|
||||||
|
//建立表 desc 是说明
|
||||||
|
String createTable="create table systable(col1 varchar(20),col2 varchar(10),col3 varchar(20),desc varchar(20));";
|
||||||
|
private static final int VERSION = 1;
|
||||||
|
private static final String dataBaseName = "store.db";
|
||||||
|
public SqlHelpUtil(Context context, String name, CursorFactory factory,
|
||||||
|
int version) {
|
||||||
|
super(context, name, factory, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
db.execSQL(createTable);
|
||||||
|
}
|
||||||
|
public SqlHelpUtil(Context context, String name, int version) {
|
||||||
|
this(context, name, null, version);
|
||||||
|
}
|
||||||
|
public SqlHelpUtil(Context context) {
|
||||||
|
this(context, dataBaseName, VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
188
app/src/main/java/com/chaoran/entiry/Basemodel.java
Normal file
188
app/src/main/java/com/chaoran/entiry/Basemodel.java
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*数据集 模块主表(basemodel)实体类
|
||||||
|
*此类在当前系统中无用 只是为了与服务器映射
|
||||||
|
*/
|
||||||
|
public class Basemodel implements Serializable{
|
||||||
|
private String modelid;// 模块ID 主键
|
||||||
|
private String modellx;// 模块类型
|
||||||
|
private String model_proc;// 模块计算存储过程
|
||||||
|
private String modelname;// 模块名称
|
||||||
|
private String meizhu;// 备注
|
||||||
|
private String show_fs;// 展现方式
|
||||||
|
private String url;// BI报表运行路径
|
||||||
|
private String save_tb;// 临时表名
|
||||||
|
private String is_zuhe;// 模块集合
|
||||||
|
private String usemodel;// 调用数据模块ID
|
||||||
|
private String chartName;// 图形英文名
|
||||||
|
private String chartChinaName;// 图形中文名
|
||||||
|
private String groupByColumn;// 聚合列
|
||||||
|
private String sumColumn;// 求和列
|
||||||
|
private String xcolumn;// 横轴列
|
||||||
|
private String modelSQL;// 模块集合SQL
|
||||||
|
private String gridType;//表格类型
|
||||||
|
private String dimension;//维度
|
||||||
|
private String pivotText;//下钻内容
|
||||||
|
|
||||||
|
|
||||||
|
public String getPivotText() {
|
||||||
|
return pivotText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPivotText(String pivotText) {
|
||||||
|
this.pivotText = pivotText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIs_zuhe() {
|
||||||
|
return is_zuhe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIs_zuhe(String is_zuhe) {
|
||||||
|
this.is_zuhe = is_zuhe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGridType() {
|
||||||
|
return gridType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGridType(String gridType) {
|
||||||
|
this.gridType = gridType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDimension() {
|
||||||
|
return dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDimension(String dimension) {
|
||||||
|
this.dimension = dimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsemodel() {
|
||||||
|
return usemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsemodel(String usemodel) {
|
||||||
|
this.usemodel = usemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelSQL() {
|
||||||
|
return modelSQL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModelSQL(String modelSQL) {
|
||||||
|
this.modelSQL = modelSQL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelid() {
|
||||||
|
return modelid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModelid(String modelid) {
|
||||||
|
this.modelid = modelid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModellx() {
|
||||||
|
return modellx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModellx(String modellx) {
|
||||||
|
this.modellx = modellx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModel_proc() {
|
||||||
|
return model_proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModel_proc(String model_proc) {
|
||||||
|
this.model_proc = model_proc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModelname() {
|
||||||
|
return modelname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModelname(String modelname) {
|
||||||
|
this.modelname = modelname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMeizhu() {
|
||||||
|
return meizhu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeizhu(String meizhu) {
|
||||||
|
this.meizhu = meizhu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShow_fs() {
|
||||||
|
return show_fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShow_fs(String show_fs) {
|
||||||
|
this.show_fs = show_fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSave_tb() {
|
||||||
|
return save_tb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSave_tb(String save_tb) {
|
||||||
|
this.save_tb = save_tb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChartName() {
|
||||||
|
return chartName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChartName(String chartName) {
|
||||||
|
this.chartName = chartName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChartChinaName() {
|
||||||
|
return chartChinaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChartChinaName(String chartChinaName) {
|
||||||
|
this.chartChinaName = chartChinaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGroupByColumn() {
|
||||||
|
return groupByColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupByColumn(String groupByColumn) {
|
||||||
|
this.groupByColumn = groupByColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSumColumn() {
|
||||||
|
return sumColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSumColumn(String sumColumn) {
|
||||||
|
this.sumColumn = sumColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getXcolumn() {
|
||||||
|
return xcolumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXcolumn(String xcolumn) {
|
||||||
|
this.xcolumn = xcolumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
14
app/src/main/java/com/chaoran/entiry/DanJuEntity.java
Normal file
14
app/src/main/java/com/chaoran/entiry/DanJuEntity.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DanJuEntity implements Serializable{
|
||||||
|
public FangAtyjk fangAtyjkVO;//方案通用接口数据源
|
||||||
|
public DjMxZt djMxZtVo; // 明细总体数据源
|
||||||
|
public ArrayList mxzdArray; // 明细字段数据源
|
||||||
|
public ArrayList menuArray;// 单据菜单数据源
|
||||||
|
public String pageNr;// 页面内容
|
||||||
|
public String rightMenu;//右键菜单内容
|
||||||
|
}
|
||||||
47
app/src/main/java/com/chaoran/entiry/DataGrid.java
Normal file
47
app/src/main/java/com/chaoran/entiry/DataGrid.java
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class DataGrid implements Serializable {
|
||||||
|
private ArrayList<LinkedHashMap> tableHead;//保存表头数据
|
||||||
|
private ArrayList<HashMap> tableData;//保存表格数据
|
||||||
|
private ArrayList otherData;//保存其它数据
|
||||||
|
// private Basemodel basemodel;
|
||||||
|
//
|
||||||
|
// public Basemodel getBasemodel() {
|
||||||
|
// return basemodel;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setBasemodel(Basemodel basemodel) {
|
||||||
|
// this.basemodel = basemodel;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public ArrayList<LinkedHashMap> getTableHead() {
|
||||||
|
return tableHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableHead(ArrayList<LinkedHashMap> tableHead) {
|
||||||
|
this.tableHead = tableHead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<HashMap> getTableData() {
|
||||||
|
return tableData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTableData(ArrayList<HashMap> tableData) {
|
||||||
|
this.tableData = tableData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList getOtherData() {
|
||||||
|
return otherData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOtherData(ArrayList otherData) {
|
||||||
|
this.otherData = otherData;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
19
app/src/main/java/com/chaoran/entiry/DjMxZt.java
Normal file
19
app/src/main/java/com/chaoran/entiry/DjMxZt.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 单据明细总体实体类
|
||||||
|
*/
|
||||||
|
public class DjMxZt implements Serializable{
|
||||||
|
public String fgdxzt;//非固定行字体
|
||||||
|
public String gdxzt;//固定行字体
|
||||||
|
public Boolean lbgx;//列表格线
|
||||||
|
public Boolean xbgx;//行表格线
|
||||||
|
public int fgdxbjs;//非固定行背景色
|
||||||
|
public String rsSubFun;//记录提交执行函数
|
||||||
|
public String rsDelFun;//记录删除执行函数
|
||||||
|
public String rsAddFun;//记录增加执行函数
|
||||||
|
public String rsCheckFun;//记录校验执行函数
|
||||||
|
public String rsMoveFun;//记录移动执行函数
|
||||||
|
}
|
||||||
76
app/src/main/java/com/chaoran/entiry/Djselefa.java
Normal file
76
app/src/main/java/com/chaoran/entiry/Djselefa.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
public class Djselefa implements java.io.Serializable{
|
||||||
|
private String fangalx;
|
||||||
|
private String fangabh;
|
||||||
|
private String fangamch;
|
||||||
|
private String emptylyb;
|
||||||
|
private String selectmx;
|
||||||
|
private String t_sql;
|
||||||
|
private String hz_sql;
|
||||||
|
private String mx_sql;
|
||||||
|
|
||||||
|
public String getFangalx() {
|
||||||
|
return fangalx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFangalx(String fangalx) {
|
||||||
|
this.fangalx = fangalx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFangabh() {
|
||||||
|
return fangabh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFangabh(String fangabh) {
|
||||||
|
this.fangabh = fangabh;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFangamch() {
|
||||||
|
return fangamch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFangamch(String fangamch) {
|
||||||
|
this.fangamch = fangamch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmptylyb() {
|
||||||
|
return emptylyb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmptylyb(String emptylyb) {
|
||||||
|
this.emptylyb = emptylyb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectmx() {
|
||||||
|
return selectmx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectmx(String selectmx) {
|
||||||
|
this.selectmx = selectmx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getT_sql() {
|
||||||
|
return t_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setT_sql(String t_sql) {
|
||||||
|
this.t_sql = t_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHz_sql() {
|
||||||
|
return hz_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHz_sql(String hz_sql) {
|
||||||
|
this.hz_sql = hz_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMx_sql() {
|
||||||
|
return mx_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMx_sql(String mx_sql) {
|
||||||
|
this.mx_sql = mx_sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/src/main/java/com/chaoran/entiry/FangAtyjk.java
Normal file
13
app/src/main/java/com/chaoran/entiry/FangAtyjk.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/*单据中的*方案通用接口维护实体类*/
|
||||||
|
public class FangAtyjk implements Serializable{
|
||||||
|
|
||||||
|
public String djInit;//单据进入初始化函数
|
||||||
|
public String newDjInit;//新开单据初始化函数
|
||||||
|
public String djExit;//单据退出执行函数
|
||||||
|
public String djTiming;//单据定时函数
|
||||||
|
public String djRecordedBefore;//单据入账前执行函数
|
||||||
|
}
|
||||||
50
app/src/main/java/com/chaoran/entiry/PhotographUi.java
Normal file
50
app/src/main/java/com/chaoran/entiry/PhotographUi.java
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import com.example.chaoran.MainActivity;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
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.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
|
public class PhotographUi extends LinearLayout {
|
||||||
|
private SelfImage image;
|
||||||
|
private Button pz;
|
||||||
|
|
||||||
|
public PhotographUi(Context context, int h) {
|
||||||
|
super(context);
|
||||||
|
this.setOrientation(VERTICAL);
|
||||||
|
setGravity(Gravity.CENTER_VERTICAL);
|
||||||
|
this.setVerticalGravity(1);
|
||||||
|
image = new SelfImage(context,true);
|
||||||
|
addView(image, new LayoutParams(LayoutParams.MATCH_PARENT,
|
||||||
|
h));
|
||||||
|
pz = new Button(context);
|
||||||
|
pz.setText("拍照");
|
||||||
|
addView(pz, new LayoutParams(LayoutParams.MATCH_PARENT,
|
||||||
|
LayoutParams.WRAP_CONTENT));
|
||||||
|
}
|
||||||
|
public void setOnClickListener(OnClickListener clickListener){
|
||||||
|
pz.setOnClickListener(clickListener);
|
||||||
|
}
|
||||||
|
public void setImageOnClickListener(OnClickListener clickListener){
|
||||||
|
image.setOnClickListener(clickListener);
|
||||||
|
}
|
||||||
|
public void setImageBitmap(Bitmap bitmap){
|
||||||
|
image.setBitmap(bitmap);
|
||||||
|
}
|
||||||
|
public Bitmap getImageBitmap(){
|
||||||
|
return image.getBitmap();
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/src/main/java/com/chaoran/entiry/SelfButton.java
Normal file
13
app/src/main/java/com/chaoran/entiry/SelfButton.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class SelfButton extends Button {
|
||||||
|
public String clickFun;
|
||||||
|
public String nextFocus;
|
||||||
|
public SelfButton(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
34
app/src/main/java/com/chaoran/entiry/SelfCheckBox.java
Normal file
34
app/src/main/java/com/chaoran/entiry/SelfCheckBox.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
|
||||||
|
public class SelfCheckBox extends CheckBox {
|
||||||
|
|
||||||
|
public SelfCheckBox(Context context) {
|
||||||
|
super(context);
|
||||||
|
setButtonDrawable(R.drawable.checkbox_empty);
|
||||||
|
this.setPadding((int) TypedValue.applyDimension(
|
||||||
|
TypedValue.COMPLEX_UNIT_DIP, 24, context.getResources()
|
||||||
|
.getDisplayMetrics()), 0, 0,0);
|
||||||
|
setOnCheckedChangeListener(new OnCheckedChangeListener(){
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView,
|
||||||
|
boolean isChecked) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if(isChecked){
|
||||||
|
setButtonDrawable(R.drawable.checkbox_full);
|
||||||
|
}else{
|
||||||
|
setButtonDrawable(R.drawable.checkbox_empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
216
app/src/main/java/com/chaoran/entiry/SelfDateField.java
Normal file
216
app/src/main/java/com/chaoran/entiry/SelfDateField.java
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.DatePicker;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import com.chaoran.imp.InputInterface;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
|
public class SelfDateField extends RelativeLayout implements InputInterface {
|
||||||
|
private SelfEditText et;
|
||||||
|
private ImageButton but;
|
||||||
|
private Dialog dialog;
|
||||||
|
private Calendar calendar;
|
||||||
|
private SimpleDateFormat dateFormat;
|
||||||
|
private SimpleDateFormat format;
|
||||||
|
public String formatString = "yyyy-MM-dd";
|
||||||
|
|
||||||
|
public SelfDateField(final Context context) {
|
||||||
|
super(context);
|
||||||
|
et = new SelfEditText(context);
|
||||||
|
LayoutParams params = new LayoutParams(
|
||||||
|
LayoutParams.FILL_PARENT,
|
||||||
|
LayoutParams.FILL_PARENT);
|
||||||
|
params.leftMargin = 0;
|
||||||
|
params.rightMargin = 48;
|
||||||
|
params.bottomMargin = 0;
|
||||||
|
et.setPadding(0, 0, 0, 0);
|
||||||
|
et.setSingleLine(true);
|
||||||
|
// et.setLayoutParams(params);
|
||||||
|
et.setId(1);
|
||||||
|
addView(et, params);
|
||||||
|
but = new ImageButton(context);
|
||||||
|
// but.setScaleType(ScaleType.FIT_XY);
|
||||||
|
LayoutParams butParams = new LayoutParams(
|
||||||
|
48, 48);
|
||||||
|
but.setPadding(0, 0, 0, 0);
|
||||||
|
but.setBackgroundResource(R.drawable.calendar);
|
||||||
|
butParams.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||||
|
butParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||||
|
addView(but, butParams);
|
||||||
|
format = new SimpleDateFormat(formatString);
|
||||||
|
but.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (dialog == null) {
|
||||||
|
calendar = Calendar.getInstance();
|
||||||
|
dialog = new DatePickerDialog(context,
|
||||||
|
new DatePickerDialog.OnDateSetListener() {
|
||||||
|
public void onDateSet(DatePicker view,
|
||||||
|
int year, int monthOfYear,
|
||||||
|
int dayOfMonth) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if (dateFormat == null) {
|
||||||
|
dateFormat = new SimpleDateFormat(
|
||||||
|
formatString);
|
||||||
|
}
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = format.parse(year + "-"
|
||||||
|
+ (monthOfYear + 1) + "-"
|
||||||
|
+ dayOfMonth);
|
||||||
|
et.setText(dateFormat.format(date));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
et.setText("error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, calendar.get(Calendar.YEAR), calendar
|
||||||
|
.get(Calendar.MONTH), calendar
|
||||||
|
.get(Calendar.DAY_OF_MONTH));
|
||||||
|
}
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnFocusChangeListener(OnFocusChangeListener l) {
|
||||||
|
et.setOnFocusChangeListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(CharSequence text) {
|
||||||
|
if (dateFormat == null) {
|
||||||
|
dateFormat = new SimpleDateFormat(formatString);
|
||||||
|
}
|
||||||
|
Date date = null;
|
||||||
|
try {
|
||||||
|
date = format.parse(text.toString());
|
||||||
|
et.setText(dateFormat.format(date));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
et.setText(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Editable getText() {
|
||||||
|
return et.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextSize(float size) {
|
||||||
|
et.setTextSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean b) {
|
||||||
|
et.setEnabled(b);
|
||||||
|
but.setEnabled(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(Object tag) {
|
||||||
|
et.setTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getTag() {
|
||||||
|
return et.getTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundDrawable(Drawable gd) {
|
||||||
|
et.setBackgroundDrawable(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 接口方法 */
|
||||||
|
public String getDefaultValue() {
|
||||||
|
return et.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(String defaultValue) {
|
||||||
|
et.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextFocus(String focus) {
|
||||||
|
et.nextFocus = focus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusInFun(String fun) {
|
||||||
|
et.focusInFun = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusOutFun(String fun) {
|
||||||
|
et.focusOutFun = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputType(int type) {
|
||||||
|
et.setInputType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCloseKeyBoard() {
|
||||||
|
return et.getCloseKeyBoard();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCloseKeyBoard(boolean closeKeyBoard) {
|
||||||
|
et.setCloseKeyBoard(closeKeyBoard);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNextFocus() {
|
||||||
|
return et.getNextFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFocusInFun() {
|
||||||
|
return et.getFocusInFun();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFocusOutFun() {
|
||||||
|
return et.getFocusOutFun();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsNull() {
|
||||||
|
return et.getIsNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsNull(boolean isNull) {
|
||||||
|
et.setIsNull(isNull);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return et.getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLabel(String label) {
|
||||||
|
et.setLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsTextChange() {
|
||||||
|
return et.getIsTextChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsTextChange(boolean isTextChange) {
|
||||||
|
et.setIsTextChange(isTextChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTextColor(int color) {
|
||||||
|
et.setTextColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
174
app/src/main/java/com/chaoran/entiry/SelfEditText.java
Normal file
174
app/src/main/java/com/chaoran/entiry/SelfEditText.java
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import com.chaoran.imp.InputInterface;
|
||||||
|
|
||||||
|
import android.R;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.Paint.Style;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
public class SelfEditText extends EditText implements InputInterface {
|
||||||
|
public String defaultValue = "";
|
||||||
|
public String nextFocus;// 下一个组件焦点
|
||||||
|
|
||||||
|
public String focusInFun;//
|
||||||
|
public String focusOutFun;
|
||||||
|
public boolean isNull;
|
||||||
|
public String label;
|
||||||
|
public boolean isTextChange = false;
|
||||||
|
public boolean closeKeyBoard;
|
||||||
|
public String showBorder="inset";
|
||||||
|
private Paint paint;
|
||||||
|
|
||||||
|
public SelfEditText(Context context) {
|
||||||
|
super(context);
|
||||||
|
setBackgroundResource(R.drawable.editbox_background);
|
||||||
|
this.addTextChangedListener(textWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelfEditText(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
if (!showBorder.equals("none")) {
|
||||||
|
if (paint == null) {
|
||||||
|
paint = new Paint();
|
||||||
|
}
|
||||||
|
paint.setStyle(Style.STROKE);
|
||||||
|
paint.setStrokeWidth(5);
|
||||||
|
if (this.isFocused() == true){
|
||||||
|
paint.setColor(Color.parseColor("#FFA500"));
|
||||||
|
}else if (this.isEnabled()) {
|
||||||
|
paint.setColor(Color.parseColor("#708090"));
|
||||||
|
paint.setShadowLayer(5, 3, 3, Color.parseColor("#DCDCDC"));
|
||||||
|
} else {
|
||||||
|
paint.setColor(Color.parseColor("#DCDCDC"));
|
||||||
|
}
|
||||||
|
canvas.drawRoundRect(new RectF(this.getScrollX(),
|
||||||
|
this.getScrollY(), this.getWidth() - 1 + this.getScrollX(),
|
||||||
|
this.getHeight() + this.getScrollY() - 1), 3, 3, paint);
|
||||||
|
}
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(String defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNextFocus() {
|
||||||
|
return nextFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextFocus(String nextFocus) {
|
||||||
|
this.nextFocus = nextFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFocusInFun() {
|
||||||
|
return focusInFun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusInFun(String focusInFun) {
|
||||||
|
this.focusInFun = focusInFun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFocusOutFun() {
|
||||||
|
return focusOutFun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusOutFun(String focusOutFun) {
|
||||||
|
this.focusOutFun = focusOutFun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsNull() {
|
||||||
|
return isNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsNull(boolean isNull) {
|
||||||
|
this.isNull = isNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsTextChange() {
|
||||||
|
return isTextChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsTextChange(boolean isTextChange) {
|
||||||
|
this.isTextChange = isTextChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCloseKeyBoard() {
|
||||||
|
return closeKeyBoard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCloseKeyBoard(boolean closeKeyBoard) {
|
||||||
|
this.closeKeyBoard = closeKeyBoard;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TextWatcher textWatcher = new TextWatcher() {
|
||||||
|
private int start = 0;
|
||||||
|
private int length = 0;
|
||||||
|
private boolean isCome = true;
|
||||||
|
private boolean isGood = false;
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before,
|
||||||
|
int count) {
|
||||||
|
if (!isTextChange) {
|
||||||
|
isTextChange = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||||
|
int after) {
|
||||||
|
if (/*"TIAOMA".equalsIgnoreCase(nextFocus) && start != 0 && */ after > 1 && isCome) {
|
||||||
|
this.start = start;
|
||||||
|
this.length = after;
|
||||||
|
isGood = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
if (isGood) {
|
||||||
|
isGood = false;
|
||||||
|
isCome = false;
|
||||||
|
if (isNumeric(s.toString())) {
|
||||||
|
CharSequence str = s.subSequence(start, start + length);
|
||||||
|
s.clear();
|
||||||
|
s.append(str);
|
||||||
|
}
|
||||||
|
isCome = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static boolean isNumeric(String str) {
|
||||||
|
for (int i = 0; i < str.length(); i++) {
|
||||||
|
if (!Character.isLetterOrDigit(str.charAt(i))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
53
app/src/main/java/com/chaoran/entiry/SelfImage.java
Normal file
53
app/src/main/java/com/chaoran/entiry/SelfImage.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
public class SelfImage extends ImageView {
|
||||||
|
private Bitmap bitmap;
|
||||||
|
private boolean isDrawBound;
|
||||||
|
|
||||||
|
public Bitmap getBitmap() {
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBitmap(Bitmap bitmap) {
|
||||||
|
if (this.bitmap != null) {
|
||||||
|
setImageBitmap(null);
|
||||||
|
this.bitmap.recycle();
|
||||||
|
this.bitmap = null;
|
||||||
|
}
|
||||||
|
setImageBitmap(bitmap);
|
||||||
|
this.bitmap = bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelfImage(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SelfImage(Context context, boolean isDrawBound) {
|
||||||
|
super(context);
|
||||||
|
this.isDrawBound = isDrawBound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(Canvas canvas) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onDraw(canvas);
|
||||||
|
if (isDrawBound) {
|
||||||
|
Rect rec = canvas.getClipBounds();
|
||||||
|
rec.bottom--;
|
||||||
|
rec.right--;
|
||||||
|
Paint paint = new Paint();
|
||||||
|
paint.setColor(Color.RED);
|
||||||
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
|
paint.setStrokeWidth(5);
|
||||||
|
canvas.drawRect(rec, paint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
189
app/src/main/java/com/chaoran/entiry/SelfTextBut.java
Normal file
189
app/src/main/java/com/chaoran/entiry/SelfTextBut.java
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import com.chaoran.imp.InputInterface;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.GradientDrawable;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.util.TypedValue;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
public class SelfTextBut extends RelativeLayout implements InputInterface {
|
||||||
|
private SelfEditText et;
|
||||||
|
private SelfButton but;
|
||||||
|
|
||||||
|
public SelfTextBut(Context context) {
|
||||||
|
super(context);
|
||||||
|
int w = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||||
|
30, context.getResources().getDisplayMetrics());
|
||||||
|
et = new SelfEditText(context);
|
||||||
|
LayoutParams params = new LayoutParams(
|
||||||
|
LayoutParams.FILL_PARENT,
|
||||||
|
LayoutParams.FILL_PARENT);
|
||||||
|
params.setMargins(0, 0, 0, 0);
|
||||||
|
et.setPadding(0, 0, w, 0);
|
||||||
|
et.setSingleLine(true);
|
||||||
|
// et.setLayoutParams(params);
|
||||||
|
et.setId(1);
|
||||||
|
addView(et, params);
|
||||||
|
but = new SelfButton(context);
|
||||||
|
LayoutParams butParams = new LayoutParams(
|
||||||
|
w, LayoutParams.FILL_PARENT);
|
||||||
|
|
||||||
|
butParams.rightMargin = 0;
|
||||||
|
// butParams.leftMargin=this.getWidth()-10;
|
||||||
|
butParams.topMargin = 5;
|
||||||
|
butParams.bottomMargin = -2;
|
||||||
|
but.setPadding(0, 0, 0, 20);
|
||||||
|
// butParams.addRule(RelativeLayout.ALIGN_BASELINE, et.getId());
|
||||||
|
butParams.addRule(RelativeLayout.ALIGN_RIGHT, et.getId());
|
||||||
|
// butParams.addRule(RelativeLayout.ALIGN_TOP, et.getId());
|
||||||
|
// butParams.addRule(RelativeLayout.ALIGN_BOTTOM, et.getId());
|
||||||
|
// butParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||||
|
// but.setBackgroundColor(Color.BLUE);
|
||||||
|
but.setText("…");
|
||||||
|
// but.setGravity(Gravity.TOP);
|
||||||
|
// Drawable dw1 =
|
||||||
|
// this.getResources().getDrawable(R.drawable.ic_action_search);
|
||||||
|
// but.setBackgroundResource(R.drawable.cang1);
|
||||||
|
addView(but, butParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnFocusChangeListener(OnFocusChangeListener l) {
|
||||||
|
et.setOnFocusChangeListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOnClickListener(OnClickListener l) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
but.setOnClickListener(l);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setText(CharSequence text) {
|
||||||
|
et.setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Editable getText() {
|
||||||
|
return et.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClickFun(String fun) {
|
||||||
|
but.clickFun = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClickFun() {
|
||||||
|
return but.clickFun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextSize(float size) {
|
||||||
|
et.setTextSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean b) {
|
||||||
|
et.setEnabled(b);
|
||||||
|
but.setEnabled(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTag(Object tag) {
|
||||||
|
et.setTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getTag() {
|
||||||
|
return et.getTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBackgroundDrawable(Drawable gd) {
|
||||||
|
et.setBackgroundDrawable(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 接口方法 */
|
||||||
|
public String getDefaultValue() {
|
||||||
|
return et.defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(String defaultValue) {
|
||||||
|
et.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextFocus(String focus) {
|
||||||
|
et.nextFocus = focus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusInFun(String fun) {
|
||||||
|
et.focusInFun = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFocusOutFun(String fun) {
|
||||||
|
et.focusOutFun = fun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInputType(int type) {
|
||||||
|
et.setInputType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getCloseKeyBoard() {
|
||||||
|
return et.getCloseKeyBoard();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCloseKeyBoard(boolean closeKeyBoard) {
|
||||||
|
et.setCloseKeyBoard(closeKeyBoard);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNextFocus() {
|
||||||
|
return et.getNextFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFocusInFun() {
|
||||||
|
return et.getFocusInFun();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFocusOutFun() {
|
||||||
|
return et.getFocusOutFun();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsNull() {
|
||||||
|
return et.getIsNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsNull(boolean isNull) {
|
||||||
|
et.setIsNull(isNull);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLabel() {
|
||||||
|
return et.getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLabel(String label) {
|
||||||
|
et.setLabel(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getIsTextChange() {
|
||||||
|
return et.getIsTextChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsTextChange(boolean isTextChange) {
|
||||||
|
et.setIsTextChange(isTextChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTextColor(int color) {
|
||||||
|
et.setTextColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
178
app/src/main/java/com/chaoran/entiry/Sys_DanJuFormsOptions.java
Normal file
178
app/src/main/java/com/chaoran/entiry/Sys_DanJuFormsOptions.java
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class Sys_DanJuFormsOptions implements Serializable {
|
||||||
|
|
||||||
|
private String FORMlx;// 单据类型
|
||||||
|
private String FORMbs;// 单据标识
|
||||||
|
private String FORMmch;// 单据名称
|
||||||
|
private String FORMsm;// 单据说明
|
||||||
|
private String mxactive;// 是否存在单据明细
|
||||||
|
private String runtitle;// 运行标题
|
||||||
|
private String beizhu;// 备注
|
||||||
|
private String defaultFouseField;// 默认的焦点字段
|
||||||
|
private int dialog_hei;// 单据展现高度
|
||||||
|
private int dialog_wid;// 单据展现宽度
|
||||||
|
private String rv_hz_sql;// 单据再现汇总SQL语句
|
||||||
|
private String rv_mx_sql;// 单据再现明细SQL语句
|
||||||
|
private String cannewmx;// 是否能手工增加明细
|
||||||
|
private String candelmx;// 是否能删除明细
|
||||||
|
private String suffix;// 单据后缀
|
||||||
|
private byte[] FORM;// 单据内容
|
||||||
|
private String chkupfld;// 查重字段(在单据操作过程中检查单据明细内是否有重复记录,重复记录以此字段内记录的字段为准)
|
||||||
|
private String isAndroid;
|
||||||
|
private String is_lx;
|
||||||
|
|
||||||
|
public String getIs_lx() {
|
||||||
|
return is_lx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIs_lx(String is_lx) {
|
||||||
|
this.is_lx = is_lx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIsAndroid() {
|
||||||
|
return isAndroid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsAndroid(String isAndroid) {
|
||||||
|
this.isAndroid = isAndroid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFORMlx() {
|
||||||
|
return FORMlx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFORMlx(String mlx) {
|
||||||
|
FORMlx = mlx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFORMbs() {
|
||||||
|
return FORMbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFORMbs(String mbs) {
|
||||||
|
FORMbs = mbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFORMmch() {
|
||||||
|
return FORMmch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFORMmch(String mmch) {
|
||||||
|
FORMmch = mmch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFORMsm() {
|
||||||
|
return FORMsm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFORMsm(String msm) {
|
||||||
|
FORMsm = msm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMxactive() {
|
||||||
|
return mxactive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMxactive(String mxactive) {
|
||||||
|
this.mxactive = mxactive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRuntitle() {
|
||||||
|
return runtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuntitle(String runtitle) {
|
||||||
|
this.runtitle = runtitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBeizhu() {
|
||||||
|
return beizhu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBeizhu(String beizhu) {
|
||||||
|
this.beizhu = beizhu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDialog_hei() {
|
||||||
|
return dialog_hei;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDialog_hei(int dialog_hei) {
|
||||||
|
this.dialog_hei = dialog_hei;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDialog_wid() {
|
||||||
|
return dialog_wid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDialog_wid(int dialog_wid) {
|
||||||
|
this.dialog_wid = dialog_wid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRv_hz_sql() {
|
||||||
|
return rv_hz_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRv_hz_sql(String rv_hz_sql) {
|
||||||
|
this.rv_hz_sql = rv_hz_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRv_mx_sql() {
|
||||||
|
return rv_mx_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRv_mx_sql(String rv_mx_sql) {
|
||||||
|
this.rv_mx_sql = rv_mx_sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCannewmx() {
|
||||||
|
return cannewmx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCannewmx(String cannewmx) {
|
||||||
|
this.cannewmx = cannewmx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCandelmx() {
|
||||||
|
return candelmx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCandelmx(String candelmx) {
|
||||||
|
this.candelmx = candelmx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuffix() {
|
||||||
|
return suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuffix(String suffix) {
|
||||||
|
this.suffix = suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] getFORM() {
|
||||||
|
return FORM;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFORM(byte[] form) {
|
||||||
|
FORM = form;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChkupfld() {
|
||||||
|
return chkupfld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChkupfld(String chkupfld) {
|
||||||
|
this.chkupfld = chkupfld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefaultFouseField() {
|
||||||
|
return defaultFouseField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultFouseField(String defaultFouseField) {
|
||||||
|
this.defaultFouseField = defaultFouseField;
|
||||||
|
}
|
||||||
|
}
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
app/src/main/java/com/chaoran/entiry/UpdataInfo.java
Normal file
31
app/src/main/java/com/chaoran/entiry/UpdataInfo.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
/*更新实体类*/
|
||||||
|
public class UpdataInfo {
|
||||||
|
private String version;
|
||||||
|
private String url;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
}
|
||||||
133
app/src/main/java/com/chaoran/entiry/UserList.java
Normal file
133
app/src/main/java/com/chaoran/entiry/UserList.java
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class UserList implements Serializable{
|
||||||
|
private int userid;
|
||||||
|
private String username;
|
||||||
|
private String lgnname;
|
||||||
|
private String pass;
|
||||||
|
private String udesc;
|
||||||
|
private int rid;// 对应的角色id
|
||||||
|
private String jigid;// 用户所对应的机构
|
||||||
|
private String displaymode;//对应的角色显示方式
|
||||||
|
|
||||||
|
private String zhiyid_yw;
|
||||||
|
private String zhiybh_yw;
|
||||||
|
private String zhiyname_yw;
|
||||||
|
|
||||||
|
private String wldwid;
|
||||||
|
private String wldwname;
|
||||||
|
private String state;
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWldwid() {
|
||||||
|
return wldwid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWldwid(String wldwid) {
|
||||||
|
this.wldwid = wldwid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getWldwname() {
|
||||||
|
return wldwname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWldwname(String wldwname) {
|
||||||
|
this.wldwname = wldwname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJigid() {
|
||||||
|
return jigid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJigid(String jigid) {
|
||||||
|
this.jigid = jigid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRid() {
|
||||||
|
return rid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRid(int rid) {
|
||||||
|
this.rid = rid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserid() {
|
||||||
|
return userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserid(int userid) {
|
||||||
|
this.userid = userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLgnname() {
|
||||||
|
return lgnname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLgnname(String lgnname) {
|
||||||
|
this.lgnname = lgnname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPass() {
|
||||||
|
return pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPass(String pass) {
|
||||||
|
this.pass = pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUdesc() {
|
||||||
|
return udesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUdesc(String udesc) {
|
||||||
|
this.udesc = udesc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZhiyid_yw() {
|
||||||
|
return zhiyid_yw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZhiyid_yw(String zhiyid_yw) {
|
||||||
|
this.zhiyid_yw = zhiyid_yw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZhiybh_yw() {
|
||||||
|
return zhiybh_yw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZhiybh_yw(String zhiybh_yw) {
|
||||||
|
this.zhiybh_yw = zhiybh_yw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getZhiyname_yw() {
|
||||||
|
return zhiyname_yw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZhiyname_yw(String zhiyname_yw) {
|
||||||
|
this.zhiyname_yw = zhiyname_yw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplaymode() {
|
||||||
|
return displaymode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplaymode(String displaymode) {
|
||||||
|
this.displaymode = displaymode;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
app/src/main/java/com/chaoran/entiry/Zujian.java
Normal file
8
app/src/main/java/com/chaoran/entiry/Zujian.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package com.chaoran.entiry;
|
||||||
|
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class Zujian {
|
||||||
|
public TextView tv;
|
||||||
|
}
|
||||||
61
app/src/main/java/com/chaoran/imp/InputInterface.java
Normal file
61
app/src/main/java/com/chaoran/imp/InputInterface.java
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
package com.chaoran.imp;
|
||||||
|
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.view.View.OnFocusChangeListener;
|
||||||
|
|
||||||
|
public interface InputInterface {
|
||||||
|
public String getDefaultValue();
|
||||||
|
public void setDefaultValue(String defaultValue);
|
||||||
|
|
||||||
|
public String getNextFocus();
|
||||||
|
|
||||||
|
public void setNextFocus(String nextFocus);
|
||||||
|
|
||||||
|
public String getFocusInFun();
|
||||||
|
|
||||||
|
public void setFocusInFun(String focusInFun);
|
||||||
|
|
||||||
|
public String getFocusOutFun();
|
||||||
|
|
||||||
|
public void setFocusOutFun(String focusOutFun);
|
||||||
|
|
||||||
|
public boolean getIsNull();
|
||||||
|
|
||||||
|
public void setIsNull(boolean isNull);
|
||||||
|
|
||||||
|
public String getLabel();
|
||||||
|
|
||||||
|
public void setLabel(String label);
|
||||||
|
|
||||||
|
public boolean getIsTextChange();
|
||||||
|
|
||||||
|
public void setIsTextChange(boolean isTextChange);
|
||||||
|
|
||||||
|
public void setTag(final Object tag);
|
||||||
|
|
||||||
|
public Object getTag();
|
||||||
|
|
||||||
|
public void setTextSize(float size);
|
||||||
|
|
||||||
|
public void setOnFocusChangeListener(OnFocusChangeListener l);
|
||||||
|
|
||||||
|
public boolean getCloseKeyBoard();
|
||||||
|
|
||||||
|
public void setCloseKeyBoard(boolean closeKeyBoard);
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled);
|
||||||
|
|
||||||
|
public void setBackgroundDrawable(Drawable d);
|
||||||
|
|
||||||
|
public void setText(CharSequence text);
|
||||||
|
|
||||||
|
public Editable getText();
|
||||||
|
|
||||||
|
public void setPadding(int left, int top, int right, int bottom);
|
||||||
|
|
||||||
|
public void setGravity(int gravity);
|
||||||
|
|
||||||
|
public void setInputType(int type);
|
||||||
|
public void setTextColor(int color);
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package com.chaoran.listener;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.View.OnKeyListener;
|
||||||
|
import android.view.ViewGroup.LayoutParams;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.SelfImage;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
|
public class ImageClickListener implements OnClickListener {
|
||||||
|
private Activity activity;
|
||||||
|
|
||||||
|
public ImageClickListener(Activity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
SelfImage img = (SelfImage) v;
|
||||||
|
if(img.getBitmap()==null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
View contentView = LayoutInflater
|
||||||
|
.from(activity.getApplicationContext()).inflate(R.layout.popup,
|
||||||
|
null);
|
||||||
|
// 设置popupWindow的背景颜色
|
||||||
|
contentView.setBackgroundColor(Color.BLACK);
|
||||||
|
// 声明一个弹出框
|
||||||
|
final PopupWindow popupWindow = new PopupWindow(contentView,
|
||||||
|
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
|
||||||
|
popupWindow.setFocusable(true);
|
||||||
|
popupWindow.setBackgroundDrawable(new BitmapDrawable());//加上这句返回键才对PopupWindow起作用
|
||||||
|
popupWindow.showAtLocation(v, Gravity.CENTER_VERTICAL, 0, 0);
|
||||||
|
Display display = activity.getWindowManager().getDefaultDisplay();
|
||||||
|
ImageView imageView = (ImageView) contentView
|
||||||
|
.findViewById(R.id.zoomimg);
|
||||||
|
// int width = display.getWidth();
|
||||||
|
// int height = display.getHeight();
|
||||||
|
// //将图片设置为宽100,高200,在这儿就可以实现图片的大小缩放
|
||||||
|
// Bitmap resize=Bitmap.createScaledBitmap(img.getBitmap(),
|
||||||
|
// width,height, true);
|
||||||
|
// Matrix m=new Matrix();
|
||||||
|
// // m.setRotate(90); //逆时针旋转15度
|
||||||
|
// // //做好旋转与大小之后,重新创建位图,0-width宽度上显示的区域,高度类似
|
||||||
|
// Bitmap b=Bitmap.createBitmap(resize, 0, 0, resize.getWidth(),
|
||||||
|
// resize.getHeight(),m, true);
|
||||||
|
// 显示图片
|
||||||
|
imageView.setImageBitmap(img.getBitmap());
|
||||||
|
imageView.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
popupWindow.dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
app/src/main/java/com/chaoran/listener/PzClickListener.java
Normal file
54
app/src/main/java/com/chaoran/listener/PzClickListener.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package com.chaoran.listener;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.PhotographUi;
|
||||||
|
import com.example.chaoran.DjActivity;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.provider.MediaStore;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
|
||||||
|
public class PzClickListener implements OnClickListener {
|
||||||
|
private DjActivity activity;
|
||||||
|
|
||||||
|
public PzClickListener(DjActivity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (SysUtil.isHasSdcard()) {
|
||||||
|
activity.photographUi=(PhotographUi) v.getParent();
|
||||||
|
String root=android.os.Environment
|
||||||
|
.getExternalStorageDirectory().getAbsolutePath();
|
||||||
|
Intent intent = new Intent();
|
||||||
|
activity.pzImgPath = root+"/DCIM/Camera/pz.jpg";
|
||||||
|
File dir = new File(root+"/DCIM/Camera");
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdirs();
|
||||||
|
}
|
||||||
|
File mPhotoFile = new File(activity.pzImgPath);
|
||||||
|
if (!mPhotoFile.exists()) {
|
||||||
|
try {
|
||||||
|
mPhotoFile.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
DialogUtil.builder(activity, "提示信息",
|
||||||
|
"创建文件失败:" + e.toString(),0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPhotoFile));
|
||||||
|
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
activity.startActivityForResult(intent,8888);
|
||||||
|
} else {
|
||||||
|
DialogUtil.builder(activity, "提示信息", "请插入存储卡!",0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
188
app/src/main/java/com/chaoran/lx/activity/DownDataActivity.java
Normal file
188
app/src/main/java/com/chaoran/lx/activity/DownDataActivity.java
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
package com.chaoran.lx.activity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.kobjects.base64.Base64;
|
||||||
|
|
||||||
|
import com.chaoran.component.ButAdapter;
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
import com.chaoran.lx.thread.LxDataDownThread;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.example.chaoran.RunYmupThread;
|
||||||
|
import com.example.chaoran.R.id;
|
||||||
|
import com.example.chaoran.R.layout;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
|
||||||
|
import android.R.integer;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
public class DownDataActivity extends Activity {
|
||||||
|
private ListView listView;
|
||||||
|
private ArrayList mData;
|
||||||
|
private ButAdapter butAdapter;
|
||||||
|
private ProgressDialog pd;
|
||||||
|
private DBManager dbManager;
|
||||||
|
private TextView tv;// 有参数页面的才保存到这里 ,没参数页面的次控件随流程走 以免后期改造成多线程下载造成并发问题;
|
||||||
|
private Handler dataDownHandler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
if (msg.what == 10) {
|
||||||
|
pd.setMessage(msg.obj.toString());
|
||||||
|
} else if (msg.what == -1) {
|
||||||
|
pd.dismiss();
|
||||||
|
DialogUtil.builder(DownDataActivity.this, "错误信息", "下载数据失败!"
|
||||||
|
+ msg.obj,0);
|
||||||
|
} else {
|
||||||
|
pd.dismiss();
|
||||||
|
ArrayList tempList = (ArrayList) msg.obj;
|
||||||
|
String tablename = tempList.get(0).toString();
|
||||||
|
int size = dbManager.rsCount(tablename);
|
||||||
|
DialogUtil.builder(DownDataActivity.this, "提示信息", "下载数据成功!共下载"
|
||||||
|
+ size + "条",0);
|
||||||
|
((TextView) tempList.get(1)).setText(tempList.get(2).toString().concat("(")
|
||||||
|
.concat(String.valueOf(size)).concat(")"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private Handler tableDownhandler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
if (msg.what == -1) {
|
||||||
|
pd.dismiss();
|
||||||
|
DialogUtil.builder(DownDataActivity.this, "错误信息", "下载资料表失败!"
|
||||||
|
+ msg.obj,0);
|
||||||
|
} else {
|
||||||
|
mData = (ArrayList) msg.obj;
|
||||||
|
butAdapter = new ButAdapter(DownDataActivity.this, mData, pd,
|
||||||
|
dbManager, "tablename","fanganmc");
|
||||||
|
listView.setAdapter(butAdapter);
|
||||||
|
pd.dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.down_data_activity);
|
||||||
|
pd = new ProgressDialog(DownDataActivity.this);
|
||||||
|
pd.setCancelable(false);
|
||||||
|
DialogUtil.setDialog(pd, "信息提示", "正在下载离线表资料");
|
||||||
|
new RunYmupThread(null, tableDownhandler, "tableListDown", 1).start();
|
||||||
|
listView = (ListView) findViewById(R.id.downlist);
|
||||||
|
dbManager = new DBManager(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (butAdapter != null) {
|
||||||
|
butAdapter.clean();
|
||||||
|
butAdapter = null;
|
||||||
|
}
|
||||||
|
if (mData != null) {
|
||||||
|
mData.clear();
|
||||||
|
mData = null;
|
||||||
|
}
|
||||||
|
if (dbManager != null) {
|
||||||
|
dbManager.closeDB();
|
||||||
|
dbManager = null;
|
||||||
|
}
|
||||||
|
if (listView != null) {
|
||||||
|
listView = null;
|
||||||
|
}
|
||||||
|
if (pd != null) {
|
||||||
|
pd.dismiss();
|
||||||
|
pd = null;
|
||||||
|
}
|
||||||
|
tv = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
switch (resultCode) {
|
||||||
|
case 1:
|
||||||
|
Bundle bunde = data.getExtras();
|
||||||
|
HashMap map = (HashMap) bunde.getSerializable("map");
|
||||||
|
runDownThread(map, tv);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void downData(HashMap map, TextView tv) {
|
||||||
|
Object formlx = map.get("formlx");
|
||||||
|
System.out.println(formlx.toString()
|
||||||
|
+ "===================================");
|
||||||
|
if (formlx != null && formlx.toString().trim().length() > 0) {
|
||||||
|
this.tv = tv;
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putSerializable("map", map);
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
intent.setClass(getApplicationContext(), Lx_Param_Activity.class);
|
||||||
|
startActivityForResult(intent, 1);
|
||||||
|
} else {
|
||||||
|
runDownThread(map, tv);
|
||||||
|
// HashMap paramMap=new HashMap();
|
||||||
|
// String
|
||||||
|
// sql="select * from (".concat(map.get("downsql").toString()).concat(") temptable where rowNumber between")
|
||||||
|
// paramMap.put("sql",map.get("downsql"));
|
||||||
|
// if(map.containsKey("param")){
|
||||||
|
// paramMap.put("param", map.get("param"));
|
||||||
|
// }
|
||||||
|
// byte[] b;
|
||||||
|
// try {
|
||||||
|
// b = IoUtil.getbyte(paramMap);
|
||||||
|
// String paramString = Base64.encode(b);
|
||||||
|
// new RunYmupThread(paramString, dataDownHandler , "lxDataDown",
|
||||||
|
// 1).start();
|
||||||
|
// DialogUtil.setDialog(pd, "下载数据",
|
||||||
|
// "正在下载"+map.get("tablename")+"表数据");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// DialogUtil.builder(DownDataActivity.this, "错误信息",
|
||||||
|
// "组织下载数据失败!" + e.toString());
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runDownThread(HashMap map, TextView tv) {
|
||||||
|
HashMap param = null;
|
||||||
|
if (map.containsKey("param")) {
|
||||||
|
param = (HashMap) map.get("param");
|
||||||
|
}
|
||||||
|
Set<String> set = map.keySet();
|
||||||
|
for (String s : set) {
|
||||||
|
System.out.println(s + "-----" + map.get(s));
|
||||||
|
}
|
||||||
|
LxDataDownThread lxDataDownThread = new LxDataDownThread(
|
||||||
|
dataDownHandler, 1, Integer.parseInt(map.get("paging")
|
||||||
|
.toString()), dbManager, map.get("downsql").toString().toUpperCase(),
|
||||||
|
param, map.get("tablename").toString().toUpperCase(), map.get(
|
||||||
|
"createtabelsql").toString().toUpperCase(), pd, tv, map.get("fanganmc").toString());
|
||||||
|
new Thread(lxDataDownThread).start();
|
||||||
|
DialogUtil.setDialog(pd, "下载数据", "正在下载" + map.get("tablename")
|
||||||
|
+ "表数据,第1页");
|
||||||
|
}
|
||||||
|
}
|
||||||
135
app/src/main/java/com/chaoran/lx/activity/Lx_Param_Activity.java
Normal file
135
app/src/main/java/com/chaoran/lx/activity/Lx_Param_Activity.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
package com.chaoran.lx.activity;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.dom4j.DocumentException;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.DanJuEntity;
|
||||||
|
import com.chaoran.entiry.Sys_DanJuFormsOptions;
|
||||||
|
import com.chaoran.thread.DownDJRun;
|
||||||
|
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.IoUtil;
|
||||||
|
import com.util.LxParamPageCreate;
|
||||||
|
import com.util.SqlUtil;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
public class Lx_Param_Activity extends Activity {
|
||||||
|
private HashMap map;
|
||||||
|
private RelativeLayout lx_page;
|
||||||
|
private ProgressDialog pd;
|
||||||
|
private Handler downDJhandler = new Handler() {
|
||||||
|
@Override
|
||||||
|
// 当有消息发送出来的时候就执行Handler的这个方法
|
||||||
|
public void handleMessage(Message msg) {
|
||||||
|
super.handleMessage(msg);
|
||||||
|
pd.dismiss();
|
||||||
|
if (msg.what == -1) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "错误信息",
|
||||||
|
"查询参数页面内容失败:" + msg.obj,0);
|
||||||
|
} else {
|
||||||
|
Object initOb = msg.obj;
|
||||||
|
if (initOb instanceof Map) {
|
||||||
|
HashMap djInitMap = (HashMap) initOb;
|
||||||
|
Sys_DanJuFormsOptions danju = (Sys_DanJuFormsOptions) djInitMap
|
||||||
|
.get("danju");
|
||||||
|
ByteArrayInputStream in = null;
|
||||||
|
try {
|
||||||
|
DanJuEntity dj = (DanJuEntity) IoUtil.byte_obj2(danju
|
||||||
|
.getFORM());
|
||||||
|
String[] arrs = dj.pageNr.split("\\^");
|
||||||
|
if (arrs.length > 1) {
|
||||||
|
dj.pageNr = arrs[0];
|
||||||
|
}
|
||||||
|
in = new ByteArrayInputStream(dj.pageNr.getBytes());
|
||||||
|
} catch (Exception e) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "错误信息",
|
||||||
|
"生成参数页面失败!" + e.toString(),0);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
|
LxParamPageCreate.lxParamPageCreate(in,
|
||||||
|
Lx_Param_Activity.this, lx_page);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "错误信息",
|
||||||
|
"生成参数页面流失败!" + e.toString(),0);
|
||||||
|
} catch (DocumentException e) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "错误信息",
|
||||||
|
"生成参数页面失败!" + e.toString(),0);
|
||||||
|
}
|
||||||
|
in = null;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (initOb.equals("0")) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "提示信息", "PDA未注册!",0);
|
||||||
|
} else if (initOb.equals("1")) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "提示信息",
|
||||||
|
"PDA还未授权使用!",0);
|
||||||
|
} else if (initOb.equals("2")) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "提示信息", "试用期已过!",0);
|
||||||
|
} else if (initOb.equals("该模块未授权")) {
|
||||||
|
DialogUtil.builder(Lx_Param_Activity.this, "提示信息", "该模块未授权!",0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.lx_param_activity);
|
||||||
|
Bundle bundle = this.getIntent().getExtras();
|
||||||
|
map = (HashMap) bundle.getSerializable("map");
|
||||||
|
lx_page = (RelativeLayout) findViewById(R.id.lx_page);
|
||||||
|
pd = new ProgressDialog(Lx_Param_Activity.this);
|
||||||
|
pd.setCancelable(false);
|
||||||
|
DialogUtil.setDialog(pd, "信息提示", "正在下载参数页面数据");
|
||||||
|
new Thread(new DownDJRun(map.get("formlx").toString(), downDJhandler))
|
||||||
|
.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if(map!=null){
|
||||||
|
map.clear();
|
||||||
|
map=null;
|
||||||
|
}
|
||||||
|
lx_page=null;
|
||||||
|
pd=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sub_back(View v) {
|
||||||
|
HashMap tempMap = SqlUtil
|
||||||
|
.regSql(map.get("downsql").toString(), lx_page);
|
||||||
|
map.put("downsql", tempMap.get("sql"));
|
||||||
|
map.put("param", tempMap.get("param"));
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putSerializable("map", map);
|
||||||
|
Intent intent = getIntent();
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
setResult(1, intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
135
app/src/main/java/com/chaoran/lx/thread/LxDJNrThread.java
Normal file
135
app/src/main/java/com/chaoran/lx/thread/LxDJNrThread.java
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
package com.chaoran.lx.thread;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.StreamCorruptedException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
import com.chaoran.entiry.DanJuEntity;
|
||||||
|
import com.chaoran.entiry.Sys_DanJuFormsOptions;
|
||||||
|
import com.util.DateUtil;
|
||||||
|
|
||||||
|
import flex.messaging.io.ArrayList;
|
||||||
|
|
||||||
|
public class LxDJNrThread implements Runnable {
|
||||||
|
private DBManager dbManager;
|
||||||
|
private Handler menuHandler;
|
||||||
|
private String formlx;
|
||||||
|
|
||||||
|
public LxDJNrThread(DBManager dbManager, Handler menuHandler, String formlx) {
|
||||||
|
this.dbManager = dbManager;
|
||||||
|
this.menuHandler = menuHandler;
|
||||||
|
this.formlx = formlx;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String sql = "select FORMbs,mxactive,candelmx,cannewmx,defaultFouseField,dialog_hei,dialog_wid,FORMsm,FORM from Sys_DanJuFormsOptions where rtrim(formlx)='"
|
||||||
|
+ formlx + "'";
|
||||||
|
Cursor cur = dbManager.query(sql);
|
||||||
|
Sys_DanJuFormsOptions danju = null;
|
||||||
|
if (cur.moveToFirst()) {
|
||||||
|
danju = new Sys_DanJuFormsOptions();
|
||||||
|
danju.setFORMbs(cur.getString(0));
|
||||||
|
danju.setMxactive(cur.getString(1));
|
||||||
|
danju.setCandelmx(cur.getString(2));
|
||||||
|
danju.setCannewmx(cur.getString(3));
|
||||||
|
danju.setDefaultFouseField(cur.getString(4));
|
||||||
|
danju.setDialog_hei(Integer.parseInt(cur.getString(5)));
|
||||||
|
danju.setDialog_wid(Integer.parseInt(cur.getString(6)));
|
||||||
|
danju.setFORMsm(cur.getString(7));
|
||||||
|
System.out.println(cur.getColumnIndex("FORM"));
|
||||||
|
byte[] b = cur.getBlob(8);
|
||||||
|
// System.out.println(b);
|
||||||
|
danju.setFORM(b);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
HashMap fangAMap = new HashMap();
|
||||||
|
if (dbManager.existsTable("sys_SearchOptions".toUpperCase()) > 0) {
|
||||||
|
sql = "select functitle,upper('SEARCH_'+rtrim(functionname)) as funName,fangalx,dialog_wid,dialog_hei,dialog_cap,zdysql,(CASE return_one WHEN '是' THEN'Y' ELSE 'N' END )AS return_one ,audioFld from sys_SearchOptions where rtrim(fangalx)='"
|
||||||
|
+ formlx + "'";
|
||||||
|
cur = dbManager.query(sql);
|
||||||
|
HashMap tempMap = null;
|
||||||
|
int len = cur.getColumnCount();
|
||||||
|
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
||||||
|
tempMap = new HashMap();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
tempMap.put(cur.getColumnName(i), cur.getString(i));
|
||||||
|
}
|
||||||
|
fangAMap.put(tempMap.get("funName"), tempMap);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
}
|
||||||
|
System.out.println(dbManager.existsTable("sys_YmupOptions"
|
||||||
|
.toUpperCase()) + "-----------------------");
|
||||||
|
if (dbManager.existsTable("sys_YmupOptions".toUpperCase()) > 0) {
|
||||||
|
sql = "select upper('YMUP_'||rtrim(fangabh)) as funName,zdysql as zdysql from Sys_YmupOptions where rtrim(fangalx)='"
|
||||||
|
+ formlx + "'";
|
||||||
|
cur = dbManager.query(sql);
|
||||||
|
HashMap tempMap = null;
|
||||||
|
int len = cur.getColumnCount();
|
||||||
|
System.out.println(len + "--------len---------------"
|
||||||
|
+ cur.getCount());
|
||||||
|
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
||||||
|
System.out.println("-------------=========-------------");
|
||||||
|
tempMap = new HashMap();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
tempMap.put(cur.getColumnName(i), cur.getString(i));
|
||||||
|
System.out.println(cur.getColumnName(i) + "------"
|
||||||
|
+ cur.getString(i));
|
||||||
|
}
|
||||||
|
fangAMap.put(tempMap.get("funName"), tempMap);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
}
|
||||||
|
if (dbManager.existsTable("Djselefa".toUpperCase()) > 0) {
|
||||||
|
sql = "select upper('DJTQ_'+rtrim(fangabh)) as funName,fangalx,fangamch, emptylyb, selectmx, t_sql, hz_sql, mx_sql from Djselefa where rtrim(fangalx)='"
|
||||||
|
+ formlx + "'";
|
||||||
|
cur = dbManager.query(sql);
|
||||||
|
HashMap tempMap = null;
|
||||||
|
int len = cur.getColumnCount();
|
||||||
|
for (cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()) {
|
||||||
|
tempMap = new HashMap();
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
tempMap.put(cur.getColumnName(i), cur.getString(i));
|
||||||
|
}
|
||||||
|
fangAMap.put(tempMap.get("funName"), tempMap);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
}
|
||||||
|
HashMap djInitMap = new HashMap();
|
||||||
|
djInitMap.put("danju", danju);
|
||||||
|
djInitMap.put("GZID", "");
|
||||||
|
djInitMap.put("RQ", DateUtil.getDateAndTime());
|
||||||
|
djInitMap.put("ONTIME", DateUtil.getTime());
|
||||||
|
// djInitMap.put("searchList", new ArrayList());
|
||||||
|
// djInitMap.put("ymupList", new ArrayList());
|
||||||
|
// djInitMap.put("djtqList", new ArrayList());
|
||||||
|
Message message = new Message();
|
||||||
|
// ArrayList tempList = new ArrayList();
|
||||||
|
// tempList.add(djInitMap);
|
||||||
|
// tempList.add(fangAMap);
|
||||||
|
djInitMap.put("fangAMap",fangAMap);
|
||||||
|
message.obj = fangAMap;
|
||||||
|
menuHandler.sendMessage(message);
|
||||||
|
// if (danju != null) {
|
||||||
|
// System.out.println(danju.getFORM().length+"---------------------------------");
|
||||||
|
// ByteArrayInputStream bin = new ByteArrayInputStream(danju.getFORM());
|
||||||
|
// try {
|
||||||
|
// ObjectInputStream oin = new ObjectInputStream(bin);
|
||||||
|
// DanJuEntity danJuEntity=(DanJuEntity) oin.readObject();
|
||||||
|
// System.out.println(danJuEntity.pageNr + "--------");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// // TODO Auto-generated catch block
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
142
app/src/main/java/com/chaoran/lx/thread/LxDataDownThread.java
Normal file
142
app/src/main/java/com/chaoran/lx/thread/LxDataDownThread.java
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
package com.chaoran.lx.thread;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.kobjects.base64.Base64;
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
import com.sys.SysData;
|
||||||
|
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 {
|
||||||
|
private Handler handler;
|
||||||
|
private int currentPage;
|
||||||
|
private int pagingNum;// 每页条数
|
||||||
|
private DBManager dbManager;
|
||||||
|
private String sql;
|
||||||
|
private HashMap param;
|
||||||
|
private String tablename;
|
||||||
|
private String createtablesql;
|
||||||
|
private ProgressDialog pd;
|
||||||
|
private TextView tv;
|
||||||
|
private String showTvStr;
|
||||||
|
|
||||||
|
public LxDataDownThread(Handler handler, int currentPage, int pagingNum,
|
||||||
|
DBManager dbManager, String sql, HashMap param, String tablename,
|
||||||
|
String createtablesql, ProgressDialog pd, TextView tv,String showTvStr) {
|
||||||
|
this.handler = handler;
|
||||||
|
this.currentPage = currentPage;
|
||||||
|
this.pagingNum = pagingNum;
|
||||||
|
this.dbManager = dbManager;
|
||||||
|
this.sql = sql;
|
||||||
|
this.param = param;
|
||||||
|
this.tablename = tablename;
|
||||||
|
this.createtablesql = createtablesql;
|
||||||
|
this.pd = pd;
|
||||||
|
this.tv = tv;
|
||||||
|
this.showTvStr=showTvStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
luoji();
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = 1;
|
||||||
|
ArrayList tempList = new ArrayList();
|
||||||
|
tempList.add(tablename);
|
||||||
|
tempList.add(tv);
|
||||||
|
tempList.add(showTvStr);
|
||||||
|
msg.obj = tempList;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = -1;
|
||||||
|
msg.obj = e.toString();
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} finally {
|
||||||
|
dbManager = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void luoji() throws Exception {
|
||||||
|
System.gc();
|
||||||
|
String url = SysData.url + "/webservice/offLineInventoryInterface?wsdl";
|
||||||
|
String method = "lxDataDown";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
int start = (currentPage - 1) * pagingNum + 1;
|
||||||
|
String tempSql = "select * from (".concat(sql).concat(
|
||||||
|
") temptable where rowNumber between '" + start + "' and '"
|
||||||
|
+ currentPage * pagingNum + "'");
|
||||||
|
HashMap tempParamMap = new HashMap();
|
||||||
|
tempParamMap.put("sql", tempSql);
|
||||||
|
if (currentPage == 1) {
|
||||||
|
tempParamMap.put("currentPage", currentPage);
|
||||||
|
tempParamMap.put("mac", SysData.clientid);
|
||||||
|
}
|
||||||
|
if (param != null) {
|
||||||
|
tempParamMap.put("param", param);
|
||||||
|
}
|
||||||
|
byte[] b = IoUtil.getbyte(tempParamMap);
|
||||||
|
String paramString = Base64.encode(b);
|
||||||
|
rpc.addProperty("param", paramString);
|
||||||
|
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);
|
||||||
|
byte[] bb = Base64.decode(envelope.getResponse()
|
||||||
|
.toString());
|
||||||
|
Object ob = IoUtil.byte_obj(bb);
|
||||||
|
if (!(ob instanceof List)) {
|
||||||
|
throw new Exception(ob.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
List list = (List) ob;
|
||||||
|
if (currentPage == 1) {
|
||||||
|
System.out.println(tablename+"--------------------"+dbManager.existsTable(tablename));
|
||||||
|
if (dbManager.existsTable(tablename) > 0) {
|
||||||
|
dbManager.exeSql("drop table ".concat(tablename));
|
||||||
|
}
|
||||||
|
dbManager.exeSql(createtablesql);
|
||||||
|
}
|
||||||
|
if (list != null && list.size() > 0) {
|
||||||
|
dbManager.batchSave(list, tablename);
|
||||||
|
}
|
||||||
|
if (list.size() == pagingNum) {
|
||||||
|
list.clear();
|
||||||
|
list = null;
|
||||||
|
currentPage++;
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = 10;
|
||||||
|
msg.obj = "正在下载" + tablename + "表数据,第" + currentPage + "页";
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
// pd.setMessage("正在下载"+tablename+"表数据,第"+currentPage+"页");
|
||||||
|
luoji();
|
||||||
|
}
|
||||||
|
// HashMap map=new HashMap();
|
||||||
|
// map.put("obj", IoUtil.byte_obj(bb));
|
||||||
|
// map.put("tableName",tablename);
|
||||||
|
// map.put("currentPage", currentPage);
|
||||||
|
// msg.obj = map;
|
||||||
|
// handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.chaoran.lx.thread;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
|
||||||
|
public class LxMenuQueryThread implements Runnable {
|
||||||
|
private DBManager dbManager;
|
||||||
|
private List menuData;
|
||||||
|
private Handler menuHandler;
|
||||||
|
public LxMenuQueryThread(DBManager dbManager,Handler menuHandler,List menuData){
|
||||||
|
this.dbManager=dbManager;
|
||||||
|
this.menuData=menuData;
|
||||||
|
this.menuHandler=menuHandler;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Cursor cur=dbManager.query("select formlx as gn_no,formsm as mname from Sys_danjuformsoptions");
|
||||||
|
ArrayList list=new ArrayList();
|
||||||
|
HashMap<String, String> map;
|
||||||
|
while(cur.moveToNext()){
|
||||||
|
map=new HashMap<String, String>();
|
||||||
|
map.put("gn_no", cur.getString(0));
|
||||||
|
map.put("mname", cur.getString(1));
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
cur.close();
|
||||||
|
menuData.addAll(list);
|
||||||
|
Message message = new Message();
|
||||||
|
menuHandler.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
54
app/src/main/java/com/chaoran/lx/thread/LxRunYmupThread.java
Normal file
54
app/src/main/java/com/chaoran/lx/thread/LxRunYmupThread.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package com.chaoran.lx.thread;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.chaoran.db.DBManager;
|
||||||
|
|
||||||
|
import flex.messaging.io.ArrayList;
|
||||||
|
|
||||||
|
public class LxRunYmupThread implements Runnable {
|
||||||
|
private DBManager dbManager;
|
||||||
|
private String ymupSql;
|
||||||
|
private Map hzData;
|
||||||
|
private Handler handler;
|
||||||
|
public LxRunYmupThread(DBManager dbManager,String ymupSql,Map hzData,Handler handler){
|
||||||
|
this.dbManager=dbManager;
|
||||||
|
this.ymupSql=ymupSql;
|
||||||
|
this.hzData=hzData;
|
||||||
|
this.handler=handler;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
System.out.println(dbManager.rsCount("TEMP_BI_DJHZ")+"-=====------------------条");
|
||||||
|
dbManager.exeSql("delete from TEMP_BI_DJHZ");
|
||||||
|
System.out.println(dbManager.rsCount("TEMP_BI_DJHZ")+"-=====------------------条");
|
||||||
|
String hzSql="insert into TEMP_BI_DJHZ(FIELDNAME,FIELDVALUE) values(?,?)";
|
||||||
|
dbManager.batchSave(hzSql, hzData);
|
||||||
|
Cursor cursor=dbManager.query(ymupSql);
|
||||||
|
String mess=null;
|
||||||
|
if(cursor.moveToFirst()){
|
||||||
|
mess=cursor.getString(0);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
cursor=dbManager.query("select fieldname,fieldvalue from TEMP_BI_DJHZ");
|
||||||
|
ArrayList list=new ArrayList();
|
||||||
|
for(cursor.moveToFirst();!cursor.isAfterLast();cursor.moveToNext()){
|
||||||
|
HashMap hzMap=new HashMap();
|
||||||
|
hzMap.put(cursor.getString(0),cursor.getString(1));
|
||||||
|
list.add(hzMap);
|
||||||
|
}
|
||||||
|
HashMap returnMap=new HashMap();
|
||||||
|
returnMap.put("mes", mess);
|
||||||
|
returnMap.put("hz", list);
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.arg1 = 2;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
System.out.println(dbManager.rsCount("TEMP_BI_DJHZ")+"-------------------条");
|
||||||
|
}
|
||||||
|
}
|
||||||
43
app/src/main/java/com/chaoran/thread/DownApk.java
Normal file
43
app/src/main/java/com/chaoran/thread/DownApk.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package com.chaoran.thread;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
import com.util.DownloadManager;
|
||||||
|
|
||||||
|
public class DownApk implements Runnable{
|
||||||
|
private ProgressDialog pd;
|
||||||
|
private String url;
|
||||||
|
private Context context;
|
||||||
|
private Handler handler;
|
||||||
|
|
||||||
|
public DownApk(ProgressDialog pd,String url, Context context,Handler handler) {
|
||||||
|
this.pd = pd;
|
||||||
|
this.url= url;
|
||||||
|
this.context = context;
|
||||||
|
this.handler=handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
File file = DownloadManager.getFileFromServer(
|
||||||
|
url, pd, context);
|
||||||
|
Thread.currentThread().sleep(3000);
|
||||||
|
pd.dismiss();
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what=2;
|
||||||
|
msg.obj = file;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what =-5;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
app/src/main/java/com/chaoran/thread/DownDJRun.java
Normal file
60
app/src/main/java/com/chaoran/thread/DownDJRun.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package com.chaoran.thread;
|
||||||
|
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
|
||||||
|
public class DownDJRun implements Runnable {
|
||||||
|
private String formlx;
|
||||||
|
private Handler handler;
|
||||||
|
public DownDJRun(String formlx,Handler handler){
|
||||||
|
this.formlx=formlx;
|
||||||
|
this.handler=handler;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Object ob;
|
||||||
|
try {
|
||||||
|
ob = getWeather(formlx);
|
||||||
|
Message message = new Message();
|
||||||
|
message.obj = ob;
|
||||||
|
handler.sendMessage(message);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Message message = new Message();
|
||||||
|
message.obj = e.toString();
|
||||||
|
message.what = -1;
|
||||||
|
handler.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Object getWeather(String FORMlx) throws Exception {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
String method = "querydjNrWs";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("FORMlx", FORMlx);
|
||||||
|
rpc.addProperty("mac", SysData.clientid);
|
||||||
|
rpc.addProperty("userid", SysData.userid);
|
||||||
|
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);
|
||||||
|
Object djInitMap = null;
|
||||||
|
if (envelope.getResponse() != null) {// 判断是否返回结果,因为我这个是一个查询操作,是带有返回值的。
|
||||||
|
byte[] bb = org.kobjects.base64.Base64.decode(envelope
|
||||||
|
.getResponse().toString());
|
||||||
|
djInitMap = IoUtil.byte_obj(bb);
|
||||||
|
}
|
||||||
|
return djInitMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
42
app/src/main/java/com/chaoran/thread/ImageUrl.java
Normal file
42
app/src/main/java/com/chaoran/thread/ImageUrl.java
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package com.chaoran.thread;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.SelfImage;
|
||||||
|
import com.util.BitMapUtil;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
public class ImageUrl implements Runnable {
|
||||||
|
private SelfImage img;
|
||||||
|
private String url;
|
||||||
|
private Handler handler;
|
||||||
|
|
||||||
|
public ImageUrl(SelfImage img, String url, Handler handler) {
|
||||||
|
this.img = img;
|
||||||
|
this.url = url;
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Bitmap bitMap;
|
||||||
|
Message msg = new Message();
|
||||||
|
try {
|
||||||
|
bitMap = BitMapUtil.generateBitMap(url);
|
||||||
|
HashMap map=new HashMap();
|
||||||
|
map.put("image", img);
|
||||||
|
map.put("bitMap", bitMap);
|
||||||
|
msg.obj =map;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} catch (IOException e) {
|
||||||
|
msg.what=-1;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
51
app/src/main/java/com/chaoran/thread/UpdatePwdThread.java
Normal file
51
app/src/main/java/com/chaoran/thread/UpdatePwdThread.java
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package com.chaoran.thread;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
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 {
|
||||||
|
private Handler handler;
|
||||||
|
private String userid;
|
||||||
|
private String newPwd;
|
||||||
|
public UpdatePwdThread(Handler handler,String userid,String newPwd) {
|
||||||
|
this.handler=handler;
|
||||||
|
this.userid=userid;
|
||||||
|
this.newPwd=newPwd;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
String method = "updatePwd";
|
||||||
|
SoapObject rpc = new SoapObject("", method);
|
||||||
|
rpc.addProperty("userid",userid);
|
||||||
|
rpc.addProperty("newPwd",newPwd);
|
||||||
|
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);
|
||||||
|
Message msg = new Message();
|
||||||
|
try {
|
||||||
|
ht.call("", envelope);
|
||||||
|
String backmsg=envelope.getResponse().toString();
|
||||||
|
msg.obj =backmsg;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
} catch (Exception e) {
|
||||||
|
msg.obj =e.toString();
|
||||||
|
msg.what = -1;
|
||||||
|
handler.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
72
app/src/main/java/com/cr5w/scan/CR5WScanControl.java
Normal file
72
app/src/main/java/com/cr5w/scan/CR5WScanControl.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package com.cr5w.scan;
|
||||||
|
|
||||||
|
import android.app.Instrumentation;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class CR5WScanControl {
|
||||||
|
|
||||||
|
private boolean isRun = true;
|
||||||
|
private boolean isOpen = true;
|
||||||
|
|
||||||
|
public boolean getIsOpen() {
|
||||||
|
return this.isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsOpen(boolean isOpen) {
|
||||||
|
this.isOpen = isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(final Context context) {
|
||||||
|
new Thread() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
if (isRun && 1 == ScanHelper.getScanModel(context)) {
|
||||||
|
Instrumentation inst = new Instrumentation();
|
||||||
|
Log.v("cr5w-SetScanHeader", "scan: send key begin");
|
||||||
|
inst.sendKeyDownUpSync(220);
|
||||||
|
inst.sendKeyDownUpSync(221);
|
||||||
|
Log.v("cr5w-SetScanHeader", "scan: send key end");
|
||||||
|
}
|
||||||
|
sleep(500);
|
||||||
|
}
|
||||||
|
// init(context);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(Context context) {
|
||||||
|
if (!this.isOpen)
|
||||||
|
return;
|
||||||
|
Log.v("cr5w-SetScanHeader", "scan: start begin");
|
||||||
|
ScanHelper.setScanSwitchLeft(context, true);
|
||||||
|
ScanHelper.setScanSwitchRight(context, true);
|
||||||
|
Log.v("cr5w-SetScanHeader", "scan: start end");
|
||||||
|
if (!isRun) {
|
||||||
|
isRun = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(Context context) {
|
||||||
|
Log.v("cr5w-SetScanHeader", "scan: stop begin");
|
||||||
|
ScanHelper.setScanSwitchLeft(context, false);
|
||||||
|
ScanHelper.setScanSwitchRight(context, false);
|
||||||
|
Log.v("cr5w-SetScanHeader", "scan: stop end");
|
||||||
|
isRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void restart(Context context) {
|
||||||
|
stop(context);
|
||||||
|
start(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
isRun = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
283
app/src/main/java/com/cr5w/scan/ScanHelper.java
Normal file
283
app/src/main/java/com/cr5w/scan/ScanHelper.java
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
package com.cr5w.scan;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.provider.Settings;
|
||||||
|
public class ScanHelper {
|
||||||
|
/** scan settings show 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SETTINGS_HAVED = "scan_settings_haved";
|
||||||
|
/** scan settings left enable 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SETTINGS_LEFT = "scan_settings_left";
|
||||||
|
/** scan settings right enable 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SETTINGS_RIGHT = "scan_settings_right";
|
||||||
|
/** scan models settings 0 : noraml; 1 : continue auto; 2 : continue manual*/
|
||||||
|
public static final String SCAN_MODLES_SETTINGS = "scan_models_settings";
|
||||||
|
/** scan continue delay settings 0 : none; 1 : 0.5s; 2 : 1s; 3 : custom*/
|
||||||
|
public static final String SCAN_CONTINUE_DELAY_SETTINGS = "scan_continue_delay_settings";
|
||||||
|
/** scan continue delay value */
|
||||||
|
public static final String SCAN_CONTINUE_DELAY_CUSTOM_VALUE = "scan_continue_delay_custom_value";
|
||||||
|
/** barcode receive model 0 : fast; 1 : slow; 2 : broadcast*/
|
||||||
|
public static final String BARCODE_RECEIVE_MODELS_SETTINGS = "barcode_receive_models_settings";
|
||||||
|
/** barcode separator model 0 : none; 1 : '\n'; 2 : Enter*/
|
||||||
|
public static final String BARCODE_SEPARATOR_SETTINGS = "barcode_separator_settings";
|
||||||
|
/** barcode separator prefix settings 0 : no; 1 : yes*/
|
||||||
|
public static final String BARCODE_SEPARATOR_PREFIX_SETTINGS = "barcode_separator_prefix_settings";
|
||||||
|
/** barcode separator prefix content */
|
||||||
|
public static final String BARCODE_SEPARATOR_PREFIX = "barcode_separator_prefix";
|
||||||
|
/** barcode separator suffix settings 0 : no; 1 : yes*/
|
||||||
|
public static final String BARCODE_SEPARATOR_SUFFIX_SETTINGS = "barcode_separator_suffix_settings";
|
||||||
|
/** barcode separator suffix content */
|
||||||
|
public static final String BARCODE_SEPARATOR_SUFFIX = "barcode_separator_suffix";
|
||||||
|
/** scan sound settings 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SOUND_SETTINGS = "scan_sound_settings";
|
||||||
|
/** scan vibrate settings 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_VIBRATE_SETTINGS = "scan_vibrate_settings";
|
||||||
|
|
||||||
|
public static boolean getScanToggleState(Context context) {
|
||||||
|
boolean flag = false;
|
||||||
|
boolean scan_left = Settings.System.getInt(context.getContentResolver(),
|
||||||
|
SCAN_SETTINGS_LEFT, 0) != 0;
|
||||||
|
boolean scan_right = Settings.System.getInt(context.getContentResolver(),
|
||||||
|
SCAN_SETTINGS_RIGHT, 0) != 0;
|
||||||
|
if(scan_left != false || scan_right != false){
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* scan left state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanSwitchLeft(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_SETTINGS_LEFT, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan left state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanSwitchLeft(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_SETTINGS_LEFT, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan right state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanSwitchRight(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_SETTINGS_RIGHT, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan right state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanSwitchRight(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_SETTINGS_RIGHT, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan model state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : normal; 1 : continue auto; 2 : continue manual
|
||||||
|
*/
|
||||||
|
public static int getScanModel(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_MODLES_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan model state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : normal; 1 : continue auto; 2 : continue manual
|
||||||
|
*/
|
||||||
|
public static void setScanModel(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_MODLES_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan delay state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : none; 1 : 0.5s; 2 : 1s;3 : custom delay
|
||||||
|
*/
|
||||||
|
public static int getScanDelaySetting(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_CONTINUE_DELAY_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan delay state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : none; 1 : 0.5s; 2 : 1s;3 : custom delay
|
||||||
|
*/
|
||||||
|
public static void setScanDelaySetting(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_CONTINUE_DELAY_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan delay value
|
||||||
|
* @param context
|
||||||
|
* @return delay
|
||||||
|
*/
|
||||||
|
public static float getScanDelay(Context context){
|
||||||
|
return Settings.System.getFloat(context.getContentResolver(), SCAN_CONTINUE_DELAY_CUSTOM_VALUE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan delay value
|
||||||
|
* @param context
|
||||||
|
* @param delay
|
||||||
|
*/
|
||||||
|
public static void setScanDelay(Context context, float delay){
|
||||||
|
Settings.System.putFloat(context.getContentResolver(), SCAN_CONTINUE_DELAY_CUSTOM_VALUE, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode receive model state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : fast; 1 : slow; 2 : broadcast
|
||||||
|
*/
|
||||||
|
public static int getBarcodeReceiveModel(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_RECEIVE_MODELS_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set broadcast receive model state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : fast; 1 : slow; 2 : broadcast
|
||||||
|
*/
|
||||||
|
public static void setBarcodeReceiveModel(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_RECEIVE_MODELS_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode separator state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : none; 1 : newline; 2 : enter
|
||||||
|
*/
|
||||||
|
public static int getBarcodeSeparator(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_SEPARATOR_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode separator state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : none; 1 : newline; 2 : enter
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSeparator(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_SEPARATOR_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Prefix state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static boolean getBarcodePrefixState(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Prefix state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static void setBarcodePrefixState(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Prefix
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getBarcodePrefix(Context context){
|
||||||
|
return Settings.System.getString(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Prefix
|
||||||
|
* @param context
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public static void setBarcodePrefix(Context context, String prefix){
|
||||||
|
Settings.System.putString(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Suffix state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static boolean getBarcodeSuffixState(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Suffix state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSuffixState(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Suffix
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getBarcodeSuffix(Context context){
|
||||||
|
return Settings.System.getString(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Suffix
|
||||||
|
* @param context
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSuffix(Context context, String suffix){
|
||||||
|
Settings.System.putString(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX, suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan sound state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanSound(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_SOUND_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan sound state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanSound(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_SOUND_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan Vibrate state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanVibrate(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_VIBRATE_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan Vibrate state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanVibrate(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_VIBRATE_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
app/src/main/java/com/cr5w/scan/ScanKeyEventRunnable.java
Normal file
26
app/src/main/java/com/cr5w/scan/ScanKeyEventRunnable.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package com.cr5w.scan;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
public class ScanKeyEventRunnable implements Runnable {
|
||||||
|
public boolean isrun = true;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public ScanKeyEventRunnable(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
while (isrun) {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction("com.barcode.sendBroadcastScan");
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
296
app/src/main/java/com/cr5w/scan/SysBarcodeUtil.java
Normal file
296
app/src/main/java/com/cr5w/scan/SysBarcodeUtil.java
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
/**
|
||||||
|
* use permission:
|
||||||
|
* <uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||||
|
*/
|
||||||
|
package com.cr5w.scan;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wpx
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SysBarcodeUtil {
|
||||||
|
private SysBarcodeUtil(){
|
||||||
|
/* cannot be instantiated */
|
||||||
|
throw new UnsupportedOperationException("cannot be instantiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String BARCODE_SETTINGS_LEFT = "barcode_settings_left";
|
||||||
|
private static final String BARCODE_SETTINGS_LEFT_SELECTED = "barcode_settings_left_selected";
|
||||||
|
private static final String BARCODE_SETTINGS_RIGHT = "barcode_settings_right";
|
||||||
|
private static final String BARCODE_SETTINGS_RIGHT_SELECTED = "barcode_settings_right_selected";
|
||||||
|
private static final String BARCODE_TYPE = "barcode_typemessage_settings";
|
||||||
|
private static final String BARCODE_INTERVAL_SETTINGS = "BARCODE_INTERVAL_SETTINGS";
|
||||||
|
private static final String BARCODE_SENDMESSAGE_SETTINGS = "barcode_sendmessage_settings";
|
||||||
|
private static final String BARCODE_NEWPARAGRAPH_SETTINGS = "barcode_newparagraph_settings";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final String BARCODE_ACTION = "com.barcode.sendBroadcast";
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final String BARCODE_PARAM = "BARCODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static Object object;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static BroadcastReceiver barcodeReceiver = new BroadcastReceiver() {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
String action = intent.getAction();
|
||||||
|
if(BARCODE_ACTION.equals(action)){
|
||||||
|
String barcode = intent.getStringExtra(BARCODE_PARAM);
|
||||||
|
if(object == null){
|
||||||
|
Toast.makeText(context, "Object is null.", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(object instanceof EditText){
|
||||||
|
((EditText)object).setText(barcode);
|
||||||
|
}else if(object instanceof TextView){
|
||||||
|
((TextView)object).setText(barcode);
|
||||||
|
}else{
|
||||||
|
Toast.makeText(context, "Object is not fit.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static BroadcastReceiver getBarcodeReceiver(Object obj){
|
||||||
|
object = obj;
|
||||||
|
return barcodeReceiver;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IntentFilter getBarcodeFilter(){
|
||||||
|
return new IntentFilter(BARCODE_ACTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SysBarcodeUtil Instance = null;
|
||||||
|
private static Context mContext = null;
|
||||||
|
public static SysBarcodeUtil getInstance(Context context){
|
||||||
|
if(Instance == null){
|
||||||
|
Instance = new SysBarcodeUtil();
|
||||||
|
}
|
||||||
|
mContext = context;
|
||||||
|
return Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getSysBarcodeDefaultValue(){
|
||||||
|
StringBuilder strValues = new StringBuilder();
|
||||||
|
strValues.append(getLeftSwitchState(mContext)).append(",");
|
||||||
|
strValues.append(getLeftScanSelected(mContext)).append(",");
|
||||||
|
strValues.append(getRightSwitchState(mContext)).append(",");
|
||||||
|
strValues.append(getRightScanSelected(mContext)).append(",");
|
||||||
|
strValues.append(getBarcodeSendMode(mContext)).append(",");
|
||||||
|
strValues.append(getBarcodeNewParagraphMode(mContext));
|
||||||
|
|
||||||
|
return strValues.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param LeftSwitchState false : 0, true : 1
|
||||||
|
* @param LeftScanSelected 0 : hardware, 1 : camera
|
||||||
|
* @param RightSwitchState false : 0, true : 1
|
||||||
|
* @param RightScanSelected 0 : hardware, 1 : camera
|
||||||
|
* @param BarcodeSendMode 0 : fast, 1 : slow, 2 : broadcast
|
||||||
|
* @param BarcodeNewParagraphMode 0 : "Enter newline" ; 1 : "\n newline"; 2 : "no newline"
|
||||||
|
*/
|
||||||
|
public void setSysBarcodeValue(boolean LeftSwitchState,
|
||||||
|
int LeftScanSelected,
|
||||||
|
boolean RightSwitchState,
|
||||||
|
int RightScanSelected,
|
||||||
|
int BarcodeSendMode,
|
||||||
|
int BarcodeNewParagraphMode){
|
||||||
|
|
||||||
|
setLeftSwitchState(mContext, LeftSwitchState);
|
||||||
|
setLeftScanSelected(mContext, LeftScanSelected);
|
||||||
|
setRightSwitchState(mContext, RightSwitchState);
|
||||||
|
setRightScanSelected(mContext, RightScanSelected);
|
||||||
|
setBarcodeSendMode(mContext, BarcodeSendMode);
|
||||||
|
setBarcodeNewParagraphMode(mContext, BarcodeNewParagraphMode);
|
||||||
|
|
||||||
|
sendBroadcastSysBarcode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void sendBroadcastSysBarcode(){
|
||||||
|
Intent intent = new Intent("SysScanSettingChanged");
|
||||||
|
mContext.sendBroadcast(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get left scan key state 0 : close , 1 : open
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getLeftSwitchState(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_LEFT, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set left scan state
|
||||||
|
* @param flag false : 0, true : 1
|
||||||
|
*/
|
||||||
|
public static void setLeftSwitchState(Context context,boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_LEFT,flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get left scan selected(hardware or camera)
|
||||||
|
* @return 0 : hardware, 1 : camera
|
||||||
|
*/
|
||||||
|
public static int getLeftScanSelected(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_LEFT_SELECTED, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set left scan selected(hardware or camera)
|
||||||
|
* type 0 : hardware, 1 : camera
|
||||||
|
*/
|
||||||
|
public static void setLeftScanSelected(Context context,int type){
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_LEFT_SELECTED, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set right scan key state 0 : close , 1 : open
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getRightSwitchState(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_RIGHT, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get right scan state
|
||||||
|
* @param flag false : 0, true : 1
|
||||||
|
*/
|
||||||
|
public static void setRightSwitchState(Context context,boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_RIGHT,flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get right scan selected(hardware or camera)
|
||||||
|
* @return 0 : hardware, 1 : camera
|
||||||
|
*/
|
||||||
|
public static int getRightScanSelected(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_RIGHT_SELECTED, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set left scan selected(hardware or camera)
|
||||||
|
* type 0 : hardware, 1 : camera
|
||||||
|
*/
|
||||||
|
public static void setRightScanSelected(Context context,int type){
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_SETTINGS_RIGHT_SELECTED, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get send barcode type
|
||||||
|
* @return Mode 0 normal,2 repeat
|
||||||
|
*/
|
||||||
|
public static int getBarcodeType(Context context) {
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_TYPE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set send barcode interval
|
||||||
|
* @param Mode
|
||||||
|
*/
|
||||||
|
public static void setBarcodeInterval(Context context,int mode) {
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_INTERVAL_SETTINGS, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get send barcode interval
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static int getBarcodeInterval(Context context) {
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_INTERVAL_SETTINGS, 30000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set send barcode type
|
||||||
|
* @param Mode 0 normal,2 repeat
|
||||||
|
*/
|
||||||
|
public static void setBarcodeType(Context context,int mode) {
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_TYPE, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get send barcode mode
|
||||||
|
* @return Mode 0 is fast,1 is slow,2 is broadcast
|
||||||
|
*/
|
||||||
|
public static int getBarcodeSendMode(Context context) {
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_SENDMESSAGE_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set send barcode mode
|
||||||
|
* @param mode Send Mode 0 is fast,1 is slow,2 is broadcast
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSendMode(Context context,int mode) {
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_SENDMESSAGE_SETTINGS, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get newlins way mode
|
||||||
|
* @return 0 : "Enter newline" ; 1 : "\n newline"; 2 : "no newline"
|
||||||
|
*/
|
||||||
|
public static int getBarcodeNewParagraphMode(Context context) {
|
||||||
|
return Settings.System.getInt(context.getContentResolver(),
|
||||||
|
BARCODE_NEWPARAGRAPH_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set newlines way mode 0 : "Enter newline" ; 1 : "\n newline"; 2 : "no newline"
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
|
public static void setBarcodeNewParagraphMode(Context context,int mode) {
|
||||||
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
|
BARCODE_NEWPARAGRAPH_SETTINGS, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
284
app/src/main/java/com/cr5w/scan/aht70/ScanHelper.java
Normal file
284
app/src/main/java/com/cr5w/scan/aht70/ScanHelper.java
Normal file
@ -0,0 +1,284 @@
|
|||||||
|
package com.cr5w.scan.aht70;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.provider.Settings;
|
||||||
|
public class ScanHelper {
|
||||||
|
/** scan settings show 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SETTINGS_HAVED = "scan_settings_haved";
|
||||||
|
/** scan settings left enable 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SETTINGS_LEFT = "scan_settings_left";
|
||||||
|
/** scan settings right enable 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SETTINGS_RIGHT = "scan_settings_right";
|
||||||
|
/** scan models settings 0 : noraml; 1 : continue auto; 2 : continue manual*/
|
||||||
|
public static final String SCAN_MODLES_SETTINGS = "scan_models_settings";
|
||||||
|
/** scan continue delay settings 0 : none; 1 : 0.5s; 2 : 1s; 3 : custom*/
|
||||||
|
public static final String SCAN_CONTINUE_DELAY_SETTINGS = "scan_continue_delay_settings";
|
||||||
|
/** scan continue delay value */
|
||||||
|
public static final String SCAN_CONTINUE_DELAY_CUSTOM_VALUE = "scan_continue_delay_custom_value";
|
||||||
|
/** barcode receive model 0 : fast; 1 : slow; 2 : broadcast*/
|
||||||
|
public static final String BARCODE_RECEIVE_MODELS_SETTINGS = "barcode_receive_models_settings";
|
||||||
|
/** barcode separator model 0 : none; 1 : '\n'; 2 : Enter*/
|
||||||
|
public static final String BARCODE_SEPARATOR_SETTINGS = "barcode_separator_settings";
|
||||||
|
/** barcode separator prefix settings 0 : no; 1 : yes*/
|
||||||
|
public static final String BARCODE_SEPARATOR_PREFIX_SETTINGS = "barcode_separator_prefix_settings";
|
||||||
|
/** barcode separator prefix content */
|
||||||
|
public static final String BARCODE_SEPARATOR_PREFIX = "barcode_separator_prefix";
|
||||||
|
/** barcode separator suffix settings 0 : no; 1 : yes*/
|
||||||
|
public static final String BARCODE_SEPARATOR_SUFFIX_SETTINGS = "barcode_separator_suffix_settings";
|
||||||
|
/** barcode separator suffix content */
|
||||||
|
public static final String BARCODE_SEPARATOR_SUFFIX = "barcode_separator_suffix";
|
||||||
|
/** scan sound settings 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_SOUND_SETTINGS = "scan_sound_settings";
|
||||||
|
/** scan vibrate settings 0 : no; 1 : yes*/
|
||||||
|
public static final String SCAN_VIBRATE_SETTINGS = "scan_vibrate_settings";
|
||||||
|
|
||||||
|
public static boolean getScanToggleState(Context context) {
|
||||||
|
boolean flag = false;
|
||||||
|
boolean scan_left = Settings.System.getInt(context.getContentResolver(),
|
||||||
|
SCAN_SETTINGS_LEFT, 0) != 0;
|
||||||
|
boolean scan_right = Settings.System.getInt(context.getContentResolver(),
|
||||||
|
SCAN_SETTINGS_RIGHT, 0) != 0;
|
||||||
|
if(scan_left != false || scan_right != false){
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* scan left state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanSwitchLeft(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_SETTINGS_LEFT, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan left state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanSwitchLeft(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_SETTINGS_LEFT, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan right state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanSwitchRight(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_SETTINGS_RIGHT, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan right state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanSwitchRight(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_SETTINGS_RIGHT, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan model state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : normal; 1 : continue auto; 2 : continue manual
|
||||||
|
*/
|
||||||
|
public static int getScanModel(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_MODLES_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan model state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : normal; 1 : continue auto; 2 : continue manual
|
||||||
|
*/
|
||||||
|
public static void setScanModel(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_MODLES_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan delay state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : none; 1 : 0.5s; 2 : 1s;3 : custom delay
|
||||||
|
*/
|
||||||
|
public static int getScanDelaySetting(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_CONTINUE_DELAY_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan delay state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : none; 1 : 0.5s; 2 : 1s;3 : custom delay
|
||||||
|
*/
|
||||||
|
public static void setScanDelaySetting(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_CONTINUE_DELAY_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan delay value
|
||||||
|
* @param context
|
||||||
|
* @return delay
|
||||||
|
*/
|
||||||
|
public static float getScanDelay(Context context){
|
||||||
|
return Settings.System.getFloat(context.getContentResolver(), SCAN_CONTINUE_DELAY_CUSTOM_VALUE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan delay value
|
||||||
|
* @param context
|
||||||
|
* @param delay
|
||||||
|
*/
|
||||||
|
public static void setScanDelay(Context context, float delay){
|
||||||
|
Settings.System.putFloat(context.getContentResolver(), SCAN_CONTINUE_DELAY_CUSTOM_VALUE, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode receive model state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : fast; 1 : slow; 2 : broadcast
|
||||||
|
*/
|
||||||
|
public static int getBarcodeReceiveModel(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_RECEIVE_MODELS_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set broadcast receive model state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : fast; 1 : slow; 2 : broadcast
|
||||||
|
*/
|
||||||
|
public static void setBarcodeReceiveModel(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_RECEIVE_MODELS_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode separator state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : none; 1 : newline; 2 : enter
|
||||||
|
*/
|
||||||
|
public static int getBarcodeSeparator(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_SEPARATOR_SETTINGS, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode separator state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : none; 1 : newline; 2 : enter
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSeparator(Context context, int state){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_SEPARATOR_SETTINGS, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Prefix state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static boolean getBarcodePrefixState(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Prefix state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static void setBarcodePrefixState(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Prefix
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getBarcodePrefix(Context context){
|
||||||
|
return Settings.System.getString(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Prefix
|
||||||
|
* @param context
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public static void setBarcodePrefix(Context context, String prefix){
|
||||||
|
Settings.System.putString(context.getContentResolver(), BARCODE_SEPARATOR_PREFIX, prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Suffix state
|
||||||
|
* @param context
|
||||||
|
* @return 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static boolean getBarcodeSuffixState(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Suffix state
|
||||||
|
* @param context
|
||||||
|
* @param flag 0 : close; 1 : open
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSuffixState(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* barcode Suffix
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getBarcodeSuffix(Context context){
|
||||||
|
return Settings.System.getString(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set barcode Suffix
|
||||||
|
* @param context
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
public static void setBarcodeSuffix(Context context, String suffix){
|
||||||
|
Settings.System.putString(context.getContentResolver(), BARCODE_SEPARATOR_SUFFIX, suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan sound state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanSound(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_SOUND_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan sound state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanSound(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_SOUND_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* scan Vibrate state
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static boolean getScanVibrate(Context context){
|
||||||
|
return Settings.System.getInt(context.getContentResolver(), SCAN_VIBRATE_SETTINGS, 0) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set scan Vibrate state
|
||||||
|
* @param context
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static void setScanVibrate(Context context, boolean flag){
|
||||||
|
Settings.System.putInt(context.getContentResolver(), SCAN_VIBRATE_SETTINGS, flag ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
64
app/src/main/java/com/device/zk_r322a/ZKR322AControl.java
Normal file
64
app/src/main/java/com/device/zk_r322a/ZKR322AControl.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package com.device.zk_r322a;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import android.gpio.GpioJNI;
|
||||||
|
import android.util.Log;
|
||||||
|
import android_serialport_api.SerialPort;
|
||||||
|
|
||||||
|
public class ZKR322AControl {
|
||||||
|
private SerialPort mSerialPort = null;
|
||||||
|
private OutputStream mOutputStream = null;
|
||||||
|
private InputStream mInputStream = null;
|
||||||
|
//private boolean readVal = false;
|
||||||
|
|
||||||
|
public ZKR322AControl() throws SecurityException, IOException {
|
||||||
|
mSerialPort = new SerialPort(new File("/dev/ttyS4"), 115200, 8, 'N', 1,0);
|
||||||
|
mOutputStream = mSerialPort.getOutputStream();
|
||||||
|
mInputStream = mSerialPort.getInputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
if (mInputStream == null) return "";
|
||||||
|
try {
|
||||||
|
int size = mInputStream.available();
|
||||||
|
byte[] buffer = new byte[size];
|
||||||
|
size = mInputStream.read(buffer);
|
||||||
|
if (size > 0) {
|
||||||
|
return new String(buffer);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
//readVal = true;
|
||||||
|
// GpioJNI.gpio_switch_scan_trig(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
//readVal = false;
|
||||||
|
// GpioJNI.gpio_switch_scan_trig(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//public boolean isRead() {
|
||||||
|
// return readVal;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (mSerialPort != null) {
|
||||||
|
mSerialPort.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initScan() {
|
||||||
|
// GpioJNI.gpio_switch_scan_rf_ired(0);
|
||||||
|
// GpioJNI.gpio_switch_scan_power(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
2549
app/src/main/java/com/example/chaoran/DjActivity.java
Normal file
2549
app/src/main/java/com/example/chaoran/DjActivity.java
Normal file
File diff suppressed because it is too large
Load Diff
185
app/src/main/java/com/example/chaoran/DjtqActivity.java
Normal file
185
app/src/main/java/com/example/chaoran/DjtqActivity.java
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.kobjects.base64.Base64;
|
||||||
|
|
||||||
|
import com.chaoran.component.MyAdapter;
|
||||||
|
import com.chaoran.entiry.DataGrid;
|
||||||
|
import com.chaoran.entiry.Djselefa;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
import com.util.SqlUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
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.Button;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
75
app/src/main/java/com/example/chaoran/ExitThread.java
Normal file
75
app/src/main/java/com/example/chaoran/ExitThread.java
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
698
app/src/main/java/com/example/chaoran/MainActivity.java
Normal file
698
app/src/main/java/com/example/chaoran/MainActivity.java
Normal file
@ -0,0 +1,698 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
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.example.chaoran.R;
|
||||||
|
import com.honeywell.aidc.AidcManager;
|
||||||
|
import com.honeywell.aidc.AidcManager.CreatedCallback;
|
||||||
|
import com.honeywell.aidc.BarcodeReader;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.Dom4jUtil;
|
||||||
|
import com.util.InstallUtil;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
import com.util.SysUtil;
|
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.app.AlertDialog.Builder;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
System.out.println(info+"---------------------");
|
||||||
|
System.out.println(versionStr+"---------------------");
|
||||||
|
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;
|
||||||
|
// System.out.println(so.hasProperty("lgnname"));
|
||||||
|
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.username=
|
||||||
|
// so.getProperty("username").toString().trim();
|
||||||
|
SysData.is_lx = false;
|
||||||
|
login_end(user);
|
||||||
|
// SysData.jigid = user.getJigid();
|
||||||
|
// SysData.lgnname = user.getLgnname();
|
||||||
|
// SysData.userid = String.valueOf(user.getUserid());
|
||||||
|
// SysData.scale = MainActivity.this.getResources()
|
||||||
|
// .getDisplayMetrics().density + 1;
|
||||||
|
// SharedPreferences sp = MainActivity.this
|
||||||
|
// .getSharedPreferences("userTxt", MODE_PRIVATE);
|
||||||
|
// Editor editor = sp.edit();
|
||||||
|
// editor.putString("name", name.getText().toString()
|
||||||
|
// .trim());
|
||||||
|
// editor.putString("pwd",
|
||||||
|
// pwd.getText().toString().trim());
|
||||||
|
// editor.commit();
|
||||||
|
// Intent intent = new Intent();
|
||||||
|
// intent.putExtra("displaymode",
|
||||||
|
// user.getDisplaymode());
|
||||||
|
// intent.setClass(getApplicationContext(),
|
||||||
|
// DjActivity.class);
|
||||||
|
// startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 >= 200f ? 200f / MainActivity.this.getResources().getDisplayMetrics().densityDpi : 200f * 0.95f / MainActivity.this.getResources().getDisplayMetrics().densityDpi;
|
||||||
|
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());
|
||||||
|
System.out.println(SysData.exectime+"---------------------------------------SysData.exectime");
|
||||||
|
SharedPreferences sp = MainActivity.this.getSharedPreferences(
|
||||||
|
"userTxt", MODE_PRIVATE);
|
||||||
|
// Editor editor = sp.edit();
|
||||||
|
// editor.putString("name", name.getText().toString().trim());
|
||||||
|
// editor.putString("pwd", pwd.getText().toString().trim());
|
||||||
|
// editor.commit();
|
||||||
|
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 = Secure.getString(getContentResolver(),
|
||||||
|
// Secure.ANDROID_ID);
|
||||||
|
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";
|
||||||
|
// System.out
|
||||||
|
// .println(url
|
||||||
|
// +
|
||||||
|
// "--------------============================================");
|
||||||
|
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);
|
||||||
|
// intent.setClass(getApplicationContext(), BDMapActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
// startActivityForResult(intent,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onopentest(View v) {
|
||||||
|
DialogUtil.builder(this, "测试标题","测试内容!open" + v.getLeft(), 18);
|
||||||
|
// ScanManager sm = (ScanManager) getSystemService("olc_service_scan");
|
||||||
|
//
|
||||||
|
// sm.setScanSwitchLeft(false);
|
||||||
|
// sm.setScanSwitchRight(false);
|
||||||
|
// sm.setScanSwitchMiddle(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onclosetest(View v) {
|
||||||
|
DialogUtil.builder(this, "测试标题","测试内容!close" + v.getLeft(), 18);
|
||||||
|
// ScanManager sm = (ScanManager) getSystemService("olc_service_scan");
|
||||||
|
//
|
||||||
|
// sm.setScanSwitchLeft(true);
|
||||||
|
// sm.setScanSwitchRight(true);
|
||||||
|
// sm.setScanSwitchMiddle(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置按钮监听
|
||||||
|
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) {
|
||||||
|
// if (SysData.url == null) {
|
||||||
|
// DialogUtil.builder(this, "错误信息", "请检查网络!");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
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, "提示", "正在登录……");
|
||||||
|
}
|
||||||
|
|
||||||
|
// DialogUtil.setDialog(pd, "提示", "" + MainActivity.this.getResources().getDisplayMetrics().densityDpi);
|
||||||
|
new Thread(downloadRun).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void login(String name, String pwd) {
|
||||||
|
// WifiManager wifiManager=(WifiManager)
|
||||||
|
// this.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
// wifiManager.disconnect();
|
||||||
|
// wifiManager.reconnect();
|
||||||
|
try {
|
||||||
|
String url = SysData.url + "/webservice/ServiceInterface?wsdl";
|
||||||
|
// System.out
|
||||||
|
// .println(url
|
||||||
|
// + "--------------============================================");
|
||||||
|
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) {
|
||||||
|
// SoapObject result = (SoapObject) envelope.bodyIn;
|
||||||
|
// SoapObject soapChilds = (SoapObject) result.getProperty(0);
|
||||||
|
// System.out.println(soapChilds+"---"+soapChilds.getProperty("jigid"));
|
||||||
|
// System.out.println(soapChilds.getProperty("jigid"));
|
||||||
|
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";
|
||||||
|
System.out.println(path+"----------------------");
|
||||||
|
URL url = new URL(path);
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setConnectTimeout(5000);
|
||||||
|
if (conn.getResponseCode() == 200) {
|
||||||
|
is = conn.getInputStream();
|
||||||
|
// UpdataInfo info = getUpdataInfo(is);
|
||||||
|
Message msg = new Message();
|
||||||
|
msg.what = 1;
|
||||||
|
System.out.println(versionStr);
|
||||||
|
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();
|
||||||
|
// Intent intent = new Intent();
|
||||||
|
// intent.setClass(getApplicationContext(), DownDataActivity.class);
|
||||||
|
// startActivity(intent);
|
||||||
|
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) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
122
app/src/main/java/com/example/chaoran/MenuActivity.java
Normal file
122
app/src/main/java/com/example/chaoran/MenuActivity.java
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
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 org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
|
||||||
|
import com.chaoran.entiry.DanJuEntity;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.sys.SysData;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.SimpleAdapter;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
241
app/src/main/java/com/example/chaoran/NetWorkSet.java
Normal file
241
app/src/main/java/com/example/chaoran/NetWorkSet.java
Normal file
@ -0,0 +1,241 @@
|
|||||||
|
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 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
111
app/src/main/java/com/example/chaoran/ParamActivity.java
Normal file
111
app/src/main/java/com/example/chaoran/ParamActivity.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.chaoran.component.MyAdapter;
|
||||||
|
import com.chaoran.entiry.DataGrid;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.SimpleAdapter;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
190
app/src/main/java/com/example/chaoran/PdaRegActivity.java
Normal file
190
app/src/main/java/com/example/chaoran/PdaRegActivity.java
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
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.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.app.Activity;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
92
app/src/main/java/com/example/chaoran/RunSearchThread.java
Normal file
92
app/src/main/java/com/example/chaoran/RunSearchThread.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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.chaoran.entiry.DataGrid;
|
||||||
|
import com.chaoran.entiry.Sys_DanJuFormsOptions;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
|
||||||
|
/*运行检索方案线程*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
102
app/src/main/java/com/example/chaoran/RunYmupThread.java
Normal file
102
app/src/main/java/com/example/chaoran/RunYmupThread.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.ksoap2.SoapEnvelope;
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
import org.ksoap2.serialization.SoapSerializationEnvelope;
|
||||||
|
import org.ksoap2.transport.HttpTransportSE;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.DataGrid;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.IoUtil;
|
||||||
|
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
app/src/main/java/com/example/chaoran/SearchThread.java
Normal file
66
app/src/main/java/com/example/chaoran/SearchThread.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
92
app/src/main/java/com/example/chaoran/UpdatePwdActivity.java
Normal file
92
app/src/main/java/com/example/chaoran/UpdatePwdActivity.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package com.example.chaoran;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.ksoap2.serialization.SoapObject;
|
||||||
|
|
||||||
|
import com.chaoran.entiry.UpdataInfo;
|
||||||
|
import com.chaoran.thread.UpdatePwdThread;
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
import com.sys.SysData;
|
||||||
|
import com.util.DialogUtil;
|
||||||
|
import com.util.InstallUtil;
|
||||||
|
|
||||||
|
import android.R.color;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
109
app/src/main/java/com/jiebao/h518/scan/BeepManager.java
Normal file
109
app/src/main/java/com/jiebao/h518/scan/BeepManager.java
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.media.AudioManager;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
|
import android.os.Vibrator;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.example.chaoran.R;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public final class BeepManager {
|
||||||
|
|
||||||
|
private static final String TAG = BeepManager.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final float BEEP_VOLUME = 0.3f;
|
||||||
|
private static final long VIBRATE_DURATION = 200L;
|
||||||
|
|
||||||
|
private final Activity activity;
|
||||||
|
private MediaPlayer mediaPlayer;
|
||||||
|
private boolean playBeep = true;
|
||||||
|
private boolean vibrate = false;
|
||||||
|
|
||||||
|
public BeepManager(Activity activity) {
|
||||||
|
this.activity = activity;
|
||||||
|
initMediaPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPlayBeep() {
|
||||||
|
return playBeep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayBeep(boolean playBeep) {
|
||||||
|
this.playBeep = playBeep;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVibrate() {
|
||||||
|
return vibrate;
|
||||||
|
}
|
||||||
|
public void turnOffV(){
|
||||||
|
mediaPlayer.setVolume(0, 0);
|
||||||
|
}
|
||||||
|
public void turnOnV(){
|
||||||
|
mediaPlayer.setVolume(BEEP_VOLUME, BEEP_VOLUME);
|
||||||
|
}
|
||||||
|
public void setVibrate(boolean vibrate) {
|
||||||
|
this.vibrate = vibrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initMediaPlayer() {
|
||||||
|
activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
mediaPlayer = buildMediaPlayer(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playBeepSoundAndVibrate() {
|
||||||
|
if (playBeep && mediaPlayer != null) {
|
||||||
|
|
||||||
|
mediaPlayer.start();
|
||||||
|
}
|
||||||
|
if (vibrate) {
|
||||||
|
Vibrator vibrator = (Vibrator) activity
|
||||||
|
.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
|
vibrator.vibrate(VIBRATE_DURATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void release(){
|
||||||
|
if(mediaPlayer != null)
|
||||||
|
mediaPlayer.stop();
|
||||||
|
mediaPlayer.release();
|
||||||
|
mediaPlayer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MediaPlayer buildMediaPlayer(Context activity) {
|
||||||
|
|
||||||
|
|
||||||
|
MediaPlayer mediaPlayer = new MediaPlayer();
|
||||||
|
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
|
mediaPlayer
|
||||||
|
.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||||
|
public void onCompletion(MediaPlayer player) {
|
||||||
|
player.seekTo(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AssetFileDescriptor file = activity.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 ioe) {
|
||||||
|
Log.w(TAG, ioe);
|
||||||
|
mediaPlayer = null;
|
||||||
|
}
|
||||||
|
return mediaPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,290 @@
|
|||||||
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
|
||||||
|
import com.jiebao.h518.scan.BeepManager;
|
||||||
|
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 interface DiemensionalScanListener{
|
||||||
|
public void onDiemensionalScanComplete(String result,String error);
|
||||||
|
}
|
||||||
|
static final int STATE_IDLE = 0;
|
||||||
|
static final int STATE_DECODE = 1;
|
||||||
|
static final int STATE_HANDSFREE = 2;
|
||||||
|
//static final int STATE_PREVIEW = 3; // snapshot preview mode
|
||||||
|
//static final int STATE_SNAPSHOT = 4;
|
||||||
|
//static final int STATE_VIDEO = 5;
|
||||||
|
private BarCodeReader bcr;
|
||||||
|
// private SqliteService sqlite;
|
||||||
|
private Activity context;
|
||||||
|
//private ToneGenerator tg = null;
|
||||||
|
//private SoundPool soundpool = null;
|
||||||
|
private int trigMode = BarCodeReader.ParamVal.LEVEL;
|
||||||
|
private int state = STATE_IDLE;
|
||||||
|
private int soundid;
|
||||||
|
private BeepManager beepManager;
|
||||||
|
private DiemensionalScanListener scanListener;
|
||||||
|
private static DiemensionalCodeControler controler;
|
||||||
|
static {
|
||||||
|
System.loadLibrary("IAL");
|
||||||
|
System.loadLibrary("SDL");
|
||||||
|
System.loadLibrary("barcodereader");
|
||||||
|
}
|
||||||
|
|
||||||
|
private DiemensionalCodeControler(Activity context,DiemensionalScanListener scanListener) {
|
||||||
|
open();
|
||||||
|
this.context=context;
|
||||||
|
this.scanListener=scanListener;
|
||||||
|
// sqlite = new SqliteService(context);
|
||||||
|
// if(sqlite.getCount() == 0){
|
||||||
|
// sqlite.initCodeTpye();
|
||||||
|
// }
|
||||||
|
beepManager=new BeepManager(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 在程序退出时调用
|
||||||
|
*/
|
||||||
|
public static void setDiemensionalConNull(){
|
||||||
|
if(controler!=null){
|
||||||
|
controler.setIdle();
|
||||||
|
controler.release();
|
||||||
|
controler=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static DiemensionalCodeControler getCodeControler(Activity context,DiemensionalScanListener scanListener) {
|
||||||
|
if (controler == null) {
|
||||||
|
controler = new DiemensionalCodeControler(context,scanListener);
|
||||||
|
}
|
||||||
|
return controler;
|
||||||
|
}
|
||||||
|
private void beep() {
|
||||||
|
playSound();
|
||||||
|
}
|
||||||
|
private synchronized void playSound() {
|
||||||
|
|
||||||
|
beepManager.playBeepSoundAndVibrate();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
public void open() {
|
||||||
|
|
||||||
|
|
||||||
|
if (bcr == null) {
|
||||||
|
try {
|
||||||
|
bcr = BarCodeReader.open(1);
|
||||||
|
if(bcr!=null)
|
||||||
|
bcr.setDecodeCallback(this);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new RuntimeException("device open failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void release() {
|
||||||
|
try {
|
||||||
|
if(beepManager!=null)beepManager.release();
|
||||||
|
beepManager=null;
|
||||||
|
if (bcr != null)
|
||||||
|
bcr.release();
|
||||||
|
bcr = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private int doSetParam(BarCodeReader bcr,int num, int val) {
|
||||||
|
String s = "";
|
||||||
|
|
||||||
|
int ret = bcr.setParameter(num, val);
|
||||||
|
if (ret != BarCodeReader.BCR_ERROR) {
|
||||||
|
if (num == BarCodeReader.ParamNum.PRIM_TRIG_MODE) {
|
||||||
|
trigMode = val;
|
||||||
|
if (val == BarCodeReader.ParamVal.HANDSFREE) {
|
||||||
|
s = "HandsFree";
|
||||||
|
} else if (val == BarCodeReader.ParamVal.AUTO_AIM) {
|
||||||
|
s = "AutoAim";
|
||||||
|
ret = bcr
|
||||||
|
.startHandsFreeDecode(BarCodeReader.ParamVal.AUTO_AIM);
|
||||||
|
if (ret != BarCodeReader.BCR_SUCCESS) {
|
||||||
|
//dspErr("AUtoAIm start FAILED");
|
||||||
|
}
|
||||||
|
} else if (val == BarCodeReader.ParamVal.LEVEL) {
|
||||||
|
s = "Level";
|
||||||
|
}
|
||||||
|
} else if (num == BarCodeReader.ParamNum.IMG_VIDEOVF) {
|
||||||
|
//if (snapPreview = (val == 1))
|
||||||
|
// s = "SnapPreview";
|
||||||
|
}
|
||||||
|
} else{
|
||||||
|
s = " FAILED (" + ret + ")";
|
||||||
|
}
|
||||||
|
//dspStat(": Set #" + num + " to " + val + " " + s);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
private int setIdle() {
|
||||||
|
int prevState = state;
|
||||||
|
int ret = prevState; // for states taking time to chg/end
|
||||||
|
|
||||||
|
state = STATE_IDLE;
|
||||||
|
switch (prevState) {
|
||||||
|
case STATE_HANDSFREE: //当前状态为自动扫描
|
||||||
|
resetTrigger(); //取消自动扫描
|
||||||
|
break;
|
||||||
|
case STATE_DECODE: //当前状态了正在扫描
|
||||||
|
//dspStat("decode stopped");
|
||||||
|
bcr.stopDecode(); //取消扫描
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ret = STATE_IDLE;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
private void resetTrigger() {
|
||||||
|
doSetParam(bcr,BarCodeReader.ParamNum.PRIM_TRIG_MODE,
|
||||||
|
BarCodeReader.ParamVal.LEVEL);
|
||||||
|
trigMode = BarCodeReader.ParamVal.LEVEL;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 启动连续扫描
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean doHandsFree(){
|
||||||
|
System.out.println("长按----------------------------------------");
|
||||||
|
if (setIdle() != STATE_IDLE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int ret = bcr.startHandsFreeDecode(BarCodeReader.ParamVal.HANDSFREE);
|
||||||
|
System.out.println("长按----------------------------------------");
|
||||||
|
//判断返回值ret 若不等于0 启动连续扫描失败
|
||||||
|
if (ret != BarCodeReader.BCR_SUCCESS){
|
||||||
|
return false;
|
||||||
|
//dspStat("startHandFree FAILED");
|
||||||
|
}else {
|
||||||
|
trigMode = BarCodeReader.ParamVal.HANDSFREE;
|
||||||
|
state = STATE_HANDSFREE; //状态为连续扫描
|
||||||
|
return true;
|
||||||
|
//dspStat("HandsFree decoding");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private boolean doDecode() {
|
||||||
|
if (setIdle() != STATE_IDLE)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
state = STATE_DECODE;
|
||||||
|
//dspData("");
|
||||||
|
// dspStat(R.string.decoding);
|
||||||
|
bcr.startDecode(); // start decode (callback gets results)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 启动一次性扫描
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean start(){
|
||||||
|
doSetParam(bcr,298, 1);
|
||||||
|
doSetParam(bcr,306, 1);
|
||||||
|
return doDecode();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 停止扫描,适应一次或连续
|
||||||
|
*/
|
||||||
|
public void stop(){
|
||||||
|
if(state==STATE_DECODE)bcr.stopDecode();
|
||||||
|
if(state==STATE_HANDSFREE)resetTrigger();
|
||||||
|
state=STATE_IDLE;
|
||||||
|
}
|
||||||
|
public void onDecodeComplete(int symbology, int length, byte[] data,
|
||||||
|
BarCodeReader reader) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if(state == STATE_DECODE){
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
if (length > 0) {
|
||||||
|
|
||||||
|
//if (isHandsFree() == false && isAutoAim() == false)
|
||||||
|
//bcr.stopDecode();
|
||||||
|
|
||||||
|
|
||||||
|
if (symbology == 0x99) // type 99?
|
||||||
|
{
|
||||||
|
symbology = data[0];
|
||||||
|
int n = data[1];
|
||||||
|
int s = 2;
|
||||||
|
int d = 0;
|
||||||
|
int len = 0;
|
||||||
|
byte d99[] = new byte[data.length];
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
s += 2;
|
||||||
|
len = data[s++];
|
||||||
|
System.arraycopy(data, s, d99, d, len);
|
||||||
|
s += len;
|
||||||
|
d += len;
|
||||||
|
}
|
||||||
|
d99[d] = 0;
|
||||||
|
data = d99;
|
||||||
|
}
|
||||||
|
// String codeType = sqlite.searchCode(symbology);
|
||||||
|
// if(codeType == null || codeType.equals("") ){//未知条码 类型
|
||||||
|
// //dspStat("[" + decodes + "] type: " + "unknown type" + " len: " + length);
|
||||||
|
// scanListener.onDiemensionalScanComplete(null, "未知条码类型");
|
||||||
|
// return;
|
||||||
|
// }else{
|
||||||
|
// //dspStat("[" + decodes + "] type: " + codeType + " len: " + length);
|
||||||
|
// }
|
||||||
|
// dspData(byte2hex(data));
|
||||||
|
try{
|
||||||
|
String Result = new String(data,"GB2312");
|
||||||
|
scanListener.onDiemensionalScanComplete(Result, null);
|
||||||
|
//dspData(isSettingCode(SDLguiActivity.this,Result));
|
||||||
|
|
||||||
|
}catch(Exception e){
|
||||||
|
Log.i("info", "excption == "+e.getMessage());
|
||||||
|
scanListener.onDiemensionalScanComplete(null, "转码错误");
|
||||||
|
}
|
||||||
|
beep();
|
||||||
|
} else // no-decode
|
||||||
|
{
|
||||||
|
//dspData("");
|
||||||
|
//根据length来判断当前状态
|
||||||
|
switch (length) {
|
||||||
|
|
||||||
|
case BarCodeReader.DECODE_STATUS_TIMEOUT: //解码超时, 在指定的时间内没有扫到码
|
||||||
|
//dspStat("decode timed out");
|
||||||
|
scanListener.onDiemensionalScanComplete(null, "解码超时");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BarCodeReader.DECODE_STATUS_CANCELED: //取消扫描
|
||||||
|
//dspStat("decode cancelled");
|
||||||
|
scanListener.onDiemensionalScanComplete(null, "取消扫描");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BarCodeReader.DECODE_STATUS_ERROR: //扫描出错
|
||||||
|
default:
|
||||||
|
// dspStat("decode failed");
|
||||||
|
scanListener.onDiemensionalScanComplete(null, "扫描出错");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEvent(int event, int info, byte[] data, BarCodeReader reader) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
90
app/src/main/java/com/jiebao/h518/scan/NewScanControler.java
Normal file
90
app/src/main/java/com/jiebao/h518/scan/NewScanControler.java
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
import android.gpio.GpioJNI;
|
||||||
|
import android.util.Log;
|
||||||
|
import android_serialport_api.SerialPort;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
public class NewScanControler {
|
||||||
|
protected SerialPort mSerialPort;
|
||||||
|
protected OutputStream mOutputStream;
|
||||||
|
private InputStream mInputStream;
|
||||||
|
|
||||||
|
public NewScanControler() throws SecurityException, IOException {
|
||||||
|
mSerialPort = new SerialPort(new File("/dev/ttySAC1"), 9600, 8, 'N', 1,
|
||||||
|
0);
|
||||||
|
mOutputStream = mSerialPort.getOutputStream();
|
||||||
|
mInputStream = mSerialPort.getInputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
|
||||||
|
mSerialPort.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
int size;
|
||||||
|
try {
|
||||||
|
if (mInputStream == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
int cout = mInputStream.available();
|
||||||
|
byte[] buffer1 = new byte[cout];
|
||||||
|
|
||||||
|
cout = 0;
|
||||||
|
buffer1 = null;
|
||||||
|
|
||||||
|
cout = mInputStream.available();
|
||||||
|
buffer1 = new byte[cout];
|
||||||
|
|
||||||
|
size = mInputStream.read(buffer1);
|
||||||
|
if (size > 0) {
|
||||||
|
String data = new String(buffer1);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initScan() {
|
||||||
|
GpioJNI.gpio_switch_scan_rf_ired(0);
|
||||||
|
GpioJNI.gpio_switch_scan_power(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopScan() {
|
||||||
|
GpioJNI.gpio_switch_scan_trig(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scanOnce() {
|
||||||
|
int triggerVal = GpioJNI.gpio_get_scan_trig();
|
||||||
|
if (triggerVal == 1) {
|
||||||
|
GpioJNI.gpio_switch_scan_trig(0);
|
||||||
|
} else {
|
||||||
|
// checkIsSleep();
|
||||||
|
GpioJNI.gpio_switch_scan_trig(1);
|
||||||
|
}
|
||||||
|
// Log.i("info", "-----");
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkIsSleep() {
|
||||||
|
int triggerVal = GpioJNI.gpio_get_scan_trig();
|
||||||
|
if (triggerVal == 1) {
|
||||||
|
Log.i("info", "+++++");
|
||||||
|
GpioJNI.gpio_switch_scan_trig(0);
|
||||||
|
try {
|
||||||
|
Thread.sleep(200);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
144
app/src/main/java/com/jiebao/h518/scan/SqliteConnect.java
Normal file
144
app/src/main/java/com/jiebao/h518/scan/SqliteConnect.java
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
|
|
||||||
|
public class SqliteConnect extends SQLiteOpenHelper {
|
||||||
|
private static final String DATABASENAME = "h518.db";
|
||||||
|
private static final int DATABASEVERSION = 1;
|
||||||
|
|
||||||
|
public static final String TN_Account = "acount";
|
||||||
|
public static final String Account_C_Name = "name";
|
||||||
|
public static final String Account_C_Pwd = "pwd";
|
||||||
|
|
||||||
|
public static final String TN_Goods = "goods";
|
||||||
|
public static final String Goods_C_BarCode = "barcode";
|
||||||
|
public static final String Goods_C_Id = "goods_Id";
|
||||||
|
public static final String Goods_C_Name = "name";
|
||||||
|
public static final String Goods_C_Name_PinYin = "name_pinyin";
|
||||||
|
public static final String Goods_C_ProducingArea = "producing_area";
|
||||||
|
public static final String Goods_C_Standard = "standard";
|
||||||
|
public static final String Goods_C_Unit = "unit";
|
||||||
|
public static final String Goods_C_BroughtPrice = "brought_price";
|
||||||
|
public static final String Goods_C_SellPrice = "sell_price";
|
||||||
|
|
||||||
|
public static final String TN_Order = "order_msg";
|
||||||
|
public static final String Order_C_Id = "order_id";
|
||||||
|
public static final String Order_C_Barcode = "barcode";
|
||||||
|
public static final String Order_C_per_price = "per_price";
|
||||||
|
public static final String Order_C_total_price = "total_price";
|
||||||
|
public static final String Order_C_remark = "remark";
|
||||||
|
public static final String Order_C_Count = "count";
|
||||||
|
|
||||||
|
public static final String TN_Order_Details = "order_details";
|
||||||
|
public static final String OrderD_C_Id = "order_id";
|
||||||
|
public static final String OrderD_C_OrderDate = "order_date";
|
||||||
|
public static final String OrderD_C_Operator = "operator";
|
||||||
|
public static final String OrderD_C_remark = "remark";
|
||||||
|
public static final String OrderD_C_total_price = "total_price";
|
||||||
|
|
||||||
|
public static final String TN_PSOrder = "psorder_msg";
|
||||||
|
public static final String PSOrder_C_Id = "order_id";
|
||||||
|
public static final String PSOrder_C_date = "order_date";
|
||||||
|
public static final String PSOrder_C_shop_Id = "shop_id";
|
||||||
|
public static final String PSOrder_C_remark = "remark";
|
||||||
|
|
||||||
|
public static final String TN_PSOrderGoods = "psordergoods_msg";
|
||||||
|
public static final String PSOrderGoods_c_Id = "order_id";
|
||||||
|
public static final String PSOrderGoods_c_Barcode = "barcode";
|
||||||
|
public static final String PSOrderGoods_c_count = "count";
|
||||||
|
public static final String PSOrderGoods_c_per_price = "per_price";
|
||||||
|
public static final String PSOrderGoods_c_total_price = "total_price";
|
||||||
|
public static final String PSOrderGoods_c_remark = "remark";
|
||||||
|
|
||||||
|
public static final String TN_GoodsSold = "goods_sold";
|
||||||
|
public static final String GoodsSold_C_Order_Id = "order_id";
|
||||||
|
public static final String GoodsSold_C_Goods_Id = "goods_id";
|
||||||
|
public static final String GoodsSold_C_Barcode = "barcode";
|
||||||
|
public static final String GoodsSold_C_Count = "count";
|
||||||
|
public static final String GoodsSold_C_totalPrice = "total_price";
|
||||||
|
|
||||||
|
public SqliteConnect(Context context) {
|
||||||
|
super(context, DATABASENAME, null, DATABASEVERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(SQLiteDatabase db) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
db.execSQL("CREATE TABLE if not exists " + TN_Account
|
||||||
|
+ "(id integer primary key autoincrement," + ""
|
||||||
|
+ Account_C_Name + " text," + Account_C_Pwd + " text)");
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(Account_C_Name, "5180000010");
|
||||||
|
values.put(Account_C_Pwd, "123");
|
||||||
|
db.insert(TN_Account, null, values);
|
||||||
|
|
||||||
|
db.execSQL("create table if not exists " + TN_Goods
|
||||||
|
+ "(id integer primary key autoincrement," + Goods_C_BarCode
|
||||||
|
+ " text," + Goods_C_BroughtPrice + " text," + Goods_C_Id
|
||||||
|
+ " text," + Goods_C_Name + " text," + Goods_C_Name_PinYin
|
||||||
|
+ " text," + Goods_C_ProducingArea + " text,"
|
||||||
|
+ Goods_C_SellPrice + " double," + Goods_C_Standard + " text,"
|
||||||
|
+ Goods_C_Unit + ")");
|
||||||
|
db.execSQL("CREATE TABLE if not exists " + TN_Order
|
||||||
|
+ "(id integer primary key autoincrement," + "" + Order_C_Barcode
|
||||||
|
+ " text," + Order_C_Count + " long," + Order_C_Id + " text,"
|
||||||
|
+ Order_C_per_price + " double," + Order_C_remark + " text,"
|
||||||
|
+ Order_C_total_price + " double)");
|
||||||
|
db.execSQL("create table if not exists " + TN_Order_Details
|
||||||
|
+ "(id integer primary key autoincrement," + OrderD_C_Id
|
||||||
|
+ " text," + OrderD_C_Operator + " text," + OrderD_C_OrderDate
|
||||||
|
+ " datetime," + OrderD_C_remark + " text,"
|
||||||
|
+ OrderD_C_total_price + " double)");
|
||||||
|
db.execSQL("create table if not exists " + TN_PSOrder + "("
|
||||||
|
+ PSOrder_C_date + " datetime," + PSOrder_C_Id + " text,"
|
||||||
|
+ PSOrder_C_remark + " text," + PSOrder_C_shop_Id + " text)");
|
||||||
|
db.execSQL("create table if not exists " + TN_PSOrderGoods + "("
|
||||||
|
+ PSOrderGoods_c_count + " long," + PSOrderGoods_c_Barcode
|
||||||
|
+ " text," + PSOrderGoods_c_Id + " text,"
|
||||||
|
+ PSOrderGoods_c_per_price + " double," + PSOrderGoods_c_remark
|
||||||
|
+ " text," + PSOrderGoods_c_total_price + " double)");
|
||||||
|
db.execSQL("create table if not exists " + TN_GoodsSold + "("
|
||||||
|
+ GoodsSold_C_Barcode + " text," + GoodsSold_C_Count + " long,"
|
||||||
|
+ GoodsSold_C_Goods_Id + " text," + GoodsSold_C_Order_Id
|
||||||
|
+ " text," + GoodsSold_C_totalPrice + " double)");
|
||||||
|
|
||||||
|
db.execSQL("CREATE TABLE if not exists CodeType(id integer primary key autoincrement," +
|
||||||
|
"type_name text,type_id integer)" );
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TN_Account);
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TN_Goods);
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TN_Order);
|
||||||
|
db.execSQL("drop table if exists " + TN_Order_Details);
|
||||||
|
db.execSQL("drop table if exists " + TN_PSOrder);
|
||||||
|
db.execSQL("drop table if exists " + TN_PSOrderGoods);
|
||||||
|
db.execSQL("drop table if exists " + TN_GoodsSold);
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS CodeType");
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearAllMsgButAccount(SQLiteDatabase db) {
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TN_Goods);
|
||||||
|
db.execSQL("DROP TABLE IF EXISTS " + TN_Order);
|
||||||
|
db.execSQL("drop table if exists " + TN_Order_Details);
|
||||||
|
db.execSQL("drop table if exists " + TN_PSOrder);
|
||||||
|
db.execSQL("drop table if exists " + TN_PSOrderGoods);
|
||||||
|
db.execSQL("drop table if exists " + TN_GoodsSold);
|
||||||
|
onCreate(db);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
276
app/src/main/java/com/jiebao/h518/scan/SqliteService.java
Normal file
276
app/src/main/java/com/jiebao/h518/scan/SqliteService.java
Normal file
@ -0,0 +1,276 @@
|
|||||||
|
package com.jiebao.h518.scan;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class SqliteService {
|
||||||
|
private SqliteConnect sqlCon;
|
||||||
|
|
||||||
|
public SqliteService(Context context){
|
||||||
|
if(this.sqlCon == null){
|
||||||
|
sqlCon = new SqliteConnect(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized String searchCode(int codeID){
|
||||||
|
SQLiteDatabase db = sqlCon.getReadableDatabase();
|
||||||
|
String sql = "select * from CodeType where type_id = "+codeID;
|
||||||
|
Cursor cursor = db.rawQuery(sql,new String[]{});
|
||||||
|
String typeName = "";
|
||||||
|
while(cursor.moveToNext()){
|
||||||
|
typeName = cursor.getString(1);
|
||||||
|
}
|
||||||
|
db.close();
|
||||||
|
return typeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public synchronized void initCodeTpye()
|
||||||
|
{
|
||||||
|
SQLiteDatabase db = sqlCon.getWritableDatabase();
|
||||||
|
db.beginTransaction();
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 39',1)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Codabar',2)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 128',3)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Discrete (Standard) 2 of 5',4)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('IATA',5)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Interleaved 2 of 5',6)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 93',7)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-A',8)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-E0',9)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-8',10)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-13',11)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 11',12)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 49',13)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('MSI',14)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-128',15)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-E1',16)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('PDF-417',17)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 16K',18)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 39 Full ASCII',19)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-D',20)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 39 Trioptic',21)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Bookland',22)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Coupon Code',23)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('NW-7',24)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('ISBT-128',25)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Micro PDF',26)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('DataMatrix',27)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('QR Code',28)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Micro PDF CCA',29)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('PostNet US',30)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Planet Code',31)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Code 32',32)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('ISBT-128 Con',33)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Japan Postal',34)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Australian Postal',35)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Dutch Postal',36)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('MaxiCode',37)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Canadian Postal',38)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UK Postal',39)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Macro PDF',40)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Macro QR',41)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Micro QR',44)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Aztec',45)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Aztec Rune',46)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('GS1 DataBar-14',48)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('GS1 DataBar Limited',49)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('GS1 DataBar Expanded',50)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('USPS 4CB',52)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPU 4State',53)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('ISSN',54)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Scanlet',55)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CueCode',56)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Matrix 2 of 5',57)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-A + 2 Supplemental',72)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-E0 + 2 Supplemental',73)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-8 + 2 Supplemental',74)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-13 + 2 Supplemental',75)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-E1 + 2 Supplemental',80)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA EAN-13',82)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA EAN-8',83)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA GS1 DataBar Expanded',84)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA GS1 DataBar Limited',85)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA GS1 DataBar-14',86)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA UPC-A',87)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCA UPC-E',88)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCC EAN-128',89)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('TLC-39',90)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB EAN-128',97)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB EAN-13',98)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB EAN-8',99)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB GS1 DataBar Expanded',100)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB GS1 DataBar Limited',101)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB GS1 DataBar-14',102)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB UPC-A',103)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('CCB UPC-E',104)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Signature Capture',105)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Chinese 2 of 5',114)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Korean 3 of 5',115)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-A + 5 supplemental',136)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-E0 + 5 supplemental',137)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-8 + 5 supplemental',138)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('EAN-13 + 5 supplemental',139)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('UPC-E1 + 5 Supplemental',144)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('Macro Micro PDF',154)");
|
||||||
|
db.execSQL("insert into CodeType(type_name,type_id)"
|
||||||
|
+"values('GS1 Databar Coupon',180)");
|
||||||
|
db.setTransactionSuccessful();
|
||||||
|
db.endTransaction();
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
// public synchronized void saveResult(List<ScanUntil> scanUntil){
|
||||||
|
// SQLiteDatabase db = sqlCon.getWritableDatabase();
|
||||||
|
//
|
||||||
|
// for(int i=0;i<scanUntil.size();i++){
|
||||||
|
// db.execSQL("insert into scan_result(result,date)" +
|
||||||
|
// "values(??)",new Object[]{scanUntil.get(i).getScanResult(),scanUntil.get(i).getScanDate()});
|
||||||
|
// }
|
||||||
|
// db.close();
|
||||||
|
// }
|
||||||
|
// public synchronized List<ScanUntil> readResult(){
|
||||||
|
// SQLiteDatabase db = sqlCon.getReadableDatabase();
|
||||||
|
// Cursor cur = db.rawQuery("select * from scan_result order by id desc", new String[]{});
|
||||||
|
// List<ScanUntil> list = new ArrayList<ScanUntil>();
|
||||||
|
// ScanUntil until;
|
||||||
|
// while(cur.moveToNext()){
|
||||||
|
// until = new ScanUntil();
|
||||||
|
// until.setScanResult(cur.getString(1));
|
||||||
|
// until.setScanDate(cur.getString(2));
|
||||||
|
// list.add(until);
|
||||||
|
// }
|
||||||
|
// db.close();
|
||||||
|
// return list;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public synchronized int getCount(){
|
||||||
|
SQLiteDatabase db = sqlCon.getReadableDatabase();
|
||||||
|
String sql = "select count(id) from CodeType ";
|
||||||
|
Cursor cur = db.rawQuery(sql, new String[]{});
|
||||||
|
|
||||||
|
int sum = 0;
|
||||||
|
while (cur.moveToNext()) {
|
||||||
|
sum = cur.getInt(0);
|
||||||
|
}
|
||||||
|
Log.i("info", "sum == "+sum);
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param pagesize 每页的记录数
|
||||||
|
* @param count 总记录数
|
||||||
|
* @return 总页<E680BB>?
|
||||||
|
*/
|
||||||
|
public static int computeTotalPagesBasedOnCount(int pagesize, int count) {
|
||||||
|
if (pagesize <= 0 || count <= 0)
|
||||||
|
return -1; // <20>?<3F><>数不可能小于或等<E68896>? 或<>?总数也不能小于或者等<E88085>?0,否则返<E58899>?1
|
||||||
|
int x = count / pagesize + 1; // 不满<E4B88D>?<3F><>,也进位
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// public synchronized List<ScanUntil> fenye(int i){
|
||||||
|
// SQLiteDatabase db = sqlCon.getReadableDatabase();
|
||||||
|
// String sql = "select * from scan_result order by id desc limit 100 offset "+ i*100;
|
||||||
|
// Cursor cur = db.rawQuery(sql, new String[]{});
|
||||||
|
// List<ScanUntil> list = new ArrayList<ScanUntil>();
|
||||||
|
// ScanUntil until;
|
||||||
|
// while(cur.moveToNext()){
|
||||||
|
// until = new ScanUntil();
|
||||||
|
// until.setScanResult(cur.getString(1));
|
||||||
|
// until.setScanDate(cur.getString(2));
|
||||||
|
// list.add(until);
|
||||||
|
// }
|
||||||
|
// db.close();
|
||||||
|
// Log.i("info", "分页数量 == "+list.size());
|
||||||
|
// return list;
|
||||||
|
// }
|
||||||
|
}
|
||||||
64
app/src/main/java/com/lianxin/nr510/Engine.java
Normal file
64
app/src/main/java/com/lianxin/nr510/Engine.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package com.lianxin.nr510;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
|
||||||
|
public class Engine {
|
||||||
|
|
||||||
|
private NR510Running runEngine = null;
|
||||||
|
|
||||||
|
public void start(Context context) {
|
||||||
|
if (runEngine == null) {
|
||||||
|
runEngine = new NR510Running(context);
|
||||||
|
new Thread(runEngine).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(Context context) {
|
||||||
|
if (runEngine != null) {
|
||||||
|
Intent intent = new Intent("com.lachesis.barcode.STOP_BARCODE");
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
runEngine.closeRunning();
|
||||||
|
runEngine = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NR510Running implements Runnable {
|
||||||
|
|
||||||
|
private boolean scanRunning = true;
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
public NR510Running(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeRunning() {
|
||||||
|
scanRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while (true) {
|
||||||
|
if (scanRunning) {
|
||||||
|
Intent intent = new Intent("com.lachesis.barcode.START_BARCODE");
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
intent = new Intent("com.lachesis.barcode.STOP_BARCODE");
|
||||||
|
context.sendBroadcast(intent);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mining.app.zxing.camera;
|
||||||
|
|
||||||
|
import android.hardware.Camera;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
final class AutoFocusCallback implements Camera.AutoFocusCallback {
|
||||||
|
|
||||||
|
private static final String TAG = AutoFocusCallback.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final long AUTOFOCUS_INTERVAL_MS = 1500L;
|
||||||
|
|
||||||
|
private Handler autoFocusHandler;
|
||||||
|
private int autoFocusMessage;
|
||||||
|
|
||||||
|
void setHandler(Handler autoFocusHandler, int autoFocusMessage) {
|
||||||
|
this.autoFocusHandler = autoFocusHandler;
|
||||||
|
this.autoFocusMessage = autoFocusMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onAutoFocus(boolean success, Camera camera) {
|
||||||
|
if (autoFocusHandler != null) {
|
||||||
|
Message message = autoFocusHandler.obtainMessage(autoFocusMessage, success);
|
||||||
|
autoFocusHandler.sendMessageDelayed(message, AUTOFOCUS_INTERVAL_MS);
|
||||||
|
autoFocusHandler = null;
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Got auto-focus callback, but no handler for it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,287 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2010 ZXing authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.mining.app.zxing.camera;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Point;
|
||||||
|
import android.hardware.Camera;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.Display;
|
||||||
|
import android.view.WindowManager;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
final class CameraConfigurationManager {
|
||||||
|
|
||||||
|
private static final String TAG = CameraConfigurationManager.class.getSimpleName();
|
||||||
|
|
||||||
|
private static final int TEN_DESIRED_ZOOM = 27;
|
||||||
|
private static final int DESIRED_SHARPNESS = 30;
|
||||||
|
|
||||||
|
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private Point screenResolution;
|
||||||
|
private Point cameraResolution;
|
||||||
|
private int previewFormat;
|
||||||
|
private String previewFormatString;
|
||||||
|
|
||||||
|
CameraConfigurationManager(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads, one time, values from the camera that are needed by the app.
|
||||||
|
*/
|
||||||
|
void initFromCameraParameters(Camera camera) {
|
||||||
|
Camera.Parameters parameters = camera.getParameters();
|
||||||
|
previewFormat = parameters.getPreviewFormat();
|
||||||
|
previewFormatString = parameters.get("preview-format");
|
||||||
|
Log.d(TAG, "Default preview format: " + previewFormat + '/' + previewFormatString);
|
||||||
|
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
Display display = manager.getDefaultDisplay();
|
||||||
|
screenResolution = new Point(display.getWidth(), display.getHeight());
|
||||||
|
Log.d(TAG, "Screen resolution: " + screenResolution);
|
||||||
|
cameraResolution = getCameraResolution(parameters, screenResolution);
|
||||||
|
Log.d(TAG, "Camera resolution: " + screenResolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the camera up to take preview images which are used for both preview and decoding.
|
||||||
|
* We detect the preview format here so that buildLuminanceSource() can build an appropriate
|
||||||
|
* LuminanceSource subclass. In the future we may want to force YUV420SP as it's the smallest,
|
||||||
|
* and the planar Y can be used for barcode scanning without a copy in some cases.
|
||||||
|
*/
|
||||||
|
void setDesiredCameraParameters(Camera camera) {
|
||||||
|
Camera.Parameters parameters = camera.getParameters();
|
||||||
|
Log.d(TAG, "Setting preview size: " + cameraResolution);
|
||||||
|
parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
|
||||||
|
setFlash(parameters);
|
||||||
|
setZoom(parameters);
|
||||||
|
//setSharpness(parameters);
|
||||||
|
//modify here
|
||||||
|
|
||||||
|
// camera.setDisplayOrientation(90);
|
||||||
|
setDisplayOrientation(camera, 90);
|
||||||
|
camera.setParameters(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
Point getCameraResolution() {
|
||||||
|
return cameraResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point getScreenResolution() {
|
||||||
|
return screenResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPreviewFormat() {
|
||||||
|
return previewFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getPreviewFormatString() {
|
||||||
|
return previewFormatString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Point getCameraResolution(Camera.Parameters parameters, Point screenResolution) {
|
||||||
|
|
||||||
|
String previewSizeValueString = parameters.get("preview-size-values");
|
||||||
|
// saw this on Xperia
|
||||||
|
if (previewSizeValueString == null) {
|
||||||
|
previewSizeValueString = parameters.get("preview-size-value");
|
||||||
|
}
|
||||||
|
|
||||||
|
Point cameraResolution = null;
|
||||||
|
|
||||||
|
if (previewSizeValueString != null) {
|
||||||
|
Log.d(TAG, "preview-size-values parameter: " + previewSizeValueString);
|
||||||
|
cameraResolution = findBestPreviewSizeValue(previewSizeValueString, screenResolution);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cameraResolution == null) {
|
||||||
|
// Ensure that the camera resolution is a multiple of 8, as the screen may not be.
|
||||||
|
cameraResolution = new Point(
|
||||||
|
(screenResolution.x >> 3) << 3,
|
||||||
|
(screenResolution.y >> 3) << 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cameraResolution;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString, Point screenResolution) {
|
||||||
|
int bestX = 0;
|
||||||
|
int bestY = 0;
|
||||||
|
int diff = Integer.MAX_VALUE;
|
||||||
|
for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
|
||||||
|
|
||||||
|
previewSize = previewSize.trim();
|
||||||
|
int dimPosition = previewSize.indexOf('x');
|
||||||
|
if (dimPosition < 0) {
|
||||||
|
Log.w(TAG, "Bad preview-size: " + previewSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newX;
|
||||||
|
int newY;
|
||||||
|
try {
|
||||||
|
newX = Integer.parseInt(previewSize.substring(0, dimPosition));
|
||||||
|
newY = Integer.parseInt(previewSize.substring(dimPosition + 1));
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, "Bad preview-size: " + previewSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int newDiff = Math.abs(newX - screenResolution.x) + Math.abs(newY - screenResolution.y);
|
||||||
|
if (newDiff == 0) {
|
||||||
|
bestX = newX;
|
||||||
|
bestY = newY;
|
||||||
|
break;
|
||||||
|
} else if (newDiff < diff) {
|
||||||
|
bestX = newX;
|
||||||
|
bestY = newY;
|
||||||
|
diff = newDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bestX > 0 && bestY > 0) {
|
||||||
|
return new Point(bestX, bestY);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int findBestMotZoomValue(CharSequence stringValues, int tenDesiredZoom) {
|
||||||
|
int tenBestValue = 0;
|
||||||
|
for (String stringValue : COMMA_PATTERN.split(stringValues)) {
|
||||||
|
stringValue = stringValue.trim();
|
||||||
|
double value;
|
||||||
|
try {
|
||||||
|
value = Double.parseDouble(stringValue);
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
return tenDesiredZoom;
|
||||||
|
}
|
||||||
|
int tenValue = (int) (10.0 * value);
|
||||||
|
if (Math.abs(tenDesiredZoom - value) < Math.abs(tenDesiredZoom - tenBestValue)) {
|
||||||
|
tenBestValue = tenValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tenBestValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFlash(Camera.Parameters parameters) {
|
||||||
|
// FIXME: This is a hack to turn the flash off on the Samsung Galaxy.
|
||||||
|
// And this is a hack-hack to work around a different value on the Behold II
|
||||||
|
// Restrict Behold II check to Cupcake, per Samsung's advice
|
||||||
|
//if (Build.MODEL.contains("Behold II") &&
|
||||||
|
// CameraManager.SDK_INT == Build.VERSION_CODES.CUPCAKE) {
|
||||||
|
if (Build.MODEL.contains("Behold II") && CameraManager.SDK_INT == 3) { // 3 = Cupcake
|
||||||
|
parameters.set("flash-value", 1);
|
||||||
|
} else {
|
||||||
|
parameters.set("flash-value", 2);
|
||||||
|
}
|
||||||
|
// This is the standard setting to turn the flash off that all devices should honor.
|
||||||
|
parameters.set("flash-mode", "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setZoom(Camera.Parameters parameters) {
|
||||||
|
|
||||||
|
String zoomSupportedString = parameters.get("zoom-supported");
|
||||||
|
if (zoomSupportedString != null && !Boolean.parseBoolean(zoomSupportedString)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tenDesiredZoom = TEN_DESIRED_ZOOM;
|
||||||
|
|
||||||
|
String maxZoomString = parameters.get("max-zoom");
|
||||||
|
if (maxZoomString != null) {
|
||||||
|
try {
|
||||||
|
int tenMaxZoom = (int) (10.0 * Double.parseDouble(maxZoomString));
|
||||||
|
if (tenDesiredZoom > tenMaxZoom) {
|
||||||
|
tenDesiredZoom = tenMaxZoom;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, "Bad max-zoom: " + maxZoomString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String takingPictureZoomMaxString = parameters.get("taking-picture-zoom-max");
|
||||||
|
if (takingPictureZoomMaxString != null) {
|
||||||
|
try {
|
||||||
|
int tenMaxZoom = Integer.parseInt(takingPictureZoomMaxString);
|
||||||
|
if (tenDesiredZoom > tenMaxZoom) {
|
||||||
|
tenDesiredZoom = tenMaxZoom;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
Log.w(TAG, "Bad taking-picture-zoom-max: " + takingPictureZoomMaxString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String motZoomValuesString = parameters.get("mot-zoom-values");
|
||||||
|
if (motZoomValuesString != null) {
|
||||||
|
tenDesiredZoom = findBestMotZoomValue(motZoomValuesString, tenDesiredZoom);
|
||||||
|
}
|
||||||
|
|
||||||
|
String motZoomStepString = parameters.get("mot-zoom-step");
|
||||||
|
if (motZoomStepString != null) {
|
||||||
|
try {
|
||||||
|
double motZoomStep = Double.parseDouble(motZoomStepString.trim());
|
||||||
|
int tenZoomStep = (int) (10.0 * motZoomStep);
|
||||||
|
if (tenZoomStep > 1) {
|
||||||
|
tenDesiredZoom -= tenDesiredZoom % tenZoomStep;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
// continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set zoom. This helps encourage the user to pull back.
|
||||||
|
// Some devices like the Behold have a zoom parameter
|
||||||
|
if (maxZoomString != null || motZoomValuesString != null) {
|
||||||
|
parameters.set("zoom", String.valueOf(tenDesiredZoom / 10.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most devices, like the Hero, appear to expose this zoom parameter.
|
||||||
|
// It takes on values like "27" which appears to mean 2.7x zoom
|
||||||
|
if (takingPictureZoomMaxString != null) {
|
||||||
|
parameters.set("taking-picture-zoom", tenDesiredZoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getDesiredSharpness() {
|
||||||
|
return DESIRED_SHARPNESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* compatible 1.6
|
||||||
|
* @param camera
|
||||||
|
* @param angle
|
||||||
|
*/
|
||||||
|
protected void setDisplayOrientation(Camera camera, int angle){
|
||||||
|
Method downPolymorphic;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
downPolymorphic = camera.getClass().getMethod("setDisplayOrientation", new Class[] { int.class });
|
||||||
|
if (downPolymorphic != null)
|
||||||
|
downPolymorphic.invoke(camera, new Object[] { angle });
|
||||||
|
}
|
||||||
|
catch (Exception e1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user