- private void handleUploadFinished(Context context, Intent intent) {
- // remove successfull uploading, ignore rest for reupload on reconnect
- /*
- if (intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, false)) {
- DbHandler db = new DbHandler(context);
- String localPath = intent.getStringExtra(FileUploader.EXTRA_OLD_FILE_PATH);
- if (!db.removeIUPendingFile(localPath)) {
- Log_OC.w(TAG, "Tried to remove non existing instant upload file " + localPath);
- }
- db.close();
+ 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;