1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2,
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 package com
.owncloud
.android
.ui
.activity
;
23 import android
.accounts
.Account
;
24 import android
.app
.AlertDialog
;
25 import android
.app
.ProgressDialog
;
26 import android
.app
.Dialog
;
27 import android
.content
.BroadcastReceiver
;
28 import android
.content
.ComponentName
;
29 import android
.content
.ContentResolver
;
30 import android
.content
.Context
;
31 import android
.content
.DialogInterface
;
32 import android
.content
.Intent
;
33 import android
.content
.IntentFilter
;
34 import android
.content
.ServiceConnection
;
35 import android
.content
.SharedPreferences
;
36 import android
.content
.res
.Resources
.NotFoundException
;
37 import android
.database
.Cursor
;
38 import android
.net
.Uri
;
39 import android
.os
.Bundle
;
40 import android
.os
.Handler
;
41 import android
.os
.IBinder
;
42 import android
.preference
.PreferenceManager
;
43 import android
.provider
.MediaStore
;
44 import android
.support
.v4
.app
.Fragment
;
45 import android
.support
.v4
.app
.FragmentTransaction
;
46 import android
.util
.Log
;
47 import android
.view
.View
;
48 import android
.view
.ViewGroup
;
49 import android
.widget
.ArrayAdapter
;
50 import android
.widget
.TextView
;
51 import android
.widget
.Toast
;
53 import com
.actionbarsherlock
.app
.ActionBar
;
54 import com
.actionbarsherlock
.app
.ActionBar
.OnNavigationListener
;
55 import com
.actionbarsherlock
.view
.Menu
;
56 import com
.actionbarsherlock
.view
.MenuInflater
;
57 import com
.actionbarsherlock
.view
.MenuItem
;
58 import com
.actionbarsherlock
.view
.Window
;
59 import com
.owncloud
.android
.Log_OC
;
60 import com
.owncloud
.android
.R
;
61 import com
.owncloud
.android
.authentication
.AccountAuthenticator
;
62 import com
.owncloud
.android
.datamodel
.DataStorageManager
;
63 import com
.owncloud
.android
.datamodel
.FileDataStorageManager
;
64 import com
.owncloud
.android
.datamodel
.OCFile
;
65 import com
.owncloud
.android
.files
.services
.FileDownloader
;
66 import com
.owncloud
.android
.files
.services
.FileDownloader
.FileDownloaderBinder
;
67 import com
.owncloud
.android
.files
.services
.FileObserverService
;
68 import com
.owncloud
.android
.files
.services
.FileUploader
;
69 import com
.owncloud
.android
.files
.services
.FileUploader
.FileUploaderBinder
;
70 import com
.owncloud
.android
.operations
.CreateFolderOperation
;
71 import com
.owncloud
.android
.operations
.OnRemoteOperationListener
;
72 import com
.owncloud
.android
.operations
.RemoteOperation
;
73 import com
.owncloud
.android
.operations
.RemoteOperationResult
;
74 import com
.owncloud
.android
.operations
.RemoveFileOperation
;
75 import com
.owncloud
.android
.operations
.RenameFileOperation
;
76 import com
.owncloud
.android
.operations
.SynchronizeFileOperation
;
77 import com
.owncloud
.android
.operations
.RemoteOperationResult
.ResultCode
;
78 import com
.owncloud
.android
.syncadapter
.FileSyncService
;
79 import com
.owncloud
.android
.ui
.dialog
.EditNameDialog
;
80 import com
.owncloud
.android
.ui
.dialog
.SslValidatorDialog
;
81 import com
.owncloud
.android
.ui
.dialog
.EditNameDialog
.EditNameDialogListener
;
82 import com
.owncloud
.android
.ui
.dialog
.SslValidatorDialog
.OnSslValidatorListener
;
83 import com
.owncloud
.android
.ui
.fragment
.FileDetailFragment
;
84 import com
.owncloud
.android
.ui
.fragment
.FileFragment
;
85 import com
.owncloud
.android
.ui
.fragment
.OCFileListFragment
;
86 import com
.owncloud
.android
.ui
.preview
.PreviewImageActivity
;
87 import com
.owncloud
.android
.ui
.preview
.PreviewMediaFragment
;
88 import com
.owncloud
.android
.ui
.preview
.PreviewVideoActivity
;
91 * Displays, what files the user has available in his ownCloud.
93 * @author Bartek Przybylski
94 * @author David A. Velasco
97 public class FileDisplayActivity
extends FileActivity
implements
98 OCFileListFragment
.ContainerActivity
, FileDetailFragment
.ContainerActivity
, OnNavigationListener
, OnSslValidatorListener
, OnRemoteOperationListener
, EditNameDialogListener
{
100 private ArrayAdapter
<String
> mDirectories
;
102 /** Access point to the cached database for the current ownCloud {@link Account} */
103 private DataStorageManager mStorageManager
= null
;
105 private SyncBroadcastReceiver mSyncBroadcastReceiver
;
106 private UploadFinishReceiver mUploadFinishReceiver
;
107 private DownloadFinishReceiver mDownloadFinishReceiver
;
108 private FileDownloaderBinder mDownloaderBinder
= null
;
109 private FileUploaderBinder mUploaderBinder
= null
;
110 private ServiceConnection mDownloadConnection
= null
, mUploadConnection
= null
;
111 private RemoteOperationResult mLastSslUntrustedServerResult
= null
;
113 private boolean mDualPane
;
114 private View mLeftFragmentContainer
;
115 private View mRightFragmentContainer
;
117 private static final String KEY_WAITING_TO_PREVIEW
= "WAITING_TO_PREVIEW";
119 public static final int DIALOG_SHORT_WAIT
= 0;
120 private static final int DIALOG_CHOOSE_UPLOAD_SOURCE
= 1;
121 private static final int DIALOG_SSL_VALIDATOR
= 2;
122 private static final int DIALOG_CERT_NOT_SAVED
= 3;
124 public static final String ACTION_DETAILS
= "com.owncloud.android.ui.activity.action.DETAILS";
126 private static final int ACTION_SELECT_CONTENT_FROM_APPS
= 1;
127 private static final int ACTION_SELECT_MULTIPLE_FILES
= 2;
129 private static final String TAG
= FileDisplayActivity
.class.getSimpleName();
131 private static final String TAG_LIST_OF_FILES
= "LIST_OF_FILES";
132 private static final String TAG_SECOND_FRAGMENT
= "SECOND_FRAGMENT";
134 private OCFile mWaitingToPreview
;
135 private Handler mHandler
;
138 protected void onCreate(Bundle savedInstanceState
) {
139 Log_OC
.d(TAG
, "onCreate() start");
140 super.onCreate(savedInstanceState
);
142 requestWindowFeature(Window
.FEATURE_INDETERMINATE_PROGRESS
);
144 mHandler
= new Handler();
146 /// bindings to transference services
147 mUploadConnection
= new ListServiceConnection();
148 mDownloadConnection
= new ListServiceConnection();
149 bindService(new Intent(this, FileUploader
.class), mUploadConnection
, Context
.BIND_AUTO_CREATE
);
150 bindService(new Intent(this, FileDownloader
.class), mDownloadConnection
, Context
.BIND_AUTO_CREATE
);
152 // PIN CODE request ; best location is to decide, let's try this first
153 if (getIntent().getAction() != null
&& getIntent().getAction().equals(Intent
.ACTION_MAIN
) && savedInstanceState
== null
) {
158 Intent observer_intent
= new Intent(this, FileObserverService
.class);
159 observer_intent
.putExtra(FileObserverService
.KEY_FILE_CMD
, FileObserverService
.CMD_INIT_OBSERVED_LIST
);
160 startService(observer_intent
);
162 /// Load of saved instance state
163 if(savedInstanceState
!= null
) {
164 mWaitingToPreview
= (OCFile
) savedInstanceState
.getParcelable(FileDisplayActivity
.KEY_WAITING_TO_PREVIEW
);
167 mWaitingToPreview
= null
;
172 // Inflate and set the layout view
173 setContentView(R
.layout
.files
);
174 mDualPane
= getResources().getBoolean(R
.bool
.large_land_layout
);
175 mLeftFragmentContainer
= findViewById(R
.id
.left_fragment_container
);
176 mRightFragmentContainer
= findViewById(R
.id
.right_fragment_container
);
177 if (savedInstanceState
== null
) {
178 createMinFragments();
182 mDirectories
= new CustomArrayAdapter
<String
>(this, R
.layout
.sherlock_spinner_dropdown_item
);
183 getSupportActionBar().setHomeButtonEnabled(true
); // mandatory since Android ICS, according to the official documentation
184 setSupportProgressBarIndeterminateVisibility(false
); // always AFTER setContentView(...) ; to work around bug in its implementation
186 Log_OC
.d(TAG
, "onCreate() end");
191 protected void onDestroy() {
193 if (mDownloadConnection
!= null
)
194 unbindService(mDownloadConnection
);
195 if (mUploadConnection
!= null
)
196 unbindService(mUploadConnection
);
201 * Called when the ownCloud {@link Account} associated to the Activity was just updated.
204 protected void onAccountSet(boolean stateWasRecovered
) {
205 if (getAccount() != null
) {
206 mStorageManager
= new FileDataStorageManager(getAccount(), getContentResolver());
208 /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
209 OCFile file
= getFile();
211 file
= mStorageManager
.getFileByPath(file
.getRemotePath()); // currentDir = null if not in the current Account
214 // fall back to root folder
215 file
= mStorageManager
.getFileByPath(OCFile
.PATH_SEPARATOR
); // never returns null
219 while(file
!= null
&& file
.getFileName() != OCFile
.PATH_SEPARATOR
) {
220 if (file
.isDirectory()) {
221 mDirectories
.add(file
.getFileName());
223 file
= mStorageManager
.getFileById(file
.getParentId());
225 mDirectories
.add(OCFile
.PATH_SEPARATOR
);
226 if (!stateWasRecovered
) {
227 Log_OC
.e(TAG
, "Initializing Fragments in onAccountChanged..");
228 initFragmentsWithFile();
232 Log_OC
.wtf(TAG
, "onAccountChanged was called with NULL account associated!");
237 private void createMinFragments() {
238 OCFileListFragment listOfFiles
= new OCFileListFragment();
239 FragmentTransaction transaction
= getSupportFragmentManager().beginTransaction();
240 transaction
.add(R
.id
.left_fragment_container
, listOfFiles
, TAG_LIST_OF_FILES
);
241 transaction
.commit();
244 private void initFragmentsWithFile() {
245 if (getAccount() != null
&& getFile() != null
) {
247 OCFile file
= getFile();
248 Fragment secondFragment
= chooseInitialSecondFragment(file
);
249 if (secondFragment
!= null
) {
250 setSecondFragment(secondFragment
);
254 Log
.wtf(TAG
, "initFragments() called with invalid NULLs!");
255 if (getAccount() == null
) {
256 Log
.wtf(TAG
, "\t account is NULL");
258 if (getFile() == null
) {
259 Log
.wtf(TAG
, "\t file is NULL");
264 private Fragment
chooseInitialSecondFragment(OCFile file
) {
265 Fragment secondFragment
= null
;
266 if (file
!= null
&& !file
.isDirectory()) {
267 if (file
.isDown() && PreviewMediaFragment
.canBePreviewed(file
)) {
268 int startPlaybackPosition
= getIntent().getIntExtra(PreviewVideoActivity
.EXTRA_START_POSITION
, 0);
269 boolean autoplay
= getIntent().getBooleanExtra(PreviewVideoActivity
.EXTRA_AUTOPLAY
, true
);
270 secondFragment
= new PreviewMediaFragment(file
, getAccount(), startPlaybackPosition
, autoplay
);
273 secondFragment
= new FileDetailFragment(file
, getAccount());
276 return secondFragment
;
281 * Replaces the second fragment managed by the activity with the received as
284 * Assumes never will be more than two fragments managed at the same time.
286 * @param fragment New second Fragment to set.
288 private void setSecondFragment(Fragment fragment
) {
289 FragmentTransaction transaction
= getSupportFragmentManager().beginTransaction();
290 transaction
.replace(R
.id
.right_fragment_container
, fragment
, TAG_SECOND_FRAGMENT
);
291 transaction
.commit();
295 private void updateFragmentsVisibility(boolean existsSecondFragment
) {
297 if (mLeftFragmentContainer
.getVisibility() != View
.VISIBLE
) {
298 mLeftFragmentContainer
.setVisibility(View
.VISIBLE
);
300 if (mRightFragmentContainer
.getVisibility() != View
.VISIBLE
) {
301 mRightFragmentContainer
.setVisibility(View
.VISIBLE
);
304 } else if (existsSecondFragment
) {
305 if (mLeftFragmentContainer
.getVisibility() != View
.GONE
) {
306 mLeftFragmentContainer
.setVisibility(View
.GONE
);
308 if (mRightFragmentContainer
.getVisibility() != View
.VISIBLE
) {
309 mRightFragmentContainer
.setVisibility(View
.VISIBLE
);
313 if (mLeftFragmentContainer
.getVisibility() != View
.VISIBLE
) {
314 mLeftFragmentContainer
.setVisibility(View
.VISIBLE
);
316 if (mRightFragmentContainer
.getVisibility() != View
.GONE
) {
317 mRightFragmentContainer
.setVisibility(View
.GONE
);
323 private OCFileListFragment
getListOfFilesFragment() {
324 Fragment listOfFiles
= getSupportFragmentManager().findFragmentByTag(FileDisplayActivity
.TAG_LIST_OF_FILES
);
325 if (listOfFiles
!= null
) {
326 return (OCFileListFragment
)listOfFiles
;
328 Log_OC
.wtf(TAG
, "Access to unexisting list of files fragment!!");
332 protected FileFragment
getSecondFragment() {
333 Fragment second
= getSupportFragmentManager().findFragmentByTag(FileDisplayActivity
.TAG_SECOND_FRAGMENT
);
334 if (second
!= null
) {
335 return (FileFragment
)second
;
340 public void cleanSecondFragment() {
341 Fragment second
= getSecondFragment();
342 if (second
!= null
) {
343 FragmentTransaction tr
= getSupportFragmentManager().beginTransaction();
346 updateFragmentsVisibility(false
);
350 protected void refeshListOfFilesFragment() {
351 OCFileListFragment fileListFragment
= getListOfFilesFragment();
352 if (fileListFragment
!= null
) {
353 fileListFragment
.listDirectory();
357 protected void refreshSecondFragment(String downloadEvent
, String downloadedRemotePath
, boolean success
) {
358 FileFragment secondFragment
= getSecondFragment();
359 boolean waitedPreview
= (mWaitingToPreview
!= null
&& mWaitingToPreview
.getRemotePath().equals(downloadedRemotePath
));
360 if (secondFragment
!= null
&& secondFragment
instanceof FileDetailFragment
) {
361 FileDetailFragment detailsFragment
= (FileDetailFragment
) secondFragment
;
362 OCFile fileInFragment
= detailsFragment
.getFile();
363 if (fileInFragment
!= null
&& !downloadedRemotePath
.equals(fileInFragment
.getRemotePath())) {
364 // the user browsed to other file ; forget the automatic preview
365 mWaitingToPreview
= null
;
367 } else if (downloadEvent
.equals(FileDownloader
.DOWNLOAD_ADDED_MESSAGE
)) {
368 // grant that the right panel updates the progress bar
369 detailsFragment
.listenForTransferProgress();
370 detailsFragment
.updateFileDetails(true
, false
);
372 } else if (downloadEvent
.equals(FileDownloader
.DOWNLOAD_FINISH_MESSAGE
)) {
373 // update the right panel
374 boolean detailsFragmentChanged
= false
;
377 mWaitingToPreview
= mStorageManager
.getFileById(mWaitingToPreview
.getFileId()); // update the file from database, for the local storage path
378 if (PreviewMediaFragment
.canBePreviewed(mWaitingToPreview
)) {
379 startMediaPreview(mWaitingToPreview
, 0, true
);
380 detailsFragmentChanged
= true
;
382 openFile(mWaitingToPreview
);
385 mWaitingToPreview
= null
;
387 if (!detailsFragmentChanged
) {
388 detailsFragment
.updateFileDetails(false
, (success
));
396 public boolean onCreateOptionsMenu(Menu menu
) {
397 MenuInflater inflater
= getSherlock().getMenuInflater();
398 inflater
.inflate(R
.menu
.main_menu
, menu
);
403 public boolean onOptionsItemSelected(MenuItem item
) {
404 boolean retval
= true
;
405 switch (item
.getItemId()) {
406 case R
.id
.action_create_dir
: {
407 EditNameDialog dialog
= EditNameDialog
.newInstance(getString(R
.string
.uploader_info_dirname
), "", -1, -1, this);
408 dialog
.show(getSupportFragmentManager(), "createdirdialog");
411 case R
.id
.action_sync_account
: {
412 startSynchronization();
415 case R
.id
.action_upload
: {
416 showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE
);
419 case R
.id
.action_settings
: {
420 Intent settingsIntent
= new Intent(this, Preferences
.class);
421 startActivity(settingsIntent
);
424 case android
.R
.id
.home
: {
425 FileFragment second
= getSecondFragment();
426 OCFile currentDir
= getCurrentDir();
427 if((currentDir
!= null
&& currentDir
.getParentId() != 0) ||
428 (second
!= null
&& second
.getFile() != null
)) {
434 retval
= super.onOptionsItemSelected(item
);
439 private void startSynchronization() {
440 ContentResolver
.cancelSync(null
, AccountAuthenticator
.AUTHORITY
); // cancel the current synchronizations of any ownCloud account
441 Bundle bundle
= new Bundle();
442 bundle
.putBoolean(ContentResolver
.SYNC_EXTRAS_MANUAL
, true
);
443 ContentResolver
.requestSync(
445 AccountAuthenticator
.AUTHORITY
, bundle
);
450 public boolean onNavigationItemSelected(int itemPosition
, long itemId
) {
451 int i
= itemPosition
;
455 // the next operation triggers a new call to this method, but it's necessary to
456 // ensure that the name exposed in the action bar is the current directory when the
457 // user selected it in the navigation list
458 if (itemPosition
!= 0)
459 getSupportActionBar().setSelectedNavigationItem(0);
464 * Called, when the user selected something for uploading
466 protected void onActivityResult(int requestCode
, int resultCode
, Intent data
) {
467 super.onActivityResult(requestCode
, resultCode
, data
);
469 if (requestCode
== ACTION_SELECT_CONTENT_FROM_APPS
&& (resultCode
== RESULT_OK
|| resultCode
== UploadFilesActivity
.RESULT_OK_AND_MOVE
)) {
470 requestSimpleUpload(data
, resultCode
);
472 } else if (requestCode
== ACTION_SELECT_MULTIPLE_FILES
&& (resultCode
== RESULT_OK
|| resultCode
== UploadFilesActivity
.RESULT_OK_AND_MOVE
)) {
473 requestMultipleUpload(data
, resultCode
);
478 private void requestMultipleUpload(Intent data
, int resultCode
) {
479 String
[] filePaths
= data
.getStringArrayExtra(UploadFilesActivity
.EXTRA_CHOSEN_FILES
);
480 if (filePaths
!= null
) {
481 String
[] remotePaths
= new String
[filePaths
.length
];
482 String remotePathBase
= "";
483 for (int j
= mDirectories
.getCount() - 2; j
>= 0; --j
) {
484 remotePathBase
+= OCFile
.PATH_SEPARATOR
+ mDirectories
.getItem(j
);
486 if (!remotePathBase
.endsWith(OCFile
.PATH_SEPARATOR
))
487 remotePathBase
+= OCFile
.PATH_SEPARATOR
;
488 for (int j
= 0; j
< remotePaths
.length
; j
++) {
489 remotePaths
[j
] = remotePathBase
+ (new File(filePaths
[j
])).getName();
492 Intent i
= new Intent(this, FileUploader
.class);
493 i
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
494 i
.putExtra(FileUploader
.KEY_LOCAL_FILE
, filePaths
);
495 i
.putExtra(FileUploader
.KEY_REMOTE_FILE
, remotePaths
);
496 i
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_MULTIPLE_FILES
);
497 if (resultCode
== UploadFilesActivity
.RESULT_OK_AND_MOVE
)
498 i
.putExtra(FileUploader
.KEY_LOCAL_BEHAVIOUR
, FileUploader
.LOCAL_BEHAVIOUR_MOVE
);
502 Log_OC
.d(TAG
, "User clicked on 'Update' with no selection");
503 Toast t
= Toast
.makeText(this, getString(R
.string
.filedisplay_no_file_selected
), Toast
.LENGTH_LONG
);
510 private void requestSimpleUpload(Intent data
, int resultCode
) {
511 String filepath
= null
;
513 Uri selectedImageUri
= data
.getData();
515 String filemanagerstring
= selectedImageUri
.getPath();
516 String selectedImagePath
= getPath(selectedImageUri
);
518 if (selectedImagePath
!= null
)
519 filepath
= selectedImagePath
;
521 filepath
= filemanagerstring
;
523 } catch (Exception e
) {
524 Log_OC
.e(TAG
, "Unexpected exception when trying to read the result of Intent.ACTION_GET_CONTENT", e
);
528 if (filepath
== null
) {
529 Log_OC
.e(TAG
, "Couldnt resolve path to file");
530 Toast t
= Toast
.makeText(this, getString(R
.string
.filedisplay_unexpected_bad_get_content
), Toast
.LENGTH_LONG
);
536 Intent i
= new Intent(this, FileUploader
.class);
537 i
.putExtra(FileUploader
.KEY_ACCOUNT
,
539 String remotepath
= new String();
540 for (int j
= mDirectories
.getCount() - 2; j
>= 0; --j
) {
541 remotepath
+= OCFile
.PATH_SEPARATOR
+ mDirectories
.getItem(j
);
543 if (!remotepath
.endsWith(OCFile
.PATH_SEPARATOR
))
544 remotepath
+= OCFile
.PATH_SEPARATOR
;
545 remotepath
+= new File(filepath
).getName();
547 i
.putExtra(FileUploader
.KEY_LOCAL_FILE
, filepath
);
548 i
.putExtra(FileUploader
.KEY_REMOTE_FILE
, remotepath
);
549 i
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_SINGLE_FILE
);
550 if (resultCode
== UploadFilesActivity
.RESULT_OK_AND_MOVE
)
551 i
.putExtra(FileUploader
.KEY_LOCAL_BEHAVIOUR
, FileUploader
.LOCAL_BEHAVIOUR_MOVE
);
556 public void onBackPressed() {
557 OCFileListFragment listOfFiles
= getListOfFilesFragment();
558 if (mDualPane
|| getSecondFragment() == null
) {
559 if (listOfFiles
!= null
) { // should never be null, indeed
560 if (mDirectories
.getCount() <= 1) {
565 listOfFiles
.onBrowseUp();
568 if (listOfFiles
!= null
) { // should never be null, indeed
569 setFile(listOfFiles
.getCurrentFile());
571 cleanSecondFragment();
572 updateNavigationElementsInActionBar(null
);
576 protected void onSaveInstanceState(Bundle outState
) {
577 // responsibility of restore is preferred in onCreate() before than in onRestoreInstanceState when there are Fragments involved
578 Log_OC
.e(TAG
, "onSaveInstanceState() start");
579 super.onSaveInstanceState(outState
);
580 outState
.putParcelable(FileDisplayActivity
.KEY_WAITING_TO_PREVIEW
, mWaitingToPreview
);
581 Log_OC
.d(TAG
, "onSaveInstanceState() end");
585 protected void onStart() {
587 FileFragment second
= getSecondFragment();
588 updateFragmentsVisibility(second
!= null
);
589 updateNavigationElementsInActionBar((second
== null
) ? null
: second
.getFile());
593 protected void onResume() {
595 Log_OC
.e(TAG
, "onResume() start");
597 // Listen for sync messages
598 IntentFilter syncIntentFilter
= new IntentFilter(FileSyncService
.SYNC_MESSAGE
);
599 mSyncBroadcastReceiver
= new SyncBroadcastReceiver();
600 registerReceiver(mSyncBroadcastReceiver
, syncIntentFilter
);
602 // Listen for upload messages
603 IntentFilter uploadIntentFilter
= new IntentFilter(FileUploader
.UPLOAD_FINISH_MESSAGE
);
604 mUploadFinishReceiver
= new UploadFinishReceiver();
605 registerReceiver(mUploadFinishReceiver
, uploadIntentFilter
);
607 // Listen for download messages
608 IntentFilter downloadIntentFilter
= new IntentFilter(FileDownloader
.DOWNLOAD_ADDED_MESSAGE
);
609 downloadIntentFilter
.addAction(FileDownloader
.DOWNLOAD_FINISH_MESSAGE
);
610 mDownloadFinishReceiver
= new DownloadFinishReceiver();
611 registerReceiver(mDownloadFinishReceiver
, downloadIntentFilter
);
613 // List current directory
614 OCFileListFragment listOfFiles
= getListOfFilesFragment();
615 if (listOfFiles
!= null
) {
616 listOfFiles
.listDirectory(getCurrentDir()); // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check)
619 Log_OC
.d(TAG
, "onResume() end");
624 protected void onPause() {
626 Log_OC
.e(TAG
, "onPause() start");
627 if (mSyncBroadcastReceiver
!= null
) {
628 unregisterReceiver(mSyncBroadcastReceiver
);
629 mSyncBroadcastReceiver
= null
;
631 if (mUploadFinishReceiver
!= null
) {
632 unregisterReceiver(mUploadFinishReceiver
);
633 mUploadFinishReceiver
= null
;
635 if (mDownloadFinishReceiver
!= null
) {
636 unregisterReceiver(mDownloadFinishReceiver
);
637 mDownloadFinishReceiver
= null
;
640 Log_OC
.d(TAG
, "onPause() end");
645 protected void onPrepareDialog(int id
, Dialog dialog
, Bundle args
) {
646 if (id
== DIALOG_SSL_VALIDATOR
&& mLastSslUntrustedServerResult
!= null
) {
647 ((SslValidatorDialog
)dialog
).updateResult(mLastSslUntrustedServerResult
);
653 protected Dialog
onCreateDialog(int id
) {
654 Dialog dialog
= null
;
655 AlertDialog
.Builder builder
;
657 case DIALOG_SHORT_WAIT
: {
658 ProgressDialog working_dialog
= new ProgressDialog(this);
659 working_dialog
.setMessage(getResources().getString(
660 R
.string
.wait_a_moment
));
661 working_dialog
.setIndeterminate(true
);
662 working_dialog
.setCancelable(false
);
663 dialog
= working_dialog
;
666 case DIALOG_CHOOSE_UPLOAD_SOURCE
: {
668 String
[] items
= null
;
670 String
[] allTheItems
= { getString(R
.string
.actionbar_upload_files
),
671 getString(R
.string
.actionbar_upload_from_apps
),
672 getString(R
.string
.actionbar_failed_instant_upload
) };
674 String
[] commonItems
= { getString(R
.string
.actionbar_upload_files
),
675 getString(R
.string
.actionbar_upload_from_apps
) };
677 if (InstantUploadActivity
.IS_ENABLED
)
682 builder
= new AlertDialog
.Builder(this);
683 builder
.setTitle(R
.string
.actionbar_upload
);
684 builder
.setItems(items
, new DialogInterface
.OnClickListener() {
685 public void onClick(DialogInterface dialog
, int item
) {
688 Intent action
= new Intent(FileDisplayActivity
.this, UploadFilesActivity
.class);
689 action
.putExtra(UploadFilesActivity
.EXTRA_ACCOUNT
, FileDisplayActivity
.this.getAccount());
690 startActivityForResult(action
, ACTION_SELECT_MULTIPLE_FILES
);
692 // TODO create and handle new fragment
693 // LocalFileListFragment
695 } else if (item
== 1) {
696 Intent action
= new Intent(Intent
.ACTION_GET_CONTENT
);
697 action
= action
.setType("*/*").addCategory(Intent
.CATEGORY_OPENABLE
);
698 startActivityForResult(Intent
.createChooser(action
, getString(R
.string
.upload_chooser_title
)),
699 ACTION_SELECT_CONTENT_FROM_APPS
);
700 } else if (item
== 2 && InstantUploadActivity
.IS_ENABLED
) {
701 Intent action
= new Intent(FileDisplayActivity
.this, InstantUploadActivity
.class);
702 action
.putExtra(FileUploader
.KEY_ACCOUNT
, FileDisplayActivity
.this.getAccount());
703 startActivity(action
);
707 dialog
= builder
.create();
710 case DIALOG_SSL_VALIDATOR
: {
711 dialog
= SslValidatorDialog
.newInstance(this, mLastSslUntrustedServerResult
, this);
714 case DIALOG_CERT_NOT_SAVED
: {
715 builder
= new AlertDialog
.Builder(this);
716 builder
.setMessage(getResources().getString(R
.string
.ssl_validator_not_saved
));
717 builder
.setCancelable(false
);
718 builder
.setPositiveButton(R
.string
.common_ok
, new DialogInterface
.OnClickListener() {
720 public void onClick(DialogInterface dialog
, int which
) {
724 dialog
= builder
.create();
736 * Translates a content URI of an image to a physical path
738 * @param uri The URI to resolve
739 * @return The path to the image or null if it could not be found
741 public String
getPath(Uri uri
) {
742 String
[] projection
= { MediaStore
.Images
.Media
.DATA
};
743 Cursor cursor
= managedQuery(uri
, projection
, null
, null
, null
);
744 if (cursor
!= null
) {
745 int column_index
= cursor
746 .getColumnIndexOrThrow(MediaStore
.Images
.Media
.DATA
);
747 cursor
.moveToFirst();
748 return cursor
.getString(column_index
);
754 * Pushes a directory to the drop down list
755 * @param directory to push
756 * @throws IllegalArgumentException If the {@link OCFile#isDirectory()} returns false.
758 public void pushDirname(OCFile directory
) {
759 if(!directory
.isDirectory()){
760 throw new IllegalArgumentException("Only directories may be pushed!");
762 mDirectories
.insert(directory
.getFileName(), 0);
767 * Pops a directory name from the drop down list
768 * @return True, unless the stack is empty
770 public boolean popDirname() {
771 mDirectories
.remove(mDirectories
.getItem(0));
772 return !mDirectories
.isEmpty();
775 // Custom array adapter to override text colors
776 private class CustomArrayAdapter
<T
> extends ArrayAdapter
<T
> {
778 public CustomArrayAdapter(FileDisplayActivity ctx
, int view
) {
782 public View
getView(int position
, View convertView
, ViewGroup parent
) {
783 View v
= super.getView(position
, convertView
, parent
);
785 ((TextView
) v
).setTextColor(getResources().getColorStateList(
786 android
.R
.color
.white
));
790 public View
getDropDownView(int position
, View convertView
,
792 View v
= super.getDropDownView(position
, convertView
, parent
);
794 ((TextView
) v
).setTextColor(getResources().getColorStateList(
795 android
.R
.color
.white
));
802 private class SyncBroadcastReceiver
extends BroadcastReceiver
{
805 * {@link BroadcastReceiver} to enable syncing feedback in UI
808 public void onReceive(Context context
, Intent intent
) {
809 boolean inProgress
= intent
.getBooleanExtra(FileSyncService
.IN_PROGRESS
, false
);
810 String accountName
= intent
.getStringExtra(FileSyncService
.ACCOUNT_NAME
);
812 Log_OC
.d(TAG
, "sync of account " + accountName
+ " is in_progress: " + inProgress
);
814 if (getAccount() != null
&& accountName
.equals(getAccount().name
)) {
816 String synchFolderRemotePath
= intent
.getStringExtra(FileSyncService
.SYNC_FOLDER_REMOTE_PATH
);
818 boolean fillBlankRoot
= false
;
819 OCFile currentDir
= getCurrentDir();
820 if (currentDir
== null
) {
821 currentDir
= mStorageManager
.getFileByPath(OCFile
.PATH_SEPARATOR
);
822 fillBlankRoot
= (currentDir
!= null
);
825 if ((synchFolderRemotePath
!= null
&& currentDir
!= null
&& (currentDir
.getRemotePath().equals(synchFolderRemotePath
)))
828 currentDir
= getStorageManager().getFileByPath(synchFolderRemotePath
);
829 OCFileListFragment fileListFragment
= getListOfFilesFragment();
830 if (fileListFragment
!= null
) {
831 fileListFragment
.listDirectory(currentDir
);
836 setSupportProgressBarIndeterminateVisibility(inProgress
);
837 removeStickyBroadcast(intent
);
841 RemoteOperationResult synchResult
= (RemoteOperationResult
)intent
.getSerializableExtra(FileSyncService
.SYNC_RESULT
);
842 if (synchResult
!= null
) {
843 if (synchResult
.getCode().equals(RemoteOperationResult
.ResultCode
.SSL_RECOVERABLE_PEER_UNVERIFIED
)) {
844 mLastSslUntrustedServerResult
= synchResult
;
845 showDialog(DIALOG_SSL_VALIDATOR
);
852 private class UploadFinishReceiver
extends BroadcastReceiver
{
854 * Once the file upload has finished -> update view
855 * @author David A. Velasco
856 * {@link BroadcastReceiver} to enable upload feedback in UI
859 public void onReceive(Context context
, Intent intent
) {
860 String uploadedRemotePath
= intent
.getStringExtra(FileDownloader
.EXTRA_REMOTE_PATH
);
861 String accountName
= intent
.getStringExtra(FileUploader
.ACCOUNT_NAME
);
862 boolean sameAccount
= getAccount() != null
&& accountName
.equals(getAccount().name
);
863 OCFile currentDir
= getCurrentDir();
864 boolean isDescendant
= (currentDir
!= null
) && (uploadedRemotePath
!= null
) && (uploadedRemotePath
.startsWith(currentDir
.getRemotePath()));
865 if (sameAccount
&& isDescendant
) {
866 refeshListOfFilesFragment();
874 * Class waiting for broadcast events from the {@link FielDownloader} service.
876 * Updates the UI when a download is started or finished, provided that it is relevant for the
879 private class DownloadFinishReceiver
extends BroadcastReceiver
{
881 public void onReceive(Context context
, Intent intent
) {
882 boolean sameAccount
= isSameAccount(context
, intent
);
883 String downloadedRemotePath
= intent
.getStringExtra(FileDownloader
.EXTRA_REMOTE_PATH
);
884 boolean isDescendant
= isDescendant(downloadedRemotePath
);
886 if (sameAccount
&& isDescendant
) {
887 refeshListOfFilesFragment();
888 refreshSecondFragment(intent
.getAction(), downloadedRemotePath
, intent
.getBooleanExtra(FileDownloader
.EXTRA_DOWNLOAD_RESULT
, false
));
891 removeStickyBroadcast(intent
);
894 private boolean isDescendant(String downloadedRemotePath
) {
895 OCFile currentDir
= getCurrentDir();
896 return (currentDir
!= null
&& downloadedRemotePath
!= null
&& downloadedRemotePath
.startsWith(currentDir
.getRemotePath()));
899 private boolean isSameAccount(Context context
, Intent intent
) {
900 String accountName
= intent
.getStringExtra(FileDownloader
.ACCOUNT_NAME
);
901 return (accountName
!= null
&& getAccount() != null
&& accountName
.equals(getAccount().name
));
910 public DataStorageManager
getStorageManager() {
911 return mStorageManager
;
918 * Updates action bar and second fragment, if in dual pane mode.
921 public void onBrowsedDownTo(OCFile directory
) {
922 pushDirname(directory
);
923 cleanSecondFragment();
924 updateNavigationElementsInActionBar(null
);
928 * Opens the image gallery showing the image {@link OCFile} received as parameter.
930 * @param file Image {@link OCFile} to show.
933 public void startImagePreview(OCFile file
) {
934 Intent showDetailsIntent
= new Intent(this, PreviewImageActivity
.class);
935 showDetailsIntent
.putExtra(EXTRA_FILE
, file
);
936 showDetailsIntent
.putExtra(EXTRA_ACCOUNT
, getAccount());
937 startActivity(showDetailsIntent
);
941 * Stars the preview of an already down media {@link OCFile}.
943 * @param file Media {@link OCFile} to preview.
944 * @param startPlaybackPosition Media position where the playback will be started, in milliseconds.
945 * @param autoplay When 'true', the playback will start without user interactions.
948 public void startMediaPreview(OCFile file
, int startPlaybackPosition
, boolean autoplay
) {
949 Fragment mediaFragment
= new PreviewMediaFragment(file
, getAccount(), startPlaybackPosition
, autoplay
);
950 setSecondFragment(mediaFragment
);
951 updateFragmentsVisibility(true
);
952 updateNavigationElementsInActionBar(file
);
957 * Requests the download of the received {@link OCFile} , updates the UI
958 * to monitor the download progress and prepares the activity to preview
959 * or open the file when the download finishes.
961 * @param file {@link OCFile} to download and preview.
964 public void startDownloadForPreview(OCFile file
) {
965 Fragment detailFragment
= new FileDetailFragment(file
, getAccount());
966 setSecondFragment(detailFragment
);
967 mWaitingToPreview
= file
;
968 requestForDownload();
969 updateFragmentsVisibility(true
);
970 updateNavigationElementsInActionBar(file
);
976 * Shows the information of the {@link OCFile} received as a
977 * parameter in the second fragment.
979 * @param file {@link OCFile} whose details will be shown
982 public void showDetails(OCFile file
) {
983 Fragment detailFragment
= new FileDetailFragment(file
, getAccount());
984 setSecondFragment(detailFragment
);
985 updateFragmentsVisibility(true
);
986 updateNavigationElementsInActionBar(file
);
994 private void updateNavigationElementsInActionBar(OCFile currentFile
) {
995 ActionBar actionBar
= getSupportActionBar();
996 if (currentFile
== null
|| mDualPane
) {
997 // only list of files - set for browsing through folders
998 OCFile currentDir
= getCurrentDir();
999 actionBar
.setDisplayHomeAsUpEnabled(currentDir
!= null
&& currentDir
.getParentId() != 0);
1000 actionBar
.setDisplayShowTitleEnabled(false
);
1001 actionBar
.setNavigationMode(ActionBar
.NAVIGATION_MODE_LIST
);
1002 actionBar
.setListNavigationCallbacks(mDirectories
, this); // assuming mDirectories is updated
1005 actionBar
.setDisplayHomeAsUpEnabled(true
);
1006 actionBar
.setDisplayShowTitleEnabled(true
);
1007 actionBar
.setTitle(currentFile
.getFileName());
1008 actionBar
.setNavigationMode(ActionBar
.NAVIGATION_MODE_STANDARD
);
1017 public OCFile
getInitialDirectory() {
1018 return getCurrentDir();
1026 public void onFileStateChanged() {
1027 refeshListOfFilesFragment();
1035 public FileDownloaderBinder
getFileDownloaderBinder() {
1036 return mDownloaderBinder
;
1044 public FileUploaderBinder
getFileUploaderBinder() {
1045 return mUploaderBinder
;
1049 /** Defines callbacks for service binding, passed to bindService() */
1050 private class ListServiceConnection
implements ServiceConnection
{
1053 public void onServiceConnected(ComponentName component
, IBinder service
) {
1054 if (component
.equals(new ComponentName(FileDisplayActivity
.this, FileDownloader
.class))) {
1055 Log_OC
.d(TAG
, "Download service connected");
1056 mDownloaderBinder
= (FileDownloaderBinder
) service
;
1057 if (mWaitingToPreview
!= null
) {
1058 requestForDownload();
1061 } else if (component
.equals(new ComponentName(FileDisplayActivity
.this, FileUploader
.class))) {
1062 Log_OC
.d(TAG
, "Upload service connected");
1063 mUploaderBinder
= (FileUploaderBinder
) service
;
1067 // a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS
1068 OCFileListFragment listOfFiles
= getListOfFilesFragment();
1069 if (listOfFiles
!= null
) {
1070 listOfFiles
.listDirectory();
1072 FileFragment secondFragment
= getSecondFragment();
1073 if (secondFragment
!= null
&& secondFragment
instanceof FileDetailFragment
) {
1074 FileDetailFragment detailFragment
= (FileDetailFragment
)secondFragment
;
1075 detailFragment
.listenForTransferProgress();
1076 detailFragment
.updateFileDetails(false
, false
);
1081 public void onServiceDisconnected(ComponentName component
) {
1082 if (component
.equals(new ComponentName(FileDisplayActivity
.this, FileDownloader
.class))) {
1083 Log_OC
.d(TAG
, "Download service disconnected");
1084 mDownloaderBinder
= null
;
1085 } else if (component
.equals(new ComponentName(FileDisplayActivity
.this, FileUploader
.class))) {
1086 Log_OC
.d(TAG
, "Upload service disconnected");
1087 mUploaderBinder
= null
;
1095 * Launch an intent to request the PIN code to the user before letting him use the app
1097 private void requestPinCode() {
1098 boolean pinStart
= false
;
1099 SharedPreferences appPrefs
= PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
1100 pinStart
= appPrefs
.getBoolean("set_pincode", false
);
1102 Intent i
= new Intent(getApplicationContext(), PinCodeActivity
.class);
1103 i
.putExtra(PinCodeActivity
.EXTRA_ACTIVITY
, "FileDisplayActivity");
1110 public void onSavedCertificate() {
1111 startSynchronization();
1116 public void onFailedSavingCertificate() {
1117 showDialog(DIALOG_CERT_NOT_SAVED
);
1122 * Updates the view associated to the activity after the finish of some operation over files
1123 * in the current account.
1125 * @param operation Removal operation performed.
1126 * @param result Result of the removal.
1129 public void onRemoteOperationFinish(RemoteOperation operation
, RemoteOperationResult result
) {
1130 if (operation
instanceof RemoveFileOperation
) {
1131 onRemoveFileOperationFinish((RemoveFileOperation
)operation
, result
);
1133 } else if (operation
instanceof RenameFileOperation
) {
1134 onRenameFileOperationFinish((RenameFileOperation
)operation
, result
);
1136 } else if (operation
instanceof SynchronizeFileOperation
) {
1137 onSynchronizeFileOperationFinish((SynchronizeFileOperation
)operation
, result
);
1139 } else if (operation
instanceof CreateFolderOperation
) {
1140 onCreateFolderOperationFinish((CreateFolderOperation
)operation
, result
);
1146 * Updates the view associated to the activity after the finish of an operation trying to remove a
1149 * @param operation Removal operation performed.
1150 * @param result Result of the removal.
1152 private void onRemoveFileOperationFinish(RemoveFileOperation operation
, RemoteOperationResult result
) {
1153 dismissDialog(DIALOG_SHORT_WAIT
);
1154 if (result
.isSuccess()) {
1155 Toast msg
= Toast
.makeText(this, R
.string
.remove_success_msg
, Toast
.LENGTH_LONG
);
1157 OCFile removedFile
= operation
.getFile();
1158 getSecondFragment();
1159 FileFragment second
= getSecondFragment();
1160 if (second
!= null
&& removedFile
.equals(second
.getFile())) {
1161 cleanSecondFragment();
1163 if (mStorageManager
.getFileById(removedFile
.getParentId()).equals(getCurrentDir())) {
1164 refeshListOfFilesFragment();
1168 Toast msg
= Toast
.makeText(this, R
.string
.remove_fail_msg
, Toast
.LENGTH_LONG
);
1170 if (result
.isSslRecoverableException()) {
1171 mLastSslUntrustedServerResult
= result
;
1172 showDialog(DIALOG_SSL_VALIDATOR
);
1178 * Updates the view associated to the activity after the finish of an operation trying create a new folder
1180 * @param operation Creation operation performed.
1181 * @param result Result of the creation.
1183 private void onCreateFolderOperationFinish(CreateFolderOperation operation
, RemoteOperationResult result
) {
1184 if (result
.isSuccess()) {
1185 dismissDialog(DIALOG_SHORT_WAIT
);
1186 refeshListOfFilesFragment();
1189 dismissDialog(DIALOG_SHORT_WAIT
);
1191 Toast msg
= Toast
.makeText(FileDisplayActivity
.this, R
.string
.create_dir_fail_msg
, Toast
.LENGTH_LONG
);
1194 } catch (NotFoundException e
) {
1195 Log_OC
.e(TAG
, "Error while trying to show fail message " , e
);
1202 * Updates the view associated to the activity after the finish of an operation trying to rename a
1205 * @param operation Renaming operation performed.
1206 * @param result Result of the renaming.
1208 private void onRenameFileOperationFinish(RenameFileOperation operation
, RemoteOperationResult result
) {
1209 dismissDialog(DIALOG_SHORT_WAIT
);
1210 OCFile renamedFile
= operation
.getFile();
1211 if (result
.isSuccess()) {
1213 FileFragment details
= getSecondFragment();
1214 if (details
!= null
&& details
instanceof FileDetailFragment
&& renamedFile
.equals(details
.getFile()) ) {
1215 ((FileDetailFragment
) details
).updateFileDetails(renamedFile
, getAccount());
1218 if (mStorageManager
.getFileById(renamedFile
.getParentId()).equals(getCurrentDir())) {
1219 refeshListOfFilesFragment();
1223 if (result
.getCode().equals(ResultCode
.INVALID_LOCAL_FILE_NAME
)) {
1224 Toast msg
= Toast
.makeText(this, R
.string
.rename_local_fail_msg
, Toast
.LENGTH_LONG
);
1226 // TODO throw again the new rename dialog
1228 Toast msg
= Toast
.makeText(this, R
.string
.rename_server_fail_msg
, Toast
.LENGTH_LONG
);
1230 if (result
.isSslRecoverableException()) {
1231 mLastSslUntrustedServerResult
= result
;
1232 showDialog(DIALOG_SSL_VALIDATOR
);
1239 private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation
, RemoteOperationResult result
) {
1240 dismissDialog(DIALOG_SHORT_WAIT
);
1241 OCFile syncedFile
= operation
.getLocalFile();
1242 if (!result
.isSuccess()) {
1243 if (result
.getCode() == ResultCode
.SYNC_CONFLICT
) {
1244 Intent i
= new Intent(this, ConflictsResolveActivity
.class);
1245 i
.putExtra(ConflictsResolveActivity
.EXTRA_FILE
, syncedFile
);
1246 i
.putExtra(ConflictsResolveActivity
.EXTRA_ACCOUNT
, getAccount());
1250 Toast msg
= Toast
.makeText(this, R
.string
.sync_file_fail_msg
, Toast
.LENGTH_LONG
);
1255 if (operation
.transferWasRequested()) {
1256 refeshListOfFilesFragment();
1257 onTransferStateChanged(syncedFile
, true
, true
);
1260 Toast msg
= Toast
.makeText(this, R
.string
.sync_file_nothing_to_do_msg
, Toast
.LENGTH_LONG
);
1271 public void onTransferStateChanged(OCFile file
, boolean downloading
, boolean uploading
) {
1273 FileFragment details
= getSecondFragment();
1274 if (details
!= null
&& details
instanceof FileDetailFragment
&& file
.equals(details
.getFile()) ) {
1275 if (downloading
|| uploading
) {
1276 ((FileDetailFragment
)details
).updateFileDetails(file
, getAccount());
1278 ((FileDetailFragment
)details
).updateFileDetails(false
, true
);
1285 public void onDismiss(EditNameDialog dialog
) {
1286 if (dialog
.getResult()) {
1287 String newDirectoryName
= dialog
.getNewFilename().trim();
1288 Log_OC
.d(TAG
, "'create directory' dialog dismissed with new name " + newDirectoryName
);
1289 if (newDirectoryName
.length() > 0) {
1290 String path
= getCurrentDir().getRemotePath();
1293 path
+= newDirectoryName
+ OCFile
.PATH_SEPARATOR
;
1294 RemoteOperation operation
= new CreateFolderOperation(path
, getCurrentDir().getFileId(), mStorageManager
);
1295 operation
.execute( getAccount(),
1296 FileDisplayActivity
.this,
1297 FileDisplayActivity
.this,
1299 FileDisplayActivity
.this);
1301 showDialog(DIALOG_SHORT_WAIT
);
1307 private void requestForDownload() {
1308 Account account
= getAccount();
1309 if (!mDownloaderBinder
.isDownloading(account
, mWaitingToPreview
)) {
1310 Intent i
= new Intent(this, FileDownloader
.class);
1311 i
.putExtra(FileDownloader
.EXTRA_ACCOUNT
, account
);
1312 i
.putExtra(FileDownloader
.EXTRA_FILE
, mWaitingToPreview
);
1318 private OCFile
getCurrentDir() {
1319 OCFile file
= getFile();
1321 if (file
.isDirectory()) {
1324 return mStorageManager
.getFileById(file
.getParentId());