update
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / FileOperationsHelper.java
1 /**
2 * ownCloud Android client application
3 *
4 * @author masensio
5 * @author David A. Velasco
6 * Copyright (C) 2015 ownCloud Inc.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 package com.owncloud.android.files;
23
24 import android.accounts.Account;
25 import android.content.ActivityNotFoundException;
26 import android.content.Context;
27 import android.content.Intent;
28 import android.graphics.Bitmap;
29 import android.content.pm.PackageManager;
30 import android.content.pm.ResolveInfo;
31 import android.graphics.Bitmap;
32 import android.net.Uri;
33 import android.support.v4.app.DialogFragment;
34 import android.webkit.MimeTypeMap;
35 import android.widget.Toast;
36
37 import com.owncloud.android.MainApp;
38 import com.owncloud.android.R;
39 import com.owncloud.android.authentication.AccountUtils;
40 import com.owncloud.android.datamodel.OCFile;
41 import com.owncloud.android.datamodel.ThumbnailsCacheManager;
42 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
43 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
44 import com.owncloud.android.lib.common.network.WebdavUtils;
45 import com.owncloud.android.lib.common.utils.Log_OC;
46 import com.owncloud.android.lib.resources.shares.ShareType;
47 import com.owncloud.android.lib.resources.status.OwnCloudVersion;
48 import com.owncloud.android.services.OperationsService;
49 import com.owncloud.android.services.observer.FileObserverService;
50 import com.owncloud.android.ui.activity.FileActivity;
51 import com.owncloud.android.ui.adapter.DiskLruImageCacheFileProvider;
52 import com.owncloud.android.ui.activity.ShareActivity;
53 import com.owncloud.android.ui.dialog.ShareLinkToDialog;
54
55 import org.apache.http.protocol.HTTP;
56
57 import java.io.File;
58 import java.util.List;
59
60 import java.io.ByteArrayOutputStream;
61 import java.io.File;
62 import java.io.FileNotFoundException;
63 import java.io.FileOutputStream;
64 import java.io.IOException;
65
66 import org.apache.http.protocol.HTTP;
67
68 import java.util.ArrayList;
69 import java.util.List;
70
71 /**
72 *
73 */
74 public class FileOperationsHelper {
75
76 private static final String TAG = FileOperationsHelper.class.getName();
77
78 private static final String FTAG_CHOOSER_DIALOG = "CHOOSER_DIALOG";
79
80 protected FileActivity mFileActivity = null;
81
82 /// Identifier of operation in progress which result shouldn't be lost
83 private long mWaitingForOpId = Long.MAX_VALUE;
84
85 public FileOperationsHelper(FileActivity fileActivity) {
86 mFileActivity = fileActivity;
87 }
88
89
90 public void openFile(OCFile file) {
91 if (file != null) {
92 String storagePath = file.getStoragePath();
93 String encodedStoragePath = WebdavUtils.encodePath(storagePath);
94
95 Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
96 intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath),
97 file.getMimetype());
98 intentForSavedMimeType.setFlags(
99 Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
100 );
101
102 Intent intentForGuessedMimeType = null;
103 if (storagePath.lastIndexOf('.') >= 0) {
104 String guessedMimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
105 storagePath.substring(storagePath.lastIndexOf('.') + 1)
106 );
107 if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
108 intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
109 intentForGuessedMimeType.
110 setDataAndType(Uri.parse("file://"+ encodedStoragePath),
111 guessedMimeType);
112 intentForGuessedMimeType.setFlags(
113 Intent.FLAG_GRANT_READ_URI_PERMISSION |
114 Intent.FLAG_GRANT_WRITE_URI_PERMISSION
115 );
116 }
117 }
118
119 Intent openFileWithIntent;
120 if (intentForGuessedMimeType != null) {
121 openFileWithIntent = intentForGuessedMimeType;
122 } else {
123 openFileWithIntent = intentForSavedMimeType;
124 }
125
126 List<ResolveInfo> launchables = mFileActivity.getPackageManager().
127 queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS);
128
129 if(launchables != null && launchables.size() > 0) {
130 try {
131 mFileActivity.startActivity(
132 Intent.createChooser(
133 openFileWithIntent, mFileActivity.getString(R.string.actionbar_open_with)
134 )
135 );
136 } catch (ActivityNotFoundException anfe) {
137 showNoAppForFileTypeToast(mFileActivity.getApplicationContext());
138 }
139 } else {
140 showNoAppForFileTypeToast(mFileActivity.getApplicationContext());
141 }
142
143 } else {
144 Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
145 }
146 }
147
148 /**
149 * Displays a toast stating that no application could be found to open the file.
150 *
151 * @param context the context to be able to show a toast.
152 */
153 private void showNoAppForFileTypeToast(Context context) {
154 Toast.makeText(context,
155 R.string.file_list_no_app_for_file_type, Toast.LENGTH_SHORT)
156 .show();
157 }
158
159 public void shareFileWithLink(OCFile file) {
160
161 if (isSharedSupported()) {
162 if (file != null) {
163 String link = "https://fake.url";
164 Intent intent = createShareWithLinkIntent(link);
165 String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
166 DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent,
167 packagesToExclude, file);
168 chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
169
170 } else {
171 Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
172 }
173
174 } else {
175 // Show a Message
176 Toast t = Toast.makeText(
177 mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api),
178 Toast.LENGTH_LONG
179 );
180 t.show();
181 }
182 }
183
184
185 public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) {
186
187 if (file != null) {
188 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
189 getString(R.string.wait_a_moment));
190
191 Intent service = new Intent(mFileActivity, OperationsService.class);
192 service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
193 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
194 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
195 service.putExtra(OperationsService.EXTRA_PASSWORD_SHARE, password);
196 service.putExtra(OperationsService.EXTRA_SEND_INTENT, sendIntent);
197 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
198
199 } else {
200 Log_OC.wtf(TAG, "Trying to open a NULL OCFile");
201 }
202 }
203
204
205 private Intent createShareWithLinkIntent(String link) {
206 Intent intentToShareLink = new Intent(Intent.ACTION_SEND);
207 intentToShareLink.putExtra(Intent.EXTRA_TEXT, link);
208 intentToShareLink.setType(HTTP.PLAIN_TEXT_TYPE);
209 return intentToShareLink;
210 }
211
212
213 /**
214 * Helper method to share a file with a know sharee. Starts a request to do it in {@link OperationsService}
215 *
216 * @param file The file to share.
217 * @param shareeName Name (user name or group name) of the target sharee.
218 * @param shareType The share type determines the sharee type.
219 */
220 public void shareFileWithSharee(OCFile file, String shareeName, ShareType shareType) {
221 if (file != null) {
222 // TODO check capability?
223 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
224 getString(R.string.wait_a_moment));
225
226 Intent service = new Intent(mFileActivity, OperationsService.class);
227 service.setAction(OperationsService.ACTION_CREATE_SHARE_WITH_SHAREE);
228 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
229 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
230 service.putExtra(OperationsService.EXTRA_SHARE_WITH, shareeName);
231 service.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
232 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
233
234 } else {
235 Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
236 }
237 }
238
239
240 /**
241 * @return 'True' if the server supports the Share API
242 */
243 public boolean isSharedSupported() {
244 if (mFileActivity.getAccount() != null) {
245 OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
246 return (serverVersion != null && serverVersion.isSharedSupported());
247 }
248 return false;
249 }
250
251
252 public void unshareFileWithLink(OCFile file) {
253
254 // Unshare the file: Create the intent
255 Intent unshareService = new Intent(mFileActivity, OperationsService.class);
256 unshareService.setAction(OperationsService.ACTION_UNSHARE);
257 unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
258 unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
259 unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, ShareType.PUBLIC_LINK);
260 unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, "");
261
262 unshareFile(unshareService);
263 }
264
265 public void unshareFileWithUserOrGroup(OCFile file, ShareType shareType, String userOrGroup){
266
267 // Unshare the file: Create the intent
268 Intent unshareService = new Intent(mFileActivity, OperationsService.class);
269 unshareService.setAction(OperationsService.ACTION_UNSHARE);
270 unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
271 unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
272 unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
273 unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, userOrGroup);
274
275 unshareFile(unshareService);
276 }
277
278
279 private void unshareFile(Intent unshareService){
280 if (isSharedSupported()) {
281 // Unshare the file
282 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().
283 queueNewOperation(unshareService);
284
285 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
286 getString(R.string.wait_a_moment));
287
288 } else {
289 // Show a Message
290 Toast t = Toast.makeText(mFileActivity,
291 mFileActivity.getString(R.string.share_link_no_support_share_api),
292 Toast.LENGTH_LONG);
293 t.show();
294
295 }
296 }
297
298 /**
299 * Show an instance of {@link ShareType} for sharing or unsharing the {@OCFile} received as parameter.
300 *
301 * @param file File to share or unshare.
302 */
303 public void showShareFile(OCFile file){
304 Intent intent = new Intent(mFileActivity, ShareActivity.class);
305 intent.putExtra(mFileActivity.EXTRA_FILE, file);
306 intent.putExtra(mFileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
307 mFileActivity.startActivity(intent);
308
309 }
310
311
312 /**
313 * @return 'True' if the server supports the Search Users API
314 */
315 public boolean isSearchUsersSupportedSupported() {
316 if (mFileActivity.getAccount() != null) {
317 OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
318 return (serverVersion != null && serverVersion.isSearchUsersSupported());
319 }
320 return false;
321 }
322
323 public void sendDownloadedFile(OCFile file) {
324 if (file != null) {
325 String storagePath = file.getStoragePath();
326 String encodedStoragePath = WebdavUtils.encodePath(storagePath);
327 Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
328 // set MimeType
329 sendIntent.setType(file.getMimetype());
330 sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath));
331 sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
332
333 // Show dialog, without the own app
334 String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
335 DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent,
336 packagesToExclude, file);
337 chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
338
339 } else {
340 Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
341 }
342 }
343
344 public void setPictureAs(OCFile file) {
345 if (file != null){
346 if (file.isDown()) {
347 File externalFile = new File(file.getStoragePath());
348 Uri sendUri = Uri.fromFile(externalFile);
349 Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
350 intent.setDataAndType(sendUri, file.getMimetype());
351 intent.putExtra("mimeType", file.getMimetype());
352 mFileActivity.startActivityForResult(Intent.createChooser(intent,
353 mFileActivity.getString(R.string.set_as)), 200);
354 } else {
355 // TODO re-enable after resized images is available
356 Uri sendUri = Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath());
357 Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
358 intent.setDataAndType(sendUri, file.getMimetype());
359 intent.putExtra("mimeType", file.getMimetype());
360 mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
361
362 // Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
363 // // set MimeType
364 // sendIntent.setType(file.getMimetype());
365 //// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName()));
366 // sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
367 // sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
368 //
369 // // Show dialog, without the own app
370 // String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
371 // DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
372 // chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
373 }
374 } else {
375 Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
376 }
377 }
378
379 public void sendCachedImage(OCFile file) {
380 if (file != null) {
381 Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
382 // set MimeType
383 sendIntent.setType(file.getMimetype());
384 // sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName()));
385 sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
386 sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
387
388 // Show dialog, without the own app
389 String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
390 DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
391 chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
392 } else {
393 Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
394 }
395 }
396
397 public void syncFiles(ArrayList<OCFile> files) {
398 for (OCFile file: files) {
399 syncFile(file);
400 }
401 }
402
403 /**
404 * Request the synchronization of a file or folder with the OC server, including its contents.
405 *
406 * @param file The file or folder to synchronize
407 */
408 public void syncFile(OCFile file) {
409 if (!file.isFolder()){
410 Intent intent = new Intent(mFileActivity, OperationsService.class);
411 intent.setAction(OperationsService.ACTION_SYNC_FILE);
412 intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
413 intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
414 intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
415 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
416 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
417 getString(R.string.wait_a_moment));
418
419 } else {
420 Intent intent = new Intent(mFileActivity, OperationsService.class);
421 intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
422 intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
423 intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
424 mFileActivity.startService(intent);
425
426 }
427 }
428
429 public void toggleFavorites(ArrayList<OCFile> files, boolean isFavorite){
430 for (OCFile file: files) {
431 toggleFavorite(file, isFavorite);
432 }
433 }
434
435 public void toggleFavorite(OCFile file, boolean isFavorite) {
436 file.setFavorite(isFavorite);
437 mFileActivity.getStorageManager().saveFile(file);
438
439 /// register the OCFile instance in the observer service to monitor local updates
440 Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
441 mFileActivity,
442 file,
443 mFileActivity.getAccount(),
444 isFavorite);
445 mFileActivity.startService(observedFileIntent);
446
447 /// immediate content synchronization
448 if (file.isFavorite()) {
449 syncFile(file);
450 }
451 }
452
453 public void renameFile(OCFile file, String newFilename) {
454 // RenameFile
455 Intent service = new Intent(mFileActivity, OperationsService.class);
456 service.setAction(OperationsService.ACTION_RENAME);
457 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
458 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
459 service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
460 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
461
462 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
463 getString(R.string.wait_a_moment));
464 }
465
466
467 public void removeFile(OCFile file, boolean onlyLocalCopy) {
468 // RemoveFile
469 Intent service = new Intent(mFileActivity, OperationsService.class);
470 service.setAction(OperationsService.ACTION_REMOVE);
471 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
472 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
473 service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
474 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
475
476 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
477 getString(R.string.wait_a_moment));
478 }
479
480
481 public void createFolder(String remotePath, boolean createFullPath) {
482 // Create Folder
483 Intent service = new Intent(mFileActivity, OperationsService.class);
484 service.setAction(OperationsService.ACTION_CREATE_FOLDER);
485 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
486 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);
487 service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
488 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
489
490 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
491 getString(R.string.wait_a_moment));
492 }
493
494 /**
495 * Cancel the transference in downloads (files/folders) and file uploads
496 * @param file OCFile
497 */
498 public void cancelTransference(OCFile file) {
499 Account account = mFileActivity.getAccount();
500 if (file.isFolder()) {
501 OperationsService.OperationsServiceBinder opsBinder =
502 mFileActivity.getOperationsServiceBinder();
503 if (opsBinder != null) {
504 opsBinder.cancel(account, file);
505 }
506 }
507
508 // for both files and folders
509 FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
510 if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) {
511 downloaderBinder.cancel(account, file);
512 }
513 FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
514 if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
515 uploaderBinder.cancel(account, file);
516 }
517 }
518
519 /**
520 * Start move file operation
521 *
522 * @param newfile File where it is going to be moved
523 * @param currentFile File with the previous info
524 */
525 public void moveFile(OCFile newfile, OCFile currentFile) {
526 // Move files
527 Intent service = new Intent(mFileActivity, OperationsService.class);
528 service.setAction(OperationsService.ACTION_MOVE_FILE);
529 service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, newfile.getRemotePath());
530 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, currentFile.getRemotePath());
531 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
532 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
533
534 // TODO Tobi loading dialog?
535 // mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
536 // getString(R.string.wait_a_moment));
537 }
538
539 /**
540 * Start copy file operation
541 *
542 * @param newfile File where it is going to be moved
543 * @param currentFile File with the previous info
544 */
545 public void copyFile(OCFile newfile, OCFile currentFile) {
546 // Copy files
547 Intent service = new Intent(mFileActivity, OperationsService.class);
548 service.setAction(OperationsService.ACTION_COPY_FILE);
549 service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, newfile.getRemotePath());
550 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, currentFile.getRemotePath());
551 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
552 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
553
554 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
555 getString(R.string.wait_a_moment));
556 }
557
558 public long getOpIdWaitingFor() {
559 return mWaitingForOpId;
560 }
561
562
563 public void setOpIdWaitingFor(long waitingForOpId) {
564 mWaitingForOpId = waitingForOpId;
565 }
566
567 /**
568 * @return 'True' if the server doesn't need to check forbidden characters
569 */
570 public boolean isVersionWithForbiddenCharacters() {
571 if (mFileActivity.getAccount() != null) {
572 OwnCloudVersion serverVersion =
573 AccountUtils.getServerVersion(mFileActivity.getAccount());
574 return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters());
575 }
576 return false;
577 }
578 }