- // register for upload finishe message
- // there is a litte problem with android API, we can register for particular
- // intent in registerReceiver but we cannot unregister from precise intent
- // we can unregister from entire listenings but thats suck a bit.
- // On the other hand this might be only for dynamicly registered
- // broadcast receivers, needs investigation.
- IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
- context.getApplicationContext().registerReceiver(this, filter);
-
+ if (!instantVideoUploadEnabled(context)) {
+ Log_OC.d(TAG, "Instant video upload disabled, ignoring new video");
+ 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 = { Video.Media.DATA, Video.Media.DISPLAY_NAME, Video.Media.MIME_TYPE, Video.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(Video.Media.DATA));
+ file_name = c.getString(c.getColumnIndex(Video.Media.DISPLAY_NAME));
+ mime_type = c.getString(c.getColumnIndex(Video.Media.MIME_TYPE));
+ c.close();
+ Log_OC.d(TAG, file_path + "");
+
+ if (!isOnline(context) || (instantVideoUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
+ return;
+ }
+