Browse Source

RA Image Android

统一图片文件命名,并修复可能因为文件名重复引起覆盖的问题。
Ray Zhang 8 years ago
parent
commit
f79581b1f8

+ 14 - 3
RA Image/app/src/main/java/com/usai/redant/raimage/MainActivity.java

@@ -706,7 +706,18 @@ public class MainActivity extends AppCompatActivity
 
     private File compressImageFile(File imgFile) {
 
-        File routedFile = RAUtil.routeBitmap(imgFile);
+
+        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
+                .format(new Date());
+
+        String barcode_title = "PIID";
+        if (MainActivity.this.getClass().equals(ModelActivity.class)) { // model
+            barcode_title = "Model";
+        }
+        String imageFileName = barcode_title + timeStamp +".jpg";
+
+
+        File routedFile = RAUtil.routeBitmap(imgFile,imageFileName);
 
 		SharedPreferences preferences = RedAntApplication.getInstance().getSharedPreferences("UploadManager", 0);
 		boolean auto_compress = preferences.getBoolean("compress",true);
@@ -1004,7 +1015,7 @@ public class MainActivity extends AppCompatActivity
 	private File createImageFile() throws IOException
 	{
 		// Create an image file name
-		String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
+		String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmssff")
 				.format(new Date());
 		String imageFileName = "JPEG_" + timeStamp + "_";
 		File storageDir = new File(Environment.getExternalStorageDirectory()
@@ -1522,7 +1533,7 @@ public class MainActivity extends AppCompatActivity
 		countTextView.setText("no photo");
 
 		if(noteTextView!=null)
-			noteTextView.setHint("Note:");
+			noteTextView.setText("");
 
 	}
 

+ 12 - 4
RA Image/app/src/main/java/com/usai/util/RAUtil.java

@@ -236,7 +236,7 @@ public class RAUtil {
 
     }
 
-    public static File routeBitmap(File sourceFile)
+    public static File routeBitmap(File sourceFile,String file_name)
     {
         /**
          * 获取图片的旋转角度,有些系统把拍照的图片旋转了,有的没有旋转
@@ -252,10 +252,18 @@ public class RAUtil {
          */
         Bitmap newbitmap = RAUtil.rotaingImageView(degree, cbitmap);
 
+        //sourceFile.get
+        String routedPath = "";
+        if(file_name==null) {
+            String path = sourceFile.getPath();
 
-        String path = sourceFile.getPath();
-
-        String routedPath = path.replace(".jpg", "_routed.jpg");
+            routedPath=path.replace(".jpg", "_routed.jpg");
+        }
+        else
+        {
+            String path = sourceFile.getParent();
+            routedPath = path+"/"+file_name;
+        }
         File routedFile = new File(routedPath);
         try {