Ver Fonte

RA Image Android

1 增加验证逻辑。
2 修复一些小错误。
3 解决昨天的JSONObject 报异常导致读取失败的问题。
4 去掉不用的权限。
5 修改输入窗口的状态保存逻辑,消除潜在闪退。
6 修改输入窗口的照片显示,去掉图片缩小处理。
Ray Zhang há 8 anos atrás
pai
commit
554ec0cea8

+ 1 - 1
RA Image/app/app.iml

@@ -101,7 +101,7 @@
       <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
       <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
     </content>
-    <orderEntry type="jdk" jdkName="Android API 25 Platform (1)" jdkType="Android SDK" />
+    <orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" exported="" name="core-2.3.0" level="project" />
     <orderEntry type="library" exported="" name="constraint-layout-solver-1.0.2" level="project" />

+ 1 - 1
RA Image/app/build.gradle

@@ -9,7 +9,7 @@ android {
         minSdkVersion 14
         targetSdkVersion 25
         versionCode 1
-        versionName "A151123"
+        versionName "A170720"
     }
 
     buildTypes {

+ 1 - 1
RA Image/app/src/main/AndroidManifest.xml

@@ -10,7 +10,7 @@
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
     <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
     <uses-permission android:name="android.permission.INTERNET" />
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <!--<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />-->
     <uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
 
     <application

+ 1 - 1
RA Image/app/src/main/java/com/usai/redant/raimage/FullScreenLoginActivity.java

@@ -566,7 +566,7 @@ public class FullScreenLoginActivity extends Activity {
 //                Manifest.permission.ACCESS_NETWORK_STATE,
 //                Manifest.permission.ACCESS_WIFI_STATE,
 //                Manifest.permission.INTERNET,
-                Manifest.permission.ACCESS_FINE_LOCATION,
+//                Manifest.permission.ACCESS_FINE_LOCATION,
 //
 //                Manifest.permission.CHANGE_CONFIGURATION
 

+ 277 - 76
RA Image/app/src/main/java/com/usai/redant/raimage/MainActivity.java

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

+ 1 - 1
RA Image/app/src/main/java/com/usai/redant/raimage/TaskActivity.java

@@ -279,7 +279,7 @@ public class TaskActivity extends AppCompatActivity {
                     status="warring";
                     break;
             }
-            double percent = item.getDouble("progress",0);
+            double percent = item.getDouble("progress",(double)item.getInt("progress",0));
             String err = item.getString("msg");
             String name = item.getString("file","");
 

+ 44 - 47
RA Image/app/src/main/java/com/usai/redant/raimage/UploadService.java

@@ -6,9 +6,6 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.SharedPreferences;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.os.Binder;
@@ -27,8 +24,8 @@ public class UploadService extends Service
 //	private UploadThread	uploadThread;
 
 	private boolean			queue_changed	= false;
-	LocationManager			locationManager;
-	LocationListener		locationListener;
+//	LocationManager			locationManager;
+//	LocationListener		locationListener;
 
 	public RAUploadManager			uploadManager = new RAUploadManager();
 
@@ -88,9 +85,9 @@ public class UploadService extends Service
 		IntentFilter msgFilter = new IntentFilter();
 
 		msgFilter.addAction("REDANT.POP.MODIFY_QUEUE");
-		msgFilter.addAction("REDANT.POP.GPS_ON");
-		msgFilter.addAction("REDANT.POP.GPS_OFF");
-		msgFilter.addAction("REDANT.POP.REQUEST_LOCATION");
+//		msgFilter.addAction("REDANT.POP.GPS_ON");
+//		msgFilter.addAction("REDANT.POP.GPS_OFF");
+//		msgFilter.addAction("REDANT.POP.REQUEST_LOCATION");
 		msgFilter.addAction("REDANT.POP.RESET_LOCATION");
 		msgFilter.addAction("REDANT.POP.QUERY_UPLOAD_STATE");
         msgFilter.addAction("REDANT.RAImage.ADD_TASK");
@@ -101,46 +98,46 @@ public class UploadService extends Service
 		// registerReceiver(uploadReceiver,
 		// new IntentFilter("modify upload queue"));
 
-		locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
+//		locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
 
-		locationListener = new LocationListener()
-		{
-
-			// Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
-			@Override
-			public void onStatusChanged(String provider, int status,
-					Bundle extras)
-			{
-
-			}
-
-			// Provider被enable时触发此函数,比如GPS被打开
-			@Override
-			public void onProviderEnabled(String provider)
-			{
-
-			}
-
-			// Provider被disable时触发此函数,比如GPS被关闭
-			@Override
-			public void onProviderDisabled(String provider)
-			{
-
-			}
-
-			// 当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
-			@Override
-			public void onLocationChanged(Location location)
-			{
-				// if (location != null)
-				// {
-				// location_changed = true;
-				// Log.d("Map",
-				// "Location changed : Lat: " + location.getLatitude()
-				// + " Lng: " + location.getLongitude());
-				// }
-			}
-		};
+//		locationListener = new LocationListener()
+//		{
+//
+//			// Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
+//			@Override
+//			public void onStatusChanged(String provider, int status,
+//					Bundle extras)
+//			{
+//
+//			}
+//
+//			// Provider被enable时触发此函数,比如GPS被打开
+//			@Override
+//			public void onProviderEnabled(String provider)
+//			{
+//
+//			}
+//
+//			// Provider被disable时触发此函数,比如GPS被关闭
+//			@Override
+//			public void onProviderDisabled(String provider)
+//			{
+//
+//			}
+//
+//			// 当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
+//			@Override
+//			public void onLocationChanged(Location location)
+//			{
+//				// if (location != null)
+//				// {
+//				// location_changed = true;
+//				// Log.d("Map",
+//				// "Location changed : Lat: " + location.getLatitude()
+//				// + " Lng: " + location.getLongitude());
+//				// }
+//			}
+//		};
 
 		super.onCreate();
 

+ 71 - 0
RA Image/app/src/main/java/com/usai/util/Network.java

@@ -116,6 +116,8 @@ public class Network
 	static String				URL_VERIFY_USER					= "handset_login.php";
 	static String				URL_LOGIN					= "index.php?_action=handset_new";
 	static String				URL_UPLOAD					= "index.php?_action=handset_new";
+	static String				URL_VERIFY_CODE					= "index.php?_action=handset_new";
+
 	public static class SSLSocketFactoryEx extends SSLSocketFactory
 	{
 
@@ -884,9 +886,78 @@ public class Network
 		// }
 		// return RESULT_ERROR;
 	}
+	public static JSONObject Verify_Code(Bundle Params)
+	{
+		String TAG = "net_dbg@Verify_Code";
+		if (!Network.NetworkIsAvailable())
+		{
+
+			Log.d(TAG, "network not available!");
+			try {
+				return new JSONObject("{result:" + Network.RESULT_NET_NOTAVAILABLE+ "}");
+			} catch (JSONException e) {
+				e.printStackTrace();
+			}
+
+		}
+		Params.putString("_operate","valid_upload");
+		String jstr = getJson(RedAntApplication.active_address
+                + Network.URL_VERIFY_CODE,Params);
+//		file.delete();
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is null");
+			try {
+				return new JSONObject("{result:" + Network.RESULT_NET_ERROR+ "}");
+			} catch (JSONException e) {
+				e.printStackTrace();
+			}
+
+		}
+		Log.d(TAG, "json string:"+jstr);
+		JSONObject jsobj;
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				return jsobj;
+			}
+			try {
+				return new JSONObject("{result:" + Network.RESULT_NET_ERROR+ "}");
+			} catch (JSONException e) {
+				e.printStackTrace();
+			}
+
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			Log.d(TAG, "json format wrong:"+jstr);
+			e.printStackTrace();
+//			try {
+//				return new JSONObject("{result:" + Network.RESULT_NET_ERROR+ "}");
+//			} catch (JSONException e1) {
+//				e.printStackTrace();
+//			}
+			return null;
+		}
+		return null;
+	}
 	public static JSONObject UploadImage(String path, Bundle Params,String server,FileUploadListener listener)
 	{
 		String TAG = "net_dbg@UploadImage";
+		if (!Network.NetworkIsAvailable())
+		{
+
+			Log.d(TAG, "network not available!");
+			try {
+				return new JSONObject("{result:" + Network.RESULT_NET_NOTAVAILABLE+ "}");
+			} catch (JSONException e) {
+				e.printStackTrace();
+			}
+
+		}
 //		Bitmap source = BitmapFactory.decodeFile(path);
 //
 //		int originWidth = source.getWidth();

+ 17 - 20
RA Image/app/src/main/java/com/usai/util/RAUtil.java

@@ -1,8 +1,6 @@
 package com.usai.util;
 
-import android.Manifest;
 import android.app.Activity;
-import android.content.pm.PackageManager;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.Matrix;
@@ -10,7 +8,6 @@ import android.media.ExifInterface;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
 import android.support.v4.content.PermissionChecker;
 import android.util.Log;
 
@@ -35,19 +32,19 @@ import java.util.Set;
 
 public class RAUtil {
     public static final int MY_PERMISSIONS_REQUEST= 1;
-    public static void checkPermissions1(Activity activity, String[] permissions)
-    {
-        Log.d("_RAIMAGE", "checkPermissions1:==================================== ");
-        for(String permission : permissions) {
-            boolean bshow=ActivityCompat.shouldShowRequestPermissionRationale(activity,permission);
-            boolean granted= ContextCompat.checkSelfPermission(activity,
-                    Manifest.permission.ACCESS_FINE_LOCATION)
-                    == PackageManager.PERMISSION_GRANTED;
-            boolean pc = PermissionChecker.checkSelfPermission(activity,permission)==PermissionChecker.PERMISSION_GRANTED;
-            Log.d("_RAIMAGE", "checkPermissions1: "+permission+"  SHOW  "+bshow+"  granted  "+granted +","+pc);
-        }
-        Log.d("_RAIMAGE", "checkPermissions1:==================================== ");
-    }
+//    public static void checkPermissions1(Activity activity, String[] permissions)
+//    {
+//        Log.d("_RAIMAGE", "checkPermissions1:==================================== ");
+//        for(String permission : permissions) {
+//            boolean bshow=ActivityCompat.shouldShowRequestPermissionRationale(activity,permission);
+//            boolean granted= ContextCompat.checkSelfPermission(activity,
+//                    Manifest.permission.ACCESS_FINE_LOCATION)
+//                    == PackageManager.PERMISSION_GRANTED;
+//            boolean pc = PermissionChecker.checkSelfPermission(activity,permission)==PermissionChecker.PERMISSION_GRANTED;
+//            Log.d("_RAIMAGE", "checkPermissions1: "+permission+"  SHOW  "+bshow+"  granted  "+granted +","+pc);
+//        }
+//        Log.d("_RAIMAGE", "checkPermissions1:==================================== ");
+//    }
     public static Boolean checkPermissions(Activity activity, String[] permissions)
     {
         if (Build.VERSION.SDK_INT >= 23)
@@ -66,11 +63,11 @@ public class RAUtil {
         ArrayList<String> request_list = new ArrayList<String>();
         for(String permission : permissions) {
             boolean bshow=ActivityCompat.shouldShowRequestPermissionRationale(activity,permission);
-            boolean granted= ContextCompat.checkSelfPermission(activity,
-                    Manifest.permission.ACCESS_FINE_LOCATION)
-                    == PackageManager.PERMISSION_GRANTED;
+//            boolean granted= ContextCompat.checkSelfPermission(activity,
+//                    Manifest.permission.ACCESS_FINE_LOCATION)
+//                    == PackageManager.PERMISSION_GRANTED;
             boolean pc = PermissionChecker.checkSelfPermission(activity,permission)==PermissionChecker.PERMISSION_GRANTED;
-            Log.d("_RAIMAGE", "checkPermissions23: "+permission+"  SHOW  "+bshow+"  granted  "+granted +","+pc);
+//            Log.d("_RAIMAGE", "checkPermissions23: "+permission+"  SHOW  "+bshow+"  granted  "+granted +","+pc);
 
             if(!pc)
                 request_list.add(permission);

+ 4 - 4
RA Image/app/src/main/res/layout-land/activity_model.xml

@@ -34,17 +34,17 @@
         android:layout_alignParentTop="true"
         android:layout_marginBottom="32dp"
         android:layout_marginLeft="32dp"
+        android:layout_marginStart="32dp"
         android:layout_marginTop="8dp"
-        android:scaleType="fitCenter"
         android:background="@drawable/black_border"
         android:padding="0.1dp"
+        android:scaleType="centerCrop"
         app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintDimensionRatio="h,1:1"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintTop_toBottomOf="@+id/manufacture_btn"
-        app:srcCompat="@drawable/no_pic"
-        app:layout_constraintDimensionRatio="h,1:1"
         app:layout_constraintVertical_bias="1.0"
-        android:layout_marginStart="32dp"></ImageView>
+        app:srcCompat="@drawable/no_pic"></ImageView>
 
 
     <TextView

+ 3 - 3
RA Image/app/src/main/res/layout-land/activity_pop.xml

@@ -17,14 +17,14 @@
         android:layout_marginBottom="32dp"
         android:layout_marginLeft="32dp"
         android:layout_marginTop="32dp"
-        android:scaleType="fitCenter"
         android:background="@drawable/black_border"
         android:padding="0.1dp"
+        android:scaleType="centerCrop"
         app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintDimensionRatio="h,1:1"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintTop_toTopOf="parent"
-        app:srcCompat="@drawable/no_pic"
-        app:layout_constraintDimensionRatio="h,1:1"></ImageView>
+        app:srcCompat="@drawable/no_pic"></ImageView>
 
     <TextView
         android:id="@+id/photo_count_lb"

+ 3 - 3
RA Image/app/src/main/res/layout/activity_model.xml

@@ -28,14 +28,14 @@
         android:layout_width="0dp"
         android:layout_height="0dp"
         android:layout_marginBottom="8dp"
-        android:layout_marginEnd="32dp"
+
         android:layout_marginLeft="32dp"
         android:layout_marginRight="32dp"
-        android:layout_marginStart="32dp"
+
         android:layout_marginTop="20dp"
-        android:scaleType="fitCenter"
         android:background="@drawable/black_border"
         android:padding="0.1dp"
+        android:scaleType="centerCrop"
         app:layout_constraintBottom_toTopOf="@+id/barcode_et"
         app:layout_constraintDimensionRatio="w,1:1"
         app:layout_constraintHorizontal_bias="0.511"

+ 1 - 1
RA Image/app/src/main/res/layout/activity_pop.xml

@@ -18,7 +18,7 @@
         android:layout_marginTop="32dp"
         android:background="@drawable/black_border"
         android:padding="0.1dp"
-        android:scaleType="fitCenter"
+        android:scaleType="centerCrop"
         app:layout_constraintDimensionRatio="w,1:1"
         app:layout_constraintHorizontal_bias="0.0"
         app:layout_constraintLeft_toLeftOf="parent"