+ private void handleNewPictureAction(Context context, Intent intent) {
+ Cursor c = null;
+ String file_path = null;
+ String file_name = null;
+ String mime_type = null;
+
+ Log_OC.w(TAG, "New photo received");
+
+ if (!instantPictureUploadEnabled(context)) {
+ Log_OC.d(TAG, "Instant picture upload disabled, ignoring new picture");
+ return;
+ }
+
+ Account account = AccountUtils.getCurrentOwnCloudAccount(context);
+ if (account == null) {
+ Log_OC.w(TAG, "No ownCloud account found for instant upload, aborting");
+ return;
+ }
+
+ String[] CONTENT_PROJECTION = { Images.Media.DATA, Images.Media.DISPLAY_NAME, Images.Media.MIME_TYPE, Images.Media.SIZE };
+ c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null);
+ if (!c.moveToFirst()) {
+ Log_OC.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
+ return;
+ }
+ file_path = c.getString(c.getColumnIndex(Images.Media.DATA));
+ file_name = c.getString(c.getColumnIndex(Images.Media.DISPLAY_NAME));
+ mime_type = c.getString(c.getColumnIndex(Images.Media.MIME_TYPE));
+ c.close();
+ Log_OC.d(TAG, file_path + "");
+
+ // save always temporally the picture to upload
+ DbHandler db = new DbHandler(context);
+ db.putFileForLater(file_path, account.name, null);
+ db.close();
+
+ if (!isOnline(context)
+ || (instantPictureUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))
+ || (instantUploadWhenChargingOnly(context) && !isCharging(context))
+ ) {
+ return;
+ }
+
+ Intent i = new Intent(context, FileUploader.class);
+ i.putExtra(FileUploader.KEY_ACCOUNT, account);
+ i.putExtra(FileUploader.KEY_LOCAL_FILE, file_path);
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, FileStorageUtils.getInstantUploadFilePath(context, file_name));
+ i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
+ i.putExtra(FileUploader.KEY_MIME_TYPE, mime_type);
+ i.putExtra(FileUploader.KEY_INSTANT_UPLOAD, true);
+
+ // instant upload behaviour
+ SharedPreferences appPreferences = PreferenceManager.getDefaultSharedPreferences(context);
+ String behaviour = appPreferences.getString("prefs_instant_behaviour", "NOTHING");
+
+ if (behaviour.equalsIgnoreCase("NOTHING")) {
+ Log_OC.d(TAG, "upload file and do nothing");
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_FORGET);
+ } else if (behaviour.equalsIgnoreCase("COPY")) {
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_COPY);
+ Log_OC.d(TAG, "upload file and copy file to oc folder");
+ } else if (behaviour.equalsIgnoreCase("MOVE")) {
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
+ Log_OC.d(TAG, "upload file and move file to oc folder");
+ } else if (behaviour.equalsIgnoreCase("DELETE")){
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_REMOVE);
+ Log_OC.d(TAG, "upload file and delete file in original place");