修改eclipse项目为as项目

This commit is contained in:
2020-11-10 01:45:14 +08:00
commit b2c8455a6c
217 changed files with 25818 additions and 0 deletions

View 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>

View 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();
}
}
}

View 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");
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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
}
}

View 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;
}
}

View 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;//右键菜单内容
}

View 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;
}
}

View 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;//记录移动执行函数
}

View 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;
}
}

View 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;//单据入账前执行函数
}

View 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();
}
}

View 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);
}
}

View 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
}
}

View 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);
}
}

View 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;
}
}

View 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);
}
}
}

View 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);
}
}

View 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;
}
}

View 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);
}
}
}

View 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;
}
}

View 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;
}
}

View File

@ -0,0 +1,8 @@
package com.chaoran.entiry;
import android.widget.ImageView;
import android.widget.TextView;
public class Zujian {
public TextView tv;
}

View 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);
}

View File

@ -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();
}
});
}
}

View 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);
}
}
}

View 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页");
}
}

View 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();
}
}

View 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();
// }
// }
}
}

View 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);
}
}

View File

@ -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);
}
}

View 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")+"-------------------条");
}
}

View 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();
}
}
}

View 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;
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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;
}
}

View 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);
}
}

View 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();
}
}
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

File diff suppressed because it is too large Load Diff

View 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();
}
}

View 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();
}
}
}
}

View 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();
}
}
}

View 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;
}
}

View 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);
}
};
}

View 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();
}
}
}

View 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();
}
}

View 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);
}
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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;
}
}

View 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;
}
}

View File

@ -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
}
}

View 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();
}
}
}
}

View 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);
}
}

View 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;
// }
}

View 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;
}
}
}
}

View File

@ -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");
}
}
}

View File

@ -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)
{
}
}
}

View File

@ -0,0 +1,326 @@
/*
* Copyright (C) 2008 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 java.io.IOException;
import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
import android.hardware.Camera;
import android.os.Build;
import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder;
/**
* This object wraps the Camera service object and expects to be the only one talking to it. The
* implementation encapsulates the steps needed to take preview-sized images, which are used for
* both preview and decoding.
*
*/
public final class CameraManager {
private static final String TAG = CameraManager.class.getSimpleName();
private static final int MIN_FRAME_WIDTH = 600;
private static final int MIN_FRAME_HEIGHT = 600;
private static final int MAX_FRAME_WIDTH = 600;
private static final int MAX_FRAME_HEIGHT = 600;
private static CameraManager cameraManager;
static final int SDK_INT; // Later we can use Build.VERSION.SDK_INT
static {
int sdkInt;
try {
sdkInt = Integer.parseInt(Build.VERSION.SDK);
} catch (NumberFormatException nfe) {
// Just to be safe
sdkInt = 10000;
}
SDK_INT = sdkInt;
}
private final Context context;
private final CameraConfigurationManager configManager;
private Camera camera;
private Rect framingRect;
private Rect framingRectInPreview;
private boolean initialized;
private boolean previewing;
private final boolean useOneShotPreviewCallback;
/**
* Preview frames are delivered here, which we pass on to the registered handler. Make sure to
* clear the handler so it will only receive one message.
*/
private final PreviewCallback previewCallback;
/** Autofocus callbacks arrive here, and are dispatched to the Handler which requested them. */
private final AutoFocusCallback autoFocusCallback;
/**
* Initializes this static object with the Context of the calling Activity.
*
* @param context The Activity which wants to use the camera.
*/
public static void init(Context context) {
if (cameraManager == null) {
cameraManager = new CameraManager(context);
}
}
/**
* Gets the CameraManager singleton instance.
*
* @return A reference to the CameraManager singleton.
*/
public static CameraManager get() {
return cameraManager;
}
private CameraManager(Context context) {
this.context = context;
this.configManager = new CameraConfigurationManager(context);
// Camera.setOneShotPreviewCallback() has a race condition in Cupcake, so we use the older
// Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
// the more efficient one shot callback, as the older one can swamp the system and cause it
// to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK.
//useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE;
useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > 3; // 3 = Cupcake
previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback);
autoFocusCallback = new AutoFocusCallback();
}
/**
* Opens the camera driver and initializes the hardware parameters.
*
* @param holder The surface object which the camera will draw preview frames into.
* @throws IOException Indicates the camera driver failed to open.
*/
public void openDriver(SurfaceHolder holder) throws IOException {
if (camera == null) {
camera = Camera.open();
if (camera == null) {
throw new IOException();
}
camera.setPreviewDisplay(holder);
if (!initialized) {
initialized = true;
configManager.initFromCameraParameters(camera);
}
configManager.setDesiredCameraParameters(camera);
//FIXME
// SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
//<2F>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ǰ<EFBFBD><C7B0>
// if (prefs.getBoolean(PreferencesActivity.KEY_FRONT_LIGHT, false)) {
// FlashlightManager.enableFlashlight();
// }
FlashlightManager.enableFlashlight();
}
}
/**
* Closes the camera driver if still in use.
*/
public void closeDriver() {
if (camera != null) {
FlashlightManager.disableFlashlight();
camera.release();
camera = null;
}
}
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public void startPreview() {
if (camera != null && !previewing) {
camera.startPreview();
previewing = true;
}
}
/**
* Tells the camera to stop drawing preview frames.
*/
public void stopPreview() {
if (camera != null && previewing) {
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
camera.stopPreview();
previewCallback.setHandler(null, 0);
autoFocusCallback.setHandler(null, 0);
previewing = false;
}
}
/**
* A single preview frame will be returned to the handler supplied. The data will arrive as byte[]
* in the message.obj field, with width and height encoded as message.arg1 and message.arg2,
* respectively.
*
* @param handler The handler to send the message to.
* @param message The what field of the message to be sent.
*/
public void requestPreviewFrame(Handler handler, int message) {
if (camera != null && previewing) {
previewCallback.setHandler(handler, message);
if (useOneShotPreviewCallback) {
camera.setOneShotPreviewCallback(previewCallback);
} else {
camera.setPreviewCallback(previewCallback);
}
}
}
/**
* Asks the camera hardware to perform an autofocus.
*
* @param handler The Handler to notify when the autofocus completes.
* @param message The message to deliver.
*/
public void requestAutoFocus(Handler handler, int message) {
if (camera != null && previewing) {
autoFocusCallback.setHandler(handler, message);
//Log.d(TAG, "Requesting auto-focus callback");
camera.autoFocus(autoFocusCallback);
}
}
/**
* Calculates the framing rect which the UI should draw to show the user where to place the
* barcode. This target helps with alignment as well as forces the user to hold the device
* far enough away to ensure the image will be in focus.
*
* @return The rectangle to draw on screen in window coordinates.
*/
public Rect getFramingRect() {
Point screenResolution = configManager.getScreenResolution();
if (framingRect == null) {
if (camera == null) {
return null;
}
int width = screenResolution.x * 3 / 4;
if (width < MIN_FRAME_WIDTH) {
width = MIN_FRAME_WIDTH;
} else if (width > MAX_FRAME_WIDTH) {
width = MAX_FRAME_WIDTH;
}
int height = screenResolution.y * 3 / 4;
if (height < MIN_FRAME_HEIGHT) {
height = MIN_FRAME_HEIGHT;
} else if (height > MAX_FRAME_HEIGHT) {
height = MAX_FRAME_HEIGHT;
}
int leftOffset = (screenResolution.x - width) / 2;
int topOffset = (screenResolution.y - height) / 2;
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
Log.d(TAG, "Calculated framing rect: " + framingRect);
}
return framingRect;
}
/**
* Like {@link #getFramingRect} but coordinates are in terms of the preview frame,
* not UI / screen.
*/
public Rect getFramingRectInPreview() {
if (framingRectInPreview == null) {
Rect rect = new Rect(getFramingRect());
Point cameraResolution = configManager.getCameraResolution();
Point screenResolution = configManager.getScreenResolution();
//modify here
// rect.left = rect.left * cameraResolution.x / screenResolution.x;
// rect.right = rect.right * cameraResolution.x / screenResolution.x;
// rect.top = rect.top * cameraResolution.y / screenResolution.y;
// rect.bottom = rect.bottom * cameraResolution.y / screenResolution.y;
rect.left = rect.left * cameraResolution.y / screenResolution.x;
rect.right = rect.right * cameraResolution.y / screenResolution.x;
rect.top = rect.top * cameraResolution.x / screenResolution.y;
rect.bottom = rect.bottom * cameraResolution.x / screenResolution.y;
framingRectInPreview = rect;
}
return framingRectInPreview;
}
/**
* Converts the result points from still resolution coordinates to screen coordinates.
*
* @param points The points returned by the Reader subclass through Result.getResultPoints().
* @return An array of Points scaled to the size of the framing rect and offset appropriately
* so they can be drawn in screen coordinates.
*/
/*
public Point[] convertResultPoints(ResultPoint[] points) {
Rect frame = getFramingRectInPreview();
int count = points.length;
Point[] output = new Point[count];
for (int x = 0; x < count; x++) {
output[x] = new Point();
output[x].x = frame.left + (int) (points[x].getX() + 0.5f);
output[x].y = frame.top + (int) (points[x].getY() + 0.5f);
}
return output;
}
*/
/**
* A factory method to build the appropriate LuminanceSource object based on the format
* of the preview buffers, as described by Camera.Parameters.
*
* @param data A preview frame.
* @param width The width of the image.
* @param height The height of the image.
* @return A PlanarYUVLuminanceSource instance.
*/
public PlanarYUVLuminanceSource buildLuminanceSource(byte[] data, int width, int height) {
Rect rect = getFramingRectInPreview();
int previewFormat = configManager.getPreviewFormat();
String previewFormatString = configManager.getPreviewFormatString();
switch (previewFormat) {
// This is the standard Android format which all devices are REQUIRED to support.
// In theory, it's the only one we should ever care about.
case PixelFormat.YCbCr_420_SP:
// This format has never been seen in the wild, but is compatible as we only care
// about the Y channel, so allow it.
case PixelFormat.YCbCr_422_SP:
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
rect.width(), rect.height());
default:
// The Samsung Moment incorrectly uses this variant instead of the 'sp' version.
// Fortunately, it too has all the Y data up front, so we can read it.
if ("yuv420p".equals(previewFormatString)) {
return new PlanarYUVLuminanceSource(data, width, height, rect.left, rect.top,
rect.width(), rect.height());
}
}
throw new IllegalArgumentException("Unsupported picture format: " +
previewFormat + '/' + previewFormatString);
}
public Context getContext() {
return context;
}
}

View File

