mirror of
https://github.com/nextcloud/android.git
synced 2024-11-25 06:35:48 +03:00
Progress on number of things
This commit is contained in:
parent
9f94104eed
commit
3a3c4767fd
5 changed files with 329 additions and 145 deletions
|
@ -1,22 +1,22 @@
|
||||||
/**
|
/**
|
||||||
* ownCloud Android client application
|
* ownCloud Android client application
|
||||||
*
|
*
|
||||||
* @author Bartek Przybylski
|
* @author Bartek Przybylski
|
||||||
* @author David A. Velasco
|
* @author David A. Velasco
|
||||||
* Copyright (C) 2011 Bartek Przybylski
|
* Copyright (C) 2011 Bartek Przybylski
|
||||||
* Copyright (C) 2016 ownCloud Inc.
|
* Copyright (C) 2016 ownCloud Inc.
|
||||||
*
|
* <p>
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2,
|
* it under the terms of the GNU General Public License version 2,
|
||||||
* as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
*
|
* <p>
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
* <p>
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.owncloud.android.ui.activity;
|
package com.owncloud.android.ui.activity;
|
||||||
|
@ -81,6 +81,7 @@ import com.owncloud.android.operations.SynchronizeFileOperation;
|
||||||
import com.owncloud.android.operations.UploadFileOperation;
|
import com.owncloud.android.operations.UploadFileOperation;
|
||||||
import com.owncloud.android.services.observer.FileObserverService;
|
import com.owncloud.android.services.observer.FileObserverService;
|
||||||
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
||||||
|
import com.owncloud.android.ui.events.ToggleMenuItemsVisibilityEvent;
|
||||||
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
||||||
import com.owncloud.android.ui.fragment.FileDetailFragment;
|
import com.owncloud.android.ui.fragment.FileDetailFragment;
|
||||||
import com.owncloud.android.ui.fragment.FileFragment;
|
import com.owncloud.android.ui.fragment.FileFragment;
|
||||||
|
@ -97,6 +98,9 @@ import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.ErrorMessageAdapter;
|
import com.owncloud.android.utils.ErrorMessageAdapter;
|
||||||
import com.owncloud.android.utils.PermissionUtil;
|
import com.owncloud.android.utils.PermissionUtil;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -146,10 +150,15 @@ public class FileDisplayActivity extends HookActivity
|
||||||
private OCFile mWaitingToSend;
|
private OCFile mWaitingToSend;
|
||||||
|
|
||||||
private Collection<MenuItem> mDrawerMenuItemstoShowHideList;
|
private Collection<MenuItem> mDrawerMenuItemstoShowHideList;
|
||||||
|
private Collection<MenuItem> mMenuItemsToHide = new ArrayList<>();
|
||||||
|
private Collection<MenuItem> mMenuItemsToShow = new ArrayList<>();
|
||||||
|
|
||||||
private String searchQuery;
|
private String searchQuery;
|
||||||
|
|
||||||
private SearchView searchView;
|
private SearchView searchView;
|
||||||
|
|
||||||
|
private Menu mMenu;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
Log_OC.v(TAG, "onCreate() start");
|
Log_OC.v(TAG, "onCreate() start");
|
||||||
|
@ -186,7 +195,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
setupToolbar();
|
setupToolbar();
|
||||||
|
|
||||||
// setup drawer
|
// setup drawer
|
||||||
if(MainApp.isOnlyOnDevice()) {
|
if (MainApp.isOnlyOnDevice()) {
|
||||||
setupDrawer(R.id.nav_on_device);
|
setupDrawer(R.id.nav_on_device);
|
||||||
} else {
|
} else {
|
||||||
setupDrawer(R.id.nav_all_files);
|
setupDrawer(R.id.nav_all_files);
|
||||||
|
@ -576,17 +585,62 @@ public class FileDisplayActivity extends HookActivity
|
||||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
boolean drawerOpen = isDrawerOpen();
|
boolean drawerOpen = isDrawerOpen();
|
||||||
|
|
||||||
for (MenuItem menuItem:mDrawerMenuItemstoShowHideList) {
|
for (MenuItem menuItem : mDrawerMenuItemstoShowHideList) {
|
||||||
menuItem.setVisible(!drawerOpen);
|
menuItem.setVisible(!drawerOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (MenuItem menuItem : mMenuItemsToHide) {
|
||||||
|
menuItem.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (MenuItem menuItem : mMenuItemsToShow) {
|
||||||
|
menuItem.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
return super.onPrepareOptionsMenu(menu);
|
return super.onPrepareOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
|
public void onMessageEvent(final ToggleMenuItemsVisibilityEvent event) {
|
||||||
|
mMenuItemsToHide = new ArrayList<>();
|
||||||
|
mMenuItemsToShow = new ArrayList<>();
|
||||||
|
|
||||||
|
if (mMenu != null) {
|
||||||
|
if (event.getMenuHideType().equals(
|
||||||
|
ToggleMenuItemsVisibilityEvent.MenuHideType.HIDE_LIST_GRID_SWITCH_ITEM)) {
|
||||||
|
if (event.isHideMenuItems()) {
|
||||||
|
mMenuItemsToHide.add(mMenu.findItem(R.id.action_switch_view));
|
||||||
|
} else {
|
||||||
|
mMenuItemsToShow.add(mMenu.findItem(R.id.action_switch_view));
|
||||||
|
}
|
||||||
|
} else if (event.getMenuHideType().equals(
|
||||||
|
ToggleMenuItemsVisibilityEvent.MenuHideType.HIDE_SORT_AND_LG_SWITCH_ITEM)) {
|
||||||
|
if (event.isHideMenuItems()) {
|
||||||
|
mMenuItemsToHide.add(mMenu.findItem(R.id.action_switch_view));
|
||||||
|
mMenuItemsToHide.add(mMenu.findItem(R.id.action_sort));
|
||||||
|
} else {
|
||||||
|
mMenuItemsToShow.add(mMenu.findItem(R.id.action_switch_view));
|
||||||
|
mMenuItemsToHide.add(mMenu.findItem(R.id.action_sort));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (event.getMenuHideType().equals(
|
||||||
|
ToggleMenuItemsVisibilityEvent.MenuHideType.HIDE_SORT_ITEM)) {
|
||||||
|
if (event.isHideMenuItems()) {
|
||||||
|
mMenuItemsToHide.add(mMenu.findItem(R.id.action_sort));
|
||||||
|
} else {
|
||||||
|
mMenuItemsToShow.add(mMenu.findItem(R.id.action_sort));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidateOptionsMenu();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
MenuInflater inflater = getMenuInflater();
|
MenuInflater inflater = getMenuInflater();
|
||||||
inflater.inflate(R.menu.main_menu, menu);
|
inflater.inflate(R.menu.main_menu, menu);
|
||||||
|
mMenu = menu;
|
||||||
menu.findItem(R.id.action_create_dir).setVisible(false);
|
menu.findItem(R.id.action_create_dir).setVisible(false);
|
||||||
|
|
||||||
final MenuItem item = menu.findItem(R.id.action_search);
|
final MenuItem item = menu.findItem(R.id.action_search);
|
||||||
|
@ -765,16 +819,16 @@ public class FileDisplayActivity extends HookActivity
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
|
||||||
if (requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS &&
|
if (requestCode == REQUEST_CODE__SELECT_CONTENT_FROM_APPS &&
|
||||||
(resultCode == RESULT_OK ||
|
(resultCode == RESULT_OK ||
|
||||||
resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
|
resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
|
||||||
|
|
||||||
requestUploadOfContentFromApps(data, resultCode);
|
requestUploadOfContentFromApps(data, resultCode);
|
||||||
|
|
||||||
} else if (requestCode == REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM &&
|
} else if (requestCode == REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM &&
|
||||||
(resultCode == RESULT_OK ||
|
(resultCode == RESULT_OK ||
|
||||||
resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE ||
|
resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE ||
|
||||||
resultCode == UploadFilesActivity.RESULT_OK_AND_DO_NOTHING ||
|
resultCode == UploadFilesActivity.RESULT_OK_AND_DO_NOTHING ||
|
||||||
resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
|
resultCode == UploadFilesActivity.RESULT_OK_AND_DELETE)) {
|
||||||
|
|
||||||
requestUploadOfFilesFromFileSystem(data, resultCode);
|
requestUploadOfFilesFromFileSystem(data, resultCode);
|
||||||
|
|
||||||
|
@ -863,8 +917,8 @@ public class FileDisplayActivity extends HookActivity
|
||||||
|
|
||||||
//getClipData is only supported on api level 16+, Jelly Bean
|
//getClipData is only supported on api level 16+, Jelly Bean
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
|
||||||
contentIntent.getClipData() != null &&
|
contentIntent.getClipData() != null &&
|
||||||
contentIntent.getClipData().getItemCount() > 0) {
|
contentIntent.getClipData().getItemCount() > 0) {
|
||||||
|
|
||||||
for (int i = 0; i < contentIntent.getClipData().getItemCount(); i++) {
|
for (int i = 0; i < contentIntent.getClipData().getItemCount(); i++) {
|
||||||
streamsToUpload.add(contentIntent.getClipData().getItemAt(i).getUri());
|
streamsToUpload.add(contentIntent.getClipData().getItemAt(i).getUri());
|
||||||
|
@ -949,10 +1003,10 @@ public class FileDisplayActivity extends HookActivity
|
||||||
searchView.setQuery("", true);
|
searchView.setQuery("", true);
|
||||||
searchView.onActionViewCollapsed();
|
searchView.onActionViewCollapsed();
|
||||||
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
|
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
|
||||||
} else if(isDrawerOpen && isFabOpen) {
|
} else if (isDrawerOpen && isFabOpen) {
|
||||||
// close drawer first
|
// close drawer first
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
} else if(isDrawerOpen && !isFabOpen) {
|
} else if (isDrawerOpen && !isFabOpen) {
|
||||||
// close drawer
|
// close drawer
|
||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
} else if (!isDrawerOpen && isFabOpen) {
|
} else if (!isDrawerOpen && isFabOpen) {
|
||||||
|
@ -1059,7 +1113,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFabOpen() {
|
public boolean isFabOpen() {
|
||||||
if(getListOfFilesFragment() != null
|
if (getListOfFilesFragment() != null
|
||||||
&& getListOfFilesFragment().getFabMain() != null
|
&& getListOfFilesFragment().getFabMain() != null
|
||||||
&& getListOfFilesFragment().getFabMain().isExpanded()) {
|
&& getListOfFilesFragment().getFabMain().isExpanded()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1124,7 +1178,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
OCFileListFragment fileListFragment = getListOfFilesFragment();
|
||||||
if (fileListFragment != null) {
|
if (fileListFragment != null) {
|
||||||
fileListFragment.listDirectory(currentDir,
|
fileListFragment.listDirectory(currentDir,
|
||||||
MainApp.isOnlyOnDevice(), false);
|
MainApp.isOnlyOnDevice(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setFile(currentFile);
|
setFile(currentFile);
|
||||||
|
@ -1189,7 +1243,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
|
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
|
||||||
if (ocFileListFragment != null) {
|
if (ocFileListFragment != null) {
|
||||||
if (!mSyncInProgress) {
|
if (!mSyncInProgress) {
|
||||||
ocFileListFragment.setEmptyListMessage(ExtendedListFragment.SearchType.NO_SEARCH);
|
ocFileListFragment.setEmptyListMessage(ExtendedListFragment.SearchType.NO_SEARCH);
|
||||||
} else {
|
} else {
|
||||||
ocFileListFragment.setEmptyListLoadingMessage();
|
ocFileListFragment.setEmptyListLoadingMessage();
|
||||||
}
|
}
|
||||||
|
@ -1264,8 +1318,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
OCFile ocFile = getFile();
|
OCFile ocFile = getFile();
|
||||||
if (PreviewImageFragment.canBePreviewed(ocFile)) {
|
if (PreviewImageFragment.canBePreviewed(ocFile)) {
|
||||||
startImagePreview(getFile());
|
startImagePreview(getFile());
|
||||||
}
|
} else if (PreviewTextFragment.canBePreviewed(ocFile)) {
|
||||||
else if (PreviewTextFragment.canBePreviewed(ocFile)) {
|
|
||||||
startTextPreview(ocFile);
|
startTextPreview(ocFile);
|
||||||
}
|
}
|
||||||
// TODO what about other kind of previews?
|
// TODO what about other kind of previews?
|
||||||
|
@ -1544,8 +1597,8 @@ public class FileDisplayActivity extends HookActivity
|
||||||
private void onRemoveFileOperationFinish(RemoveFileOperation operation,
|
private void onRemoveFileOperationFinish(RemoveFileOperation operation,
|
||||||
RemoteOperationResult result) {
|
RemoteOperationResult result) {
|
||||||
Toast msg = Toast.makeText(this,
|
Toast msg = Toast.makeText(this,
|
||||||
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
|
ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
|
||||||
Toast.LENGTH_LONG);
|
Toast.LENGTH_LONG);
|
||||||
msg.show();
|
msg.show();
|
||||||
|
|
||||||
if (result.isSuccess()) {
|
if (result.isSuccess()) {
|
||||||
|
@ -1925,7 +1978,7 @@ public class FileDisplayActivity extends HookActivity
|
||||||
* @param files collection of {@link OCFile} files which operations are wanted to be cancel
|
* @param files collection of {@link OCFile} files which operations are wanted to be cancel
|
||||||
*/
|
*/
|
||||||
public void cancelTransference(Collection<OCFile> files) {
|
public void cancelTransference(Collection<OCFile> files) {
|
||||||
for(OCFile file: files) {
|
for (OCFile file : files) {
|
||||||
cancelTransference(file);
|
cancelTransference(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
|
||||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||||
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
|
||||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||||
|
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
||||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
import com.owncloud.android.utils.FileStorageUtils;
|
import com.owncloud.android.utils.FileStorageUtils;
|
||||||
|
@ -81,6 +82,7 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
|
|
||||||
private FilesFilter mFilesFilter;
|
private FilesFilter mFilesFilter;
|
||||||
private OCFile currentDirectory;
|
private OCFile currentDirectory;
|
||||||
|
private boolean isSpecialFilter;
|
||||||
|
|
||||||
public FileListListAdapter(
|
public FileListListAdapter(
|
||||||
boolean justFolders,
|
boolean justFolders,
|
||||||
|
@ -300,7 +302,7 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
checkBoxV.setVisibility(View.VISIBLE);
|
checkBoxV.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this if-else is needed even though favorite icon is visible by default
|
// this if-else is needed even though kept-in-sync icon is visible by default
|
||||||
// because android reuses views in listview
|
// because android reuses views in listview
|
||||||
if (!file.isAvailableOffline()) {
|
if (!file.isAvailableOffline()) {
|
||||||
view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE);
|
view.findViewById(R.id.favoriteIcon).setVisibility(View.GONE);
|
||||||
|
@ -396,6 +398,8 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
*/
|
*/
|
||||||
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager
|
public void swapDirectory(OCFile directory, FileDataStorageManager updatedStorageManager
|
||||||
, boolean onlyOnDevice) {
|
, boolean onlyOnDevice) {
|
||||||
|
isSpecialFilter = false;
|
||||||
|
|
||||||
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
|
if (updatedStorageManager != null && !updatedStorageManager.equals(mStorageManager)) {
|
||||||
mStorageManager = updatedStorageManager;
|
mStorageManager = updatedStorageManager;
|
||||||
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||||
|
@ -422,18 +426,37 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(ArrayList<Object> objects) {
|
public void setData(ArrayList<Object> objects, ExtendedListFragment.SearchType searchType) {
|
||||||
|
isSpecialFilter = true;
|
||||||
|
|
||||||
mFiles = new Vector<>();
|
mFiles = new Vector<>();
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) objects.get(i));
|
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) objects.get(i));
|
||||||
mFiles.add(ocFile);
|
mFiles.add(ocFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mShowHiddenFiles) {
|
/*if (!mShowHiddenFiles) {
|
||||||
mFiles = filterHiddenFiles(mFiles);
|
mFiles = filterHiddenFiles(mFiles);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
mFiles = FileStorageUtils.sortOcFolder(mFiles);
|
if (searchType.equals(ExtendedListFragment.SearchType.FAVORITE_SEARCH) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.FAVORITE_SEARCH_FILTER) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH_FILTER) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.PHOTO_SEARCH) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.PHOTOS_SEARCH_FILTER) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.VIDEO_SEARCH) ||
|
||||||
|
searchType.equals(ExtendedListFragment.SearchType.VIDEO_SEARCH_FILTER)) {
|
||||||
|
Integer tempSortOrder = FileStorageUtils.mSortOrder;
|
||||||
|
Boolean tempSortAsc = FileStorageUtils.mSortAscending;
|
||||||
|
FileStorageUtils.mSortOrder = 1;
|
||||||
|
FileStorageUtils.mSortAscending = false;
|
||||||
|
mFiles = FileStorageUtils.sortOcFolder(mFiles);
|
||||||
|
FileStorageUtils.mSortOrder = tempSortOrder;
|
||||||
|
FileStorageUtils.mSortAscending = tempSortAsc;
|
||||||
|
} else {
|
||||||
|
mFiles = FileStorageUtils.sortOcFolder(mFiles);
|
||||||
|
}
|
||||||
|
|
||||||
mFilesAll = new Vector<>();
|
mFilesAll = new Vector<>();
|
||||||
mFilesAll.addAll(mFiles);
|
mFilesAll.addAll(mFiles);
|
||||||
|
@ -505,18 +528,23 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FilterResults performFiltering(CharSequence constraint) {
|
protected FilterResults performFiltering(CharSequence constraint) {
|
||||||
|
|
||||||
|
|
||||||
FilterResults results = new FilterResults();
|
FilterResults results = new FilterResults();
|
||||||
Vector<OCFile> filteredFiles = new Vector<>();
|
Vector<OCFile> filteredFiles = new Vector<>();
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(constraint)) {
|
if (!TextUtils.isEmpty(constraint)) {
|
||||||
for (int i = 0; i < mFilesAll.size(); i++) {
|
for (int i = 0; i < mFilesAll.size(); i++) {
|
||||||
OCFile currentFile = mFilesAll.get(i);
|
OCFile currentFile = mFilesAll.get(i);
|
||||||
if (currentFile.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
|
if (!isSpecialFilter) {
|
||||||
currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) &&
|
if (currentFile.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
|
||||||
!filteredFiles.contains(currentFile)) {
|
currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) &&
|
||||||
filteredFiles.add(currentFile);
|
!filteredFiles.contains(currentFile)) {
|
||||||
|
filteredFiles.add(currentFile);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) &&
|
||||||
|
!filteredFiles.contains(currentFile)) {
|
||||||
|
filteredFiles.add(currentFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
/**
|
||||||
|
* Nextcloud Android client application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017 Mario Danic
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.owncloud.android.ui.events;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hide menu items event
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ToggleMenuItemsVisibilityEvent {
|
||||||
|
public enum MenuHideType {
|
||||||
|
HIDE_LIST_GRID_SWITCH_ITEM,
|
||||||
|
HIDE_SORT_ITEM,
|
||||||
|
HIDE_SORT_AND_LG_SWITCH_ITEM
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public final MenuHideType menuHideType;
|
||||||
|
public final boolean hideMenuItems;
|
||||||
|
|
||||||
|
public ToggleMenuItemsVisibilityEvent(MenuHideType menuHideType, boolean hideMenuItems) {
|
||||||
|
this.menuHideType = menuHideType;
|
||||||
|
this.hideMenuItems = hideMenuItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHideMenuItems() {
|
||||||
|
return hideMenuItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuHideType getMenuHideType() {
|
||||||
|
return menuHideType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -52,8 +52,11 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.getbase.floatingactionbutton.FloatingActionButton;
|
import com.getbase.floatingactionbutton.FloatingActionButton;
|
||||||
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
import com.getbase.floatingactionbutton.FloatingActionsMenu;
|
||||||
|
import com.owncloud.android.MainApp;
|
||||||
import com.owncloud.android.R;
|
import com.owncloud.android.R;
|
||||||
|
import com.owncloud.android.authentication.AccountUtils;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||||
|
import com.owncloud.android.lib.resources.files.SearchOperation;
|
||||||
import com.owncloud.android.ui.ExtendedListView;
|
import com.owncloud.android.ui.ExtendedListView;
|
||||||
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
import com.owncloud.android.ui.activity.FileDisplayActivity;
|
||||||
import com.owncloud.android.ui.activity.FolderPickerActivity;
|
import com.owncloud.android.ui.activity.FolderPickerActivity;
|
||||||
|
@ -61,7 +64,9 @@ import com.owncloud.android.ui.activity.OnEnforceableRefreshListener;
|
||||||
import com.owncloud.android.ui.activity.UploadFilesActivity;
|
import com.owncloud.android.ui.activity.UploadFilesActivity;
|
||||||
import com.owncloud.android.ui.adapter.FileListListAdapter;
|
import com.owncloud.android.ui.adapter.FileListListAdapter;
|
||||||
import com.owncloud.android.ui.adapter.LocalFileListAdapter;
|
import com.owncloud.android.ui.adapter.LocalFileListAdapter;
|
||||||
|
import com.owncloud.android.ui.events.SearchEvent;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.parceler.Parcel;
|
import org.parceler.Parcel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -306,8 +311,14 @@ public class ExtendedListFragment extends Fragment
|
||||||
handler.postDelayed(new Runnable() {
|
handler.postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FileListListAdapter fileListListAdapter = (FileListListAdapter) mAdapter;
|
if (AccountUtils.hasSearchSupport(AccountUtils.
|
||||||
fileListListAdapter.getFilter().filter(query);
|
getCurrentOwnCloudAccount(MainApp.getAppContext()))) {
|
||||||
|
EventBus.getDefault().post(new SearchEvent(query, SearchOperation.SearchType.FILE_SEARCH,
|
||||||
|
SearchEvent.UnsetType.NO_UNSET));
|
||||||
|
} else {
|
||||||
|
FileListListAdapter fileListListAdapter = (FileListListAdapter) mAdapter;
|
||||||
|
fileListListAdapter.getFilter().filter(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
} else if (mAdapter != null && mAdapter instanceof LocalFileListAdapter) {
|
} else if (mAdapter != null && mAdapter instanceof LocalFileListAdapter) {
|
||||||
|
@ -444,12 +455,12 @@ public class ExtendedListFragment extends Fragment
|
||||||
* Calculates the position of the item that will be used as a reference to
|
* Calculates the position of the item that will be used as a reference to
|
||||||
* reposition the visible items in the list when the device is turned to
|
* reposition the visible items in the list when the device is turned to
|
||||||
* other position.
|
* other position.
|
||||||
*
|
* <p>
|
||||||
* The current policy is take as a reference the visible item in the center
|
* The current policy is take as a reference the visible item in the center
|
||||||
* of the screen.
|
* of the screen.
|
||||||
*
|
*
|
||||||
* @return The position in the list of the visible item in the center of the
|
* @return The position in the list of the visible item in the center of the
|
||||||
* screen.
|
* screen.
|
||||||
*/
|
*/
|
||||||
protected int getReferencePosition() {
|
protected int getReferencePosition() {
|
||||||
if (mCurrentListView != null) {
|
if (mCurrentListView != null) {
|
||||||
|
@ -549,12 +560,12 @@ public class ExtendedListFragment extends Fragment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disables swipe gesture.
|
* Disables swipe gesture.
|
||||||
*
|
* <p>
|
||||||
* Sets the 'enabled' state of the refresh layouts contained in the fragment.
|
* Sets the 'enabled' state of the refresh layouts contained in the fragment.
|
||||||
*
|
* <p>
|
||||||
* When 'false' is set, prevents user gestures but keeps the option to refresh programatically,
|
* When 'false' is set, prevents user gestures but keeps the option to refresh programatically,
|
||||||
*
|
*
|
||||||
* @param enabled Desired state for capturing swipe gesture.
|
* @param enabled Desired state for capturing swipe gesture.
|
||||||
*/
|
*/
|
||||||
public void setSwipeEnabled(boolean enabled) {
|
public void setSwipeEnabled(boolean enabled) {
|
||||||
mRefreshListLayout.setEnabled(enabled);
|
mRefreshListLayout.setEnabled(enabled);
|
||||||
|
@ -564,10 +575,10 @@ public class ExtendedListFragment extends Fragment
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the 'visibility' state of the FAB contained in the fragment.
|
* Sets the 'visibility' state of the FAB contained in the fragment.
|
||||||
*
|
* <p>
|
||||||
* When 'false' is set, FAB visibility is set to View.GONE programmatically,
|
* When 'false' is set, FAB visibility is set to View.GONE programmatically,
|
||||||
*
|
*
|
||||||
* @param enabled Desired visibility for the FAB.
|
* @param enabled Desired visibility for the FAB.
|
||||||
*/
|
*/
|
||||||
public void setFabEnabled(boolean enabled) {
|
public void setFabEnabled(boolean enabled) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
@ -593,77 +604,84 @@ public class ExtendedListFragment extends Fragment
|
||||||
* @param message the message
|
* @param message the message
|
||||||
* @param icon the icon to be shown
|
* @param icon the icon to be shown
|
||||||
*/
|
*/
|
||||||
public void setMessageForEmptyList(@StringRes int headline, @StringRes int message, @DrawableRes int icon) {
|
public void setMessageForEmptyList(@StringRes final int headline, @StringRes final int message, @DrawableRes final int icon) {
|
||||||
if (mEmptyListContainer != null && mEmptyListMessage != null) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
mEmptyListHeadline.setText(headline);
|
@Override
|
||||||
mEmptyListMessage.setText(message);
|
public void run() {
|
||||||
mEmptyListIcon.setImageResource(icon);
|
|
||||||
|
if (mEmptyListContainer != null && mEmptyListMessage != null) {
|
||||||
|
mEmptyListHeadline.setText(headline);
|
||||||
|
mEmptyListMessage.setText(message);
|
||||||
|
mEmptyListIcon.setImageResource(icon);
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mEmptyListIcon.setVisibility(View.VISIBLE);
|
mEmptyListIcon.setVisibility(View.VISIBLE);
|
||||||
mEmptyListProgress.setVisibility(View.GONE);
|
mEmptyListProgress.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmptyListMessage(SearchType searchType) {
|
public void setEmptyListMessage(final SearchType searchType) {
|
||||||
if (searchType == NO_SEARCH) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
setMessageForEmptyList(
|
@Override
|
||||||
R.string.file_list_empty_headline,
|
public void run() {
|
||||||
R.string.file_list_empty,
|
|
||||||
R.drawable.ic_list_empty_folder
|
|
||||||
);
|
|
||||||
} else if (searchType == FILE_SEARCH) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
|
||||||
R.string.file_list_empty, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == FAVORITE_SEARCH) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
|
||||||
R.string.file_list_empty_favorites, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == VIDEO_SEARCH) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search_videos,
|
|
||||||
R.string.file_list_empty_text_videos, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == PHOTO_SEARCH) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search_photos,
|
|
||||||
R.string.file_list_empty_text_photos, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == RECENTLY_MODIFIED_SEARCH) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
|
||||||
R.string.file_list_empty_recently_modified, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == RECENTLY_ADDED_SEARCH) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
|
||||||
R.string.file_list_empty_recently_added, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == REGULAR_FILTER) {
|
|
||||||
setMessageForEmptyList(R.string.file_list_empty_headline_search,
|
|
||||||
R.string.file_list_empty_search, R.drawable.ic_search_light_grey);
|
|
||||||
} else if (searchType == FAVORITE_SEARCH_FILTER) {
|
|
||||||
|
|
||||||
} else if (searchType == VIDEO_SEARCH_FILTER) {
|
if (searchType == NO_SEARCH) {
|
||||||
|
setMessageForEmptyList(
|
||||||
|
R.string.file_list_empty_headline,
|
||||||
|
R.string.file_list_empty,
|
||||||
|
R.drawable.ic_list_empty_folder
|
||||||
|
);
|
||||||
|
} else if (searchType == FILE_SEARCH) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
||||||
|
R.string.file_list_empty, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == FAVORITE_SEARCH) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
||||||
|
R.string.file_list_empty_favorites, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == VIDEO_SEARCH) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_server_search_videos,
|
||||||
|
R.string.file_list_empty_text_videos, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == PHOTO_SEARCH) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_server_search_photos,
|
||||||
|
R.string.file_list_empty_text_photos, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == RECENTLY_MODIFIED_SEARCH) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
||||||
|
R.string.file_list_empty_recently_modified, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == RECENTLY_ADDED_SEARCH) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
|
||||||
|
R.string.file_list_empty_recently_added, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == REGULAR_FILTER) {
|
||||||
|
setMessageForEmptyList(R.string.file_list_empty_headline_search,
|
||||||
|
R.string.file_list_empty_search, R.drawable.ic_search_light_grey);
|
||||||
|
} else if (searchType == FAVORITE_SEARCH_FILTER) {
|
||||||
|
|
||||||
} else if (searchType == RECENTLY_MODIFIED_SEARCH_FILTER) {
|
} else if (searchType == VIDEO_SEARCH_FILTER) {
|
||||||
|
|
||||||
} else if (searchType == RECENTLY_ADDED_SEARCH_FILTER) {
|
} else if (searchType == RECENTLY_MODIFIED_SEARCH_FILTER) {
|
||||||
|
|
||||||
}
|
} else if (searchType == RECENTLY_ADDED_SEARCH_FILTER) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set message for empty list view.
|
* Set message for empty list view.
|
||||||
*/
|
*/
|
||||||
public void setEmptyListLoadingMessage() {
|
public void setEmptyListLoadingMessage() {
|
||||||
if (mEmptyListContainer != null && mEmptyListMessage != null) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
mEmptyListHeadline.setText(R.string.file_list_loading);
|
@Override
|
||||||
mEmptyListMessage.setText("");
|
public void run() {
|
||||||
|
if (mEmptyListContainer != null && mEmptyListMessage != null) {
|
||||||
|
mEmptyListHeadline.setText(R.string.file_list_loading);
|
||||||
|
mEmptyListMessage.setText("");
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mEmptyListIcon.setVisibility(View.GONE);
|
mEmptyListIcon.setVisibility(View.GONE);
|
||||||
mEmptyListProgress.setVisibility(View.VISIBLE);
|
mEmptyListProgress.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -77,6 +77,7 @@ import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
|
||||||
import com.owncloud.android.ui.events.DummyDrawerEvent;
|
import com.owncloud.android.ui.events.DummyDrawerEvent;
|
||||||
import com.owncloud.android.ui.events.MenuItemClickEvent;
|
import com.owncloud.android.ui.events.MenuItemClickEvent;
|
||||||
import com.owncloud.android.ui.events.SearchEvent;
|
import com.owncloud.android.ui.events.SearchEvent;
|
||||||
|
import com.owncloud.android.ui.events.ToggleMenuItemsVisibilityEvent;
|
||||||
import com.owncloud.android.ui.helpers.SparseBooleanArrayParcelable;
|
import com.owncloud.android.ui.helpers.SparseBooleanArrayParcelable;
|
||||||
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
import com.owncloud.android.ui.interfaces.OCFileListFragmentInterface;
|
||||||
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||||
|
@ -97,7 +98,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Fragment that lists all files and folders in a given path.
|
* A Fragment that lists all files and folders in a given path.
|
||||||
*
|
* <p>
|
||||||
* TODO refactor to get rid of direct dependency on FileDisplayActivity
|
* TODO refactor to get rid of direct dependency on FileDisplayActivity
|
||||||
*/
|
*/
|
||||||
public class OCFileListFragment extends ExtendedListFragment implements OCFileListFragmentInterface {
|
public class OCFileListFragment extends ExtendedListFragment implements OCFileListFragmentInterface {
|
||||||
|
@ -407,8 +408,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
/**
|
/**
|
||||||
* records a click on a mini FAB and thus:
|
* records a click on a mini FAB and thus:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>persists the click fact</li>
|
* <li>persists the click fact</li>
|
||||||
* <li>removes the mini FAB labels</li>
|
* <li>removes the mini FAB labels</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
private void recordMiniFabClick() {
|
private void recordMiniFabClick() {
|
||||||
|
@ -442,9 +443,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for multiple selection mode.
|
* Handler for multiple selection mode.
|
||||||
*
|
* <p>
|
||||||
* Manages input from the user when one or more files or folders are selected in the list.
|
* Manages input from the user when one or more files or folders are selected in the list.
|
||||||
*
|
* <p>
|
||||||
* Also listens to changes in navigation drawer to hide and recover multiple selection when it's opened
|
* Also listens to changes in navigation drawer to hide and recover multiple selection when it's opened
|
||||||
* and closed.
|
* and closed.
|
||||||
*/
|
*/
|
||||||
|
@ -478,7 +479,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
* When the navigation drawer is closed, action mode is recovered in the same state as was
|
* When the navigation drawer is closed, action mode is recovered in the same state as was
|
||||||
* when the drawer was (started to be) opened.
|
* when the drawer was (started to be) opened.
|
||||||
*
|
*
|
||||||
* @param drawerView Navigation drawer just closed.
|
* @param drawerView Navigation drawer just closed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerClosed(View drawerView) {
|
public void onDrawerClosed(View drawerView) {
|
||||||
|
@ -499,7 +500,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
* If the action mode is active when the navigation drawer starts to move, the action
|
* If the action mode is active when the navigation drawer starts to move, the action
|
||||||
* mode is closed and the selection stored to be recovered when the drawer is closed.
|
* mode is closed and the selection stored to be recovered when the drawer is closed.
|
||||||
*
|
*
|
||||||
* @param newState One of STATE_IDLE, STATE_DRAGGING or STATE_SETTLING.
|
* @param newState One of STATE_IDLE, STATE_DRAGGING or STATE_SETTLING.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDrawerStateChanged(int newState) {
|
public void onDrawerStateChanged(int newState) {
|
||||||
|
@ -644,7 +645,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call this, when the user presses the up button.
|
* Call this, when the user presses the up button.
|
||||||
*
|
* <p>
|
||||||
* Tries to move up the current folder one level. If the parent folder was removed from the
|
* Tries to move up the current folder one level. If the parent folder was removed from the
|
||||||
* database, it continues browsing up until finding an existing folders.
|
* database, it continues browsing up until finding an existing folders.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -730,8 +731,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
/**
|
/**
|
||||||
* Start the appropriate action(s) on the currently selected files given menu selected by the user.
|
* Start the appropriate action(s) on the currently selected files given menu selected by the user.
|
||||||
*
|
*
|
||||||
* @param menuId Identifier of the action menu selected by the user
|
* @param menuId Identifier of the action menu selected by the user
|
||||||
* @return 'true' if the menu selection started any action, 'false' otherwise.
|
* @return 'true' if the menu selection started any action, 'false' otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean onFileActionChosen(int menuId) {
|
public boolean onFileActionChosen(int menuId) {
|
||||||
final ArrayList<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
|
final ArrayList<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
|
||||||
|
@ -998,8 +999,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
/**
|
/**
|
||||||
* Determines if user set folder to grid or list view. If folder is not set itself,
|
* Determines if user set folder to grid or list view. If folder is not set itself,
|
||||||
* it finds a parent that is set (at least root is set).
|
* it finds a parent that is set (at least root is set).
|
||||||
* @param file Folder to check.
|
*
|
||||||
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
|
* @param file Folder to check.
|
||||||
|
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
|
||||||
*/
|
*/
|
||||||
public boolean isGridViewPreferred(OCFile file) {
|
public boolean isGridViewPreferred(OCFile file) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
@ -1106,6 +1108,39 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
unsetAllMenuItems(true);
|
unsetAllMenuItems(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
|
||||||
|
setEmptyListMessage(SearchType.FILE_SEARCH);
|
||||||
|
currentSearchType = SearchType.FILE_SEARCH;
|
||||||
|
} else if (event.getSearchType().equals(SearchOperation.SearchType.CONTENT_TYPE_SEARCH)) {
|
||||||
|
if (event.getSearchQuery().equals("image/%")) {
|
||||||
|
setEmptyListMessage(SearchType.PHOTO_SEARCH);
|
||||||
|
currentSearchType = SearchType.PHOTO_SEARCH;
|
||||||
|
} else if (event.getSearchQuery().equals("video/%")) {
|
||||||
|
setEmptyListMessage(SearchType.VIDEO_SEARCH);
|
||||||
|
currentSearchType = SearchType.VIDEO_SEARCH;
|
||||||
|
}
|
||||||
|
} else if (event.getSearchType().equals(SearchOperation.SearchType.FAVORITE_SEARCH)) {
|
||||||
|
setEmptyListMessage(SearchType.FAVORITE_SEARCH);
|
||||||
|
currentSearchType = SearchType.FAVORITE_SEARCH;
|
||||||
|
} else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_ADDED_SEARCH)) {
|
||||||
|
setEmptyListMessage(SearchType.RECENTLY_ADDED_SEARCH);
|
||||||
|
currentSearchType = SearchType.RECENTLY_ADDED_SEARCH;
|
||||||
|
} else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH)) {
|
||||||
|
setEmptyListMessage(SearchType.RECENTLY_MODIFIED_SEARCH);
|
||||||
|
currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Runnable switchViewsRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (isGridViewPreferred(mFile) && !isGridEnabled()) {
|
||||||
|
switchToGridView();
|
||||||
|
} else if (!isGridViewPreferred(mFile) && isGridEnabled()) {
|
||||||
|
switchToListView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Account currentAccount = com.owncloud.android.authentication.AccountUtils.
|
Account currentAccount = com.owncloud.android.authentication.AccountUtils.
|
||||||
getCurrentOwnCloudAccount(MainApp.getAppContext());
|
getCurrentOwnCloudAccount(MainApp.getAppContext());
|
||||||
|
@ -1120,33 +1155,33 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
getClientFor(ocAccount, MainApp.getAppContext());
|
getClientFor(ocAccount, MainApp.getAppContext());
|
||||||
SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
|
SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
|
||||||
RemoteOperationResult remoteOperationResult = operation.execute(mClient);
|
RemoteOperationResult remoteOperationResult = operation.execute(mClient);
|
||||||
if (remoteOperationResult.isSuccess() || remoteOperationResult.getData() != null) {
|
if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
|
||||||
|
|
||||||
if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
|
|
||||||
setEmptyListMessage(SearchType.FILE_SEARCH);
|
|
||||||
currentSearchType = SearchType.FILE_SEARCH;
|
|
||||||
} else if (event.getSearchType().equals(SearchOperation.SearchType.CONTENT_TYPE_SEARCH)) {
|
|
||||||
if (event.getSearchQuery().equals("image/%")) {
|
|
||||||
setEmptyListMessage(SearchType.PHOTO_SEARCH);
|
|
||||||
currentSearchType = SearchType.PHOTO_SEARCH;
|
|
||||||
} else if (event.getSearchQuery().equals("video/%")) {
|
|
||||||
setEmptyListMessage(SearchType.VIDEO_SEARCH);
|
|
||||||
currentSearchType = SearchType.VIDEO_SEARCH;
|
|
||||||
}
|
|
||||||
} else if (event.getSearchType().equals(SearchOperation.SearchType.FAVORITE_SEARCH)) {
|
|
||||||
setEmptyListMessage(SearchType.FAVORITE_SEARCH);
|
|
||||||
currentSearchType = SearchType.FAVORITE_SEARCH;
|
|
||||||
} else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_ADDED_SEARCH)) {
|
|
||||||
setEmptyListMessage(SearchType.RECENTLY_ADDED_SEARCH);
|
|
||||||
currentSearchType = SearchType.RECENTLY_ADDED_SEARCH;
|
|
||||||
} else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH)) {
|
|
||||||
setEmptyListMessage(SearchType.RECENTLY_MODIFIED_SEARCH);
|
|
||||||
currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
mAdapter.setData(remoteOperationResult.getData());
|
|
||||||
|
|
||||||
|
mAdapter.setData(remoteOperationResult.getData(), currentSearchType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentSearchType.equals(SearchType.PHOTO_SEARCH)) {
|
||||||
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
switchToGridView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
EventBus.getDefault().post(new ToggleMenuItemsVisibilityEvent(
|
||||||
|
ToggleMenuItemsVisibilityEvent.MenuHideType.HIDE_SORT_AND_LG_SWITCH_ITEM, true));
|
||||||
|
} else if (currentSearchType.equals(SearchType.NO_SEARCH) || currentSearchType.equals(
|
||||||
|
SearchType.REGULAR_FILTER)) {
|
||||||
|
EventBus.getDefault().post(new ToggleMenuItemsVisibilityEvent(
|
||||||
|
ToggleMenuItemsVisibilityEvent.MenuHideType.HIDE_SORT_AND_LG_SWITCH_ITEM, false));
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
|
||||||
|
} else {
|
||||||
|
EventBus.getDefault().post(new ToggleMenuItemsVisibilityEvent(
|
||||||
|
ToggleMenuItemsVisibilityEvent.MenuHideType.HIDE_SORT_ITEM, true));
|
||||||
|
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (AuthenticatorException e) {
|
} catch (AuthenticatorException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
||||||
|
|
Loading…
Reference in a new issue