Merge branch 'setAsWallpaper' into beta
[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, "Set As"), 200);
353 } else {
354 // TODO re-enable after resized images is available
355 Uri sendUri = Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath());
356 Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
357 intent.setDataAndType(sendUri, file.getMimetype());
358 intent.putExtra("mimeType", file.getMimetype());
359 mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
360
361 // Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
362 // // set MimeType
363 // sendIntent.setType(file.getMimetype());
364 //// sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName()));
365 // sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
366 // sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
367 //
368 // // Show dialog, without the own app
369 // String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
370 // DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
371 // chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
372 }
373 } else {
374 Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
375 }
376 }
377
378 public void sendCachedImage(OCFile file) {
379 if (file != null) {
380 Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
381 // set MimeType
382 sendIntent.setType(file.getMimetype());
383 // sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName()));
384 sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
385 sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action
386
387 // Show dialog, without the own app
388 String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
389 DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
390 chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
391 } else {
392 Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
393 }
394 }
395
396 public void syncFiles(ArrayList<OCFile> files) {
397 for (OCFile file: files) {
398 syncFile(file);
399 }
400 }
401
402 /**
403 * Request the synchronization of a file or folder with the OC server, including its contents.
404 *
405 * @param file The file or folder to synchronize
406 */
407 public void syncFile(OCFile file) {
408 if (!file.isFolder()){
409 Intent intent = new Intent(mFileActivity, OperationsService.class);
410 intent.setAction(OperationsService.ACTION_SYNC_FILE);
411 intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
412 intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
413 intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
414 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
415 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
416 getString(R.string.wait_a_moment));
417
418 } else {
419 Intent intent = new Intent(mFileActivity, OperationsService.class);
420 intent.setAction(OperationsService.ACTION_SYNC_FOLDER);
421 intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
422 intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
423 mFileActivity.startService(intent);
424
425 }
426 }
427
428 public void toggleFavorites(ArrayList<OCFile> files, boolean isFavorite){
429 for (OCFile file: files) {
430 toggleFavorite(file, isFavorite);
431 }
432 }
433
434 public void toggleFavorite(OCFile file, boolean isFavorite) {
435 file.setFavorite(isFavorite);
436 mFileActivity.getStorageManager().saveFile(file);
437
438 /// register the OCFile instance in the observer service to monitor local updates
439 Intent observedFileIntent = FileObserverService.makeObservedFileIntent(
440 mFileActivity,
441 file,
442 mFileActivity.getAccount(),
443 isFavorite);
444 mFileActivity.startService(observedFileIntent);
445
446 /// immediate content synchronization
447 if (file.isFavorite()) {
448 syncFile(file);
449 }
450 }
451
452 public void renameFile(OCFile file, String newFilename) {
453 // RenameFile
454 Intent service = new Intent(mFileActivity, OperationsService.class);
455 service.setAction(OperationsService.ACTION_RENAME);
456 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
457 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
458 service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
459 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
460
461 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
462 getString(R.string.wait_a_moment));
463 }
464
465
466 public void removeFile(OCFile file, boolean onlyLocalCopy) {
467 // RemoveFile
468 Intent service = new Intent(mFileActivity, OperationsService.class);
469 service.setAction(OperationsService.ACTION_REMOVE);
470 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
471 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
472 service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
473 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
474
475 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
476 getString(R.string.wait_a_moment));
477 }
478
479
480 public void createFolder(String remotePath, boolean createFullPath) {
481 // Create Folder
482 Intent service = new Intent(mFileActivity, OperationsService.class);
483 service.setAction(OperationsService.ACTION_CREATE_FOLDER);
484 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
485 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, remotePath);
486 service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
487 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
488
489 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
490 getString(R.string.wait_a_moment));
491 }
492
493 /**
494 * Cancel the transference in downloads (files/folders) and file uploads
495 * @param file OCFile
496 */
497 public void cancelTransference(OCFile file) {
498 Account account = mFileActivity.getAccount();
499 if (file.isFolder()) {
500 OperationsService.OperationsServiceBinder opsBinder =
501 mFileActivity.getOperationsServiceBinder();
502 if (opsBinder != null) {
503 opsBinder.cancel(account, file);
504 }
505 }
506
507 // for both files and folders
508 FileDownloaderBinder downloaderBinder = mFileActivity.getFileDownloaderBinder();
509 if (downloaderBinder != null && downloaderBinder.isDownloading(account, file)) {
510 downloaderBinder.cancel(account, file);
511 }
512 FileUploaderBinder uploaderBinder = mFileActivity.getFileUploaderBinder();
513 if (uploaderBinder != null && uploaderBinder.isUploading(account, file)) {
514 uploaderBinder.cancel(account, file);
515 }
516 }
517
518 /**
519 * Start move file operation
520 *
521 * @param newfile File where it is going to be moved
522 * @param currentFile File with the previous info
523 */
524 public void moveFile(OCFile newfile, OCFile currentFile) {
525 // Move files
526 Intent service = new Intent(mFileActivity, OperationsService.class);
527 service.setAction(OperationsService.ACTION_MOVE_FILE);
528 service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, newfile.getRemotePath());
529 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, currentFile.getRemotePath());
530 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
531 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
532
533 // TODO Tobi loading dialog?
534 // mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
535 // getString(R.string.wait_a_moment));
536 }
537
538 /**
539 * Start copy file operation
540 *
541 * @param newfile File where it is going to be moved
542 * @param currentFile File with the previous info
543 */
544 public void copyFile(OCFile newfile, OCFile currentFile) {
545 // Copy files
546 Intent service = new Intent(mFileActivity, OperationsService.class);
547 service.setAction(OperationsService.ACTION_COPY_FILE);
548 service.putExtra(OperationsService.EXTRA_NEW_PARENT_PATH, newfile.getRemotePath());
549 service.putExtra(OperationsService.EXTRA_REMOTE_PATH, currentFile.getRemotePath());
550 service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
551 mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
552
553 mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
554 getString(R.string.wait_a_moment));
555 }
556
557 public long getOpIdWaitingFor() {
558 return mWaitingForOpId;
559 }
560
561
562 public void setOpIdWaitingFor(long waitingForOpId) {
563 mWaitingForOpId = waitingForOpId;
564 }
565
566 /**
567 * @return 'True' if the server doesn't need to check forbidden characters
568 */
569 public boolean isVersionWithForbiddenCharacters() {
570 if (mFileActivity.getAccount() != null) {
571 OwnCloudVersion serverVersion =
572 AccountUtils.getServerVersion(mFileActivity.getAccount());
573 return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters());
574 }
575 return false;
576 }
577 }