|
@@ -27,10 +27,12 @@ import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
import android.content.IntentFilter;
|
|
|
|
|
+import android.content.SharedPreferences;
|
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
import android.database.sqlite.SQLiteDatabase;
|
|
|
import android.text.Editable;
|
|
import android.text.Editable;
|
|
|
import android.text.TextWatcher;
|
|
import android.text.TextWatcher;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
+import android.view.KeyEvent;
|
|
|
import android.view.Menu;
|
|
import android.view.Menu;
|
|
|
import android.view.MenuItem;
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
@@ -44,108 +46,30 @@ public class MainActivity extends Activity
|
|
|
// static final int ACTIVITY_CAMERA = 0;
|
|
// static final int ACTIVITY_CAMERA = 0;
|
|
|
// static final int ACTIVITY_VIEW = 1;
|
|
// static final int ACTIVITY_VIEW = 1;
|
|
|
// static final String serverurl = "http://192.168.23.1/xampp/";
|
|
// static final String serverurl = "http://192.168.23.1/xampp/";
|
|
|
- static final String TAG = "MainActivity";
|
|
|
|
|
- static final int REQUEST_TAKE_PHOTO = 1;
|
|
|
|
|
- static final int REQUEST_SCAN_BARCODE = 2;
|
|
|
|
|
- static final int REQUEST_LOCKER = 3;
|
|
|
|
|
|
|
+ static final String TAG = "MainActivity";
|
|
|
|
|
+ static final int REQUEST_TAKE_PHOTO = 1;
|
|
|
|
|
+ static final int REQUEST_PREVIEW = 4;
|
|
|
|
|
+ static final int REQUEST_SCAN_BARCODE = 2;
|
|
|
|
|
+ static final int REQUEST_LOCKER = 3;
|
|
|
// HashMap<String, String> hashMap = new HashMap<String, String>();
|
|
// HashMap<String, String> hashMap = new HashMap<String, String>();
|
|
|
|
|
|
|
|
// ArrayList<String> pic_file = new ArrayList<String>();
|
|
// ArrayList<String> pic_file = new ArrayList<String>();
|
|
|
// ArrayList<bitmap>
|
|
// ArrayList<bitmap>
|
|
|
// ArrayList<>
|
|
// ArrayList<>
|
|
|
// private String thumbpath = null;
|
|
// private String thumbpath = null;
|
|
|
- private int iwidth = 640;
|
|
|
|
|
- private int iheight = 480;
|
|
|
|
|
- private File photoFile = null;
|
|
|
|
|
- Bitmap thumbBitmap = null;
|
|
|
|
|
|
|
+ private int iwidth = 640;
|
|
|
|
|
+ private int iheight = 480;
|
|
|
|
|
+ private File photoFile = null;
|
|
|
|
|
+ Bitmap thumbBitmap = null;
|
|
|
// private int iPhotoCount = 0;
|
|
// private int iPhotoCount = 0;
|
|
|
- public String LastFileName = "";
|
|
|
|
|
- private boolean m_blocked = false;
|
|
|
|
|
- TextView m_tvalert;
|
|
|
|
|
|
|
+ public String LastFileName = "";
|
|
|
|
|
+ private boolean m_blocked = false;
|
|
|
|
|
+ TextView m_tvalert;
|
|
|
// private String user;
|
|
// private String user;
|
|
|
// private String password;
|
|
// private String password;
|
|
|
// String m_sName;
|
|
// String m_sName;
|
|
|
// String m_sPassword;
|
|
// String m_sPassword;
|
|
|
- ArrayList<String> photoList = new ArrayList<String>();
|
|
|
|
|
- // private SurfaceView picSV;
|
|
|
|
|
- // private Camera camera;
|
|
|
|
|
- //
|
|
|
|
|
-// private final BroadcastReceiver m_lockedReceiver = new BroadcastReceiver()
|
|
|
|
|
-// {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onReceive(
|
|
|
|
|
-// Context context,
|
|
|
|
|
-// Intent intent)
|
|
|
|
|
-// {
|
|
|
|
|
-// String action = intent
|
|
|
|
|
-// .getAction();
|
|
|
|
|
-// if (action
|
|
|
|
|
-// .equals(Intent.ACTION_SCREEN_OFF))
|
|
|
|
|
-// {
|
|
|
|
|
-// Log.e("hg",
|
|
|
|
|
-// "�յ��㲥!!!=======>m_blocked="
|
|
|
|
|
-// + m_blocked);
|
|
|
|
|
-// if (m_blocked == true)
|
|
|
|
|
-// return;
|
|
|
|
|
-// Intent activityintent = new Intent();
|
|
|
|
|
-// activityintent
|
|
|
|
|
-// .setClass(
|
|
|
|
|
-// MainActivity.this,
|
|
|
|
|
-// LockerActivity.class);
|
|
|
|
|
-// startActivityForResult(
|
|
|
|
|
-// activityintent,
|
|
|
|
|
-// REQUEST_LOCKER);
|
|
|
|
|
-// Log.e(TAG,
|
|
|
|
|
-// "===================>start locker");
|
|
|
|
|
-// m_blocked = true;
|
|
|
|
|
-// }
|
|
|
|
|
-// // if
|
|
|
|
|
-// // (action.equals(Intent.ACTION_USER_PRESENT))
|
|
|
|
|
-// // {
|
|
|
|
|
-// //
|
|
|
|
|
-// // Log.e("hg",
|
|
|
|
|
-// // "�յ��㲥!!!=======>m_blocked="
|
|
|
|
|
-// // +
|
|
|
|
|
-// // m_blocked);
|
|
|
|
|
-// // if
|
|
|
|
|
-// // (m_blocked
|
|
|
|
|
-// // == true)
|
|
|
|
|
-// // return;
|
|
|
|
|
-// // Intent
|
|
|
|
|
-// // activityintent
|
|
|
|
|
-// // = new
|
|
|
|
|
-// // Intent();
|
|
|
|
|
-// // activityintent
|
|
|
|
|
-// // .setClass(MainActivity.this,
|
|
|
|
|
-// // LockerActivity.class);
|
|
|
|
|
-// // startActivityForResult(activityintent,
|
|
|
|
|
-// // REQUEST_LOCKER);
|
|
|
|
|
-// // Log.e(TAG,
|
|
|
|
|
-// // "===================>start locker");
|
|
|
|
|
-// // m_blocked
|
|
|
|
|
-// // = true;
|
|
|
|
|
-// // }
|
|
|
|
|
-// }
|
|
|
|
|
-// };
|
|
|
|
|
-
|
|
|
|
|
- // @Override
|
|
|
|
|
- // protected void onStart() {
|
|
|
|
|
- // Log.i(TAG, "onStart========>m_blocked="+m_blocked);
|
|
|
|
|
- // // TODO Auto-generated method stub
|
|
|
|
|
- //
|
|
|
|
|
- // if (m_blocked) {
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
- // super.onStart();
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // @Override
|
|
|
|
|
- // protected void onStop() {
|
|
|
|
|
- // Log.i(TAG, "onStop========>");
|
|
|
|
|
- // // TODO Auto-generated method stub
|
|
|
|
|
- //
|
|
|
|
|
- // super.onStop();
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ ArrayList<String> photoList = new ArrayList<String>();
|
|
|
|
|
|
|
|
private void StartCamera()
|
|
private void StartCamera()
|
|
|
{
|
|
{
|
|
@@ -179,6 +103,18 @@ public class MainActivity extends Activity
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (keyCode == KeyEvent.KEYCODE_BACK)
|
|
|
|
|
+ {
|
|
|
|
|
+ clear();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return super.onKeyDown(keyCode, event);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
|
{
|
|
{
|
|
@@ -186,7 +122,6 @@ public class MainActivity extends Activity
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_main1);
|
|
setContentView(R.layout.activity_main1);
|
|
|
|
|
|
|
|
-
|
|
|
|
|
ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
|
thumbsImageView.setOnClickListener(new View.OnClickListener()
|
|
thumbsImageView.setOnClickListener(new View.OnClickListener()
|
|
|
{
|
|
{
|
|
@@ -194,24 +129,14 @@ public class MainActivity extends Activity
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v)
|
|
public void onClick(View v)
|
|
|
{
|
|
{
|
|
|
|
|
+ if (photoList.size() < 1)
|
|
|
|
|
+ return;
|
|
|
|
|
|
|
|
Intent intent = new Intent(MainActivity.this,
|
|
Intent intent = new Intent(MainActivity.this,
|
|
|
PhotoPreviewActivity.class);
|
|
PhotoPreviewActivity.class);
|
|
|
intent.putExtra("pic_list", (Serializable) photoList);
|
|
intent.putExtra("pic_list", (Serializable) photoList);
|
|
|
- startActivity(intent);
|
|
|
|
|
|
|
+ startActivityForResult(intent, REQUEST_PREVIEW);
|
|
|
|
|
|
|
|
- // File folder = new
|
|
|
|
|
- // File(Environment.getExternalStorageDirectory().getPath()+"/redant/pop/temp");
|
|
|
|
|
- // File[] allFiles = folder.listFiles();
|
|
|
|
|
- // new SingleMediaScanner(MainActivity.this, allFiles[0]);
|
|
|
|
|
- // Intent intent = new Intent();
|
|
|
|
|
- // // Intent.ACTION_PICK,
|
|
|
|
|
- // //
|
|
|
|
|
- // android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
|
|
|
- // // startActivityForResult(intent, REQUEST_SCAN_BARCODE);
|
|
|
|
|
- //
|
|
|
|
|
- // intent.setClass(MainActivity.this, CaptureActivity.class);
|
|
|
|
|
- // startActivityForResult(intent, REQUEST_SCAN_BARCODE);
|
|
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
// m_sName = intent.getStringExtra("user");
|
|
// m_sName = intent.getStringExtra("user");
|
|
@@ -222,7 +147,7 @@ public class MainActivity extends Activity
|
|
|
IntentFilter msgFilter = new IntentFilter();
|
|
IntentFilter msgFilter = new IntentFilter();
|
|
|
Intent intent = getIntent();
|
|
Intent intent = getIntent();
|
|
|
msgFilter.addAction("android.intent.action.SCREEN_OFF");
|
|
msgFilter.addAction("android.intent.action.SCREEN_OFF");
|
|
|
-// msgFilter.addAction("REDANT.POP.USER_CHECK_FAILED");
|
|
|
|
|
|
|
+ // msgFilter.addAction("REDANT.POP.USER_CHECK_FAILED");
|
|
|
msgFilter.addAction("REDANT.POP.FINISH_UPLOAD_QUEUE");
|
|
msgFilter.addAction("REDANT.POP.FINISH_UPLOAD_QUEUE");
|
|
|
msgFilter.addAction("REDANT.POP.FINISH_UPLOAD_QUEUE_WITH_ERROR");
|
|
msgFilter.addAction("REDANT.POP.FINISH_UPLOAD_QUEUE_WITH_ERROR");
|
|
|
msgFilter.setPriority(2147483647);
|
|
msgFilter.setPriority(2147483647);
|
|
@@ -239,14 +164,7 @@ public class MainActivity extends Activity
|
|
|
// photoList = A
|
|
// photoList = A
|
|
|
// savedInstanceState.getStringArrayList("photoList");
|
|
// savedInstanceState.getStringArrayList("photoList");
|
|
|
photoFile = (File) savedInstanceState.getSerializable("photoFile");
|
|
photoFile = (File) savedInstanceState.getSerializable("photoFile");
|
|
|
- // iPhotoCount = savedInstanceState.getInt("iPhotoCount");
|
|
|
|
|
- // thumbpath = savedInstanceState.getString("thumbpath");
|
|
|
|
|
- // if (savedInstanceState.getString("m_sName") != null)
|
|
|
|
|
- // m_sName = savedInstanceState.getString("m_sName");
|
|
|
|
|
- // if (savedInstanceState.getString("m_sPassword") != null)
|
|
|
|
|
- // m_sPassword = savedInstanceState.getString("m_sPassword");
|
|
|
|
|
- // ImageView thumbsImageView = (ImageView)
|
|
|
|
|
- // findViewById(R.id.ivThumbs);
|
|
|
|
|
|
|
+
|
|
|
if (thumbBitmap != null)
|
|
if (thumbBitmap != null)
|
|
|
{
|
|
{
|
|
|
thumbsImageView.setImageBitmap(thumbBitmap);
|
|
thumbsImageView.setImageBitmap(thumbBitmap);
|
|
@@ -257,48 +175,7 @@ public class MainActivity extends Activity
|
|
|
countTextView.setText(photoList.size() + " Photos");
|
|
countTextView.setText(photoList.size() + " Photos");
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
-// EditText edit = (EditText) findViewById(R.id.pidval);
|
|
|
|
|
-
|
|
|
|
|
-// edit.addTextChangedListener(new TextWatcher()
|
|
|
|
|
-// {
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void onTextChanged(CharSequence s, int start, int before,
|
|
|
|
|
-// int count)
|
|
|
|
|
-// {
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
|
|
-// int after)
|
|
|
|
|
-// {
|
|
|
|
|
-// }
|
|
|
|
|
-//
|
|
|
|
|
-// @Override
|
|
|
|
|
-// public void afterTextChanged(Editable s)
|
|
|
|
|
-// {
|
|
|
|
|
-// // EditText edit = (EditText) findViewById(R.id.edit);
|
|
|
|
|
-// ImageButton ibtnUpload = (ImageButton) findViewById(R.id.ibtnOk);
|
|
|
|
|
-// if (photoList.size() > 0 && s.length() > 0)
|
|
|
|
|
-// {
|
|
|
|
|
-// ibtnUpload.setVisibility(View.VISIBLE);
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// else
|
|
|
|
|
-// {
|
|
|
|
|
-// ibtnUpload.setVisibility(View.INVISIBLE);
|
|
|
|
|
-//
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-// });
|
|
|
|
|
- // if (getRequestedOrientation() ==
|
|
|
|
|
- // ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
|
|
|
|
|
- // LinearLayout landLayout = (LinearLayout) findViewById(R.id.land);
|
|
|
|
|
- // landLayout.setVisibility(View.VISIBLE);
|
|
|
|
|
- // } else {
|
|
|
|
|
- // LinearLayout portLayout = (LinearLayout) findViewById(R.id.port);
|
|
|
|
|
- // portLayout.setVisibility(View.VISIBLE);
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+
|
|
|
ImageButton ibtnscan = (ImageButton) findViewById(R.id.ibtnScan);
|
|
ImageButton ibtnscan = (ImageButton) findViewById(R.id.ibtnScan);
|
|
|
ibtnscan.setOnClickListener(new View.OnClickListener()
|
|
ibtnscan.setOnClickListener(new View.OnClickListener()
|
|
|
{
|
|
{
|
|
@@ -306,11 +183,8 @@ public class MainActivity extends Activity
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v)
|
|
public void onClick(View v)
|
|
|
{
|
|
{
|
|
|
- Log.e(TAG,"==============>Click Scan button");
|
|
|
|
|
|
|
+ Log.e(TAG, "==============>Click Scan button");
|
|
|
Intent intent = new Intent();
|
|
Intent intent = new Intent();
|
|
|
- // Intent.ACTION_PICK,
|
|
|
|
|
- // android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
|
|
|
|
|
- // startActivityForResult(intent, REQUEST_SCAN_BARCODE);
|
|
|
|
|
|
|
|
|
|
intent.setClass(MainActivity.this, CaptureActivity.class);
|
|
intent.setClass(MainActivity.this, CaptureActivity.class);
|
|
|
startActivityForResult(intent, REQUEST_SCAN_BARCODE);
|
|
startActivityForResult(intent, REQUEST_SCAN_BARCODE);
|
|
@@ -426,30 +300,6 @@ public class MainActivity extends Activity
|
|
|
return image;
|
|
return image;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // public static void savePic(Bitmap b, String strFileName)
|
|
|
|
|
- // {
|
|
|
|
|
- // FileOutputStream fos = null;
|
|
|
|
|
- // try
|
|
|
|
|
- // {
|
|
|
|
|
- // fos = new FileOutputStream(strFileName);
|
|
|
|
|
- // if (null != fos)
|
|
|
|
|
- // {
|
|
|
|
|
- //
|
|
|
|
|
- // b.compress(Bitmap.CompressFormat.PNG, 90, fos);
|
|
|
|
|
- // fos.flush();
|
|
|
|
|
- // fos.close();
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // catch (FileNotFoundException e)
|
|
|
|
|
- // {
|
|
|
|
|
- // e.printStackTrace();
|
|
|
|
|
- // }
|
|
|
|
|
- // catch (IOException e)
|
|
|
|
|
- // {
|
|
|
|
|
- // e.printStackTrace();
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
boolean createDir(String path)
|
|
boolean createDir(String path)
|
|
|
{
|
|
{
|
|
|
Log.i(TAG, "readFile:createDir=" + path);
|
|
Log.i(TAG, "readFile:createDir=" + path);
|
|
@@ -503,26 +353,10 @@ public class MainActivity extends Activity
|
|
|
if (resultCode == Activity.RESULT_OK) // ��������
|
|
if (resultCode == Activity.RESULT_OK) // ��������
|
|
|
|
|
|
|
|
{
|
|
{
|
|
|
- // Log.e(TAG, msg)
|
|
|
|
|
- // Bundle bundle = data.getExtras();
|
|
|
|
|
- // if(thumbBitmap!=null)
|
|
|
|
|
- // thumbBitmap=null;
|
|
|
|
|
- // thumbBitmap = (Bitmap) bundle.get("data");
|
|
|
|
|
- // // ��ȡ������ص����ݣ���ת��ΪBitmapͼƬ��ʽ
|
|
|
|
|
- // Bitmap thumbBitmap = BitmapFactory.decodeFile(photoFile
|
|
|
|
|
- // .toString());
|
|
|
|
|
-
|
|
|
|
|
- // CreateThumb(photoFile);
|
|
|
|
|
|
|
+
|
|
|
Log.e(TAG, photoFile.toString());
|
|
Log.e(TAG, photoFile.toString());
|
|
|
photoList.add(photoFile.toString());
|
|
photoList.add(photoFile.toString());
|
|
|
|
|
|
|
|
- // Bitmap.createScaledBitmap(
|
|
|
|
|
- // thumbBitmap, thumbsImageView.getWidth(),
|
|
|
|
|
- // thumbsImageView.getHeight(), false));
|
|
|
|
|
- // Log.i(TAG, "thumb size" + thumbBitmap.getHeight() + "x"
|
|
|
|
|
- // + thumbBitmap.getWidth());
|
|
|
|
|
- // thumbpath = photoFile.toString();
|
|
|
|
|
- // Log.e(TAG, "get thumbpath==" + thumbpath);
|
|
|
|
|
StartCamera();
|
|
StartCamera();
|
|
|
// iPhotoCount++;
|
|
// iPhotoCount++;
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
@@ -530,14 +364,9 @@ public class MainActivity extends Activity
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- // �˳�����
|
|
|
|
|
- // File emptyFile = new File(LastFileName);
|
|
|
|
|
- // boolean b=emptyFile.delete();
|
|
|
|
|
- // Log.i(TAG, "lastpicPath: " + thumbpath);
|
|
|
|
|
|
|
+
|
|
|
ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
|
- // LayerDrawable
|
|
|
|
|
- // thumbsImageView.setImageDrawable(drawable);
|
|
|
|
|
- // thumbBitmap=getImageThumbnail(thumbpath, iwidth,iheight);
|
|
|
|
|
|
|
+
|
|
|
if (photoList.size() > 0)
|
|
if (photoList.size() > 0)
|
|
|
{
|
|
{
|
|
|
thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory
|
|
thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory
|
|
@@ -546,11 +375,7 @@ public class MainActivity extends Activity
|
|
|
if (thumbBitmap != null)
|
|
if (thumbBitmap != null)
|
|
|
thumbsImageView.setImageBitmap(thumbBitmap);
|
|
thumbsImageView.setImageBitmap(thumbBitmap);
|
|
|
}
|
|
}
|
|
|
- // thumbBitmap = ThumbnailUtils.extractThumbnail(
|
|
|
|
|
- // BitmapFactory.decodeFile(thumbpath), iwidth, iheight);
|
|
|
|
|
- // saveMyBitmap("thumbtest",thumbBitmap);
|
|
|
|
|
- // if (thumbBitmap != null)
|
|
|
|
|
- // thumbsImageView.setImageBitmap(thumbBitmap);
|
|
|
|
|
|
|
+
|
|
|
photoFile.delete();
|
|
photoFile.delete();
|
|
|
TextView countTextView = (TextView) findViewById(R.id.tvPhotoCount);
|
|
TextView countTextView = (TextView) findViewById(R.id.tvPhotoCount);
|
|
|
countTextView.setText(photoList.size() + " Photos");
|
|
countTextView.setText(photoList.size() + " Photos");
|
|
@@ -565,6 +390,26 @@ public class MainActivity extends Activity
|
|
|
if (resultCode == Activity.RESULT_OK)
|
|
if (resultCode == Activity.RESULT_OK)
|
|
|
m_blocked = false;
|
|
m_blocked = false;
|
|
|
}
|
|
}
|
|
|
|
|
+ else if (requestCode == REQUEST_PREVIEW)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int i = 0; i < photoList.size(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ File file = new File(photoList.get(i));
|
|
|
|
|
+ if (!file.exists())
|
|
|
|
|
+ {
|
|
|
|
|
+ photoList.remove(i);
|
|
|
|
|
+ i--;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ TextView countTextView = (TextView) findViewById(R.id.tvPhotoCount);
|
|
|
|
|
+ countTextView.setText(photoList.size() + " Photos");
|
|
|
|
|
+ if (photoList.size() == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
|
|
|
+ thumbsImageView.setImageResource(R.drawable.no_pic);
|
|
|
|
|
+ thumbBitmap = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
else if (requestCode == REQUEST_SCAN_BARCODE)
|
|
else if (requestCode == REQUEST_SCAN_BARCODE)
|
|
|
{
|
|
{
|
|
|
if (resultCode == Activity.RESULT_OK)
|
|
if (resultCode == Activity.RESULT_OK)
|
|
@@ -629,38 +474,46 @@ public class MainActivity extends Activity
|
|
|
switch (item.getItemId())
|
|
switch (item.getItemId())
|
|
|
{
|
|
{
|
|
|
case R.id.action_clear:
|
|
case R.id.action_clear:
|
|
|
- clearfornew();
|
|
|
|
|
|
|
+ clear();
|
|
|
break;
|
|
break;
|
|
|
case R.id.action_type_pid:
|
|
case R.id.action_type_pid:
|
|
|
{
|
|
{
|
|
|
- final View edit = new EditText(this);
|
|
|
|
|
- new AlertDialog.Builder(this)
|
|
|
|
|
- .setIconAttribute(android.R.attr.alertDialogIcon)
|
|
|
|
|
- .setTitle(R.string.title_input_pid)
|
|
|
|
|
- .setView(edit)
|
|
|
|
|
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
|
- public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
|
|
- String pid = ((EditText)edit).getText().toString();
|
|
|
|
|
- TextView pidval = (TextView) findViewById(R.id.pidval);
|
|
|
|
|
- pidval.setText(pid);
|
|
|
|
|
-
|
|
|
|
|
- /* User clicked OK so do some stuff */
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
|
|
|
|
- public void onClick(DialogInterface dialog, int whichButton) {
|
|
|
|
|
-
|
|
|
|
|
- /* User clicked cancel so do some stuff */
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .create().show();
|
|
|
|
|
|
|
+ final View edit = new EditText(this);
|
|
|
|
|
+ new AlertDialog.Builder(this)
|
|
|
|
|
+ .setIconAttribute(android.R.attr.alertDialogIcon)
|
|
|
|
|
+ .setTitle(R.string.title_input_pid)
|
|
|
|
|
+ .setView(edit)
|
|
|
|
|
+ .setPositiveButton(android.R.string.ok,
|
|
|
|
|
+ new DialogInterface.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ public void onClick(DialogInterface dialog,
|
|
|
|
|
+ int whichButton)
|
|
|
|
|
+ {
|
|
|
|
|
+ String pid = ((EditText) edit)
|
|
|
|
|
+ .getText().toString();
|
|
|
|
|
+ TextView pidval = (TextView) findViewById(R.id.pidval);
|
|
|
|
|
+ pidval.setText(pid);
|
|
|
|
|
+
|
|
|
|
|
+ /* User clicked OK so do some stuff */
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .setNegativeButton(android.R.string.cancel,
|
|
|
|
|
+ new DialogInterface.OnClickListener()
|
|
|
|
|
+ {
|
|
|
|
|
+ public void onClick(DialogInterface dialog,
|
|
|
|
|
+ int whichButton)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ /* User clicked cancel so do some stuff */
|
|
|
|
|
+ }
|
|
|
|
|
+ }).create().show();
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case R.id.action_view_queue:
|
|
case R.id.action_view_queue:
|
|
|
{
|
|
{
|
|
|
- Intent intent = new Intent();
|
|
|
|
|
- intent.setClass(MainActivity.this, UploadQueueActivity.class);
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ intent.setClass(MainActivity.this, UploadQueueActivity.class);
|
|
|
|
|
+ startActivity(intent);
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
default:
|
|
default:
|
|
@@ -705,8 +558,13 @@ public class MainActivity extends Activity
|
|
|
return BitmapFactory.decodeByteArray(data, 0, data.length);// ���ֽ��������λͼ
|
|
return BitmapFactory.decodeByteArray(data, 0, data.length);// ���ֽ��������λͼ
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void clearfornew()
|
|
|
|
|
|
|
+ private void clear()
|
|
|
{
|
|
{
|
|
|
|
|
+ for (int i = 0; i < photoList.size(); i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ File file = new File(photoList.get(i));
|
|
|
|
|
+ file.delete();
|
|
|
|
|
+ }
|
|
|
photoList.clear();
|
|
photoList.clear();
|
|
|
TextView pidval = (TextView) findViewById(R.id.pidval);
|
|
TextView pidval = (TextView) findViewById(R.id.pidval);
|
|
|
pidval.setText("");
|
|
pidval.setText("");
|
|
@@ -719,255 +577,93 @@ public class MainActivity extends Activity
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // public class UploadTask extends AsyncTask<Void, Void, Boolean>
|
|
|
|
|
- // {
|
|
|
|
|
- // String err_msg="";
|
|
|
|
|
- // @Override
|
|
|
|
|
- // protected Boolean doInBackground(Void... params)
|
|
|
|
|
- // {
|
|
|
|
|
- // boolean bret=true;
|
|
|
|
|
- //
|
|
|
|
|
- //
|
|
|
|
|
- // SQLiteDatabase db = dbUtil.OpenDB(MainActivity.this, null, true);
|
|
|
|
|
- // EditText edit = (EditText) findViewById(R.id.edit);
|
|
|
|
|
- // String pid = edit.getText().toString();
|
|
|
|
|
- //
|
|
|
|
|
- // if (Network.NetworkIsAvailable(MainActivity.this))
|
|
|
|
|
- // {
|
|
|
|
|
- // int verifyresult = Network.VerifyUser(m_sName, m_sPassword);
|
|
|
|
|
- // if (verifyresult == Network.RESULT_TRUE)
|
|
|
|
|
- // {
|
|
|
|
|
- // /* user is authorized */
|
|
|
|
|
- // for (int i = 0; i < photoList.size(); i++)
|
|
|
|
|
- // {
|
|
|
|
|
- // int uploadresult = Network.UploadFile(photoList.get(i),
|
|
|
|
|
- // m_sName, m_sPassword, pid);
|
|
|
|
|
- // if (uploadresult != Network.RESULT_TRUE)
|
|
|
|
|
- // {
|
|
|
|
|
- // /*
|
|
|
|
|
- // * upload failed write to local db upload when
|
|
|
|
|
- // * connect to network next time;
|
|
|
|
|
- // */
|
|
|
|
|
- //
|
|
|
|
|
- // /*
|
|
|
|
|
- // * serious error occur must notify user
|
|
|
|
|
- // * immediately
|
|
|
|
|
- // */
|
|
|
|
|
- // if (uploadresult == Network.RESULT_LOCALFILE_ERROR)
|
|
|
|
|
- // err_msg+="Warring! Local picture file not found! ";
|
|
|
|
|
- // if( uploadresult == Network.RESULT_USERAUTH_ERROR)
|
|
|
|
|
- // err_msg+="Warring! Authorize check failed when uploading photos! ";
|
|
|
|
|
- //
|
|
|
|
|
- // ContentValues cv = new ContentValues();
|
|
|
|
|
- // cv.put("picker", m_sName);
|
|
|
|
|
- // cv.put("err_code", uploadresult);
|
|
|
|
|
- // cv.put("pid", pid);
|
|
|
|
|
- // cv.put("local_path", photoList.get(i));
|
|
|
|
|
- // db.insert("pics", null, cv);
|
|
|
|
|
- // bret=false;
|
|
|
|
|
- // }
|
|
|
|
|
- // else
|
|
|
|
|
- // {
|
|
|
|
|
- // /* upload success delete file */
|
|
|
|
|
- // File file = new File(photoList.get(i));
|
|
|
|
|
- // file.delete();
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
- // else
|
|
|
|
|
- // if (verifyresult == Network.RESULT_FALSE)
|
|
|
|
|
- // {
|
|
|
|
|
- // /*
|
|
|
|
|
- // * user is not authorized serious error occur must
|
|
|
|
|
- // * notify user
|
|
|
|
|
- // */
|
|
|
|
|
- // Log.e(TAG, "notification====================>");
|
|
|
|
|
- // // String text=m_tvalert.getText().toString();
|
|
|
|
|
- // err_msg+="Warring! Authorize check failed when uploading photos!";
|
|
|
|
|
- // bret=false;
|
|
|
|
|
- // for (int i = 0; i < photoList.size(); i++)
|
|
|
|
|
- // {
|
|
|
|
|
- // ContentValues cv = new ContentValues();
|
|
|
|
|
- // cv.put("picker", m_sName);
|
|
|
|
|
- // cv.put("err_code", Network.RESULT_USERAUTH_ERROR);
|
|
|
|
|
- // cv.put("pid", pid);
|
|
|
|
|
- // cv.put("local_path", photoList.get(i));
|
|
|
|
|
- // db.insert("pics", null, cv);
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
- // else
|
|
|
|
|
- // {
|
|
|
|
|
- // /* an error occur */
|
|
|
|
|
- // for (int i = 0; i < photoList.size(); i++)
|
|
|
|
|
- // {
|
|
|
|
|
- // ContentValues cv = new ContentValues();
|
|
|
|
|
- // cv.put("picker", m_sName);
|
|
|
|
|
- // cv.put("err_code", Network.RESULT_NET_ERROR);
|
|
|
|
|
- // cv.put("pid", pid);
|
|
|
|
|
- // cv.put("local_path", photoList.get(i));
|
|
|
|
|
- // db.insert("pics", null, cv);
|
|
|
|
|
- // }
|
|
|
|
|
- // bret = false;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // else
|
|
|
|
|
- // {
|
|
|
|
|
- // /*
|
|
|
|
|
- // * net work is not available store into local DB it will auto
|
|
|
|
|
- // * upload when connect to network next time;
|
|
|
|
|
- // */
|
|
|
|
|
- //
|
|
|
|
|
- // for (int i = 0; i < photoList.size(); i++)
|
|
|
|
|
- // {
|
|
|
|
|
- // ContentValues cv = new ContentValues();
|
|
|
|
|
- // cv.put("picker", m_sName);
|
|
|
|
|
- // cv.put("err_code", Network.RESULT_NET_ERROR);
|
|
|
|
|
- // cv.put("pid", pid);
|
|
|
|
|
- // cv.put("local_path", photoList.get(i));
|
|
|
|
|
- // db.insert("pics", null, cv);
|
|
|
|
|
- // }
|
|
|
|
|
- // bret=false;
|
|
|
|
|
- // // m_tvalert.setText("Upload failed when uploading photos!");
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // dbUtil.CloseDB(db);
|
|
|
|
|
- // return bret;
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // @Override
|
|
|
|
|
- // protected void onPostExecute(final Boolean success)
|
|
|
|
|
- // {
|
|
|
|
|
- // if(success)
|
|
|
|
|
- // {
|
|
|
|
|
- // m_tvalert.setTextColor(getResources().getColor(R.color.message_success));
|
|
|
|
|
- // m_tvalert.setText("Upload successed!");
|
|
|
|
|
- // }
|
|
|
|
|
- // else
|
|
|
|
|
- // {
|
|
|
|
|
- // m_tvalert.setTextColor(getResources().getColor(R.color.message_fail));
|
|
|
|
|
- // m_tvalert.setText(err_msg);
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- //
|
|
|
|
|
- // // mAuthTask = null;
|
|
|
|
|
- // // showProgress(false);
|
|
|
|
|
- // //
|
|
|
|
|
- // // if (success) {
|
|
|
|
|
- // //
|
|
|
|
|
- // // // SharedPreferences.Editor editor = RunOnce.edit();
|
|
|
|
|
- // // // editor.putBoolean("FirstRun"+globalUtil.getVerName(this),
|
|
|
|
|
- // // false);
|
|
|
|
|
- // // // // Don't forget to commit your edits!!!
|
|
|
|
|
- // // // editor.commit();
|
|
|
|
|
- // // Intent intent = new Intent();
|
|
|
|
|
- // // intent.setClass(LoginActivity.this, MainActivity.class);
|
|
|
|
|
- // // startActivity(intent);
|
|
|
|
|
- // // finish();
|
|
|
|
|
- // // } else {
|
|
|
|
|
- // // m_etPassword
|
|
|
|
|
- // // .setError(getString(R.string.error_incorrect_password));
|
|
|
|
|
- // // m_etPassword.requestFocus();
|
|
|
|
|
- // // }
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // @Override
|
|
|
|
|
- // protected void onCancelled()
|
|
|
|
|
- // {
|
|
|
|
|
- // // mAuthTask = null;
|
|
|
|
|
- // // showProgress(false);
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // public class SingleMediaScanner implements MediaScannerConnectionClient {
|
|
|
|
|
- //
|
|
|
|
|
- // private MediaScannerConnection mMs;
|
|
|
|
|
- // private File mFile;
|
|
|
|
|
- //
|
|
|
|
|
- // public SingleMediaScanner(Context context, File f) {
|
|
|
|
|
- // mFile = f;
|
|
|
|
|
- // mMs = new MediaScannerConnection(context, this);
|
|
|
|
|
- // mMs.connect();
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // public void onMediaScannerConnected() {
|
|
|
|
|
- // Log.d(null, ""+mFile.getAbsolutePath());
|
|
|
|
|
- // Log.d(null,
|
|
|
|
|
- // ""+Environment.getExternalStorageDirectory().getPath()+"/photo/");
|
|
|
|
|
- // Log.d(null, new
|
|
|
|
|
- // File(Environment.getExternalStorageDirectory().getPath()+"/photo/").getAbsolutePath());
|
|
|
|
|
- //
|
|
|
|
|
- // mMs.scanFile(mFile.getAbsolutePath(), null);
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // public void onScanCompleted(String path, Uri uri) {
|
|
|
|
|
- // Intent intent = new Intent(Intent.ACTION_VIEW);
|
|
|
|
|
- // intent.setData(uri);
|
|
|
|
|
- // startActivity(intent);
|
|
|
|
|
- // mMs.disconnect();
|
|
|
|
|
- // }
|
|
|
|
|
- //
|
|
|
|
|
- // }
|
|
|
|
|
-
|
|
|
|
|
- private final BroadcastReceiver MainActivityReceiver = new BroadcastReceiver()
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- public void onReceive(
|
|
|
|
|
- Context context,
|
|
|
|
|
- Intent intent)
|
|
|
|
|
- {
|
|
|
|
|
- String action = intent
|
|
|
|
|
- .getAction();
|
|
|
|
|
- // 如果捕捉到的action是ACTION_BATTERY_CHANGED
|
|
|
|
|
|
|
+ private void clearfornew()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- if ("REDANT.POP.USER_CHECK_FAILED"
|
|
|
|
|
- .equals(action))
|
|
|
|
|
- {
|
|
|
|
|
- m_tvalert
|
|
|
|
|
- .setTextColor(getResources()
|
|
|
|
|
- .getColor(
|
|
|
|
|
- R.color.message_fail));
|
|
|
|
|
- m_tvalert
|
|
|
|
|
- .setText("Upload failed:user verify failure.");
|
|
|
|
|
|
|
+ photoList.clear();
|
|
|
|
|
+ TextView pidval = (TextView) findViewById(R.id.pidval);
|
|
|
|
|
+ pidval.setText("");
|
|
|
|
|
+ updateUploadButton();
|
|
|
|
|
+ ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
|
|
|
+ thumbsImageView.setImageResource(R.drawable.no_pic);
|
|
|
|
|
+ thumbBitmap = null;
|
|
|
|
|
+ TextView countTextView = (TextView) findViewById(R.id.tvPhotoCount);
|
|
|
|
|
+ countTextView.setText("no photo");
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else if ("REDANT.POP.FINISH_UPLOAD_QUEUE"
|
|
|
|
|
- .equals(action))
|
|
|
|
|
- {
|
|
|
|
|
- m_tvalert.setTextColor(getResources().getColor(R.color.message_success));
|
|
|
|
|
- m_tvalert.setText("Upload successes!");
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else if ("REDANT.POP.FINISH_UPLOAD_QUEUE_WITH_ERROR"
|
|
|
|
|
- .equals(action))
|
|
|
|
|
- {
|
|
|
|
|
- m_tvalert.setTextColor(getResources().getColor(R.color.message_fail));
|
|
|
|
|
- m_tvalert.setText("Upload finish with some error!");
|
|
|
|
|
|
|
+ private final BroadcastReceiver MainActivityReceiver = new BroadcastReceiver()
|
|
|
|
|
+ {
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else if (action
|
|
|
|
|
- .equals(Intent.ACTION_SCREEN_OFF))
|
|
|
|
|
|
|
+ public void onReceive(
|
|
|
|
|
+ Context context,
|
|
|
|
|
+ Intent intent)
|
|
|
{
|
|
{
|
|
|
- Log.e("hg",
|
|
|
|
|
- "�յ��㲥!!!=======>m_blocked="
|
|
|
|
|
- + m_blocked);
|
|
|
|
|
- if (m_blocked == true)
|
|
|
|
|
- return;
|
|
|
|
|
- Intent activityintent = new Intent();
|
|
|
|
|
- activityintent
|
|
|
|
|
- .setClass(
|
|
|
|
|
- MainActivity.this,
|
|
|
|
|
- LockerActivity.class);
|
|
|
|
|
- startActivityForResult(
|
|
|
|
|
- activityintent,
|
|
|
|
|
- REQUEST_LOCKER);
|
|
|
|
|
- Log.e(TAG,
|
|
|
|
|
- "===================>start locker");
|
|
|
|
|
- m_blocked = true;
|
|
|
|
|
|
|
+ String action = intent
|
|
|
|
|
+ .getAction();
|
|
|
|
|
+ // 如果捕捉到的action是ACTION_BATTERY_CHANGED
|
|
|
|
|
+
|
|
|
|
|
+ if ("REDANT.POP.USER_CHECK_FAILED"
|
|
|
|
|
+ .equals(action))
|
|
|
|
|
+ {
|
|
|
|
|
+ m_tvalert
|
|
|
|
|
+ .setTextColor(getResources()
|
|
|
|
|
+ .getColor(
|
|
|
|
|
+ R.color.message_fail));
|
|
|
|
|
+ m_tvalert
|
|
|
|
|
+ .setText("Upload failed:user verify failure.");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ("REDANT.POP.FINISH_UPLOAD_QUEUE"
|
|
|
|
|
+ .equals(action))
|
|
|
|
|
+ {
|
|
|
|
|
+ m_tvalert
|
|
|
|
|
+ .setTextColor(getResources()
|
|
|
|
|
+ .getColor(
|
|
|
|
|
+ R.color.message_success));
|
|
|
|
|
+ m_tvalert
|
|
|
|
|
+ .setText("Upload successes!");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ("REDANT.POP.FINISH_UPLOAD_QUEUE_WITH_ERROR"
|
|
|
|
|
+ .equals(action))
|
|
|
|
|
+ {
|
|
|
|
|
+ m_tvalert
|
|
|
|
|
+ .setTextColor(getResources()
|
|
|
|
|
+ .getColor(
|
|
|
|
|
+ R.color.message_fail));
|
|
|
|
|
+ m_tvalert
|
|
|
|
|
+ .setText("Upload finish with some error!");
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if (action
|
|
|
|
|
+ .equals(Intent.ACTION_SCREEN_OFF))
|
|
|
|
|
+ {
|
|
|
|
|
+ Log.e("hg",
|
|
|
|
|
+ "�յ��㲥!!!=======>m_blocked="
|
|
|
|
|
+ + m_blocked);
|
|
|
|
|
+ if (m_blocked == true)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ SharedPreferences pref = RedAntApplication.getInstance()
|
|
|
|
|
+ .getSharedPreferences("POP", 0);
|
|
|
|
|
+ boolean autologin = pref.getBoolean("kepppass", false);
|
|
|
|
|
+ if(autologin)
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ Intent activityintent = new Intent();
|
|
|
|
|
+ activityintent
|
|
|
|
|
+ .setClass(
|
|
|
|
|
+ MainActivity.this,
|
|
|
|
|
+ LockerActivity.class);
|
|
|
|
|
+ startActivityForResult(
|
|
|
|
|
+ activityintent,
|
|
|
|
|
+ REQUEST_LOCKER);
|
|
|
|
|
+ Log.e(TAG,
|
|
|
|
|
+ "===================>start locker");
|
|
|
|
|
+ m_blocked = true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
}
|
|
}
|