@ -0,0 +1,146 @@
/*
* 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.os.IBinder;
import android.util.Log;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
* This class is used to activate the weak light on some camera phones (not flash)
* in order to illuminate surfaces for scanning. There is no official way to do this,
* but, classes which allow access to this function still exist on some devices.
* This therefore proceeds through a great deal of reflection.
*
* See <a href="http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/">
* http://almondmendoza.com/2009/01/05/changing-the-screen-brightness-programatically/</a> and
* <a href="http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java">
* http://code.google.com/p/droidled/source/browse/trunk/src/com/droidled/demo/DroidLED.java</a>.
* Thanks to Ryan Alford for pointing out the availability of this class.
*/
final class FlashlightManager {
private static final String TAG = FlashlightManager.class.getSimpleName();
private static final Object iHardwareService;
private static final Method setFlashEnabledMethod;
static {
iHardwareService = getHardwareService();
setFlashEnabledMethod = getSetFlashEnabledMethod(iHardwareService);
if (iHardwareService == null) {
Log.v(TAG, "This device does supports control of a flashlight");
} else {
Log.v(TAG, "This device does not support control of a flashlight");
}
}
private FlashlightManager() {
}
static void enableFlashlight() {
setFlashlight(false);
}
static void disableFlashlight() {
setFlashlight(false);
}
private static Object getHardwareService() {
Class<?> serviceManagerClass = maybeForName("android.os.ServiceManager");
if (serviceManagerClass == null) {
return null;
}
Method getServiceMethod = maybeGetMethod(serviceManagerClass, "getService", String.class);
if (getServiceMethod == null) {
return null;
}
Object hardwareService = invoke(getServiceMethod, null, "hardware");
if (hardwareService == null) {
return null;
}
Class<?> iHardwareServiceStubClass = maybeForName("android.os.IHardwareService$Stub");
if (iHardwareServiceStubClass == null) {
return null;
}
Method asInterfaceMethod = maybeGetMethod(iHardwareServiceStubClass, "asInterface", IBinder.class);
if (asInterfaceMethod == null) {
return null;
}
return invoke(asInterfaceMethod, null, hardwareService);
}
private static Method getSetFlashEnabledMethod(Object iHardwareService) {
if (iHardwareService == null) {
return null;
}
Class<?> proxyClass = iHardwareService.getClass();
return maybeGetMethod(proxyClass, "setFlashlightEnabled", boolean.class);
}
private static Class<?> maybeForName(String name) {
try {
return Class.forName(name);
} catch (ClassNotFoundException cnfe) {
// OK
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while finding class " + name, re);
return null;
}
}
private static Method maybeGetMethod(Class<?> clazz, String name, Class<?>... argClasses) {
try {
return clazz.getMethod(name, argClasses);
} catch (NoSuchMethodException nsme) {
// OK
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while finding method " + name, re);
return null;
}
}
private static Object invoke(Method method, Object instance, Object... args) {
try {
return method.invoke(instance, args);
} catch (IllegalAccessException e) {
Log.w(TAG, "Unexpected error while invoking " + method, e);
return null;
} catch (InvocationTargetException e) {
Log.w(TAG, "Unexpected error while invoking " + method, e.getCause());
return null;
} catch (RuntimeException re) {
Log.w(TAG, "Unexpected error while invoking " + method, re);
return null;
}
}
private static void setFlashlight(boolean active) {
if (iHardwareService != null) {
invoke(setFlashEnabledMethod, iHardwareService, active);
}
}
}

View File

@ -0,0 +1,133 @@
/*
* Copyright 2009 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 com.google.zxing.LuminanceSource;
import android.graphics.Bitmap;
/**
* This object extends LuminanceSource around an array of YUV data returned from the camera driver,
* with the option to crop to a rectangle within the full data. This can be used to exclude
* superfluous pixels around the perimeter and speed up decoding.
*
* It works for any pixel format where the Y channel is planar and appears first, including
* YCbCr_420_SP and YCbCr_422_SP.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class PlanarYUVLuminanceSource extends LuminanceSource {
private final byte[] yuvData;
private final int dataWidth;
private final int dataHeight;
private final int left;
private final int top;
public PlanarYUVLuminanceSource(byte[] yuvData, int dataWidth, int dataHeight, int left, int top,
int width, int height) {
super(width, height);
if (left + width > dataWidth || top + height > dataHeight) {
throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
}
this.yuvData = yuvData;
this.dataWidth = dataWidth;
this.dataHeight = dataHeight;
this.left = left;
this.top = top;
}
@Override
public byte[] getRow(int y, byte[] row) {
if (y < 0 || y >= getHeight()) {
throw new IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == null || row.length < width) {
row = new byte[width];
}
int offset = (y + top) * dataWidth + left;
System.arraycopy(yuvData, offset, row, 0, width);
return row;
}
@Override
public byte[] getMatrix() {
int width = getWidth();
int height = getHeight();
// If the caller asks for the entire underlying image, save the copy and give them the
// original data. The docs specifically warn that result.length must be ignored.
if (width == dataWidth && height == dataHeight) {
return yuvData;
}
int area = width * height;
byte[] matrix = new byte[area];
int inputOffset = top * dataWidth + left;
// If the width matches the full width of the underlying data, perform a single copy.
if (width == dataWidth) {
System.arraycopy(yuvData, inputOffset, matrix, 0, area);
return matrix;
}
// Otherwise copy one cropped row at a time.
byte[] yuv = yuvData;
for (int y = 0; y < height; y++) {
int outputOffset = y * width;
System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
inputOffset += dataWidth;
}
return matrix;
}
@Override
public boolean isCropSupported() {
return true;
}
public int getDataWidth() {
return dataWidth;
}
public int getDataHeight() {
return dataHeight;
}
public Bitmap renderCroppedGreyscaleBitmap() {
int width = getWidth();
int height = getHeight();
int[] pixels = new int[width * height];
byte[] yuv = yuvData;
int inputOffset = top * dataWidth + left;
for (int y = 0; y < height; y++) {
int outputOffset = y * width;
for (int x = 0; x < width; x++) {
int grey = yuv[inputOffset + x] & 0xff;
pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
}
inputOffset += dataWidth;
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
return bitmap;
}
}

View File

@ -0,0 +1,59 @@
/*
* 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.graphics.Point;
import android.hardware.Camera;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
final class PreviewCallback implements Camera.PreviewCallback {
private static final String TAG = PreviewCallback.class.getSimpleName();
private final CameraConfigurationManager configManager;
private final boolean useOneShotPreviewCallback;
private Handler previewHandler;
private int previewMessage;
PreviewCallback(CameraConfigurationManager configManager, boolean useOneShotPreviewCallback) {
this.configManager = configManager;
this.useOneShotPreviewCallback = useOneShotPreviewCallback;
}
void setHandler(Handler previewHandler, int previewMessage) {
this.previewHandler = previewHandler;
this.previewMessage = previewMessage;
}
public void onPreviewFrame(byte[] data, Camera camera) {
Point cameraResolution = configManager.getCameraResolution();
if (!useOneShotPreviewCallback) {
camera.setPreviewCallback(null);
}
if (previewHandler != null) {
Message message = previewHandler.obtainMessage(previewMessage, cameraResolution.x,
cameraResolution.y, data);
message.sendToTarget();
previewHandler = null;
} else {
Log.d(TAG, "Got preview callback, but no handler for it");
}
}
}

View File

@ -0,0 +1,137 @@
/*
* Copyright (C) 2008 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.decoding;
import java.util.Vector;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import com.example.chaoran.MipcaActivityCapture;
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.view.ViewfinderResultPointCallback;
/**
* This class handles all the messaging which comprises the state machine for capture.
*/
public final class CaptureActivityHandler extends Handler {
private static final String TAG = CaptureActivityHandler.class.getSimpleName();
private final MipcaActivityCapture activity;
private final DecodeThread decodeThread;
private State state;
private enum State {
PREVIEW,
SUCCESS,
DONE
}
public CaptureActivityHandler(MipcaActivityCapture activity, Vector<BarcodeFormat> decodeFormats,
String characterSet) {
this.activity = activity;
decodeThread = new DecodeThread(activity, decodeFormats, characterSet,
new ViewfinderResultPointCallback(activity.getViewfinderView()));
decodeThread.start();
state = State.SUCCESS;
// Start ourselves capturing previews and decoding.
CameraManager.get().startPreview();
restartPreviewAndDecode();
}
@Override
public void handleMessage(Message message) {
switch (message.what) {
case R.id.auto_focus:
//Log.d(TAG, "Got auto-focus message");
// When one auto focus pass finishes, start another. This is the closest thing to
// continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
if (state == State.PREVIEW) {
CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
}
break;
case R.id.restart_preview:
Log.d(TAG, "Got restart preview message");
restartPreviewAndDecode();
break;
case R.id.decode_succeeded:
Log.d(TAG, "Got decode succeeded message");
state = State.SUCCESS;
Bundle bundle = message.getData();
/***********************************************************************/
Bitmap barcode = bundle == null ? null :
(Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD>߳<EFBFBD>
activity.handleDecode((Result) message.obj, barcode);//<2F><><EFBFBD>ؽ<EFBFBD><D8BD>? /***********************************************************************/
break;
case R.id.decode_failed:
// We're decoding as fast as possible, so when one decode fails, start another.
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
break;
case R.id.return_scan_result:
Log.d(TAG, "Got return scan result message");
activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
activity.finish();
break;
case R.id.launch_product_query:
Log.d(TAG, "Got product query message");
String url = (String) message.obj;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
activity.startActivity(intent);
break;
}
}
public void quitSynchronously() {
state = State.DONE;
CameraManager.get().stopPreview();
Message quit = Message.obtain(decodeThread.getHandler(), R.id.quit);
quit.sendToTarget();
try {
decodeThread.join();
} catch (InterruptedException e) {
// continue
}
// Be absolutely sure we don't send any queued up messages
removeMessages(R.id.decode_succeeded);
removeMessages(R.id.decode_failed);
}
private void restartPreviewAndDecode() {
if (state == State.SUCCESS) {
state = State.PREVIEW;
CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
activity.drawViewfinder();
}
}
}

View File

@ -0,0 +1,104 @@
/*
* 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.decoding;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import java.util.regex.Pattern;
import android.content.Intent;
import android.net.Uri;
import com.google.zxing.BarcodeFormat;
final class DecodeFormatManager {
private static final Pattern COMMA_PATTERN = Pattern.compile(",");
static final Vector<BarcodeFormat> PRODUCT_FORMATS;
static final Vector<BarcodeFormat> ONE_D_FORMATS;
static final Vector<BarcodeFormat> QR_CODE_FORMATS;
static final Vector<BarcodeFormat> DATA_MATRIX_FORMATS;
static {
PRODUCT_FORMATS = new Vector<BarcodeFormat>(5);
PRODUCT_FORMATS.add(BarcodeFormat.UPC_A);
PRODUCT_FORMATS.add(BarcodeFormat.UPC_E);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_13);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_8);
PRODUCT_FORMATS.add(BarcodeFormat.RSS14);
ONE_D_FORMATS = new Vector<BarcodeFormat>(PRODUCT_FORMATS.size() + 4);
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
ONE_D_FORMATS.add(BarcodeFormat.CODE_39);
ONE_D_FORMATS.add(BarcodeFormat.CODE_93);
ONE_D_FORMATS.add(BarcodeFormat.CODE_128);
ONE_D_FORMATS.add(BarcodeFormat.ITF);
QR_CODE_FORMATS = new Vector<BarcodeFormat>(1);
QR_CODE_FORMATS.add(BarcodeFormat.QR_CODE);
DATA_MATRIX_FORMATS = new Vector<BarcodeFormat>(1);
DATA_MATRIX_FORMATS.add(BarcodeFormat.DATA_MATRIX);
}
private DecodeFormatManager() {}
static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
List<String> scanFormats = null;
String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
if (scanFormatsString != null) {
scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
}
return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE));
}
static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
if (formats != null && formats.size() == 1 && formats.get(0) != null){
formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
}
return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
}
private static Vector<BarcodeFormat> parseDecodeFormats(Iterable<String> scanFormats,
String decodeMode) {
if (scanFormats != null) {
Vector<BarcodeFormat> formats = new Vector<BarcodeFormat>();
try {
for (String format : scanFormats) {
formats.add(BarcodeFormat.valueOf(format));
}
return formats;
} catch (IllegalArgumentException iae) {
// ignore it then
}
}
if (decodeMode != null) {
if (Intents.Scan.PRODUCT_MODE.equals(decodeMode)) {
return PRODUCT_FORMATS;
}
if (Intents.Scan.QR_CODE_MODE.equals(decodeMode)) {
return QR_CODE_FORMATS;
}
if (Intents.Scan.DATA_MATRIX_MODE.equals(decodeMode)) {
return DATA_MATRIX_FORMATS;
}
if (Intents.Scan.ONE_D_MODE.equals(decodeMode)) {
return ONE_D_FORMATS;
}
}
return null;
}
}

View File

@ -0,0 +1,110 @@
/*
* 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.decoding;
import java.util.Hashtable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.example.chaoran.MipcaActivityCapture;
import com.example.chaoran.R;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.common.HybridBinarizer;
import com.mining.app.zxing.camera.CameraManager;
import com.mining.app.zxing.camera.PlanarYUVLuminanceSource;
final class DecodeHandler extends Handler {
private static final String TAG = DecodeHandler.class.getSimpleName();
private final MipcaActivityCapture activity;
private final MultiFormatReader multiFormatReader;
DecodeHandler(MipcaActivityCapture activity, Hashtable<DecodeHintType, Object> hints) {
multiFormatReader = new MultiFormatReader();
multiFormatReader.setHints(hints);
this.activity = activity;
}
@Override
public void handleMessage(Message message) {
switch (message.what) {
case R.id.decode:
//Log.d(TAG, "Got decode message");
decode((byte[]) message.obj, message.arg1, message.arg2);
break;
case R.id.quit:
Looper.myLooper().quit();
break;
}
}
/**
* Decode the data within the viewfinder rectangle, and time how long it took. For efficiency,
* reuse the same reader objects from one decode to the next.
*
* @param data The YUV preview frame.
* @param width The width of the preview frame.
* @param height The height of the preview frame.
*/
private void decode(byte[] data, int width, int height) {
long start = System.currentTimeMillis();
Result rawResult = null;
//modify here
byte[] rotatedData = new byte[data.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++)
rotatedData[x * height + height - y - 1] = data[x + y * width];
}
int tmp = width; // Here we are swapping, that's the difference to #11
width = height;
height = tmp;
PlanarYUVLuminanceSource source = CameraManager.get().buildLuminanceSource(rotatedData, width, height);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
try {
rawResult = multiFormatReader.decodeWithState(bitmap);
} catch (ReaderException re) {
// continue
} finally {
multiFormatReader.reset();
}
if (rawResult != null) {
long end = System.currentTimeMillis();
Log.d(TAG, "Found barcode (" + (end - start) + " ms):\n" + rawResult.toString());
Message message = Message.obtain(activity.getHandler(), R.id.decode_succeeded, rawResult);
Bundle bundle = new Bundle();
bundle.putParcelable(DecodeThread.BARCODE_BITMAP, source.renderCroppedGreyscaleBitmap());
message.setData(bundle);
//Log.d(TAG, "Sending decode succeeded message...");
message.sendToTarget();
} else {
Message message = Message.obtain(activity.getHandler(), R.id.decode_failed);
message.sendToTarget();
}
}
}

