Ver Fonte

RA Image Android

完成Android 4.4-8.0 权限适配。
去掉部分无用的旧逻辑
修复一些测试的bug。
Ray Zhang há 8 anos atrás
pai
commit
2ca131379c

+ 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" />

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

@@ -5,20 +5,16 @@ import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.annotation.TargetApi;
 import android.app.ActionBar;
+import android.app.Activity;
 import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
 import android.os.AsyncTask;
 import android.os.Build;
 import android.os.Bundle;
-import android.app.Activity;
-import android.provider.Settings;
-import android.support.v4.content.ContextCompat;
+import android.support.v4.app.ActivityCompat;
 import android.text.TextUtils;
 import android.util.Log;
 import android.view.Gravity;
@@ -26,24 +22,20 @@ import android.view.KeyEvent;
 import android.view.View;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.Switch;
 import android.widget.TextView;
 import android.widget.Toast;
 
 import com.usai.util.AES;
-import com.usai.util.Crypto;
 import com.usai.util.Network;
 import com.usai.util.RAUtil;
-import com.usai.util.dbUtil;
 import com.usai.util.dbgUtil;
 
-import org.json.JSONException;
 import org.json.JSONObject;
 
+//import android.support.v7.app.AlertDialog;
+
 public class FullScreenLoginActivity extends Activity {
 
 
@@ -532,66 +524,182 @@ public class FullScreenLoginActivity extends Activity {
                 });
 
 
-        if(TextUtils.isEmpty(RedAntApplication.station_name))
+//        if(TextUtils.isEmpty(RedAntApplication.station_name))
+//        {
+//            Intent intent = new Intent();
+//            intent.setClass(FullScreenLoginActivity.this,ServerSettingActivity.class);
+////            startActivity(intent);
+//            startActivityForResult(intent, 0);
+//        }
+        boolean pop = checkAllPermission();
+        if(!pop)
+        {
+            if(TextUtils.isEmpty(RedAntApplication.station_name))
         {
             Intent intent = new Intent();
             intent.setClass(FullScreenLoginActivity.this,ServerSettingActivity.class);
 //            startActivity(intent);
             startActivityForResult(intent, 0);
         }
+        }
+
     }
 
     @Override
     protected void onResume() {
         super.onResume();
 
-        boolean granted = checkAllPermission();
-        if (!granted) {
-//            new AlertDialog.Builder(this)
-//                    .setTitle("Warning")
-//                    .setMessage("RA Image need some permission")
-//                    .setPositiveButton("Setting", new DialogInterface.OnClickListener() {
-//                        @Override
-//                        public void onClick(DialogInterface dialog, int which) {
-//                            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
-//                            intent.setData(Uri.parse("package:" + getPackageName()));
-//                            startActivity(intent);
-//                        }
-//                    })
-//                    .setNegativeButton("No", new DialogInterface.OnClickListener() {
-//                        @Override
-//                        public void onClick(DialogInterface dialog, int which) {
-//                            finish();
-//                        }
-//                    })
-//                    .show();
-        }
+
+//        if (!granted) {
+////            new AlertDialog.Builder(this)
+////                    .setTitle("Warning")
+////                    .setMessage("RA Image need some permission")
+////                    .setPositiveButton("Setting", new DialogInterface.OnClickListener() {
+////                        @Override
+////                        public void onClick(DialogInterface dialog, int which) {
+////                            Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+////                            intent.setData(Uri.parse("package:" + getPackageName()));
+////                            startActivity(intent);
+////                        }
+////                    })
+////                    .setNegativeButton("No", new DialogInterface.OnClickListener() {
+////                        @Override
+////                        public void onClick(DialogInterface dialog, int which) {
+////                            finish();
+////                        }
+////                    })
+////                    .show();
+//        }
 
     }
 
     public boolean checkAllPermission() {
 
+
+
         String[] permissions = {
                 Manifest.permission.CAMERA,
-                Manifest.permission.VIBRATE,
+//                Manifest.permission.VIBRATE,
                 Manifest.permission.WRITE_EXTERNAL_STORAGE,
                 Manifest.permission.READ_EXTERNAL_STORAGE,
-                Manifest.permission.RECEIVE_BOOT_COMPLETED,
-                Manifest.permission.ACCESS_NETWORK_STATE,
-                Manifest.permission.ACCESS_WIFI_STATE,
-                Manifest.permission.INTERNET,
+//                Manifest.permission.RECEIVE_BOOT_COMPLETED,
+//                Manifest.permission.ACCESS_NETWORK_STATE,
+//                Manifest.permission.ACCESS_WIFI_STATE,
+//                Manifest.permission.INTERNET,
                 Manifest.permission.ACCESS_FINE_LOCATION,
-                Manifest.permission.CHANGE_CONFIGURATION
+//
+//                Manifest.permission.CHANGE_CONFIGURATION
+
+
+
         };
 
-        for(String permission : permissions) {
-            boolean granted = RAUtil.checkPermission(this,permission);
-            if (!granted) {
-                return false;
+
+
+//        RAUtil.checkPermissions1(this,permissions);
+        boolean ret = true;
+//        for(String permission : permissions) {
+//            boolean granted = ;
+//            if (!granted) {
+//                ret= false;
+//            }
+//        }
+
+
+        return RAUtil.checkPermissions(this,permissions);
+
+//        return ret;
+    }
+
+
+
+    @Override
+    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
+    {
+
+        if (requestCode == RAUtil.MY_PERMISSIONS_REQUEST)
+        {
+            boolean missing=false;
+            boolean request = false;
+            for(int i=0;i<grantResults.length;i++)
+            {
+
+                if(grantResults[i]!=PackageManager.PERMISSION_GRANTED)
+                    missing=true;
+                boolean bshow= ActivityCompat.shouldShowRequestPermissionRationale(this,permissions[i]);
+                if(bshow)
+                    request = true;
             }
-        }
 
-        return true;
+            String msg=null;
+            if(request)
+                msg="RA Image needs some essential permissions.";
+            else
+                msg="RA Image will quit because missing some essential permissions.\nPlease check your system setting.";
+
+            if(missing) {
+                final boolean finalRequest = request;
+                new AlertDialog.Builder(this)
+                        .setTitle("Warning")
+                        .setMessage(msg)
+                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+                            @Override
+                            public void onClick(DialogInterface dialog, int which) {
+//                                checkAllPermission();
+                                if (finalRequest)
+                                    checkAllPermission();
+                                else
+                                    finish();
+                            }
+                        })
+//                    .setNegativeButton("No", new DialogInterface.OnClickListener() {
+//                        @Override
+//                        public void onClick(DialogInterface dialog, int which) {
+//                            finish();
+//                        }
+//                    })
+                        .show();
+            }
+            else
+            {
+                if(TextUtils.isEmpty(RedAntApplication.station_name))
+                {
+                    Intent intent = new Intent();
+                    intent.setClass(FullScreenLoginActivity.this,ServerSettingActivity.class);
+//            startActivity(intent);
+                    startActivityForResult(intent, 0);
+                }
+            }
+//            if (grantResults[0] == PackageManager.PERMISSION_GRANTED)
+//            {
+//               // callPhone();
+//            } else
+//            {
+//
+//
+//                            new AlertDialog.Builder(this)
+//                    .setTitle("Warning")
+//                    .setMessage("RA Image missing essential permission")
+//                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
+//                        @Override
+//                        public void onClick(DialogInterface dialog, int which) {
+//                            checkAllPermission();
+//                        }
+//                    })
+////                    .setNegativeButton("No", new DialogInterface.OnClickListener() {
+////                        @Override
+////                        public void onClick(DialogInterface dialog, int which) {
+////                            finish();
+////                        }
+////                    })
+//                    .show();
+//
+//                // Permission Denied
+//               // Toast.makeText(MainActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show();
+//            }
+            return;
+        }
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
     }
 
 //    public boolean checkPermission(String per) {

