Progress on number of things

This commit is contained in:
Mario Danic 2017-03-13 01:01:11 +01:00 committed by AndyScherzinger
parent 9f94104eed
commit 3a3c4767fd
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
5 changed files with 329 additions and 145 deletions

View file

@ -5,16 +5,16 @@
* @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/>.
*/ */
@ -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");
@ -580,13 +589,58 @@ public class FileDisplayActivity extends HookActivity
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);
@ -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?

View 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);
} }*/
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); 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,19 +528,24 @@ 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 (!isSpecialFilter) {
if (currentFile.getParentRemotePath().equals(currentDirectory.getRemotePath()) && if (currentFile.getParentRemotePath().equals(currentDirectory.getRemotePath()) &&
currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) && currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) &&
!filteredFiles.contains(currentFile)) { !filteredFiles.contains(currentFile)) {
filteredFiles.add(currentFile); filteredFiles.add(currentFile);
} }
} else {
if (currentFile.getFileName().toLowerCase().contains(constraint.toString().toLowerCase()) &&
!filteredFiles.contains(currentFile)) {
filteredFiles.add(currentFile);
}
}
} }
} }

View file

@ -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;
}
}

View file

@ -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,9 +311,15 @@ public class ExtendedListFragment extends Fragment
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if (AccountUtils.hasSearchSupport(AccountUtils.
getCurrentOwnCloudAccount(MainApp.getAppContext()))) {
EventBus.getDefault().post(new SearchEvent(query, SearchOperation.SearchType.FILE_SEARCH,
SearchEvent.UnsetType.NO_UNSET));
} else {
FileListListAdapter fileListListAdapter = (FileListListAdapter) mAdapter; FileListListAdapter fileListListAdapter = (FileListListAdapter) mAdapter;
fileListListAdapter.getFilter().filter(query); fileListListAdapter.getFilter().filter(query);
} }
}
}, delay); }, delay);
} else if (mAdapter != null && mAdapter instanceof LocalFileListAdapter) { } else if (mAdapter != null && mAdapter instanceof LocalFileListAdapter) {
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@ -444,7 +455,7 @@ 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.
* *
@ -549,9 +560,9 @@ 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.
@ -564,7 +575,7 @@ 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.
@ -593,23 +604,28 @@ 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) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (mEmptyListContainer != null && mEmptyListMessage != null) { if (mEmptyListContainer != null && mEmptyListMessage != null) {
mEmptyListHeadline.setText(headline); mEmptyListHeadline.setText(headline);
mEmptyListMessage.setText(message); mEmptyListMessage.setText(message);
mEmptyListIcon.setImageResource(icon); 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) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (searchType == NO_SEARCH) { if (searchType == NO_SEARCH) {
setMessageForEmptyList( setMessageForEmptyList(
R.string.file_list_empty_headline, R.string.file_list_empty_headline,
@ -647,23 +663,25 @@ public class ExtendedListFragment extends Fragment
} }
} }
});
}
/** /**
* Set message for empty list view. * Set message for empty list view.
*/ */
public void setEmptyListLoadingMessage() { public void setEmptyListLoadingMessage() {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (mEmptyListContainer != null && mEmptyListMessage != null) { if (mEmptyListContainer != null && mEmptyListMessage != null) {
mEmptyListHeadline.setText(R.string.file_list_loading); mEmptyListHeadline.setText(R.string.file_list_loading);
mEmptyListMessage.setText(""); 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);
} }
});
} }
});
} }
/** /**

View file

@ -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 {
@ -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.
*/ */
@ -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/>
@ -998,6 +999,7 @@ 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. * @param file Folder to check.
* @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred. * @return 'true' is folder should be shown in grid mode, 'false' if list mode is preferred.
*/ */
@ -1106,22 +1108,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
unsetAllMenuItems(true); unsetAllMenuItems(true);
} }
Account currentAccount = com.owncloud.android.authentication.AccountUtils.
getCurrentOwnCloudAccount(MainApp.getAppContext());
try {
OwnCloudAccount ocAccount = new OwnCloudAccount(
currentAccount,
MainApp.getAppContext()
);
OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
RemoteOperationResult remoteOperationResult = operation.execute(mClient);
if (remoteOperationResult.isSuccess() || remoteOperationResult.getData() != null) {
if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) { if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
setEmptyListMessage(SearchType.FILE_SEARCH); setEmptyListMessage(SearchType.FILE_SEARCH);
currentSearchType = SearchType.FILE_SEARCH; currentSearchType = SearchType.FILE_SEARCH;
@ -1144,9 +1130,58 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH; currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
} }
mAdapter.setData(remoteOperationResult.getData());
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.
getCurrentOwnCloudAccount(MainApp.getAppContext());
try {
OwnCloudAccount ocAccount = new OwnCloudAccount(
currentAccount,
MainApp.getAppContext()
);
OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
RemoteOperationResult remoteOperationResult = operation.execute(mClient);
if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
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) {