2 * ownCloud Android client application
4 * @author Bartek Przybylski
6 * @author David A. Velasco
7 * Copyright (C) 2011 Bartek Przybylski
8 * Copyright (C) 2015 ownCloud Inc.
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2,
12 * as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 package com
.owncloud
.android
.ui
.fragment
;
25 import android
.app
.Activity
;
26 import android
.content
.Intent
;
27 import android
.content
.SharedPreferences
;
28 import android
.os
.Build
;
29 import android
.os
.Bundle
;
30 import android
.preference
.PreferenceManager
;
31 import android
.support
.v4
.widget
.SwipeRefreshLayout
;
32 import android
.view
.ContextMenu
;
33 import android
.view
.Menu
;
34 import android
.view
.MenuInflater
;
35 import android
.view
.MenuItem
;
36 import android
.view
.View
;
37 import android
.widget
.AdapterView
;
38 import android
.widget
.AdapterView
.AdapterContextMenuInfo
;
39 import android
.widget
.PopupMenu
;
40 import android
.widget
.TextView
;
41 import android
.widget
.Toast
;
43 import com
.owncloud
.android
.R
;
44 import com
.owncloud
.android
.authentication
.AccountUtils
;
45 import com
.owncloud
.android
.datamodel
.FileDataStorageManager
;
46 import com
.owncloud
.android
.datamodel
.OCFile
;
47 import com
.owncloud
.android
.files
.FileMenuFilter
;
48 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
49 import com
.owncloud
.android
.lib
.resources
.status
.OwnCloudVersion
;
50 import com
.owncloud
.android
.ui
.activity
.FileActivity
;
51 import com
.owncloud
.android
.ui
.activity
.FileDisplayActivity
;
52 import com
.owncloud
.android
.ui
.activity
.FolderPickerActivity
;
53 import com
.owncloud
.android
.ui
.activity
.OnEnforceableRefreshListener
;
54 import com
.owncloud
.android
.ui
.activity
.UploadFilesActivity
;
55 import com
.owncloud
.android
.ui
.adapter
.FileListListAdapter
;
56 import com
.owncloud
.android
.ui
.dialog
.ConfirmationDialogFragment
;
57 import com
.owncloud
.android
.ui
.dialog
.CreateFolderDialogFragment
;
58 import com
.owncloud
.android
.ui
.dialog
.FileActionsDialogFragment
;
59 import com
.owncloud
.android
.ui
.dialog
.RemoveFileDialogFragment
;
60 import com
.owncloud
.android
.ui
.dialog
.RenameFileDialogFragment
;
61 import com
.owncloud
.android
.ui
.dialog
.UploadSourceDialogFragment
;
62 import com
.owncloud
.android
.ui
.preview
.PreviewImageFragment
;
63 import com
.owncloud
.android
.ui
.preview
.PreviewMediaFragment
;
64 import com
.owncloud
.android
.ui
.preview
.PreviewTextFragment
;
65 import com
.owncloud
.android
.utils
.FileStorageUtils
;
70 * A Fragment that lists all files and folders in a given path.
72 * TODO refactor to get rid of direct dependency on FileDisplayActivity
74 public class OCFileListFragment
extends ExtendedListFragment
75 implements FileActionsDialogFragment
.FileActionsDialogFragmentListener
{
77 private static final String TAG
= OCFileListFragment
.class.getSimpleName();
79 private static final String MY_PACKAGE
= OCFileListFragment
.class.getPackage() != null ?
80 OCFileListFragment
.class.getPackage().getName() : "com.owncloud.android.ui.fragment";
82 public final static String ARG_JUST_FOLDERS
= MY_PACKAGE
+ ".JUST_FOLDERS";
83 public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS
= MY_PACKAGE
+ ".ALLOW_CONTEXTUAL";
84 public final static String ARG_HIDE_FAB
= MY_PACKAGE
+ ".HIDE_FAB";
86 private static final String KEY_FILE
= MY_PACKAGE
+ ".extra.FILE";
87 private static final String KEY_FAB_EVER_CLICKED
= "FAB_EVER_CLICKED";
89 private static String DIALOG_CREATE_FOLDER
= "DIALOG_CREATE_FOLDER";
91 private FileFragment
.ContainerActivity mContainerActivity
;
93 private OCFile mFile
= null
;
94 private FileListListAdapter mAdapter
;
95 private boolean mJustFolders
;
97 private OCFile mTargetFile
;
99 private boolean miniFabClicked
= false
;
105 public void onAttach(Activity activity
) {
106 super.onAttach(activity
);
107 Log_OC
.e(TAG
, "onAttach");
109 mContainerActivity
= (FileFragment
.ContainerActivity
) activity
;
111 } catch (ClassCastException e
) {
112 throw new ClassCastException(activity
.toString() + " must implement " +
113 FileFragment
.ContainerActivity
.class.getSimpleName());
116 setOnRefreshListener((OnEnforceableRefreshListener
) activity
);
118 } catch (ClassCastException e
) {
119 throw new ClassCastException(activity
.toString() + " must implement " +
120 SwipeRefreshLayout
.OnRefreshListener
.class.getSimpleName());
126 public void onDetach() {
127 setOnRefreshListener(null
);
128 mContainerActivity
= null
;
136 public void onActivityCreated(Bundle savedInstanceState
) {
137 super.onActivityCreated(savedInstanceState
);
138 Log_OC
.e(TAG
, "onActivityCreated() start");
140 if (savedInstanceState
!= null
) {
141 mFile
= savedInstanceState
.getParcelable(KEY_FILE
);
145 setFooterEnabled(false
);
147 setFooterEnabled(true
);
150 Bundle args
= getArguments();
151 mJustFolders
= (args
== null
) ? false
: args
.getBoolean(ARG_JUST_FOLDERS
, false
);
152 mAdapter
= new FileListListAdapter(
157 setListAdapter(mAdapter
);
159 registerLongClickListener();
161 boolean hideFab
= (args
!= null
) && args
.getBoolean(ARG_HIDE_FAB
, false
);
163 setFabEnabled(false
);
166 registerFabListeners();
168 // detect if a mini FAB has ever been clicked
169 final SharedPreferences prefs
= PreferenceManager
.getDefaultSharedPreferences(getActivity());
170 if(prefs
.getLong(KEY_FAB_EVER_CLICKED
, 0) > 0) {
171 miniFabClicked
= true
;
174 // add labels to the min FABs when none of them has ever been clicked on
175 if(!miniFabClicked
) {
184 * adds labels to all mini FABs.
186 private void setFabLabels() {
187 getFabUpload().setTitle(getResources().getString(R
.string
.actionbar_upload
));
188 getFabMkdir().setTitle(getResources().getString(R
.string
.actionbar_mkdir
));
189 getFabUploadFromApp().setTitle(getResources().getString(R
.string
.actionbar_upload_from_apps
));
193 * registers all listeners on all mini FABs.
195 private void registerFabListeners() {
196 registerFabUploadListeners();
197 registerFabMkDirListeners();
198 registerFabUploadFromAppListeners();
202 * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
203 * on the Upload mini FAB for the linked action and {@link Toast} showing the underlying action.
205 private void registerFabUploadListeners() {
206 getFabUpload().setOnClickListener(new View
.OnClickListener() {
208 public void onClick(View v
) {
209 Intent action
= new Intent(getActivity(), UploadFilesActivity
.class);
211 UploadFilesActivity
.EXTRA_ACCOUNT
,
212 ((FileActivity
) getActivity()).getAccount()
214 getActivity().startActivityForResult(action
, UploadSourceDialogFragment
.ACTION_SELECT_MULTIPLE_FILES
);
215 getFabMain().collapse();
216 recordMiniFabClick();
220 getFabUpload().setOnLongClickListener(new View
.OnLongClickListener() {
222 public boolean onLongClick(View v
) {
223 Toast
.makeText(getActivity(), R
.string
.actionbar_upload
, Toast
.LENGTH_SHORT
).show();
230 * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
231 * on the 'Create Dir' mini FAB for the linked action and {@link Toast} showing the underlying action.
233 private void registerFabMkDirListeners() {
234 getFabMkdir().setOnClickListener(new View
.OnClickListener() {
236 public void onClick(View v
) {
237 CreateFolderDialogFragment dialog
=
238 CreateFolderDialogFragment
.newInstance(mFile
);
239 dialog
.show(getActivity().getSupportFragmentManager(), FileDisplayActivity
.DIALOG_CREATE_FOLDER
);
240 getFabMain().collapse();
241 recordMiniFabClick();
245 getFabMkdir().setOnLongClickListener(new View
.OnLongClickListener() {
247 public boolean onLongClick(View v
) {
248 Toast
.makeText(getActivity(), R
.string
.actionbar_mkdir
, Toast
.LENGTH_SHORT
).show();
255 * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
256 * on the Upload from App mini FAB for the linked action and {@link Toast} showing the underlying action.
258 private void registerFabUploadFromAppListeners() {
259 getFabUploadFromApp().setOnClickListener(new View
.OnClickListener() {
261 public void onClick(View v
) {
262 Intent action
= new Intent(Intent
.ACTION_GET_CONTENT
);
263 action
= action
.setType("*/*").addCategory(Intent
.CATEGORY_OPENABLE
);
265 //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
266 if (Build
.VERSION
.SDK_INT
>= Build
.VERSION_CODES
.JELLY_BEAN_MR2
) {
267 action
.putExtra(Intent
.EXTRA_ALLOW_MULTIPLE
, true
);
270 getActivity().startActivityForResult(
271 Intent
.createChooser(action
, getString(R
.string
.upload_chooser_title
)),
272 UploadSourceDialogFragment
.ACTION_SELECT_CONTENT_FROM_APPS
274 getFabMain().collapse();
275 recordMiniFabClick();
279 getFabUploadFromApp().setOnLongClickListener(new View
.OnLongClickListener() {
281 public boolean onLongClick(View v
) {
282 Toast
.makeText(getActivity(),
283 R
.string
.actionbar_upload_from_apps
,
284 Toast
.LENGTH_SHORT
).show();
291 * records a click on a mini FAB and thus:
293 * <li>persists the click fact</li>
294 * <li>removes the mini FAB labels</li>
297 private void recordMiniFabClick() {
298 // only record if it hasn't been done already at some other time
299 if(!miniFabClicked
) {
300 final SharedPreferences sp
= PreferenceManager
.getDefaultSharedPreferences(getActivity());
301 sp
.edit().putLong(KEY_FAB_EVER_CLICKED
, 1).commit();
302 miniFabClicked
= true
;
307 * removes the labels on all known min FABs.
309 private void removeFabLabels() {
310 getFabUpload().setTitle(null
);
311 getFabMkdir().setTitle(null
);
312 getFabUploadFromApp().setTitle(null
);
313 ((TextView
) getFabUpload().getTag(com
.getbase
.floatingactionbutton
.R
.id
.fab_label
)).setVisibility(View
.GONE
);
314 ((TextView
) getFabMkdir().getTag(com
.getbase
.floatingactionbutton
.R
.id
.fab_label
)).setVisibility(View
.GONE
);
315 ((TextView
) getFabUploadFromApp().getTag(com
.getbase
.floatingactionbutton
.R
.id
.fab_label
)).setVisibility(View
.GONE
);
318 private void registerLongClickListener() {
319 getListView().setOnItemLongClickListener(new AdapterView
.OnItemLongClickListener() {
320 public boolean onItemLongClick(AdapterView
<?
> arg0
, View v
,
321 int index
, long arg3
) {
322 showFileAction(index
);
328 private void showFileAction(int fileIndex
) {
329 Bundle args
= getArguments();
330 PopupMenu pm
= new PopupMenu(getActivity(),null
);
331 Menu menu
= pm
.getMenu();
333 boolean allowContextualActions
=
334 (args
== null
) ? true
: args
.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS
, true
);
336 if (allowContextualActions
) {
337 MenuInflater inflater
= getActivity().getMenuInflater();
339 inflater
.inflate(R
.menu
.file_actions_menu
, menu
);
340 OCFile targetFile
= (OCFile
) mAdapter
.getItem(fileIndex
);
342 if (mContainerActivity
.getStorageManager() != null
) {
343 FileMenuFilter mf
= new FileMenuFilter(
345 mContainerActivity
.getStorageManager().getAccount(),
352 /// TODO break this direct dependency on FileDisplayActivity... if possible
353 MenuItem item
= menu
.findItem(R
.id
.action_open_file_with
);
354 FileFragment frag
= ((FileDisplayActivity
)getActivity()).getSecondFragment();
355 if (frag
!= null
&& frag
instanceof FileDetailFragment
&&
356 frag
.getFile().getFileId() == targetFile
.getFileId()) {
357 item
= menu
.findItem(R
.id
.action_see_details
);
359 item
.setVisible(false
);
360 item
.setEnabled(false
);
364 FileActionsDialogFragment dialog
= FileActionsDialogFragment
.newInstance(menu
,
365 fileIndex
, targetFile
.getFileName());
366 dialog
.setTargetFragment(this, 0);
367 dialog
.show(getFragmentManager(), FileActionsDialogFragment
.FTAG_FILE_ACTIONS
);
372 * Saves the current listed folder.
375 public void onSaveInstanceState(Bundle outState
) {
376 super.onSaveInstanceState(outState
);
377 outState
.putParcelable(KEY_FILE
, mFile
);
381 * Call this, when the user presses the up button.
383 * Tries to move up the current folder one level. If the parent folder was removed from the
384 * database, it continues browsing up until finding an existing folders.
386 * @return Count of folder levels browsed up.
388 public int onBrowseUp() {
389 OCFile parentDir
= null
;
393 FileDataStorageManager storageManager
= mContainerActivity
.getStorageManager();
395 String parentPath
= null
;
396 if (mFile
.getParentId() != FileDataStorageManager
.ROOT_PARENT_ID
) {
397 parentPath
= new File(mFile
.getRemotePath()).getParent();
398 parentPath
= parentPath
.endsWith(OCFile
.PATH_SEPARATOR
) ? parentPath
:
399 parentPath
+ OCFile
.PATH_SEPARATOR
;
400 parentDir
= storageManager
.getFileByPath(parentPath
);
403 parentDir
= storageManager
.getFileByPath(OCFile
.ROOT_PATH
);
405 while (parentDir
== null
) {
406 parentPath
= new File(parentPath
).getParent();
407 parentPath
= parentPath
.endsWith(OCFile
.PATH_SEPARATOR
) ? parentPath
:
408 parentPath
+ OCFile
.PATH_SEPARATOR
;
409 parentDir
= storageManager
.getFileByPath(parentPath
);
411 } // exit is granted because storageManager.getFileByPath("/") never returns null
414 // TODO Enable when "On Device" is recovered ?
415 listDirectory(mFile
/*, MainApp.getOnlyOnDevice()*/);
419 // restore index and top position
420 restoreIndexAndTopPosition();
422 } // else - should never happen now
428 public void onItemClick(AdapterView
<?
> l
, View v
, int position
, long id
) {
429 OCFile file
= (OCFile
) mAdapter
.getItem(position
);
431 if (file
.isFolder()) {
432 // update state and view of this fragment
433 // TODO Enable when "On Device" is recovered ?
434 listDirectory(file
/*, MainApp.getOnlyOnDevice()*/);
435 // then, notify parent activity to let it update its state and view
436 mContainerActivity
.onBrowsedDownTo(file
);
437 // save index and top position
438 saveIndexAndTopPosition(position
);
440 } else { /// Click on a file
441 if (PreviewImageFragment
.canBePreviewed(file
)) {
442 // preview image - it handles the download, if needed
443 ((FileDisplayActivity
)mContainerActivity
).startImagePreview(file
);
444 } else if (PreviewTextFragment
.canBePreviewed(file
)){
445 ((FileDisplayActivity
)mContainerActivity
).startTextPreview(file
);
446 } else if (file
.isDown()) {
447 if (PreviewMediaFragment
.canBePreviewed(file
)) {
449 ((FileDisplayActivity
) mContainerActivity
).startMediaPreview(file
, 0, true
);
451 mContainerActivity
.getFileOperationsHelper().openFile(file
);
455 // automatic download, preview on finish
456 ((FileDisplayActivity
) mContainerActivity
).startDownloadForPreview(file
);
462 Log_OC
.d(TAG
, "Null object in ListAdapter!!");
471 public void onCreateContextMenu(
472 ContextMenu menu
, View v
, ContextMenu
.ContextMenuInfo menuInfo
) {
473 Bundle args
= getArguments();
474 boolean allowContextualActions
=
475 (args
== null
) ? true
: args
.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS
, true
);
476 if (allowContextualActions
) {
477 MenuInflater inflater
= getActivity().getMenuInflater();
478 inflater
.inflate(R
.menu
.file_actions_menu
, menu
);
479 AdapterContextMenuInfo info
= (AdapterContextMenuInfo
) menuInfo
;
480 OCFile targetFile
= (OCFile
) mAdapter
.getItem(info
.position
);
482 if (mContainerActivity
.getStorageManager() != null
) {
483 FileMenuFilter mf
= new FileMenuFilter(
485 mContainerActivity
.getStorageManager().getAccount(),
492 /// TODO break this direct dependency on FileDisplayActivity... if possible
493 MenuItem item
= menu
.findItem(R
.id
.action_open_file_with
);
494 FileFragment frag
= ((FileDisplayActivity
)getActivity()).getSecondFragment();
495 if (frag
!= null
&& frag
instanceof FileDetailFragment
&&
496 frag
.getFile().getFileId() == targetFile
.getFileId()) {
497 item
= menu
.findItem(R
.id
.action_see_details
);
499 item
.setVisible(false
);
500 item
.setEnabled(false
);
510 public boolean onFileActionChosen(int menuId
, int filePosition
) {
511 mTargetFile
= (OCFile
) mAdapter
.getItem(filePosition
);
513 case R
.id
.action_share_file
: {
514 mContainerActivity
.getFileOperationsHelper().shareFileWithLink(mTargetFile
);
517 case R
.id
.action_share_with_users
: {
518 mContainerActivity
.getFileOperationsHelper().showShareFile(mTargetFile
);
521 case R
.id
.action_open_file_with
: {
522 mContainerActivity
.getFileOperationsHelper().openFile(mTargetFile
);
525 case R
.id
.action_unshare_file
: {
526 mContainerActivity
.getFileOperationsHelper().unshareFileWithLink(mTargetFile
);
529 case R
.id
.action_rename_file
: {
530 RenameFileDialogFragment dialog
= RenameFileDialogFragment
.newInstance(mTargetFile
);
531 dialog
.show(getFragmentManager(), FileDetailFragment
.FTAG_RENAME_FILE
);
534 case R
.id
.action_remove_file
: {
535 RemoveFileDialogFragment dialog
= RemoveFileDialogFragment
.newInstance(mTargetFile
);
536 dialog
.show(getFragmentManager(), ConfirmationDialogFragment
.FTAG_CONFIRMATION
);
539 case R
.id
.action_download_file
:
540 case R
.id
.action_sync_file
: {
541 mContainerActivity
.getFileOperationsHelper().syncFile(mTargetFile
);
544 case R
.id
.action_cancel_sync
: {
545 ((FileDisplayActivity
)mContainerActivity
).cancelTransference(mTargetFile
);
548 case R
.id
.action_see_details
: {
549 mContainerActivity
.showDetails(mTargetFile
);
552 case R
.id
.action_send_file
: {
554 if (!mTargetFile
.isDown()) { // Download the file
555 Log_OC
.d(TAG
, mTargetFile
.getRemotePath() + " : File must be downloaded");
556 ((FileDisplayActivity
) mContainerActivity
).startDownloadForSending(mTargetFile
);
559 mContainerActivity
.getFileOperationsHelper().sendDownloadedFile(mTargetFile
);
563 case R
.id
.action_move
: {
564 Intent action
= new Intent(getActivity(), FolderPickerActivity
.class);
566 // Pass mTargetFile that contains info of selected file/folder
567 action
.putExtra(FolderPickerActivity
.EXTRA_FILE
, mTargetFile
);
568 getActivity().startActivityForResult(action
, FileDisplayActivity
.ACTION_MOVE_FILES
);
571 case R
.id
.action_favorite_file
: {
572 mContainerActivity
.getFileOperationsHelper().toggleFavorite(mTargetFile
, true
);
575 case R
.id
.action_unfavorite_file
: {
576 mContainerActivity
.getFileOperationsHelper().toggleFavorite(mTargetFile
, false
);
579 case R
.id
.action_copy
:
580 Intent action
= new Intent(getActivity(), FolderPickerActivity
.class);
582 // Pass mTargetFile that contains info of selected file/folder
583 action
.putExtra(FolderPickerActivity
.EXTRA_FILE
, mTargetFile
);
584 getActivity().startActivityForResult(action
, FileDisplayActivity
.ACTION_COPY_FILES
);
595 public boolean onContextItemSelected (MenuItem item
) {
596 AdapterContextMenuInfo info
= (AdapterContextMenuInfo
) item
.getMenuInfo();
597 boolean matched
= onFileActionChosen(item
.getItemId(),
598 ((AdapterContextMenuInfo
) item
.getMenuInfo()).position
);
600 return super.onContextItemSelected(item
);
608 * Use this to query the {@link OCFile} that is currently
609 * being displayed by this fragment
611 * @return The currently viewed OCFile
613 public OCFile
getCurrentFile() {
618 * Calls {@link OCFileListFragment#listDirectory(OCFile)} with a null parameter
620 public void listDirectory(/*boolean onlyOnDevice*/){
622 // TODO Enable when "On Device" is recovered ?
623 // listDirectory(null, onlyOnDevice);
626 public void refreshDirectory(){
627 // TODO Enable when "On Device" is recovered ?
628 listDirectory(getCurrentFile()/*, MainApp.getOnlyOnDevice()*/);
632 * Lists the given directory on the view. When the input parameter is null,
633 * it will either refresh the last known directory. list the root
634 * if there never was a directory.
636 * @param directory File to be listed
638 public void listDirectory(OCFile directory
/*, boolean onlyOnDevice*/) {
639 FileDataStorageManager storageManager
= mContainerActivity
.getStorageManager();
640 if (storageManager
!= null
) {
642 // Check input parameters for null
643 if (directory
== null
) {
647 directory
= storageManager
.getFileByPath("/");
648 if (directory
== null
) return; // no files, wait for sync
653 // If that's not a directory -> List its parent
654 if (!directory
.isFolder()) {
655 Log_OC
.w(TAG
, "You see, that is not a directory -> " + directory
.toString());
656 directory
= storageManager
.getFileById(directory
.getParentId());
659 // TODO Enable when "On Device" is recovered ?
660 mAdapter
.swapDirectory(directory
, storageManager
/*, onlyOnDevice*/);
661 if (mFile
== null
|| !mFile
.equals(directory
)) {
662 mCurrentListView
.setSelection(0);
671 private void updateLayout() {
673 int filesCount
= 0, foldersCount
= 0, imagesCount
= 0;
674 int count
= mAdapter
.getCount();
676 for (int i
=0; i
< count
; i
++) {
677 file
= (OCFile
) mAdapter
.getItem(i
);
678 if (file
.isFolder()) {
681 if (!file
.isHidden()) {
684 if (file
.isImage()) {
691 setFooterText(generateFooterText(filesCount
, foldersCount
));
693 // decide grid vs list view
694 OwnCloudVersion version
= AccountUtils
.getServerVersion(
695 ((FileActivity
)mContainerActivity
).getAccount());
696 if (version
!= null
&& version
.supportsRemoteThumbnails() &&
697 imagesCount
> 0 && imagesCount
== filesCount
) {
699 registerLongClickListener();
706 private String
generateFooterText(int filesCount
, int foldersCount
) {
708 if (filesCount
<= 0) {
709 if (foldersCount
<= 0) {
712 } else if (foldersCount
== 1) {
713 output
= getResources().getString(R
.string
.file_list__footer__folder
);
715 } else { // foldersCount > 1
716 output
= getResources().getString(R
.string
.file_list__footer__folders
, foldersCount
);
719 } else if (filesCount
== 1) {
720 if (foldersCount
<= 0) {
721 output
= getResources().getString(R
.string
.file_list__footer__file
);
723 } else if (foldersCount
== 1) {
724 output
= getResources().getString(R
.string
.file_list__footer__file_and_folder
);
726 } else { // foldersCount > 1
727 output
= getResources().getString(R
.string
.file_list__footer__file_and_folders
, foldersCount
);
729 } else { // filesCount > 1
730 if (foldersCount
<= 0) {
731 output
= getResources().getString(R
.string
.file_list__footer__files
, filesCount
);
733 } else if (foldersCount
== 1) {
734 output
= getResources().getString(R
.string
.file_list__footer__files_and_folder
, filesCount
);
736 } else { // foldersCount > 1
737 output
= getResources().getString(
738 R
.string
.file_list__footer__files_and_folders
, filesCount
, foldersCount
746 public void sortByName(boolean descending
) {
747 mAdapter
.setSortOrder(FileStorageUtils
.SORT_NAME
, descending
);
750 public void sortByDate(boolean descending
) {
751 mAdapter
.setSortOrder(FileStorageUtils
.SORT_DATE
, descending
);
754 public void sortBySize(boolean descending
) {
755 mAdapter
.setSortOrder(FileStorageUtils
.SORT_SIZE
, descending
);