+ 354 - 338
RA Image/app/src/main/java/com/usai/redant/raimage/MainActivity.java

@@ -21,7 +21,6 @@ import android.provider.MediaStore;
 import android.support.v7.app.AppCompatActivity;
 import android.text.TextUtils;
 import android.util.Log;
-import android.view.KeyEvent;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
@@ -40,7 +39,6 @@ import com.usai.util.MD5;
 import com.usai.util.Network;
 import com.usai.util.RAUtil;
 import com.usai.util.dbUtil;
-import com.usai.util.dbgUtil;
 
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -48,7 +46,6 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.Serializable;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -120,7 +117,7 @@ public class MainActivity extends AppCompatActivity
 		new AlertDialog.Builder(MainActivity.this)
 				.setTitle("Warning")
 				.setMessage(msg)
-				.setPositiveButton("YES", new DialogInterface.OnClickListener() {
+				.setPositiveButton("OK", new DialogInterface.OnClickListener() {
 					@Override
 					public void onClick(DialogInterface dialog, int which) {
 
@@ -202,9 +199,7 @@ public class MainActivity extends AppCompatActivity
             {
                 Log.d(TAG, "==============>Click Scan button");
 
-				if (!RAUtil.checkPermission(MainActivity.this,"android.permission.CAMERA")) {
-					return;
-				}
+//®
 
                 Intent intent = new Intent();
 
@@ -231,32 +226,36 @@ public class MainActivity extends AppCompatActivity
             {
 				if (TextUtils.isEmpty(pidval.getText().toString())) {
 					String barcode_title = "PIID";
-					if (this.getClass().equals(ModelActivity.class)) { // model
+					if (MainActivity.this.getClass().equals(ModelActivity.class)) { // model
 						barcode_title = "Model";
 					}
 					showWarning(barcode_title + " can not be blank!");
 					return;
 				}
+                if (MainActivity.this.getClass().equals(ModelActivity.class)) {
+                    if (TextUtils.isEmpty(manufacture)) {
+                        showWarning("manufacture can not be blank!");
+                        return;
+                    }
+                }
+
+
 
 				if (photoList.size() < 1) {
 					showWarning("You must take at least one photo");
 					return;
 				}
 
-				if (this.getClass().equals(ModelActivity.class)) { // model
-					if (TextUtils.isEmpty(manufacture)) {
-						showWarning("Manufacturer does not set.");
-						return;
-					}
-				}
-
 				try {
 
 					Intent intent = new Intent("REDANT.RAImage.ADD_TASK");
 
 					ArrayList<Bundle> taskArr = new ArrayList<Bundle>();
 					String name = "POP";
-					if (this.getClass().equals(ModelActivity.class)) {
+
+//					if(MainActivity.this instanceof ModelActivity)
+//						name=name = "Model";
+					if (MainActivity.this.getClass().equals(ModelActivity.class)) {
 						name = "Model";
 					}
 					for (String path : photoList) {
@@ -279,8 +278,9 @@ public class MainActivity extends AppCompatActivity
 						params.putString("platform","android");
 						params.putString("md5",md5);
 
-						// model
-						if (this.getClass().equals(ModelActivity.class)) {
+
+						if (MainActivity.this.getClass().equals(ModelActivity.class)) {
+
 							if (!TextUtils.isEmpty(manufacture)) {
 								params.putString("manufacturer",manufacture);
 							}
@@ -297,6 +297,7 @@ public class MainActivity extends AppCompatActivity
 					intent.putParcelableArrayListExtra("tasks",taskArr);
 
 					sendBroadcast(intent);
+                    clearfornew();
 
 				} catch (Exception e) {
 					e.printStackTrace();
@@ -447,9 +448,9 @@ public class MainActivity extends AppCompatActivity
 	private void StartCamera()
 	{
 
-		if (!RAUtil.checkPermission(this,"android.permission.CAMERA")) {
-			return;
-		}
+//		if (!RAUtil.checkPermission(this,"android.permission.CAMERA")) {
+//			return;
+//		}
 
 		Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
 		// Ensure that there's a camera activity to handle the intent
@@ -507,18 +508,18 @@ public class MainActivity extends AppCompatActivity
     }
 
 
-	@Override
-	public boolean onKeyDown(int keyCode, KeyEvent event)
-	{
-		if (keyCode == KeyEvent.KEYCODE_BACK)
-		{
-			dbgUtil.fileLog("back button click , clear&exit");
-			clear();
-
-		}
-		return super.onKeyDown(keyCode, event);
-
-	}
+//	@Override
+//	public boolean onKeyDown(int keyCode, KeyEvent event)
+//	{
+//		if (keyCode == KeyEvent.KEYCODE_BACK)
+//		{
+//			dbgUtil.fileLog("back button click , clear&exit");
+//			clear();
+//
+//		}
+//		return super.onKeyDown(keyCode, event);
+//
+//	}
 
 	@Override
 	protected void onResume()
@@ -665,6 +666,7 @@ public class MainActivity extends AppCompatActivity
 	protected void onDestroy()
 	{
 	//	sendBroadcast(new Intent("REDANT.POP.GPS_OFF"));
+        clear();
 		Log.d(TAG, "=======================>MainActivity Destroyed!");
 		unregisterReceiver(MainActivityReceiver);
 		Log.d(TAG, "=======================>msgFilter unregisted!");
@@ -753,7 +755,7 @@ public class MainActivity extends AppCompatActivity
 			return;
 		}
 		TextView pidval = (TextView) findViewById(R.id.pidval);
-		ImageButton ibtnUpload = (ImageButton) findViewById(R.id.ibtnOk);
+		ImageButton ibtnUpload = (ImageButton) findViewById(R.id.upload_btn);
 
 
 		if (photoList.size() > 0 && pidval.getText().length() > 0)
@@ -944,71 +946,72 @@ public class MainActivity extends AppCompatActivity
 				}
 				break;
 				case android.R.id.home: {
+                    clear();
 					finish();
 				}
 				break;
 			}
-			return true;
-		}
-		// TODO Auto-generated method stub
-		switch (item.getItemId())
-		{
-			case R.id.action_clear:
-				dbgUtil.fileLog("menu item clear click , clear...");
-				clear();
-				break;
-			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);
-										updateUploadButton();
-
-										/* User clicked OK so do some stuff */
-									}
-								})
-						.setNegativeButton(android.R.string.cancel,
-								new DialogInterface.OnClickListener()
-								{
-									public void onClick(DialogInterface dialog,
-											int whichButton)
-									{
-										updateUploadButton();
-										/* User clicked cancel so do some stuff */
-									}
-								}).create().show();
-			}
-				break;
-			case R.id.action_server_settings:
-			{
-				Intent intent = new Intent();
-				intent.setClass(MainActivity.this, ServerSettingActivity.class);
-				startActivity(intent);
-
-			}
-				break;
-			case R.id.action_view_queue:
-			{
-				Intent intent = new Intent();
-				intent.setClass(MainActivity.this, UploadQueueActivity.class);
-				startActivity(intent);
-				break;
-			}
-			default:
-				break;
+			return super.onOptionsItemSelected(item);
 		}
+//		// TODO Auto-generated method stub
+//		switch (item.getItemId())
+//		{
+//			case R.id.action_clear:
+//				dbgUtil.fileLog("menu item clear click , clear...");
+//				clear();
+//				break;
+//			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);
+//										updateUploadButton();
+//
+//										/* User clicked OK so do some stuff */
+//									}
+//								})
+//						.setNegativeButton(android.R.string.cancel,
+//								new DialogInterface.OnClickListener()
+//								{
+//									public void onClick(DialogInterface dialog,
+//											int whichButton)
+//									{
+//										updateUploadButton();
+//										/* User clicked cancel so do some stuff */
+//									}
+//								}).create().show();
+//			}
+//				break;
+//			case R.id.action_server_settings:
+//			{
+//				Intent intent = new Intent();
+//				intent.setClass(MainActivity.this, ServerSettingActivity.class);
+//				startActivity(intent);
+//
+//			}
+//				break;
+//			case R.id.action_view_queue:
+//			{
+//				Intent intent = new Intent();
+//				intent.setClass(MainActivity.this, UploadQueueActivity.class);
+//				startActivity(intent);
+//				break;
+//			}
+//			default:
+//				break;
+//		}
 		return super.onOptionsItemSelected(item);
 	}
 
@@ -1060,23 +1063,34 @@ public class MainActivity extends AppCompatActivity
 		return BitmapFactory.decodeByteArray(data, 0, data.length);// ���ֽ��������λͼ
 	}
 
-	private void clear()
+    @Override
+    public void onBackPressed() {
+        clear();
+        super.onBackPressed();
+    }
+
+    private void clear()
 	{
 		for (int i = 0; i < photoList.size(); i++)
 		{
 
-			
-			
-			
-			
-			String timeStamp = new SimpleDateFormat("yyyy_MM_dd")
-			.format(new Date());
-			
-			File storageDir = new File(Environment.getExternalStorageDirectory()
-					.getPath() + "/redant/pop/clear/"+timeStamp);
-			
-			if (!storageDir.exists())
-				storageDir.mkdirs();
+
+
+//
+//
+//			String timeStamp = new SimpleDateFormat("yyyy_MM_dd")
+//			.format(new Date());
+//
+//			File storageDir = new File(Environment.getExternalStorageDirectory()
+//					.getPath() + "/redant/pop/clear/"+timeStamp);
+//
+//			if (!storageDir.exists())
+//				storageDir.mkdirs();
+
+
+
+            new File(photoList.get(i)).delete();
+
 
 //			File dir1 = new File(Environment.getExternalStorageDirectory()
 //					.getPath() + "/redant");
@@ -1085,7 +1099,7 @@ public class MainActivity extends AppCompatActivity
 //			File dir3 = new File(Environment.getExternalStorageDirectory()
 //					.getPath() + "/redant/pop/clear");
 //
-//			
+//
 //			if (!dir1.exists())
 //			{
 //				boolean b = dir1.mkdir();
@@ -1098,20 +1112,20 @@ public class MainActivity extends AppCompatActivity
 //			{
 //				boolean b = dir3.mkdir();
 //			}
-//			
+//
 //			if (!storageDir.exists())
 //			{
 //				boolean b = storageDir.mkdir();
 //			}
-			
-			File srcFile = new File(photoList.get(i));
-		//	file.delete();
-			dbgUtil.fileLog("move file "+srcFile.getName()+" to "+Environment.getExternalStorageDirectory()
-					.getPath() + "/redant/pop/clear/"+timeStamp + File.separator);
-			srcFile.renameTo(new File(Environment.getExternalStorageDirectory()
-					.getPath() + "/redant/pop/clear/"+timeStamp + File.separator + srcFile.getName()));  
-			
-			
+//
+//			File srcFile = new File(photoList.get(i));
+//		//	file.delete();
+//			dbgUtil.fileLog("move file "+srcFile.getName()+" to "+Environment.getExternalStorageDirectory()
+//					.getPath() + "/redant/pop/clear/"+timeStamp + File.separator);
+//			srcFile.renameTo(new File(Environment.getExternalStorageDirectory()
+//					.getPath() + "/redant/pop/clear/"+timeStamp + File.separator + srcFile.getName()));
+//
+
 
 //			// Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
 //			// Log.d(TAG, "DIR:" + storageDir);
@@ -1121,24 +1135,26 @@ public class MainActivity extends AppCompatActivity
 //					".jpg", /* suffix */
 //					storageDir /* directory */
 //			);
-			
-			
-		}
 
-		if (newVersion) {
-			return;
-			// 以下会造成Crash
+
 		}
+        photoList.clear();
 
-		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");
+
+//        if (newVersion) {
+//			return;
+//			// 以下会造成Crash
+//		}
+//
+//
+//		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");
 
 	}
 
@@ -1168,211 +1184,211 @@ public class MainActivity extends AppCompatActivity
 																			.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.STATION_NOT_CHANGE"
-																			.equals(action))
-																	{
-																		new AlertDialog.Builder(
-																				MainActivity.this)
-																				.setIconAttribute(
-																						android.R.attr.alertDialogIcon)
-																				.setTitle(
-																						R.string.confirm_to_upload)
-																				.setMessage(
-																						"Upload to station "
-																								+ RedAntApplication.station_name)
-																				.setPositiveButton(
-																						android.R.string.ok,
-																						new DialogInterface.OnClickListener()
-																						{
-																							public void onClick(
-																									DialogInterface dialog,
-																									int whichButton)
-																							{
-
-																								SQLiteDatabase db = dbUtil
-																										.OpenDB(MainActivity.this,
-																												null,
-																												true);
-																								TextView pidval = (TextView) findViewById(R.id.pidval);
-																								String pid = pidval
-																										.getText()
-																										.toString();
-																								for (int i = 0; i < photoList
-																										.size(); i++)
-																								{
-
-																									ContentValues cv = new ContentValues();
-																									cv.put("picker",
-																											RedAntApplication.user);
-																									cv.put("server",
-																											RedAntApplication.active_address);
-																									cv.put("err_code",
-																											Network.STATUS_WAIT);
-																									cv.put("pid",
-																											pid);
-																									cv.put("local_path",
-																											photoList
-																													.get(i));
-																									db.insert(
-																											"pics",
-																											null,
-																											cv);
-
-																								}
-																								dbUtil.CloseDB(db);
-																								// new
-																								// UploadTask().execute((Void)
-																								// null);
-																								clearfornew();
-																								sendBroadcast(new Intent(
-																										"REDANT.POP.RESET_LOCATION"));
-																								Intent intent = new Intent(
-																										"REDANT.POP.MODIFY_QUEUE");
-																								sendBroadcast(intent);
-
-
-																							}
-																						})
-																				.setNegativeButton(
-																						android.R.string.cancel,
-																						new DialogInterface.OnClickListener()
-																						{
-																							public void onClick(
-																									DialogInterface dialog,
-																									int whichButton)
-																							{
-																								// debug
-																								// update_location();
-																							}
-																						})
-																				.create()
-																				.show();
-
-																	}
-																	else if ("REDANT.POP.STATION_CHANGE"
-																			.equals(action))
-																	{
-																		
-																		sendBroadcast(new Intent(
-																				"REDANT.POP.RESET_LOCATION"));
-																		new AlertDialog.Builder(
-																				MainActivity.this)
-																				.setIconAttribute(
-																						android.R.attr.alertDialogIcon)
-																				.setTitle(
-																						R.string.location_changed)
-																				.setMessage(
-																						"We have detected that your position has changed,do you want to modify the server setting? ")
-																				.setPositiveButton(
-																						android.R.string.ok,
-																						new DialogInterface.OnClickListener()
-																						{
-																							public void onClick(
-																									DialogInterface dialog,
-																									int whichButton)
-																							{
-
-																								Intent intent = new Intent();
-																								intent.setClass(
-																										MainActivity.this,
-																										ServerSettingActivity.class);
-																								startActivity(intent);
-																							}
-																						})
-																				.setNegativeButton(
-																						android.R.string.cancel,
-																						new DialogInterface.OnClickListener()
-																						{
-																							public void onClick(
-																									DialogInterface dialog,
-																									int whichButton)
-																							{
-
-																								// debug
-																								// update_location();
-																							}
-																						})
-																				.create()
-																				.show();
-
-																	}
-																	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 ("REDANT.POP.CLEAR_UPLOAD_QUEUE"
-																			.equals(action))
-																	{
-																		m_tvalert
-																				.setTextColor(getResources()
-																						.getColor(
-																								R.color.message_success));
-																		m_tvalert
-																				.setText("Error Cleared.");
-
-																	}
-																	else if (action
-																			.equals(Intent.ACTION_SCREEN_OFF))
-																	{
-																		Log.d("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.d(TAG,
-																				"===================>start locker");
-																		m_blocked = true;
-																	}
+//																	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.STATION_NOT_CHANGE"
+//																			.equals(action))
+//																	{
+//																		new AlertDialog.Builder(
+//																				MainActivity.this)
+//																				.setIconAttribute(
+//																						android.R.attr.alertDialogIcon)
+//																				.setTitle(
+//																						R.string.confirm_to_upload)
+//																				.setMessage(
+//																						"Upload to station "
+//																								+ RedAntApplication.station_name)
+//																				.setPositiveButton(
+//																						android.R.string.ok,
+//																						new DialogInterface.OnClickListener()
+//																						{
+//																							public void onClick(
+//																									DialogInterface dialog,
+//																									int whichButton)
+//																							{
+//
+//																								SQLiteDatabase db = dbUtil
+//																										.OpenDB(MainActivity.this,
+//																												null,
+//																												true);
+//																								TextView pidval = (TextView) findViewById(R.id.pidval);
+//																								String pid = pidval
+//																										.getText()
+//																										.toString();
+//																								for (int i = 0; i < photoList
+//																										.size(); i++)
+//																								{
+//
+//																									ContentValues cv = new ContentValues();
+//																									cv.put("picker",
+//																											RedAntApplication.user);
+//																									cv.put("server",
+//																											RedAntApplication.active_address);
+//																									cv.put("err_code",
+//																											Network.STATUS_WAIT);
+//																									cv.put("pid",
+//																											pid);
+//																									cv.put("local_path",
+//																											photoList
+//																													.get(i));
+//																									db.insert(
+//																											"pics",
+//																											null,
+//																											cv);
+//
+//																								}
+//																								dbUtil.CloseDB(db);
+//																								// new
+//																								// UploadTask().execute((Void)
+//																								// null);
+//																								clearfornew();
+//																								sendBroadcast(new Intent(
+//																										"REDANT.POP.RESET_LOCATION"));
+//																								Intent intent = new Intent(
+//																										"REDANT.POP.MODIFY_QUEUE");
+//																								sendBroadcast(intent);
+//
+//
+//																							}
+//																						})
+//																				.setNegativeButton(
+//																						android.R.string.cancel,
+//																						new DialogInterface.OnClickListener()
+//																						{
+//																							public void onClick(
+//																									DialogInterface dialog,
+//																									int whichButton)
+//																							{
+//																								// debug
+//																								// update_location();
+//																							}
+//																						})
+//																				.create()
+//																				.show();
+//
+//																	}
+//																	else if ("REDANT.POP.STATION_CHANGE"
+//																			.equals(action))
+//																	{
+//
+//																		sendBroadcast(new Intent(
+//																				"REDANT.POP.RESET_LOCATION"));
+//																		new AlertDialog.Builder(
+//																				MainActivity.this)
+//																				.setIconAttribute(
+//																						android.R.attr.alertDialogIcon)
+//																				.setTitle(
+//																						R.string.location_changed)
+//																				.setMessage(
+//																						"We have detected that your position has changed,do you want to modify the server setting? ")
+//																				.setPositiveButton(
+//																						android.R.string.ok,
+//																						new DialogInterface.OnClickListener()
+//																						{
+//																							public void onClick(
+//																									DialogInterface dialog,
+//																									int whichButton)
+//																							{
+//
+//																								Intent intent = new Intent();
+//																								intent.setClass(
+//																										MainActivity.this,
+//																										ServerSettingActivity.class);
+//																								startActivity(intent);
+//																							}
+//																						})
+//																				.setNegativeButton(
+//																						android.R.string.cancel,
+//																						new DialogInterface.OnClickListener()
+//																						{
+//																							public void onClick(
+//																									DialogInterface dialog,
+//																									int whichButton)
+//																							{
+//
+//																								// debug
+//																								// update_location();
+//																							}
+//																						})
+//																				.create()
+//																				.show();
+//
+//																	}
+//																	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 ("REDANT.POP.CLEAR_UPLOAD_QUEUE"
+//																			.equals(action))
+//																	{
+//																		m_tvalert
+//																				.setTextColor(getResources()
+//																						.getColor(
+//																								R.color.message_success));
+//																		m_tvalert
+//																				.setText("Error Cleared.");
+//
+//																	}
+//																	else if (action
+//																			.equals(Intent.ACTION_SCREEN_OFF))
+//																	{
+////																		Log.d("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.d(TAG,
+////																				"===================>start locker");
+////																		m_blocked = true;
+//																	}
 																}
 															};
 