View File

@ -0,0 +1,86 @@
/*
* Copyright (C) 2008 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.decoding;
import java.util.Hashtable;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
import android.os.Handler;
import android.os.Looper;
import com.example.chaoran.MipcaActivityCapture;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.DecodeHintType;
import com.google.zxing.ResultPointCallback;
/**
* This thread does all the heavy lifting of decoding the images.
* <20><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>
*/
final class DecodeThread extends Thread {
public static final String BARCODE_BITMAP = "barcode_bitmap";
private final MipcaActivityCapture activity;
private final Hashtable<DecodeHintType, Object> hints;
private Handler handler;
private final CountDownLatch handlerInitLatch;
DecodeThread(MipcaActivityCapture activity,
Vector<BarcodeFormat> decodeFormats,
String characterSet,
ResultPointCallback resultPointCallback) {
this.activity = activity;
handlerInitLatch = new CountDownLatch(1);
hints = new Hashtable<DecodeHintType, Object>(3);
if (decodeFormats == null || decodeFormats.isEmpty()) {
decodeFormats = new Vector<BarcodeFormat>();
decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
}
hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
if (characterSet != null) {
hints.put(DecodeHintType.CHARACTER_SET, characterSet);
}
hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
Handler getHandler() {
try {
handlerInitLatch.await();
} catch (InterruptedException ie) {
// continue?
}
return handler;
}
@Override
public void run() {
Looper.prepare();
handler = new DecodeHandler(activity, hints);
handlerInitLatch.countDown();
Looper.loop();
}
}

View File

@ -0,0 +1,47 @@
/*
* 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.decoding;
import android.app.Activity;
import android.content.DialogInterface;
/**
* Simple listener used to exit the app in a few cases.
*
*/
public final class FinishListener
implements DialogInterface.OnClickListener, DialogInterface.OnCancelListener, Runnable {
private final Activity activityToFinish;
public FinishListener(Activity activityToFinish) {
this.activityToFinish = activityToFinish;
}
public void onCancel(DialogInterface dialogInterface) {
run();
}
public void onClick(DialogInterface dialogInterface, int i) {
run();
}
public void run() {
activityToFinish.finish();
}
}

View File

@ -0,0 +1,71 @@
/*
* 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.decoding;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import android.app.Activity;
/**
* Finishes an activity after a period of inactivity.
*/
public final class InactivityTimer {
private static final int INACTIVITY_DELAY_SECONDS = 5 * 60;
private final ScheduledExecutorService inactivityTimer =
Executors.newSingleThreadScheduledExecutor(new DaemonThreadFactory());
private final Activity activity;
private ScheduledFuture<?> inactivityFuture = null;
public InactivityTimer(Activity activity) {
this.activity = activity;
onActivity();
}
public void onActivity() {
cancel();
inactivityFuture = inactivityTimer.schedule(new FinishListener(activity),
INACTIVITY_DELAY_SECONDS,
TimeUnit.SECONDS);
}
private void cancel() {
if (inactivityFuture != null) {
inactivityFuture.cancel(true);
inactivityFuture = null;
}
}
public void shutdown() {
cancel();
inactivityTimer.shutdown();
}
private static final class DaemonThreadFactory implements ThreadFactory {
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable);
thread.setDaemon(true);
return thread;
}
}
}

View File

