|
|
@@ -12,10 +12,10 @@ import android.content.SharedPreferences;
|
|
|
import android.database.Cursor;
|
|
|
import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
-import android.media.ThumbnailUtils;
|
|
|
import android.net.ConnectivityManager;
|
|
|
import android.net.NetworkInfo;
|
|
|
import android.net.Uri;
|
|
|
+import android.os.AsyncTask;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Environment;
|
|
|
import android.provider.MediaStore;
|
|
|
@@ -40,9 +40,12 @@ import com.usai.redant.raimage.POP.PopActivity;
|
|
|
import com.usai.redant.raimage.PhotoList.PhotoListActivity;
|
|
|
import com.usai.util.AES;
|
|
|
import com.usai.util.MD5;
|
|
|
+import com.usai.util.Network;
|
|
|
import com.usai.util.RAUtil;
|
|
|
import com.usai.util.dbgUtil;
|
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
@@ -56,7 +59,171 @@ import java.util.Date;
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity
|
|
|
{
|
|
|
- static final boolean newVersion = true;
|
|
|
+
|
|
|
+ private VerifyCodeTask verifytask=null;
|
|
|
+ public void verifyandupload(Bundle params)
|
|
|
+ {
|
|
|
+ if (verifytask != null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ verifytask = new VerifyCodeTask();
|
|
|
+ verifytask.execute(params);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class VerifyCodeTask extends AsyncTask<Bundle, Void, Boolean>
|
|
|
+ {
|
|
|
+
|
|
|
+ JSONObject json = null;
|
|
|
+
|
|
|
+ // int netconnect;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Boolean doInBackground(Bundle... params)
|
|
|
+ {
|
|
|
+ json = Network.Verify_Code(params[0]);
|
|
|
+ try {
|
|
|
+ if (json.getInt("result") == Network.RESULT_TRUE)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onPostExecute(final Boolean success)
|
|
|
+ {
|
|
|
+ Log.i("onPostExecute", "entry");
|
|
|
+ verifytask = null;
|
|
|
+// showProgress(false);
|
|
|
+
|
|
|
+ if (success)
|
|
|
+ {
|
|
|
+ //验证成功
|
|
|
+
|
|
|
+
|
|
|
+ Intent intent = new Intent("REDANT.RAImage.ADD_TASK");
|
|
|
+
|
|
|
+ ArrayList<Bundle> taskArr = new ArrayList<Bundle>();
|
|
|
+ String name = "POP";
|
|
|
+
|
|
|
+// if(MainActivity.this instanceof ModelActivity)
|
|
|
+// name=name = "Model";
|
|
|
+ if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
+ name = "Model";
|
|
|
+ }
|
|
|
+ for (String path : photoList) {
|
|
|
+ Bundle task = new Bundle();
|
|
|
+
|
|
|
+ task.putString("path",path);
|
|
|
+ task.putString("file",RAUtil.lastPathComponent(path));
|
|
|
+ task.putString("url",RedAntApplication.active_address);
|
|
|
+
|
|
|
+ String md5 = MD5.md5sum(path);
|
|
|
+ String encryptUser = AES.encrypt("usai",RedAntApplication.user);
|
|
|
+ String encryptPwd = AES.encrypt("usai",RedAntApplication.password);
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ params.putString("user",encryptUser);
|
|
|
+ params.putString("password",encryptPwd);
|
|
|
+ params.putString("mode",name);
|
|
|
+ params.putString("barcode",pidval.getText().toString());
|
|
|
+ params.putString("_operate","upload");
|
|
|
+ params.putString("platform","android");
|
|
|
+ params.putString("md5",md5);
|
|
|
+
|
|
|
+
|
|
|
+ if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
+
|
|
|
+ if (!TextUtils.isEmpty(manufacture)) {
|
|
|
+ params.putString("manufacturer",manufacture);
|
|
|
+ }
|
|
|
+ if (!TextUtils.isEmpty(noteTextView.getText().toString())) {
|
|
|
+ params.putString("note",noteTextView.getText().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ task.putBundle("params",params);
|
|
|
+
|
|
|
+ taskArr.add(task);
|
|
|
+ }
|
|
|
+
|
|
|
+ intent.putParcelableArrayListExtra("tasks",taskArr);
|
|
|
+
|
|
|
+ sendBroadcast(intent);
|
|
|
+ clearfornew();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int result = 0;
|
|
|
+ try {
|
|
|
+ result = json.getInt("result");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result = Network.RESULT_NET_ERROR;
|
|
|
+
|
|
|
+ }
|
|
|
+ switch (result)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ {
|
|
|
+ // model , piid not exist
|
|
|
+
|
|
|
+
|
|
|
+ String msg = "Piid does not exist";
|
|
|
+
|
|
|
+ if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
+ msg = "Model does not exist.";
|
|
|
+ }
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ msg,
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ //model / manufacturer not match
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ "Model/Manufacturer does not match.",
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ {
|
|
|
+ // net error.
|
|
|
+ Toast toast = Toast.makeText(getApplicationContext(),
|
|
|
+ "can not verify input information.",
|
|
|
+ Toast.LENGTH_LONG);
|
|
|
+ toast.setGravity(Gravity.CENTER, 0, 0);
|
|
|
+ toast.show();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCancelled()
|
|
|
+ {
|
|
|
+ verifytask = null;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static final boolean newVersion = true;
|
|
|
// static final int ACTIVITY_CAMERA = 0;
|
|
|
// static final int ACTIVITY_VIEW = 1;
|
|
|
// static final String serverurl = "http://192.168.23.1/xampp/";
|
|
|
@@ -173,7 +340,7 @@ public class MainActivity extends AppCompatActivity
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
final EditText edit = new EditText(MainActivity.this);
|
|
|
- String msg = "Please enter Model code";
|
|
|
+ String msg = "Please enter model name";
|
|
|
// if (MainActivity.this.getClass().equals(ModelActivity.class)) { // model
|
|
|
//
|
|
|
//
|
|
|
@@ -362,56 +529,86 @@ public class MainActivity extends AppCompatActivity
|
|
|
}
|
|
|
try {
|
|
|
|
|
|
- Intent intent = new Intent("REDANT.RAImage.ADD_TASK");
|
|
|
-
|
|
|
- ArrayList<Bundle> taskArr = new ArrayList<Bundle>();
|
|
|
- String name = "POP";
|
|
|
+ String name = "POP";
|
|
|
|
|
|
// if(MainActivity.this instanceof ModelActivity)
|
|
|
// name=name = "Model";
|
|
|
- if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
- name = "Model";
|
|
|
- }
|
|
|
- for (String path : photoList) {
|
|
|
- Bundle task = new Bundle();
|
|
|
-
|
|
|
- task.putString("path",path);
|
|
|
- task.putString("file",RAUtil.lastPathComponent(path));
|
|
|
- task.putString("url",RedAntApplication.active_address);
|
|
|
-
|
|
|
- String md5 = MD5.md5sum(path);
|
|
|
- String encryptUser = AES.encrypt("usai",RedAntApplication.user);
|
|
|
- String encryptPwd = AES.encrypt("usai",RedAntApplication.password);
|
|
|
+ if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
+ name = "Model";
|
|
|
+ }
|
|
|
+ String encryptUser = AES.encrypt("usai",RedAntApplication.user);
|
|
|
+ String encryptPwd = AES.encrypt("usai",RedAntApplication.password);
|
|
|
|
|
|
- Bundle params = new Bundle();
|
|
|
- params.putString("user",encryptUser);
|
|
|
- params.putString("password",encryptPwd);
|
|
|
- params.putString("mode",name);
|
|
|
- params.putString("barcode",pidval.getText().toString());
|
|
|
- params.putString("_operate","upload");
|
|
|
- params.putString("platform","android");
|
|
|
- params.putString("md5",md5);
|
|
|
|
|
|
|
|
|
- if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
|
|
|
- if (!TextUtils.isEmpty(manufacture)) {
|
|
|
- params.putString("manufacturer",manufacture);
|
|
|
- }
|
|
|
- if (!TextUtils.isEmpty(noteTextView.getText().toString())) {
|
|
|
- params.putString("note",noteTextView.getText().toString());
|
|
|
- }
|
|
|
- }
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ params.putString("user",encryptUser);
|
|
|
+ params.putString("password",encryptPwd);
|
|
|
+ params.putString("mode",name);
|
|
|
+ params.putString("barcode",pidval.getText().toString());
|
|
|
+ params.putString("_operate","upload");
|
|
|
+ params.putString("platform","android");
|
|
|
|
|
|
- task.putBundle("params",params);
|
|
|
+ if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
|
|
|
- taskArr.add(task);
|
|
|
- }
|
|
|
+ if (!TextUtils.isEmpty(manufacture)) {
|
|
|
+ params.putString("manufacturer",manufacture);
|
|
|
+ }
|
|
|
|
|
|
- intent.putParcelableArrayListExtra("tasks",taskArr);
|
|
|
+ }
|
|
|
|
|
|
- sendBroadcast(intent);
|
|
|
- clearfornew();
|
|
|
+ verifyandupload(params);
|
|
|
+// Intent intent = new Intent("REDANT.RAImage.ADD_TASK");
|
|
|
+//
|
|
|
+// ArrayList<Bundle> taskArr = new ArrayList<Bundle>();
|
|
|
+// String name = "POP";
|
|
|
+//
|
|
|
+//// if(MainActivity.this instanceof ModelActivity)
|
|
|
+//// name=name = "Model";
|
|
|
+// if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
+// name = "Model";
|
|
|
+// }
|
|
|
+// for (String path : photoList) {
|
|
|
+// Bundle task = new Bundle();
|
|
|
+//
|
|
|
+// task.putString("path",path);
|
|
|
+// task.putString("file",RAUtil.lastPathComponent(path));
|
|
|
+// task.putString("url",RedAntApplication.active_address);
|
|
|
+//
|
|
|
+// String md5 = MD5.md5sum(path);
|
|
|
+// String encryptUser = AES.encrypt("usai",RedAntApplication.user);
|
|
|
+// String encryptPwd = AES.encrypt("usai",RedAntApplication.password);
|
|
|
+//
|
|
|
+// Bundle params = new Bundle();
|
|
|
+// params.putString("user",encryptUser);
|
|
|
+// params.putString("password",encryptPwd);
|
|
|
+// params.putString("mode",name);
|
|
|
+// params.putString("barcode",pidval.getText().toString());
|
|
|
+// params.putString("_operate","upload");
|
|
|
+// params.putString("platform","android");
|
|
|
+// params.putString("md5",md5);
|
|
|
+//
|
|
|
+//
|
|
|
+// if (MainActivity.this.getClass().equals(ModelActivity.class)) {
|
|
|
+//
|
|
|
+// if (!TextUtils.isEmpty(manufacture)) {
|
|
|
+// params.putString("manufacturer",manufacture);
|
|
|
+// }
|
|
|
+// if (!TextUtils.isEmpty(noteTextView.getText().toString())) {
|
|
|
+// params.putString("note",noteTextView.getText().toString());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// task.putBundle("params",params);
|
|
|
+//
|
|
|
+// taskArr.add(task);
|
|
|
+// }
|
|
|
+//
|
|
|
+// intent.putParcelableArrayListExtra("tasks",taskArr);
|
|
|
+//
|
|
|
+// sendBroadcast(intent);
|
|
|
+// clearfornew();
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -447,22 +644,41 @@ public class MainActivity extends AppCompatActivity
|
|
|
protected void recovery(Bundle savedInstanceState) {
|
|
|
if (savedInstanceState != null)
|
|
|
{
|
|
|
- Bitmap savedBitmap = getBitmap(savedInstanceState
|
|
|
- .getByteArray("thumbBitmap"));
|
|
|
+// Bitmap savedBitmap = getBitmap(savedInstanceState
|
|
|
+// .getByteArray("thumbBitmap"));
|
|
|
ArrayList<String> savedPhotoList = savedInstanceState.getStringArrayList("photoList");
|
|
|
String savedPiid = savedInstanceState.getString("PIID");
|
|
|
String savedNote = savedInstanceState.getString("Note");
|
|
|
File savedPhotoFile = (File) savedInstanceState.getSerializable("photoFile");
|
|
|
String manufacture = savedInstanceState.getString("manufacture");
|
|
|
|
|
|
- if (savedBitmap != null) {
|
|
|
- thumbBitmap = savedBitmap;
|
|
|
- }
|
|
|
+// if (savedBitmap != null) {
|
|
|
+// thumbBitmap = savedBitmap;
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//photoList.clear();
|
|
|
if (savedPhotoList != null) {
|
|
|
photoList = savedPhotoList;
|
|
|
+
|
|
|
+ if(photoList.size()>=1)
|
|
|
+ thumbBitmap = BitmapFactory.decodeFile(photoList.get(photoList.size() - 1));
|
|
|
+ if(thumbBitmap!=null)
|
|
|
+ thumbsImageView.setImageBitmap(thumbBitmap);
|
|
|
+ else
|
|
|
+ thumbsImageView.setImageResource(R.drawable.no_pic);
|
|
|
Log.e(TAG, "recovery: photolist"+photoList.size());
|
|
|
}
|
|
|
+ else
|
|
|
+
|
|
|
+ {
|
|
|
+ thumbsImageView.setImageResource(R.drawable.no_pic);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (!TextUtils.isEmpty(savedPiid)) {
|
|
|
pidval.setText(savedPiid);
|
|
|
pidval.setSelection(savedPiid.length());
|
|
|
@@ -666,28 +882,7 @@ public class MainActivity extends AppCompatActivity
|
|
|
|
|
|
|
|
|
|
|
|
- if (!newVersion) {
|
|
|
- setContentView(R.layout.activity_main1);
|
|
|
-
|
|
|
- setTitle(getTitle() + "(" + RedAntApplication.station_name + ")");
|
|
|
- ImageView thumbsImageView = (ImageView) findViewById(R.id.ivThumbs);
|
|
|
- thumbsImageView.setOnClickListener(new View.OnClickListener()
|
|
|
- {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v)
|
|
|
- {
|
|
|
- if (photoList.size() < 1)
|
|
|
- return;
|
|
|
-
|
|
|
- Intent intent = new Intent(MainActivity.this,
|
|
|
- PhotoPreviewActivity.class);
|
|
|
- intent.putExtra("pic_list", (Serializable) photoList);
|
|
|
- startActivityForResult(intent, REQUEST_PREVIEW);
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
// m_sName = intent.getStringExtra("user");
|
|
|
// m_sPassword = intent.getStringExtra("password");
|
|
|
|
|
|
@@ -930,9 +1125,12 @@ public class MainActivity extends AppCompatActivity
|
|
|
}
|
|
|
if (photoList.size() > 0)
|
|
|
{
|
|
|
- thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory
|
|
|
- .decodeFile(photoList.get(photoList.size() - 1)),
|
|
|
- iwidth, iheight);
|
|
|
+ thumbBitmap = BitmapFactory.decodeFile(photoList.get(photoList.size() - 1));
|
|
|
+//
|
|
|
+//
|
|
|
+// ThumbnailUtils.extractThumbnail(BitmapFactory
|
|
|
+// .decodeFile(photoList.get(photoList.size() - 1)),
|
|
|
+// iwidth, iheight);
|
|
|
if (thumbBitmap != null)
|
|
|
thumbsImageView.setImageBitmap(thumbBitmap);
|
|
|
}
|
|
|
@@ -979,9 +1177,10 @@ public class MainActivity extends AppCompatActivity
|
|
|
thumbsImageView.setImageResource(R.drawable.no_pic);
|
|
|
thumbBitmap = null;
|
|
|
} else {
|
|
|
- thumbBitmap = ThumbnailUtils.extractThumbnail(BitmapFactory
|
|
|
- .decodeFile(photoList.get(photoList.size() - 1)),
|
|
|
- iwidth, iheight);
|
|
|
+ thumbBitmap = BitmapFactory.decodeFile(photoList.get(photoList.size() - 1));
|
|
|
+// ThumbnailUtils.extractThumbnail(BitmapFactory
|
|
|
+// .decodeFile(photoList.get(photoList.size() - 1)),
|
|
|
+// iwidth, iheight);
|
|
|
if (thumbBitmap != null)
|
|
|
thumbsImageView.setImageBitmap(thumbBitmap);
|
|
|
}
|
|
|
@@ -1152,8 +1351,10 @@ public class MainActivity extends AppCompatActivity
|
|
|
if (photoFile != null)
|
|
|
outState.putSerializable("photoFile", photoFile);
|
|
|
|
|
|
- if (thumbBitmap != null)
|
|
|
- outState.putByteArray("thumbBitmap", getBytes(thumbBitmap));// ("thumbBitmap",
|
|
|
+// if (thumbBitmap != null)
|
|
|
+// outState.putByteArray("thumbBitmap", getBytes(thumbBitmap));
|
|
|
+
|
|
|
+ // ("thumbBitmap",
|
|
|
// (Object)thumbBitmap);
|
|
|
// outState.putString("thumbpath",
|
|
|
// thumbpath);
|