+ return result;
+ }
+
+ /**
+ * Saves a new OC File after a successful upload.
+ *
+ * @param upload Upload operation completed.
+ * @param storageManager Interface to the database where the new OCFile has to be stored.
+ * @param parentDirId Id of the parent OCFile.
+ * @param size Size of the file.
+ */
+ private void saveNewOCFile(UploadFileOperation upload, FileDataStorageManager storageManager, long parentDirId, long size) {
+ OCFile newFile = new OCFile(upload.getRemotePath());
+ newFile.setMimetype(upload.getMimeType());
+ newFile.setFileLength(size);
+ newFile.setModificationTimestamp(System.currentTimeMillis());
+ newFile.setLastSyncDate(0);
+ newFile.setStoragePath(upload.getLocalPath());
+ newFile.setParentId(parentDirId);
+ if (upload.getForceOverwrite())
+ newFile.setKeepInSync(true);
+ storageManager.saveFile(newFile);
+ }
+
+ /**
+ * Creates a status notification to show the upload progress
+ *
+ * @param upload Upload operation starting.
+ */
+ private void notifyUploadStart(UploadFileOperation upload) {
+ /// create status notification with a progress bar
+ mLastPercent = 0;
+ mNotification = new Notification(R.drawable.icon, getString(R.string.uploader_upload_in_progress_ticker), System.currentTimeMillis());
+ mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
+ mDefaultNotificationContentView = mNotification.contentView;
+ mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
+ mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, false);
+ mNotification.contentView.setTextViewText(R.id.status_text, String.format(getString(R.string.uploader_upload_in_progress_content), 0, new File(upload.getLocalPath()).getName()));
+ mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
+
+ /// includes a pending intent in the notification showing the details view of the file
+ /* TODO
+ Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, upload.getFile());
+ showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, upload.getAccount());
+ showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, showDetailsIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ */