- // 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);*/
+ 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);
+ context.startService(i);
+ }
+
+ private void handleNewVideoAction(Context context, Intent intent) {
+ Cursor c = null;
+ String file_path = null;
+ String file_name = null;
+ String mime_type = null;
+
+ Log_OC.w(TAG, "New video received");
+
+ 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;
+ }