+ 4 - 10
RA Image/app/src/main/java/com/usai/redant/raimage/ServerSettingActivity.java

@@ -5,11 +5,7 @@ import android.app.AlertDialog;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
-import android.content.pm.PackageManager;
-import android.net.Uri;
 import android.os.Bundle;
-import android.provider.Settings;
-import android.support.v4.content.ContextCompat;
 import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.Menu;
@@ -21,8 +17,6 @@ import android.widget.ImageButton;
 import android.widget.RadioGroup;
 import android.widget.Toast;
 
-import com.usai.util.RAUtil;
-
 public class ServerSettingActivity extends Activity
 {
 	static final int	REQUEST_SCAN_BARCODE	= 2;
@@ -91,10 +85,10 @@ public class ServerSettingActivity extends Activity
 			public void onClick(View v)
 			{
 			//	Log.d(TAG, "==============>Click Scan button");
-				if (!RAUtil.checkPermission(ServerSettingActivity.this,"android.permission.CAMERA")) {
-
-					return;
-				}
+//				if (!RAUtil.checkPermission(ServerSettingActivity.this,"android.permission.CAMERA")) {
+//
+//					return;
+//				}
 
 				Intent intent = new Intent();
 

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

@@ -81,8 +81,8 @@ public class UploadService extends Service
 
 			@Override
 			public void handleCrashInfo(String deviceInfo, String exception) {
-				Log.d("Crash", "Device Info: " + deviceInfo);
-				Log.d("Crash", "Crash Info: " + exception);
+				Log.d("_SERVICE", "Device Info: " + deviceInfo);
+				Log.d("_SERVICE", "Crash Info: " + exception);
 			}
 		};
 

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

@@ -887,32 +887,32 @@ public class Network
 	public static JSONObject UploadImage(String path, Bundle Params,String server,FileUploadListener listener)
 	{
 		String TAG = "net_dbg@UploadImage";
-		Bitmap source = BitmapFactory.decodeFile(path);
-
-		int originWidth = source.getWidth();
-		int originHeight = source.getHeight();
-
-		int width = originWidth, height = originHeight;
-
-		if (originHeight > 1024 || originWidth > 1024)
-		{
-			if (originWidth > originHeight)
-			{
-				width = 1024;
-				height = originHeight * 1024 / originWidth;
-
-			}
-			else
-			{
-
-				height = 1024;
-				width = originWidth * 1024 / originHeight;
-
-			}
-		}
-		Bitmap scaled = Bitmap.createScaledBitmap(source, width, height, true);
-		OutputStream fOutputStream = null;
-		String scaledPath = path.replace(".jpg", "_scaled.jpg");
+//		Bitmap source = BitmapFactory.decodeFile(path);
+//
+//		int originWidth = source.getWidth();
+//		int originHeight = source.getHeight();
+//
+//		int width = originWidth, height = originHeight;
+//
+//		if (originHeight > 1024 || originWidth > 1024)
+//		{
+//			if (originWidth > originHeight)
+//			{
+//				width = 1024;
+//				height = originHeight * 1024 / originWidth;
+//
+//			}
+//			else
+//			{
+//
+//				height = 1024;
+//				width = originWidth * 1024 / originHeight;
+//
+//			}
+//		}
+//		Bitmap scaled = Bitmap.createScaledBitmap(source, width, height, true);
+//		OutputStream fOutputStream = null;
+//		String scaledPath = path.replace(".jpg", "_scaled.jpg");
 //		File file = new File(scaledPath);
 //		try
 //		{

+ 29 - 16
RA Image/app/src/main/java/com/usai/util/RAUploadManager.java

@@ -179,6 +179,18 @@ public class RAUploadManager {
                     }
 
 
+
+
+
+
+                } catch (JSONException e) {
+//                    String rmsg=result.getString("msg");
+                    taskinfo.putInt("status",TaskStatus.TaskStatusError.ordinal());
+                    taskinfo.putDouble("progress",0.0);
+                    taskinfo.putString("msg","can not upload, please contact administrator.");
+                    e.printStackTrace();
+                }
+                finally {
                     synchronized (this)
                     {
                         if (uiUpdateListener!=null) {
@@ -187,11 +199,6 @@ public class RAUploadManager {
                             uiUpdateListener.updateCell(index,taskinfo);
                         }
                     }
-
-
-
-                } catch (JSONException e) {
-                    e.printStackTrace();
                 }
 
                 return ret;
@@ -283,25 +290,29 @@ public class RAUploadManager {
 //
 //            editor.commit();
 
-            byte[] decode=Base64.decode(tasksBase64,Base64.DEFAULT);
-            ByteArrayInputStream bais= new ByteArrayInputStream(decode);
+            if(tasksBase64.length()>0)
+            {
+                byte[] decode=Base64.decode(tasksBase64,Base64.DEFAULT);
+                ByteArrayInputStream bais= new ByteArrayInputStream(decode);
 
-        ObjectInputStream ois = null;
+                ObjectInputStream ois = null;
 
-            ois = new ObjectInputStream(bais);
+                ois = new ObjectInputStream(bais);
 
-        ArrayList<String> arr_load=(ArrayList<String>)ois.readObject();
-            for(String s:arr_load)
-            {
-                Log.d("_RAIMAGE", "loadTask: "+s);
-                JSONObject jsobj = new JSONObject(s);
-                Bundle b=RAUtil.Json2Bundle(jsobj);
-                arr_queue.add(b);
+                ArrayList<String> arr_load=(ArrayList<String>)ois.readObject();
+                for(String s:arr_load)
+                {
+                    Log.d("_RAIMAGE", "loadTask: "+s);
+                    JSONObject jsobj = new JSONObject(s);
+                    Bundle b=RAUtil.Json2Bundle(jsobj);
+                    arr_queue.add(b);
 //                                String sjson=RAUtil.Bundle2Json(b).toString();
 
 //                wrap_arr.add(sjson);
+                }
             }
 
+
         } catch (IOException e) {
             e.printStackTrace();
         } catch (ClassNotFoundException e) {
@@ -368,6 +379,8 @@ public class RAUploadManager {
         }
         removeTasks(remove);
 
+
+
     }
     public void removeTask(Bundle task)
     {

+ 184 - 15
RA Image/app/src/main/java/com/usai/util/RAUtil.java

@@ -1,15 +1,21 @@
 package com.usai.util;
 
-import android.app.AlertDialog;
-import android.content.Context;
+import android.Manifest;
+import android.app.Activity;
 import android.content.pm.PackageManager;
+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;
 
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.lang.reflect.Array;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Map;
@@ -19,27 +25,190 @@ import java.util.Set;
  * Created by ray on 27/06/2017.
  */
 
+
 public class RAUtil {
-    public static Boolean checkPermission(final Context context, String permission)
+    public static final int MY_PERMISSIONS_REQUEST= 1;
+    public static void checkPermissions1(Activity activity, String[] permissions)
     {
-        // 调用Context的checkCallingOrSelfPermission来检查权限
+        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)
+        {
+            return checkPermissions_23(activity,permissions);
+        }
+        else
+        {
+            return false;
+//            return checkPermissions_23(activity,permissions);
+        }
+    }
+    public static Boolean checkPermissions_23(Activity activity, String[] permissions)
+    {
+        Log.d("_RAIMAGE", "checkPermissions23:==================================== ");
+        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 pc = PermissionChecker.checkSelfPermission(activity,permission)==PermissionChecker.PERMISSION_GRANTED;
+            Log.d("_RAIMAGE", "checkPermissions23: "+permission+"  SHOW  "+bshow+"  granted  "+granted +","+pc);
+
+            if(!pc)
+                request_list.add(permission);
+        }
+        Log.d("_RAIMAGE", "checkPermissions23:==================================== ");
 
-        if (PackageManager.PERMISSION_GRANTED!= context.checkCallingOrSelfPermission(permission)) {
 
-            String[] tmp = permission.split("\\.");
-            String permission_name = tmp[tmp.length - 1];
-            permission_name = permission_name.replace("_"," ");
+        if(request_list.isEmpty())
+            return false;
+        ActivityCompat.requestPermissions(activity,
+                request_list.toArray(new String[0]),
+                MY_PERMISSIONS_REQUEST);
 
 
-            new AlertDialog.Builder(context)
-                    .setTitle("Warning")
-                    .setMessage("RA Image need " + permission_name.toLowerCase() + " permission")
-                    .setPositiveButton("OK", null)
-                    .show();
+        return true;
+
+    }
+    public static Boolean checkPermissions_24(Activity activity, String[] permissions)
+    {
+
+
+
+
+//        ArrayList<String> request_list = new ArrayList<String>();
+//        for(String permission : permissions) {
+//
+//
+////            boolean bshow=ActivityCompat.shouldShowRequestPermissionRationale(activity,permission);
+////
+////
+////            AppOpsManager appOpsManager = (AppOpsManager) activity.getSystemService(Context.APP_OPS_SERVICE);
+////            String opsName = AppOpsManager.permissionToOp(permission);
+////            if (opsName == null) {
+////                return true;
+////            }
+////            int opsMode = appOpsManager.checkOpNoThrow(opsName, Process.myUid(), activity.getPackageName());
+//////            return opsMode == AppOpsManager.MODE_ALLOWED;
+//
+//
+////            if (ContextCompat.checkSelfPermission(activity,
+////                    Manifest.permission.ACCESS_FINE_LOCATION)
+////                    != PackageManager.PERMISSION_GRANTED||opsMode != AppOpsManager.MODE_ALLOWED)
+//
+//                request_list.add(permission);
+//
+//        }
+
+//        File logfile = new File(Environment.getExternalStorageDirectory()
+//                .getPath() + "/redant/pop/" + "debug" + ".log");
+//
+//        // int mode = Application.MODE_APPEND;
+//        if (!logfile.exists())
+//        {
+//            // mode = Application.MODE_PRIVATE;
+//            try
+//            {
+//                logfile.createNewFile();
+//            }
+//            catch (IOException e)
+//            {
+//                // TODO Auto-generated catch block
+//                e.printStackTrace();
+//
+//            }
+//        }
+        if(permissions.length==0)
+            return true;
+        ActivityCompat.requestPermissions(activity,
+                permissions,
+                MY_PERMISSIONS_REQUEST);
+
 
-            return false;
-        }
         return true;
+
+//
+//        if (ContextCompat.checkSelfPermission(activity,
+//                Manifest.permission.ACCESS_FINE_LOCATION)
+//                != PackageManager.PERMISSION_GRANTED)
+//        {
+//
+//
+////            if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
+////                    permission))
+////            {
+////                return false;
+////            }
+////            else
+//            {
+//                ActivityCompat.requestPermissions(activity,
+//                        new String[]{permission},
+//                        MY_PERMISSIONS_REQUEST);
+//                return true;
+//            }
+//        } else
+//        {
+//           return true;
+//        }
+//        if(true)
+//        return true;
+        // 调用Context的checkCallingOrSelfPermission来检查权限
+
+//        Activity activity1 = (Activity) activity;
+//        if(activity==null)
+//            return false;
+//        if (PackageManager.PERMISSION_GRANTED!= context.checkCallingOrSelfPermission(permission)) {
+//
+////            String[] tmp = permission.split("\\.");
+////            String permission_name = tmp[tmp.length - 1];
+////            permission_name = permission_name.replace("_"," ");
+////
+////
+////            new AlertDialog.Builder(context)
+////                    .setTitle("Warning")
+////                    .setMessage("RA Image need " + permission_name.toLowerCase() + " permission")
+////                    .setPositiveButton("OK", null)
+////                    .show();
+////
+////            return false;
+//
+//
+//             if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
+//                    permission)) {
+//
+//                Log.d("_RAIMAGE", "checkPermission: shouldShowRequestPermissionRationale TRUE   " + permission);
+//                // Show an expanation to the user *asynchronously* -- don't block
+//                // this thread waiting for the user's response! After the user
+//                // sees the explanation, try again to request the permission.
+//
+//            } else {
+//
+//                // No explanation needed, we can request the permission.
+//
+//
+//                Log.d("_RAIMAGE", "checkPermission: shouldShowRequestPermissionRationale false   "+ permission);
+//                ActivityCompat.requestPermissions(activity,
+//                        new String[]{permission},
+//                        123);
+//
+//                // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
+//                // app-defined int constant. The callback method gets the
+//                // result of the request.
+//            }
+//
+//        }
+//        return true;
     }
 
     public static String lastPathComponent(String path){

+ 2 - 0
RA Image/app/src/main/java/com/usai/util/dbgUtil.java

@@ -50,6 +50,8 @@ public class dbgUtil
 				.getTimeInMillis());
 
 		File[] f = dir.listFiles();
+		if(f==null)
+		    return;
 		for (int i = 0; i < f.length; i++)
 		{
 			if(!f[i].isFile())