@ -0,0 +1,190 @@
/*
* Copyright (C) 2008 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.decoding;
/**
* This class provides the constants to use when sending an Intent to Barcode Scanner.
* These strings are effectively API and cannot be changed.
*/
public final class Intents {
private Intents() {
}
public static final class Scan {
/**
* Send this intent to open the Barcodes app in scanning mode, find a barcode, and return
* the results.
*/
public static final String ACTION = "com.google.zxing.client.android.SCAN";
/**
* By default, sending Scan.ACTION will decode all barcodes that we understand. However it
* may be useful to limit scanning to certain formats. Use Intent.putExtra(MODE, value) with
* one of the values below ({@link #PRODUCT_MODE}, {@link #ONE_D_MODE}, {@link #QR_CODE_MODE}).
* Optional.
*
* Setting this is effectively shorthnad for setting explicit formats with {@link #SCAN_FORMATS}.
* It is overridden by that setting.
*/
public static final String MODE = "SCAN_MODE";
/**
* Comma-separated list of formats to scan for. The values must match the names of
* {@link com.google.zxing.BarcodeFormat}s, such as {@link com.google.zxing.BarcodeFormat#EAN_13}.
* Example: "EAN_13,EAN_8,QR_CODE"
*
* This overrides {@link #MODE}.
*/
public static final String SCAN_FORMATS = "SCAN_FORMATS";
/**
* @see com.google.zxing.DecodeHintType#CHARACTER_SET
*/
public static final String CHARACTER_SET = "CHARACTER_SET";
/**
* Decode only UPC and EAN barcodes. This is the right choice for shopping apps which get
* prices, reviews, etc. for products.
*/
public static final String PRODUCT_MODE = "PRODUCT_MODE";
/**
* Decode only 1D barcodes (currently UPC, EAN, Code 39, and Code 128).
*/
public static final String ONE_D_MODE = "ONE_D_MODE";
/**
* Decode only QR codes.
*/
public static final String QR_CODE_MODE = "QR_CODE_MODE";
/**
* Decode only Data Matrix codes.
*/
public static final String DATA_MATRIX_MODE = "DATA_MATRIX_MODE";
/**
* If a barcode is found, Barcodes returns RESULT_OK to onActivityResult() of the app which
* requested the scan via startSubActivity(). The barcodes contents can be retrieved with
* intent.getStringExtra(RESULT). If the user presses Back, the result code will be
* RESULT_CANCELED.
*/
public static final String RESULT = "SCAN_RESULT";
/**
* Call intent.getStringExtra(RESULT_FORMAT) to determine which barcode format was found.
* See Contents.Format for possible values.
*/
public static final String RESULT_FORMAT = "SCAN_RESULT_FORMAT";
/**
* Setting this to false will not save scanned codes in the history.
*/
public static final String SAVE_HISTORY = "SAVE_HISTORY";
private Scan() {
}
}
public static final class Encode {
/**
* Send this intent to encode a piece of data as a QR code and display it full screen, so
* that another person can scan the barcode from your screen.
*/
public static final String ACTION = "com.google.zxing.client.android.ENCODE";
/**
* The data to encode. Use Intent.putExtra(DATA, data) where data is either a String or a
* Bundle, depending on the type and format specified. Non-QR Code formats should
* just use a String here. For QR Code, see Contents for details.
*/
public static final String DATA = "ENCODE_DATA";
/**
* The type of data being supplied if the format is QR Code. Use
* Intent.putExtra(TYPE, type) with one of Contents.Type.
*/
public static final String TYPE = "ENCODE_TYPE";
/**
* The barcode format to be displayed. If this isn't specified or is blank,
* it defaults to QR Code. Use Intent.putExtra(FORMAT, format), where
* format is one of Contents.Format.
*/
public static final String FORMAT = "ENCODE_FORMAT";
private Encode() {
}
}
public static final class SearchBookContents {
/**
* Use Google Book Search to search the contents of the book provided.
*/
public static final String ACTION = "com.google.zxing.client.android.SEARCH_BOOK_CONTENTS";
/**
* The book to search, identified by ISBN number.
*/
public static final String ISBN = "ISBN";
/**
* An optional field which is the text to search for.
*/
public static final String QUERY = "QUERY";
private SearchBookContents() {
}
}
public static final class WifiConnect {
/**
* Internal intent used to trigger connection to a wi-fi network.
*/
public static final String ACTION = "com.google.zxing.client.android.WIFI_CONNECT";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String SSID = "SSID";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String TYPE = "TYPE";
/**
* The network to connect to, all the configuration provided here.
*/
public static final String PASSWORD = "PASSWORD";
private WifiConnect() {
}
}
public static final class Share {
/**
* Give the user a choice of items to encode as a barcode, then render it as a QR Code and
* display onscreen for a friend to scan with their phone.
*/
public static final String ACTION = "com.google.zxing.client.android.SHARE";
private Share() {
}
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright (C) 2009 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.view;
import com.google.zxing.ResultPoint;
import com.google.zxing.ResultPointCallback;
public final class ViewfinderResultPointCallback implements ResultPointCallback {
private final ViewfinderView viewfinderView;
public ViewfinderResultPointCallback(ViewfinderView viewfinderView) {
this.viewfinderView = viewfinderView;
}
public void foundPossibleResultPoint(ResultPoint point) {
viewfinderView.addPossibleResultPoint(point);
}
}

View File

@ -0,0 +1,258 @@
/*
* Copyright (C) 2008 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.view;
import java.util.Collection;
import java.util.HashSet;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.View;
import com.example.chaoran.R;
import com.google.zxing.ResultPoint;
import com.mining.app.zxing.camera.CameraManager;
/**
* This view is overlaid on top of the camera preview. It adds the viewfinder
* rectangle and partial transparency outside it, as well as the laser scanner
* animation and result points.
*
*/
public final class ViewfinderView extends View {
private static final String TAG = "log";
/**
* 刷新界面的时间
*/
private static final long ANIMATION_DELAY = 10L;
private static final int OPAQUE = 0xFF;
/**
* 四个绿色边角对应的长度
*/
private int ScreenRate;
/**
* 四个绿色边角对应的长度
*/
private static final int CORNER_WIDTH = 10;
/**
*扫描框中的中间线的宽度
*/
private static final int MIDDLE_LINE_WIDTH = 6;
/**
* 扫描框中的中间线的与扫描框左右的间隙
*/
private static final int MIDDLE_LINE_PADDING = 5;
/**
* 中间那条线每次刷新移动的距离
*/
private static final int SPEEN_DISTANCE = 5;
/**
* 手机的屏幕密度
*/
private static float density;
/**
*字体大小
*/
private static final int TEXT_SIZE = 16;
/**
* 字体距离扫描框下面的距离
*/
private static final int TEXT_PADDING_TOP = 30;
/**
* 画笔对象的引用
*/
private Paint paint;
/**
* 中间滑动线的最顶端位置
*/
private int slideTop;
/**
* 中间滑动线的最底端位置
*/
private int slideBottom;
/**
* 将扫描的二维码拍下来,这里没有这个功能,暂时不考虑
*/
private Bitmap resultBitmap;
private final int maskColor;
private final int resultColor;
private final int resultPointColor;
private Collection<ResultPoint> possibleResultPoints;
private Collection<ResultPoint> lastPossibleResultPoints;
boolean isFirst;
public ViewfinderView(Context context, AttributeSet attrs) {
super(context, attrs);
density = context.getResources().getDisplayMetrics().density;
//将像素转换成dp
ScreenRate = (int)(20 * density);
paint = new Paint();
Resources resources = getResources();
maskColor = resources.getColor(R.color.viewfinder_mask);
resultColor = resources.getColor(R.color.result_view);
resultPointColor = resources.getColor(R.color.possible_result_points);
possibleResultPoints = new HashSet<ResultPoint>(5);
}
@Override
public void onDraw(Canvas canvas) {
//中间的扫描框你要修改扫描框的大小去CameraManager里面修改
Rect frame = CameraManager.get().getFramingRect();
if (frame == null) {
return;
}
//初始化中间线滑动的最上边和最下边
if(!isFirst){
isFirst = true;
slideTop = frame.top;
slideBottom = frame.bottom;
}
//获取屏幕的宽和高
int width = canvas.getWidth();
int height = canvas.getHeight();
paint.setColor(resultBitmap != null ? resultColor : maskColor);
//画出扫描框外面的阴影部分,共四个部分,扫描框的上面到屏幕上面,扫描框的下面到屏幕下面
//扫描框的左边面到屏幕左边,扫描框的右边到屏幕右边
canvas.drawRect(0, 0, width, frame.top, paint);
canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1,
paint);
canvas.drawRect(0, frame.bottom + 1, width, height, paint);
if (resultBitmap != null) {
// Draw the opaque result bitmap over the scanning rectangle
paint.setAlpha(OPAQUE);
canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
} else {
//画扫描框边上的角总共8个部分
paint.setColor(Color.GREEN);
canvas.drawRect(frame.left, frame.top, frame.left + ScreenRate,
frame.top + CORNER_WIDTH, paint);
canvas.drawRect(frame.left, frame.top, frame.left + CORNER_WIDTH, frame.top
+ ScreenRate, paint);
canvas.drawRect(frame.right - ScreenRate, frame.top, frame.right,
frame.top + CORNER_WIDTH, paint);
canvas.drawRect(frame.right - CORNER_WIDTH, frame.top, frame.right, frame.top
+ ScreenRate, paint);
canvas.drawRect(frame.left, frame.bottom - CORNER_WIDTH, frame.left
+ ScreenRate, frame.bottom, paint);
canvas.drawRect(frame.left, frame.bottom - ScreenRate,
frame.left + CORNER_WIDTH, frame.bottom, paint);
canvas.drawRect(frame.right - ScreenRate, frame.bottom - CORNER_WIDTH,
frame.right, frame.bottom, paint);
canvas.drawRect(frame.right - CORNER_WIDTH, frame.bottom - ScreenRate,
frame.right, frame.bottom, paint);
//绘制中间的线,每次刷新界面中间的线往下移动SPEEN_DISTANCE
slideTop += SPEEN_DISTANCE;
if(slideTop >= frame.bottom){
slideTop = frame.top;
}
canvas.drawRect(frame.left + MIDDLE_LINE_PADDING, slideTop - MIDDLE_LINE_WIDTH/2, frame.right - MIDDLE_LINE_PADDING,slideTop + MIDDLE_LINE_WIDTH/2, paint);
//画扫描框下面的字
paint.setColor(Color.WHITE);
paint.setTextSize(TEXT_SIZE * density);
paint.setAlpha(0x40);
paint.setTypeface(Typeface.create("System", Typeface.BOLD));
canvas.drawText(getResources().getString(R.string.scan_text), frame.left, (float) (frame.bottom + (float)TEXT_PADDING_TOP *density), paint);
Collection<ResultPoint> currentPossible = possibleResultPoints;
Collection<ResultPoint> currentLast = lastPossibleResultPoints;
if (currentPossible.isEmpty()) {
lastPossibleResultPoints = null;
} else {
possibleResultPoints = new HashSet<ResultPoint>(5);
lastPossibleResultPoints = currentPossible;
paint.setAlpha(OPAQUE);
paint.setColor(resultPointColor);
for (ResultPoint point : currentPossible) {
canvas.drawCircle(frame.left + point.getX(), frame.top
+ point.getY(), 6.0f, paint);
}
}
if (currentLast != null) {
paint.setAlpha(OPAQUE / 2);
paint.setColor(resultPointColor);
for (ResultPoint point : currentLast) {
canvas.drawCircle(frame.left + point.getX(), frame.top
+ point.getY(), 3.0f, paint);
}
}
//只刷新扫描框的内容,其他地方不刷新
postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top,
frame.right, frame.bottom);
}
}
public void drawViewfinder() {
resultBitmap = null;
invalidate();
}
/**
* Draw a bitmap with the result points highlighted instead of the live
* scanning display.
*
* @param barcode
* An image of the decoded barcode.
*/
public void drawResultBitmap(Bitmap barcode) {
resultBitmap = barcode;
invalidate();
}
public void addPossibleResultPoint(ResultPoint point) {
possibleResultPoints.add(point);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,44 @@
package com.seuic.scan;
import com.seuic.scanner.Scanner;
import com.seuic.scanner.ScannerKey;
public class SeuicScanKeyEventRunnable implements Runnable {
private Scanner mScanner;
public boolean isrun = true;
// 需要调用ScannerKey去实现扫描按键控制扫描灯的亮和灭需要在子线程中执行
public SeuicScanKeyEventRunnable(Scanner mScanner) {
this.mScanner = mScanner;
}
public void run() {
int ret1 = ScannerKey.open();
if (ret1 > -1) {
while (isrun) {
int ret = ScannerKey.getKeyEvent();
if (ret > -1) {
// while (isrun) {
// try {
// mScanner.startScan();
// Thread.sleep(300);
// mScanner.stopScan();
// Thread.sleep(300);
// } catch (InterruptedException e) {
//
// }
// }
switch (ret) {
case ScannerKey.KEY_DOWN:
mScanner.startScan();
break;
case ScannerKey.KEY_UP:
mScanner.stopScan();
break;
}
}
}
}
}
}

View File

@ -0,0 +1,11 @@
package com.seuic.scanner;
public interface DecodeCallback {
void onDecodeComplete(String paramString);
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\DecodeCallback.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,15 @@
package com.seuic.scanner;
public class DecodeInfo {
public String barcode;
public String codetype;
public int length;
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\DecodeInfo.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,11 @@
package com.seuic.scanner;
public interface DecodeInfoCallBack {
void onDecodeComplete(DecodeInfo paramDecodeInfo);
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\DecodeInfoCallBack.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,15 @@
/* */ package com.seuic.scanner;
/* */
/* */ class Devices
/* */ {
/* */ enum DeviceModels {
/* 6 */ AUTOID6,
/* 7 */ AUTOID9;
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\Devices.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,71 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.os.Environment;
/* */ import android.util.Log;
/* */ import java.io.File;
/* */ import java.io.IOException;
/* */
/* */
/* */
/* */
/* */ public class FileUtil
/* */ {
/* */ private static final String LOG_TAG = "FileUtil";
/* 14 */ public static final String APP_TEMP_DIRECTORY = Environment.getExternalStorageDirectory() + "/PDATest";
/* */
/* */ public static boolean fileExists(String file) {
/* 17 */ File _file = new File(file);
/* 18 */ return _file.exists();
/* */ }
/* */
/* */ public static boolean createDirectory(String directory) {
/* */ try {
/* 23 */ File file = new File(directory);
/* 24 */ if (!file.exists() && !file.isDirectory()) {
/* 25 */ file.mkdir();
/* */ }
/* 27 */ return true;
/* 28 */ } catch (Exception ex) {
/* 29 */ return false;
/* */ }
/* */ }
/* */
/* */ public static void createFile(String filename) {
/* 34 */ File file = new File(filename);
/* */ try {
/* 36 */ file.createNewFile();
/* 37 */ } catch (IOException e) {
/* 38 */ Log.e("FileUtil", "createFile : " + e.getMessage());
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public static void clear(String folder) {
/* 48 */ File filefolder = new File(folder);
/* 49 */ if (filefolder != null) {
/* 50 */ if (filefolder.isDirectory()) {
/* 51 */ File[] filelist = filefolder.listFiles(); byte b; int i; File[] arrayOfFile1;
/* 52 */ for (i = (arrayOfFile1 = filelist).length, b = 0; b < i; ) { File file = arrayOfFile1[b];
/* 53 */ clear(file.getPath()); b++; }
/* */
/* */ }
/* 56 */ filefolder.delete();
/* */ }
/* */ }
/* */
/* */ public static void delete(String filename) {
/* 61 */ File file = new File(filename);
/* 62 */ if (file.exists())
/* 63 */ file.delete();
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\FileUtil.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,19 @@
package com.seuic.scanner;
public class HHPObject {
String msg;
byte codeID;
byte symLetter;
byte symModifier;
int length;
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\HHPObject.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,319 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.content.Context;
/* */ import android.os.Handler;
/* */ import android.os.Message;
/* */ import android.text.TextUtils;
/* */ import android.util.Log;
/* */ import android.util.SparseIntArray;
/* */
/* */ public class HHPScanner
/* */ extends Scanner
/* */ {
/* 13 */ final String LOG_TAG = "HHPScanner";
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 25 */ private final int DEFAULT_PARAMETER = 849;
/* */
/* */ private Thread mThread;
/* */ private boolean isEnabled = true;
/* */ private static DecodeCallback callback;
/* 30 */ private Handler mHandler = new DecodeHandler();
/* 31 */ private Runnable runnable = new DecodeRunnable();
/* */ boolean scanFinished; static { System.loadLibrary("HHPScanner_jni"); paramArray.put(257, 1); paramArray.put(258, 17); paramArray.put(259, 33); paramArray.put(260, 49); paramArray.put(261, 65); paramArray.put(263, 2); paramArray.put(264, 18); paramArray.put(265, 34); paramArray.put(266, 3); paramArray.put(267, 19); paramArray.put(265, 35); paramArray.put(273, 20); paramArray.put(289, 113); paramArray.put(290, 114); paramArray.put(291, 115); paramArray.put(292, 145); paramArray.put(305, 209); paramArray.put(307, 212); paramArray.put(310, 210); paramArray.put(311, 211); paramArray.put(321, 241); paramArray.put(322, 242); paramArray.put(323, 243); paramArray.put(337, 257); paramArray.put(338, 258); paramArray.put(339, 259); paramArray.put(341, 260); paramArray.put(353, 273); paramArray.put(354, 274); paramArray.put(355, 275); paramArray.put(401, 289); paramArray.put(402, 290); paramArray.put(403, 291); paramArray.put(513, 305); paramArray.put(514, 306); paramArray.put(515, 307); paramArray.put(577, 321); paramArray.put(578, 322); paramArray.put(579, 323); paramArray.put(593, 337); paramArray.put(594, 338); paramArray.put(595, 339); paramArray.put(609, 369); paramArray.put(617, 370); paramArray.put(610, 385); paramArray.put(618, 386); paramArray.put(611, 401); paramArray.put(612, 417); paramArray.put(613, 433); paramArray.put(689, 561); paramArray.put(690, 562); paramArray.put(691, 563); paramArray.put(836, 564); paramArray.put(529, 497); paramArray.put(705, 577); paramArray.put(706, 578); paramArray.put(707, 579); paramArray.put(721, 593); paramArray.put(722, 594); paramArray.put(723, 595); paramArray.put(561, 609); paramArray.put(562, 610); paramArray.put(563, 611); paramArray.put(737, 625); paramArray.put(739, 626); paramArray.put(739, 627); paramArray.put(545, 641); paramArray.put(546, 642); paramArray.put(547, 643); paramArray.put(753, 657); paramArray.put(754, 658); paramArray.put(755, 659); paramArray.put(769, 705); paramArray.put(770, 706); paramArray.put(771, 707); paramArray.put(785, 753); paramArray.put(786, 754); paramArray.put(787, 755); paramArray.put(788, 756);
/* */ paramArray.put(817, 785);
/* */ paramArray.put(818, 786);
/* 35 */ paramArray.put(7, 850); } HHPScanner(Context context) { super(context);
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 187 */ this.scanFinished = true; }
/* */ void decode() { HHPObject object = new HHPObject(); if (JNIGetDecode(object, 5000) > 0) { ScanLed.setLed(1); Message msg = this.mHandler.obtainMessage(); msg.obj = object; this.mHandler.sendMessage(msg); }
/* 189 */ this.scanFinished = true; } void scan() { synchronized (this.runnable) {
/* 190 */ if (this.isEnabled)
/* 191 */ if (this.scanFinished) {
/* 192 */ this.runnable.notify();
/* */ } else {
/* 194 */ this.scanFinished = true;
/* */ }
/* */ } } public boolean open() { if (JNIOpen() > -1) {
/* */ this.mThread = new Thread(this.runnable); this.mThread.start(); return true;
/* */ }
/* */ return false; }
/* */ public void close() { JNIClose(); }
/* */ public void startScan() { scan(); }
/* 202 */ public void stopScan() { JNIStopDecode(); }
/* */
/* */
/* */
/* */ public int getParams(int num) {
/* 207 */ if (paramArray.get(num, -1) == -1 && num != 801) {
/* 208 */ return -1;
/* */ }
/* */
/* 211 */ ScanParam param = new ScanParam();
/* 212 */ param.id = paramArray.get(num);
/* 213 */ JNIGetParameter(param);
/* */
/* */
/* 216 */ if (num == 7) {
/* 217 */ Log.i("HHPScanner", "12345");
/* */ }
/* */
/* 220 */ return param.value;
/* */ }
/* */
/* */
/* */ public void enable() {
/* 225 */ JNIEnable();
/* */ }
/* */
/* */
/* */ public void disable() {
/* 230 */ JNIDisable();
/* */ }
/* */
/* */
/* */
/* */ public boolean setParams(int num, int value) {
/* 236 */ if (paramArray.get(num, -1) == -1 && num != 801) {
/* 237 */ return false;
/* */ }
/* */
/* 240 */ ScanParam param = new ScanParam();
/* 241 */ if (num != 801) {
/* 242 */ param.id = paramArray.get(num);
/* */ } else {
/* */
/* 245 */ param.id = 849;
/* */ }
/* 247 */ param.value = value;
/* */
/* 249 */ if (JNISetParameter(param) == 1) {
/* 250 */ return true;
/* */ }
/* 252 */ return false;
/* */ }
/* */
/* */ public void setOCRTemplate(String template) {
/* 256 */ JNISetOCRTemplate(template);
/* */ }
/* */
/* */
/* */ public SparseIntArray getAllParams() {
/* 261 */ return paramArray;
/* */ }
/* */
/* */ static class DecodeHandler extends Handler {
/* */ public void handleMessage(Message msg) {
/* 266 */ HHPObject object = (HHPObject)msg.obj;
/* 267 */ if (HHPScanner.callback != null && !TextUtils.isEmpty(object.msg))
/* 268 */ HHPScanner.callback.onDecodeComplete(object.msg);
/* */ }
/* */ }
/* */
/* */ class DecodeRunnable
/* */ implements Runnable
/* */ {
/* */ public void run() {
/* */ while (true) {
/* 277 */ synchronized (HHPScanner.this.runnable) {
/* */ try {
/* 279 */ HHPScanner.this.runnable.wait();
/* 280 */ } catch (InterruptedException e) {
/* 281 */ Log.e("HHPScanner", "DecodeRunnable:" + e.getMessage());
/* */ }
/* 283 */ HHPScanner.this.decode();
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */ public void setDecodeCallBack(DecodeCallback decodeCallback) {
/* 291 */ callback = decodeCallback;
/* */ }
/* */
/* */ public void setDecodeInfoCallBack(DecodeInfoCallBack callback) {}
/* */
/* */ final native int JNIOpen();
/* */
/* */ final native int JNIClose();
/* */
/* */ final native int JNIEnable();
/* */
/* */ final native int JNIDisable();
/* */
/* */ final native int JNISetOCRTemplate(String paramString);
/* */
/* */ final native int JNIStopDecode();
/* */
/* */ final native int JNIGetDecode(HHPObject paramHHPObject, int paramInt);
/* */
/* */ final native int JNISetParameter(ScanParam paramScanParam);
/* */
/* */ final native int JNIGetParameter(ScanParam paramScanParam);
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\HHPScanner.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,279 @@
package com.seuic.scanner;
public interface IScanner {
boolean open();
void close();
void startScan();
void stopScan();
void enable();
void disable();
boolean setParams(int paramInt1, int paramInt2);
int getParams(int paramInt);
void setDecodeCallBack(DecodeCallback paramDecodeCallback);
void setDecodeInfoCallBack(DecodeInfoCallBack paramDecodeInfoCallBack);
public static class ParamCode {
public static final int LASTER_ONTIME = 1;
public static final int SCAN_ANGLE = 2;
public static final int TIMEOUT_SAMESYMBOL = 3;
public static final int SECURITY_LEVEL = 4;
public static final int BIDIRECTIONAL = 6;
public static final int LIGHTS = 7;
public static final int LCD_DISPLAY = 8;
public static final int ILLUMINATION_LEVEL = 9;
public static final int UPCA = 257;
public static final int UPCE = 258;
public static final int UPCE1 = 259;
public static final int EAN8 = 260;
public static final int EAN13 = 261;
public static final int BOOKLAND = 262;
public static final int UPCA_CHK = 263;
public static final int UPCE_CHK = 264;
public static final int UPCE1_CHK = 265;
public static final int UPCA_PREAM = 266;
public static final int UPCE_PREAM = 267;
public static final int UPCE1_PREAM = 268;
public static final int UPCE_TO_A = 269;
public static final int UPCE1_TO_A = 270;
public static final int EAN8_TO_13 = 271;
public static final int COUPON = 272;
public static final int UPCE_EXPANDED = 273;
public static final int CODE128 = 289;
public static final int CODE128_LEN_MIN = 290;
public static final int CODE128_LEN_MAX = 291;
public static final int ISBT128 = 292;
public static final int GS1128 = 293;
public static final int CODE39 = 305;
public static final int TRIC39 = 306;
public static final int CODE39_FULL_ASCII = 307;
public static final int CODE39_TO_CODE32 = 308;
public static final int CODE32_PREFIX = 309;
public static final int CODE39_LEN_MIN = 310;
public static final int CODE39_LEN_MAX = 311;
public static final int CODE39_CHK = 312;
public static final int CODE39_VER = 313;
public static final int CODE93 = 321;
public static final int CODE93_LEN_MIN = 322;
public static final int CODE93_LEN_MAX = 323;
public static final int CODE11 = 337;
public static final int CODE11_LEN_MIN = 338;
public static final int CODE11_LEN_MAX = 339;
public static final int CODE11_CHK_VER = 340;
public static final int CODE11_CHK = 341;
public static final int I25 = 353;
public static final int I25_LEN_MIN = 354;
public static final int I25_LEN_MAX = 355;
public static final int D25 = 369;
public static final int D25_LEN_MIN = 370;
public static final int D25_LEN_MAX = 371;
public static final int C25 = 385;
public static final int C25_LEN_MIN = 386;
public static final int C25_LEN_MAX = 387;
public static final int CODEBAR = 401;
public static final int CODEBAR_LEN_MIN = 402;
public static final int CODEBAR_LEN_MAX = 403;
public static final int MSI = 513;
public static final int MSI_LEN_MIN = 514;
public static final int MSI_LEN_MAX = 515;
public static final int RSS14 = 529;
public static final int RSS_LIMIT = 530;
public static final int RSS_EXPANDED = 531;
public static final int RSS_TO_UPCEAN = 532;
public static final int QRCODE = 545;
public static final int QRCODE_LEN_MIN = 546;
public static final int QRCODE_LEN_MAX = 547;
public static final int QRINVERSE = 548;
public static final int MICROQR = 549;
public static final int DM = 561;
public static final int DM_LEN_MIN = 562;
public static final int DM_LEN_MAX = 563;
public static final int DMINVERSE = 564;
public static final int DMI = 565;
public static final int CHINAPOST = 577;
public static final int CHINAPOST_LEN_MIN = 578;
public static final int CHINAPOST_LEN_MAX = 579;
public static final int M25 = 593;
public static final int M25_LEN_MIN = 594;
public static final int M25_LEN_MAX = 595;
public static final int POSTNET = 609;
public static final int PLANET = 610;
public static final int BRITISHPOST = 611;
public static final int JAPPOST = 612;
public static final int AUSPOST = 613;
public static final int UPU_FICS_POSTAL = 614;
public static final int USPS_4CB = 615;
public static final int NETHERLANDS_KIX_CODE = 616;
public static final int POSTNET_CHK = 617;
public static final int PLANET_CHK = 618;
public static final int K35 = 625;
public static final int COMPOSITE = 689;
public static final int COMPOSITE_LEN_MIN = 690;
public static final int COMPOSITE_LEN_MAX = 691;
public static final int PDF417 = 705;
public static final int PDF417_LEN_MIN = 706;
public static final int PDF417_LEN_MAX = 707;
public static final int MICROPDF417 = 721;
public static final int MICROPDF417_LEN_MIN = 722;
public static final int MICROPDF417_LEN_MAX = 723;
public static final int MAXICODE = 737;
public static final int MAXICODE_LEN_MIN = 738;
public static final int MAXICODE_LEN_MAX = 739;
public static final int AZTECCODE = 753;
public static final int AZTECCODE_LEN_MIN = 754;
public static final int AZTECCODE_LEN_MAX = 755;
public static final int AZTECCODE_INVERSE = 756;
public static final int CODEBLOCKF = 769;
public static final int CODEBLOCKF_LEN_MIN = 770;
public static final int CODEBLOCKF_LEN_MAX = 771;
public static final int TELEPEN = 785;
public static final int TELEPEN_LEN_MIN = 786;
public static final int TELEPEN_LEN_MAX = 787;
public static final int TELEPEN_OLDSTYLE = 788;
public static final int FACTORY_DEFAULT = 801;
public static final int OCR = 817;
public static final int OCR_TEMPLATE = 818;
public static final int COMPOSITE_CC_C = 833;
public static final int COMPOSITE_CC_AB = 834;
public static final int COMPOSITE_TLC_39 = 835;
public static final int COMPOSITE_UPCEAN = 836;
public static final int XMIT_CODE_ID = 849;
}
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\IScanner.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,84 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.content.Context;
/* */ import android.util.SparseIntArray;
/* */
/* */ public class N4313Scanner extends Scanner1D {
/* */ static {
/* 8 */ paramArray.clear();
/* 9 */ paramArray.put(1, 1);
/* 10 */ paramArray.put(2, 2);
/* 11 */ paramArray.put(3, 3);
/* */
/* */
/* 14 */ paramArray.put(257, 145);
/* 15 */ paramArray.put(258, 146);
/* 16 */ paramArray.put(260, 148);
/* 17 */ paramArray.put(261, 149);
/* 18 */ paramArray.put(263, 151);
/* 19 */ paramArray.put(264, 152);
/* */
/* 21 */ paramArray.put(289, 273);
/* 22 */ paramArray.put(292, 275);
/* 23 */ paramArray.put(293, 274);
/* */
/* 25 */ paramArray.put(305, 289);
/* 26 */ paramArray.put(307, 291);
/* 27 */ paramArray.put(309, 293);
/* 28 */ paramArray.put(310, 294);
/* 29 */ paramArray.put(311, 295);
/* 30 */ paramArray.put(312, 296);
/* */
/* 32 */ paramArray.put(321, 305);
/* 33 */ paramArray.put(322, 306);
/* 34 */ paramArray.put(323, 307);
/* */
/* 36 */ paramArray.put(337, 321);
/* 37 */ paramArray.put(338, 322);
/* 38 */ paramArray.put(339, 323);
/* */
/* */
/* 41 */ paramArray.put(353, 337);
/* 42 */ paramArray.put(354, 338);
/* 43 */ paramArray.put(355, 339);
/* */
/* 45 */ paramArray.put(513, 353);
/* 46 */ paramArray.put(514, 354);
/* 47 */ paramArray.put(515, 355);
/* */
/* 49 */ paramArray.put(401, 369);
/* 50 */ paramArray.put(402, 370);
/* 51 */ paramArray.put(403, 371);
/* */
/* 53 */ paramArray.put(369, 385);
/* 54 */ paramArray.put(370, 386);
/* 55 */ paramArray.put(371, 387);
/* */
/* 57 */ paramArray.put(385, 401);
/* 58 */ paramArray.put(386, 402);
/* 59 */ paramArray.put(387, 403);
/* */ }
/* */
/* */ N4313Scanner(Context context) {
/* 63 */ super(context);
/* */ }
/* */
/* */
/* */ protected int getLaserTime() {
/* 68 */ int laserTime = getParams(1);
/* 69 */ if (laserTime > 0) {
/* 70 */ return laserTime;
/* */ }
/* 72 */ return 5000;
/* */ }
/* */
/* */ protected void setLaserTime(int time) {
/* 76 */ this.laser_time = time;
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\N4313Scanner.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,13 @@
package com.seuic.scanner;
public class Param1D {
public int id;
public int value;
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\Param1D.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,438 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.content.Context;
/* */ import android.os.Build;
/* */ import android.text.TextUtils;
/* */ import android.util.Log;
/* */ import android.util.SparseIntArray;
/* */ import com.zebra.adc.decoder.compatible.BarCodeReader;
/* */ import java.io.UnsupportedEncodingException;
/* */ import java.util.HashMap;
/* */ import java.util.Map;
/* */
/* */
/* */
/* */
/* */ public class SE4500Scanner
/* */ extends Scanner
/* */ implements BarCodeReader.DecodeCallback
/* */ {
/* 20 */ private final String TYPE_NOT_FOUND = "Unknown Type";
/* 21 */ private final int[] TYPE_LENGTH = new int[] { 1, 3 };
/* */
/* */
/* */ static {
/* 25 */ System.loadLibrary("IAL");
/* 26 */ System.loadLibrary("SDL");
/* */
/* 28 */ if (Build.VERSION.SDK_INT >= 19) {
/* 29 */ System.loadLibrary("barcodereader44");
/* */ }
/* 31 */ else if (Build.VERSION.SDK_INT >= 18) {
/* 32 */ System.loadLibrary("barcodereader43");
/* */ } else {
/* 34 */ System.loadLibrary("barcodereader");
/* */ }
/* */
/* */
/* 38 */ paramArray.put(257, 1);
/* 39 */ paramArray.put(258, 2);
/* 40 */ paramArray.put(259, 12);
/* 41 */ paramArray.put(260, 4);
/* 42 */ paramArray.put(261, 3);
/* 43 */ paramArray.put(262, 83);
/* 44 */ paramArray.put(263, 40);
/* 45 */ paramArray.put(264, 41);
/* 46 */ paramArray.put(265, 42);
/* 47 */ paramArray.put(266, 34);
/* 48 */ paramArray.put(267, 35);
/* 49 */ paramArray.put(268, 36);
/* 50 */ paramArray.put(269, 37);
/* 51 */ paramArray.put(270, 38);
/* 52 */ paramArray.put(271, 39);
/* 53 */ paramArray.put(272, 85);
/* */
/* */
/* 56 */ paramArray.put(289, 8);
/* 57 */ paramArray.put(290, 209);
/* 58 */ paramArray.put(291, 210);
/* 59 */ paramArray.put(292, 84);
/* 60 */ paramArray.put(293, 14);
/* */
/* */
/* 63 */ paramArray.put(305, 0);
/* 64 */ paramArray.put(306, 13);
/* 65 */ paramArray.put(307, 17);
/* 66 */ paramArray.put(308, 86);
/* 67 */ paramArray.put(309, 231);
/* 68 */ paramArray.put(310, 18);
/* 69 */ paramArray.put(311, 19);
/* 70 */ paramArray.put(312, 43);
/* 71 */ paramArray.put(313, 48);
/* */
/* */
/* 74 */ paramArray.put(321, 9);
/* 75 */ paramArray.put(322, 26);
/* 76 */ paramArray.put(323, 27);
/* */
/* */
/* 79 */ paramArray.put(337, 10);
/* 80 */ paramArray.put(338, 28);
/* 81 */ paramArray.put(339, 29);
/* 82 */ paramArray.put(340, 52);
/* 83 */ paramArray.put(341, 47);
/* */
/* */
/* 86 */ paramArray.put(353, 6);
/* 87 */ paramArray.put(354, 22);
/* 88 */ paramArray.put(355, 23);
/* */
/* */
/* 91 */ paramArray.put(369, 5);
/* 92 */ paramArray.put(370, 20);
/* 93 */ paramArray.put(371, 21);
/* */
/* */
/* 96 */ paramArray.put(401, 7);
/* 97 */ paramArray.put(402, 24);
/* 98 */ paramArray.put(403, 25);
/* */
/* */
/* 101 */ paramArray.put(513, 11);
/* 102 */ paramArray.put(514, 30);
/* 103 */ paramArray.put(515, 31);
/* */
/* */
/* 106 */ paramArray.put(385, 408);
/* */
/* */
/* 109 */ paramArray.put(593, 618);
/* 110 */ paramArray.put(594, 619);
/* 111 */ paramArray.put(595, 620);
/* */
/* */
/* 114 */ paramArray.put(609, 89);
/* 115 */ paramArray.put(610, 90);
/* 116 */ paramArray.put(617, 95);
/* 117 */ paramArray.put(618, 95);
/* 118 */ paramArray.put(611, 91);
/* 119 */ paramArray.put(612, 290);
/* 120 */ paramArray.put(613, 291);
/* 121 */ paramArray.put(616, 326);
/* 122 */ paramArray.put(615, 592);
/* 123 */ paramArray.put(614, 611);
/* */
/* */
/* 126 */ paramArray.put(625, 581);
/* */
/* */
/* 129 */ paramArray.put(833, 341);
/* 130 */ paramArray.put(834, 342);
/* 131 */ paramArray.put(835, 371);
/* */
/* */
/* 134 */ paramArray.put(705, 15);
/* */
/* */
/* 137 */ paramArray.put(721, 227);
/* */
/* */
/* 140 */ paramArray.put(737, 294);
/* */
/* */
/* 143 */ paramArray.put(753, 574);
/* 144 */ paramArray.put(756, 589);
/* */
/* */
/* 147 */ paramArray.put(545, 293);
/* 148 */ paramArray.put(548, 587);
/* 149 */ paramArray.put(549, 573);
/* */
/* */
/* 152 */ paramArray.put(561, 292);
/* 153 */ paramArray.put(564, 588);
/* 154 */ paramArray.put(565, 537);
/* */
/* 156 */ paramArray.put(8, 716);
/* 157 */ paramArray.put(849, 45);
/* */
/* 159 */ paramArray.put(9, 764);
/* */ }
/* 161 */ private static Map<String, String> mMapType = new HashMap<String, String>(); static {
/* 162 */ mMapType.put("A", "UPC-A/UPC-E/UPC-E1/EAN-8/EAN-13");
/* 163 */ mMapType.put("B", "Code 39/Code 32");
/* 164 */ mMapType.put("C", "Codabar");
/* 165 */ mMapType.put("D", "Code 128/ISBT 128/ISBT 128 Concatenated");
/* 166 */ mMapType.put("E", "Code 93");
/* 167 */ mMapType.put("F", "Interleaved 2 of 5");
/* 168 */ mMapType.put("G", "Discrete 2 of 5/Discrete 2 of 5 IATA");
/* 169 */ mMapType.put("H", "Code 11");
/* 170 */ mMapType.put("J", "MSI");
/* 171 */ mMapType.put("K", "GS1-128");
/* 172 */ mMapType.put("L", "Bookland EAN");
/* 173 */ mMapType.put("M", "Trioptic Code 39");
/* 174 */ mMapType.put("N", "Coupon Code");
/* 175 */ mMapType.put("R", "GS1 DataBar Family");
/* 176 */ mMapType.put("S", "Matrix 2 of 5");
/* 177 */ mMapType.put("T", "UCC Composite/TLC 39");
/* 178 */ mMapType.put("U", "Chinese 2 of 5");
/* 179 */ mMapType.put("V", "Korean 3 of 5");
/* 180 */ mMapType.put("X", "ISSN EAN/PDF417/Macro PDF417/Micro PDF417");
/* 181 */ mMapType.put("z", "Aztec/Aztec Rune");
/* 182 */ mMapType.put("P00", "Data Matrix");
/* 183 */ mMapType.put("P01", "QR Code/MicroQR");
/* 184 */ mMapType.put("P02", "Maxicode");
/* 185 */ mMapType.put("P03", "US Postnet");
/* 186 */ mMapType.put("P04", "US Planet");
/* 187 */ mMapType.put("P05", "Japan Postal");
/* 188 */ mMapType.put("P06", "UK Postal");
/* 189 */ mMapType.put("P08", "Netherlands KIX Code");
/* 190 */ mMapType.put("P09", "Australia Post");
/* 191 */ mMapType.put("P0A", "USPS 4CB/One Code/Intelligent Mail");
/* 192 */ mMapType.put("P0B", "UPU FICS Postal");
/* 193 */ mMapType.put("P0X", "Signature Capture");
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* 202 */ private Boolean released = new Boolean(true);
/* 203 */ private static int decCount = 0; private DecodeCallback mDecodeCallBack;
/* */
/* */ public SE4500Scanner(Context context) {
/* 206 */ super(context);
/* */ }
/* */ private DecodeInfoCallBack mInfoCallBack; private BarCodeReader mBcr;
/* */
/* */ public boolean open() {
/* 211 */ synchronized (this.released) {
/* 212 */ if (!this.released.booleanValue()) {
/* 213 */ return true;
/* */ }
/* */
/* 216 */ if (Build.VERSION.SDK_INT >= 18) {
/* 217 */ this.mBcr = BarCodeReader.open(this.mContext.getApplicationContext());
/* */ } else {
/* 219 */ this.mBcr = BarCodeReader.open();
/* */ }
/* */
/* 222 */ if (this.mBcr == null) {
/* 223 */ return false;
/* */ }
/* */
/* 226 */ this.mBcr.setDecodeCallback(this);
/* 227 */ this.mBcr.setParameter(45, 2);
/* 228 */ this.released = Boolean.valueOf(false);
/* */ }
/* 230 */ return true;
/* */ }
/* */
/* */
/* */
/* */ public void close() {
/* 236 */ synchronized (this.released) {
/* */
/* 238 */ if (this.released.booleanValue()) {
/* */ return;
/* */ }
/* */
/* 242 */ if (this.mBcr != null) {
/* 243 */ this.mBcr.stopDecode();
/* 244 */ if (!this.released.booleanValue())
/* 245 */ this.mBcr.release();
/* 246 */ this.released = Boolean.valueOf(true);
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */ public void startScan() {
/* 253 */ synchronized (this) {
/* 254 */ if (this.mBcr.scanFinished.booleanValue()) {
/* 255 */ Log.i("SE4500", "Start scan finished " + this.mBcr.scanFinished);
/* 256 */ this.mBcr.scanFinished = Boolean.valueOf(false);
/* 257 */ this.mBcr.startDecode();
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */ public void stopScan() {
/* 264 */ this.mBcr.stopDecode();
/* 265 */ Log.i("SE4500", "Stop scan finished ");
/* */ try {
/* 267 */ Thread.sleep(50L);
/* 268 */ } catch (InterruptedException e) {
/* 269 */ e.printStackTrace();
/* */ }
/* */ }
/* */
/* */
/* */ public boolean setParams(int num, int value) {
/* 275 */ if (paramArray.get(num, -1) == -1 && num != 801) {
/* 276 */ return false;
/* */ }
/* */
/* */
/* 280 */ if (num == 801) {
/* 281 */ setDefault();
/* 282 */ return true;
/* */ }
/* */
/* 285 */ if (this.mBcr.setParameter(paramArray.get(num), value) == 0) {
/* 286 */ return true;
/* */ }
/* */
/* 289 */ return false;
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private void setDefault() {
/* 297 */ close();
/* */
/* 299 */ open();
/* */ }
/* */
/* */
/* */ public int getParams(int num) {
/* 304 */ if (paramArray.get(num, -1) == -1) {
/* 305 */ return -1;
/* */ }
/* */
/* 308 */ return this.mBcr.getNumParameter(paramArray.get(num));
/* */ }
/* */
/* */
/* */
/* */ public void onDecodeComplete(int symbology, int length, byte[] data, BarCodeReader reader) {
/* 314 */ synchronized (this) {
/* */
/* 316 */ if (length == -3) {
/* 317 */ decCount = symbology;
/* */ } else {
/* 319 */ this.mBcr.scanFinished = Boolean.valueOf(true);
/* */ }
/* 321 */ Log.i("SE4500", "Decode complete finished " + this.mBcr.scanFinished);
/* 322 */ if (length > 0) {
/* 323 */ synchronized (this.released) {
/* 324 */ if (!this.released.booleanValue()) {
/* 325 */ this.mBcr.stopDecode();
/* */ }
/* */ }
/* */
/* 329 */ ScanLed.setLed(1);
/* 330 */ if (symbology == 153) {
/* */
/* 332 */ symbology = data[0];
/* 333 */ int n = data[1];
/* 334 */ int s = 2;
/* 335 */ int d = 0;
/* 336 */ int len = 0;
/* 337 */ byte[] d99 = new byte[data.length];
/* 338 */ for (int i = 0; i < n; i++) {
/* 339 */ s += 2;
/* 340 */ len = data[s++];
/* 341 */ System.arraycopy(data, s, d99, d, len);
/* 342 */ s += len;
/* 343 */ d += len;
/* */ }
/* 345 */ d99[d] = 0;
/* 346 */ data = d99;
/* */ }
/* */
/* 349 */ String barcode = null;
/* */ try {
/* 351 */ barcode = (new String(data, StringUtils.guessEncoding(data))).trim();
/* 352 */ } catch (UnsupportedEncodingException e1) {
/* 353 */ e1.printStackTrace();
/* */ }
/* */
/* 356 */ DecodeInfo info = getDecodeInfo(barcode);
/* 357 */ if (this.mDecodeCallBack != null) {
/* 358 */ this.mDecodeCallBack.onDecodeComplete(info.barcode);
/* */ }
/* */
/* 361 */ if (this.mInfoCallBack != null) {
/* 362 */ this.mInfoCallBack.onDecodeComplete(info);
/* */ }
/* */ }
/* */ else {
/* */
/* 367 */ switch (length) {
/* */
/* */ }
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */
/* */ private DecodeInfo getDecodeInfo(String barcode) {
/* 379 */ DecodeInfo info = new DecodeInfo();
/* 380 */ String type = null;
/* 381 */ int typelength = 0;
/* 382 */ if (barcode.length() > this.TYPE_LENGTH[0] && !TextUtils.isEmpty(type = mMapType.get(barcode.substring(0, this.TYPE_LENGTH[0])))) {
/* 383 */ info.codetype = type;
/* 384 */ typelength = this.TYPE_LENGTH[0];
/* */ }
/* 386 */ else if (barcode.length() > this.TYPE_LENGTH[1] && !TextUtils.isEmpty(type = mMapType.get(barcode.substring(0, this.TYPE_LENGTH[1])))) {
/* 387 */ info.codetype = type;
/* 388 */ typelength = this.TYPE_LENGTH[1];
/* */ } else {
/* 390 */ info.codetype = "Unknown Type";
/* */ }
/* */
/* 393 */ info.barcode = barcode.substring(typelength);
/* 394 */ info.length = info.barcode.length();
/* 395 */ return info;
/* */ }
/* */
/* */
/* */ public void onEvent(int event, int info, byte[] data, BarCodeReader reader) {
/* 400 */ Log.i("SE4500", "onEvent " + event);
/* 401 */ switch (event) {
/* */
/* */ case 7:
/* */
/* */ try {
/* */
/* */
/* 408 */ Thread.sleep(50L);
/* 409 */ } catch (InterruptedException e) {
/* 410 */ e.printStackTrace();
/* */ }
/* */ break;
/* */ }
/* */ }
/* */
/* */
/* */
/* */
/* */ public void setDecodeCallBack(DecodeCallback callBack) {
/* 420 */ this.mDecodeCallBack = callBack;
/* */ }
/* */
/* */
/* */ public SparseIntArray getAllParams() {
/* 425 */ return paramArray;
/* */ }
/* */
/* */
/* */ public void setDecodeInfoCallBack(DecodeInfoCallBack callback) {
/* 430 */ this.mInfoCallBack = callback;
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\SE4500Scanner.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,38 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.content.Context;
/* */ import android.util.SparseIntArray;
/* */
/* */ public class SE955Scanner
/* */ extends Scanner1D {
/* */ static {
/* 9 */ paramArray.put(2, 2);
/* 10 */ paramArray.put(529, 417);
/* 11 */ paramArray.put(530, 418);
/* 12 */ paramArray.put(531, 419);
/* 13 */ paramArray.put(532, 420);
/* */ }
/* */
/* */ SE955Scanner(Context context) {
/* 17 */ super(context);
/* */ }
/* */
/* */
/* */ protected int getLaserTime() {
/* 22 */ int laserTime = getParams(1);
/* 23 */ if (laserTime > 0) {
/* 24 */ return laserTime * 100;
/* */ }
/* 26 */ return 3000;
/* */ }
/* */
/* */ protected void setLaserTime(int time) {
/* 30 */ this.laser_time = time * 100;
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\SE955Scanner.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,20 @@
/* */ package com.seuic.scanner;
/* */
/* */ class ScanLed
/* */ {
/* */ static {
/* 6 */ System.loadLibrary("Scannerled");
/* */ }
/* */
/* */ static final native int JNISetScanled(int paramInt);
/* */
/* */ static int setLed(int brightness) {
/* 12 */ return JNISetScanled(brightness);
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\ScanLed.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,13 @@
package com.seuic.scanner;
public class ScanParam {
public int id;
public int value;
}
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\ScanParam.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,72 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.app.ActivityManager;
/* */ import android.content.Context;
/* */ import android.content.Intent;
/* */ import android.util.SparseIntArray;
/* */ import java.util.List;
/* */
/* */
/* */
/* */
/* */ public abstract class Scanner
/* */ implements IScanner
/* */ {
/* */ public static final String ACTION_SEND_BARCODE = "com.android.server.scannerservice.broadcast";
/* */ public static final String ACTION_SEND_KEY = "scannerdata";
/* */ public static final String ACTION_SEND_KEY_CODE_TYPE = "codetype";
/* */ private static final String ACTION_SCANNER_SERVICE_TERMINATE = "com.android.scanner.TERMINATE";
/* */ private static final String SERVICE_NAME = "com.seuic.scanner.service.ScanService";
/* */ private static final String ACTION_START_SCAN_SERVICE = "com.seuic.action.START_SCANSERVICE";
/* */ protected boolean isEnabled = true;
/* 22 */ protected static SparseIntArray paramArray = new SparseIntArray();
/* */
/* */ Context mContext;
/* */
/* */ Scanner(Context context) {
/* 27 */ this.mContext = context;
/* */ }
/* */ public abstract SparseIntArray getAllParams();
/* */
/* */ public static void stopScanService(Context context) {
/* 32 */ while (isRunning(context, "com.seuic.scanner.service.ScanService")) {
/* 33 */ context.sendBroadcast(new Intent("com.android.scanner.TERMINATE"));
/* */ }
/* */ try {
/* 36 */ Thread.sleep(150L);
/* 37 */ } catch (InterruptedException e) {
/* 38 */ e.printStackTrace();
/* */ }
/* */ }
/* */
/* */ public static void startScanService(Context context) {
/* 43 */ context.sendBroadcast(new Intent("com.seuic.action.START_SCANSERVICE"));
/* */ }
/* */
/* */ private static boolean isRunning(Context context, String serviceName) {
/* 47 */ ActivityManager am = (ActivityManager)context.getSystemService("activity");
/* 48 */ List<ActivityManager.RunningServiceInfo> infos = am.getRunningServices(100);
/* 49 */ for (ActivityManager.RunningServiceInfo serviceInfo : infos) {
/* 50 */ if (serviceInfo.service.getClassName().equals(serviceName)) {
/* 51 */ return true;
/* */ }
/* */ }
/* 54 */ return false;
/* */ }
/* */
/* */
/* */ public void enable() {
/* 59 */ this.isEnabled = true;
/* */ }
/* */
/* */
/* */ public void disable() {
/* 64 */ this.isEnabled = false;
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\Scanner.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,327 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.content.Context;
/* */ import android.os.Handler;
/* */ import android.os.Message;
/* */ import android.util.Log;
/* */ import android.util.SparseIntArray;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ class Scanner1D
/* */ extends Scanner
/* */ {
/* */ private static final String LOG_TAG = "Scanner1D";
/* */ private static DecodeCallback callback;
/* */ private static DecodeInfoCallBack infoCallBack;
/* */ private Thread mThread;
/* */ public boolean isOpened = false;
/* */ protected int laser_time;
/* */
/* */ static {
/* 45 */ System.loadLibrary("Scanner1D");
/* */
/* 47 */ paramArray.put(1, 1);
/* 48 */ paramArray.put(3, 3);
/* 49 */ paramArray.put(4, 4);
/* 50 */ paramArray.put(6, 5);
/* */
/* 52 */ paramArray.put(257, 145);
/* 53 */ paramArray.put(258, 146);
/* 54 */ paramArray.put(259, 147);
/* 55 */ paramArray.put(260, 148);
/* 56 */ paramArray.put(261, 149);
/* 57 */ paramArray.put(262, 150);
/* 58 */ paramArray.put(263, 151);
/* 59 */ paramArray.put(264, 152);
/* 60 */ paramArray.put(265, 153);
/* 61 */ paramArray.put(266, 154);
/* 62 */ paramArray.put(267, 155);
/* 63 */ paramArray.put(268, 156);
/* 64 */ paramArray.put(269, 157);
/* 65 */ paramArray.put(270, 158);
/* 66 */ paramArray.put(272, 159);
/* */
/* 68 */ paramArray.put(289, 273);
/* 69 */ paramArray.put(292, 275);
/* 70 */ paramArray.put(293, 274);
/* */
/* 72 */ paramArray.put(305, 289);
/* 73 */ paramArray.put(306, 290);
/* 74 */ paramArray.put(307, 291);
/* 75 */ paramArray.put(308, 292);
/* 76 */ paramArray.put(309, 293);
/* 77 */ paramArray.put(310, 294);
/* 78 */ paramArray.put(311, 295);
/* 79 */ paramArray.put(312, 296);
/* 80 */ paramArray.put(313, 297);
/* */
/* 82 */ paramArray.put(321, 305);
/* 83 */ paramArray.put(322, 306);
/* 84 */ paramArray.put(323, 307);
/* */
/* 86 */ paramArray.put(337, 321);
/* 87 */ paramArray.put(338, 322);
/* 88 */ paramArray.put(339, 323);
/* 89 */ paramArray.put(340, 324);
/* 90 */ paramArray.put(341, 325);
/* */
/* 92 */ paramArray.put(353, 337);
/* 93 */ paramArray.put(354, 338);
/* 94 */ paramArray.put(355, 339);
/* */
/* 96 */ paramArray.put(513, 353);
/* 97 */ paramArray.put(514, 354);
/* 98 */ paramArray.put(515, 355);
/* */
/* 100 */ paramArray.put(401, 369);
/* 101 */ paramArray.put(402, 370);
/* 102 */ paramArray.put(403, 371);
/* */
/* 104 */ paramArray.put(369, 385);
/* 105 */ paramArray.put(370, 386);
/* 106 */ paramArray.put(371, 387);
/* */
/* 108 */ paramArray.put(385, 401);
/* 109 */ paramArray.put(386, 402);
/* 110 */ paramArray.put(387, 403);
/* */ }
/* */
/* */ public SparseIntArray getAllParams() {
/* 114 */ return paramArray;
/* */ }
/* */
/* 117 */ private Runnable runnable = new Runnable()
/* */ {
/* */ public void run()
/* */ {
/* */ while (true) {
/* 122 */ synchronized (Scanner1D.this.runnable) {
/* */ try {
/* 124 */ Scanner1D.this.runnable.wait();
/* 125 */ } catch (InterruptedException e) {
/* 126 */ Log.i("Scanner1D", "Error:" + e.getMessage());
/* */ }
/* 128 */ Scanner1D.this.decode();
/* */ }
/* */ }
/* */ }
/* */ };
/* */
/* 134 */ private Handler mHandler = new DecodeHandler();
/* */
/* */ Scanner1D(Context context) {
/* 137 */ super(context);
/* */ }
/* */
/* */
/* */ public boolean open() {
/* 142 */ if (this.isOpened) {
/* 143 */ return true;
/* */ }
/* */
/* 146 */ if (JNIOpen()) {
/* 147 */ this.isOpened = true;
/* 148 */ this.laser_time = getLaserTime();
/* 149 */ this.mThread = new Thread(this.runnable);
/* 150 */ this.mThread.start();
/* 151 */ return true;
/* */ }
/* 153 */ return false;
/* */ }
/* */
/* */ public void close() {
/* 157 */ JNIClose();
/* 158 */ this.isOpened = false;
/* */ }
/* */
/* */
/* */ public void startScan() {
/* 163 */ scan();
/* */ }
/* */
/* */ void scan() {
/* 167 */ if (!scanFinished.booleanValue()) {
/* */ return;
/* */ }
/* */
/* 171 */ synchronized (this.runnable) {
/* 172 */ this.runnable.notify();
/* */ }
/* */ }
/* */
/* */
/* 177 */ static Boolean scanFinished = Boolean.valueOf(true);
/* */ private void decode() {
/* 179 */ synchronized (this) {
/* 180 */ scanFinished = Boolean.valueOf(false);
/* 181 */ BarcodeInfo barcodeInfo = new BarcodeInfo();
/* */
/* 183 */ if (this.isEnabled &&
/* 184 */ JNIGetBarcode(barcodeInfo, this.laser_time)) {
/* */
/* 186 */ ScanLed.setLed(1);
/* 187 */ Message msg = this.mHandler.obtainMessage();
/* 188 */ msg.obj = barcodeInfo;
/* 189 */ this.mHandler.sendMessage(msg);
/* */ }
/* */
/* 192 */ scanFinished = Boolean.valueOf(true);
/* */ }
/* */ }
/* */
/* */
/* */ public void stopScan() {
/* 198 */ JNIStopScan();
/* */ }
/* */
/* */
/* */ public void enable() {
/* 203 */ JNIEnableScan();
/* 204 */ this.isEnabled = true;
/* */ }
/* */
/* */
/* */ public void disable() {
/* 209 */ JNIDisableScan();
/* 210 */ this.isEnabled = false;
/* */ }
/* */
/* */
/* */ public boolean setParams(int id, int value) {
/* 215 */ if (paramArray.get(id, -1) == -1 && id != 801) {
/* 216 */ return false;
/* */ }
/* */
/* 219 */ boolean ret = false;
/* */
/* 221 */ if (id == 801) {
/* 222 */ ret = JNIFactoryDefault();
/* 223 */ if (ret) {
/* */
/* */ try {
/* 226 */ Thread.sleep(500L);
/* 227 */ this.laser_time = getLaserTime();
/* 228 */ } catch (Exception exception) {}
/* */ }
/* */
/* */
/* 232 */ return ret;
/* */ }
/* */
/* 235 */ ScanParam param = new ScanParam();
/* 236 */ param.id = paramArray.get(id);
/* 237 */ param.value = value;
/* 238 */ ret = JNISetParam(param);
/* 239 */ if (ret && id == 1) {
/* 240 */ setLaserTime(value);
/* */ }
/* 242 */ return ret;
/* */ }
/* */
/* */
/* */
/* */ public int getParams(int id) {
/* 248 */ if (paramArray.get(id, -1) == -1) {
/* 249 */ return -1;
/* */ }
/* */
/* 252 */ ScanParam param = new ScanParam();
/* 253 */ param.id = paramArray.get(id);
/* 254 */ boolean ret = JNIGetParam(param);
/* */
/* 256 */ if (ret) {
/* 257 */ return param.value;
/* */ }
/* 259 */ return -1;
/* */ }
/* */
/* */ private class BarcodeInfo {
/* */ public String data;
/* */ public int length;
/* */ public String type;
/* */
/* */ private BarcodeInfo() {} }
/* */
/* */ public void setDecodeCallBack(DecodeCallback decodeCallback) {
/* 270 */ callback = decodeCallback;
/* */ }
/* */
/* */ static class DecodeHandler extends Handler {
/* */ public void handleMessage(Message msg) {
/* 275 */ BarcodeInfo barcodeInfo = (BarcodeInfo)msg.obj;
/* 276 */ if (Scanner1D.callback != null && !"".equals(barcodeInfo.data)) {
/* 277 */ Scanner1D.callback.onDecodeComplete(barcodeInfo.data);
/* */ }
/* */
/* 280 */ if (Scanner1D.infoCallBack != null && !"".equals(barcodeInfo.data)) {
/* 281 */ DecodeInfo info = new DecodeInfo();
/* 282 */ info.barcode = barcodeInfo.data;
/* 283 */ info.codetype = barcodeInfo.type;
/* 284 */ info.length = barcodeInfo.length;
/* 285 */ Scanner1D.infoCallBack.onDecodeComplete(info);
/* */ }
/* */ }
/* */ }
/* */
/* */
/* */
/* */ public void setDecodeInfoCallBack(DecodeInfoCallBack callback) {
/* 293 */ infoCallBack = callback;
/* */ }
/* */
/* */ protected int getLaserTime() {
/* 297 */ return -1;
/* */ }
/* */
/* */ protected void setLaserTime(int time) {
/* 301 */ this.laser_time = time;
/* */ }
/* */
/* */ public final native boolean JNIOpen();
/* */
/* */ public final native void JNIClose();
/* */
/* */ public final native boolean JNIGetBarcode(BarcodeInfo paramBarcodeInfo, int paramInt);
/* */
/* */ public final native boolean JNIStopScan();
/* */
/* */ public final native boolean JNISetParam(ScanParam paramScanParam);
/* */
/* */ public final native boolean JNIGetParam(ScanParam paramScanParam);
/* */
/* */ public final native void JNIEnableScan();
/* */
/* */ public final native void JNIDisableScan();
/* */
/* */ private final native boolean JNIFactoryDefault();
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\Scanner1D.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

View File

@ -0,0 +1,60 @@
/* */ package com.seuic.scanner;
/* */
/* */ import android.content.Context;
/* */
/* */
/* */
/* */ public class ScannerFactory
/* */ {
/* */ static final String SCN_SE4500 = "se4500";
/* */ static final String SCN_N5600 = "N5600";
/* */ static final String SCN_SE955 = "SE955";
/* */ static final String SCN_SE965 = "SE965";
/* */ static final String SCN_N4313 = "N4313";
/* */ static final String SCN_UE966 = "UE966";
/* */ static final String SCN_SE655 = "SE655";
/* */ static final String SCN_SE4710 = "SE4710";
/* */ private static Scanner scanner;
/* */ private static scanid mScanid;
/* */
/* */ public static Scanner getScanner(Context context) {
/* 21 */ Scanner.stopScanService(context);
/* */
/* 23 */ return getScannerNoStopService(context);
/* */ }
/* */
/* */
/* */ private static Scanner getScannerNoStopService(Context context) {
/* 28 */ if (scanner == null) {
/* */
/* 30 */ mScanid = new scanid();
/* 31 */ String deviceName = mScanid.readScanner();
/* 32 */ if (deviceName != null) {
/* 33 */ if (deviceName.equals("N4313")) {
/* 34 */ scanner = new N4313Scanner(context);
/* 35 */ } else if (deviceName.equals("SE955") ||
/* 36 */ deviceName.equals("SE965") ||
/* 37 */ deviceName.equals("SE655")) {
/* 38 */ scanner = new SE955Scanner(context);
/* 39 */ } else if (deviceName.endsWith("UE966")) {
/* 40 */ scanner = new UE966Scanner(context);
/* 41 */ } else if (deviceName.equals("N5600")) {
/* 42 */ scanner = new HHPScanner(context);
/* 43 */ } else if (deviceName.equals("se4500") ||
/* 44 */ deviceName.equals("SE4710")) {
/* 45 */ scanner = new SE4500Scanner(context);
/* */ }
/* */ } else {
/* 48 */ scanner = new HHPScanner(context);
/* */ }
/* */ }
/* */
/* 52 */ return scanner;
/* */ }
/* */ }
/* Location: E:\Demo\ChaoRan_A9L\libs\ScannerAPI.jar!\com\seuic\scanner\ScannerFactory.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 1.1.3
*/

Some files were not shown because too many files have changed in this diff Show More