mirror of
https://github.com/nextcloud/android.git
synced 2024-10-22 20:16:02 +03:00
commit
0677d536c0
5 changed files with 198 additions and 126 deletions
|
@ -60,11 +60,13 @@ import com.owncloud.android.ui.events.ChangeMenuEvent;
|
||||||
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.fragment.OCFileListFragment;
|
||||||
import com.owncloud.android.utils.DisplayUtils;
|
import com.owncloud.android.utils.DisplayUtils;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
import org.greenrobot.eventbus.ThreadMode;
|
||||||
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class to handle setup of the drawer implementation including user switching and avatar fetching and fallback
|
* Base class to handle setup of the drawer implementation including user switching and avatar fetching and fallback
|
||||||
|
@ -382,12 +384,16 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
case R.id.nav_favorites:
|
case R.id.nav_favorites:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
mCheckedMenuItem = menuItem.getItemId();
|
mCheckedMenuItem = menuItem.getItemId();
|
||||||
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
|
||||||
SearchEvent.UnsetType.NO_UNSET));
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
||||||
|
SearchEvent.UnsetType.NO_UNSET), menuItem);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_photos:
|
case R.id.nav_photos:
|
||||||
EventBus.getDefault().post(new SearchEvent("image/%",
|
menuItem.setChecked(true);
|
||||||
SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.NO_UNSET));
|
mCheckedMenuItem = menuItem.getItemId();
|
||||||
|
|
||||||
|
switchToSearchFragment(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||||
|
SearchEvent.UnsetType.NO_UNSET), menuItem);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_on_device:
|
case R.id.nav_on_device:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
|
@ -429,26 +435,30 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
case R.id.nav_recently_added:
|
case R.id.nav_recently_added:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
mCheckedMenuItem = menuItem.getItemId();
|
mCheckedMenuItem = menuItem.getItemId();
|
||||||
EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
||||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
switchToSearchFragment(new SearchEvent("%",SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||||
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_recently_modified:
|
case R.id.nav_recently_modified:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
mCheckedMenuItem = menuItem.getItemId();
|
mCheckedMenuItem = menuItem.getItemId();
|
||||||
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
|
||||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
||||||
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_shared:
|
case R.id.nav_shared:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
mCheckedMenuItem = menuItem.getItemId();
|
mCheckedMenuItem = menuItem.getItemId();
|
||||||
EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
|
||||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
switchToSearchFragment(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
||||||
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
||||||
break;
|
break;
|
||||||
case R.id.nav_videos:
|
case R.id.nav_videos:
|
||||||
menuItem.setChecked(true);
|
menuItem.setChecked(true);
|
||||||
mCheckedMenuItem = menuItem.getItemId();
|
mCheckedMenuItem = menuItem.getItemId();
|
||||||
EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
||||||
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
switchToSearchFragment(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
||||||
|
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem);
|
||||||
break;
|
break;
|
||||||
case Menu.NONE:
|
case Menu.NONE:
|
||||||
// account clicked
|
// account clicked
|
||||||
|
@ -458,6 +468,14 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void switchToSearchFragment(SearchEvent event, MenuItem menuItem) {
|
||||||
|
Intent recentlyAddedIntent = new Intent(getBaseContext(), FileDisplayActivity.class);
|
||||||
|
recentlyAddedIntent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(event));
|
||||||
|
recentlyAddedIntent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
||||||
|
recentlyAddedIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(recentlyAddedIntent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show the file list to the user.
|
* show the file list to the user.
|
||||||
*
|
*
|
||||||
|
|
|
@ -131,6 +131,8 @@ public class FileDisplayActivity extends HookActivity
|
||||||
|
|
||||||
public static final String ACTION_DETAILS = "com.owncloud.android.ui.activity.action.DETAILS";
|
public static final String ACTION_DETAILS = "com.owncloud.android.ui.activity.action.DETAILS";
|
||||||
|
|
||||||
|
public static final String DRAWER_MENU_ID = "DRAWER_MENU_ID";
|
||||||
|
|
||||||
public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1;
|
public static final int REQUEST_CODE__SELECT_CONTENT_FROM_APPS = REQUEST_CODE__LAST_SHARED + 1;
|
||||||
public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2;
|
public static final int REQUEST_CODE__SELECT_FILES_FROM_FILE_SYSTEM = REQUEST_CODE__LAST_SHARED + 2;
|
||||||
public static final int REQUEST_CODE__MOVE_FILES = REQUEST_CODE__LAST_SHARED + 3;
|
public static final int REQUEST_CODE__MOVE_FILES = REQUEST_CODE__LAST_SHARED + 3;
|
||||||
|
@ -170,10 +172,10 @@ public class FileDisplayActivity extends HookActivity
|
||||||
|
|
||||||
/// Load of saved instance state
|
/// Load of saved instance state
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(
|
mWaitingToPreview = savedInstanceState.getParcelable(
|
||||||
FileDisplayActivity.KEY_WAITING_TO_PREVIEW);
|
FileDisplayActivity.KEY_WAITING_TO_PREVIEW);
|
||||||
mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
|
mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
|
||||||
mWaitingToSend = (OCFile) savedInstanceState.getParcelable(
|
mWaitingToSend = savedInstanceState.getParcelable(
|
||||||
FileDisplayActivity.KEY_WAITING_TO_SEND);
|
FileDisplayActivity.KEY_WAITING_TO_SEND);
|
||||||
searchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
|
searchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
|
||||||
} else {
|
} else {
|
||||||
|
@ -245,11 +247,17 @@ public class FileDisplayActivity extends HookActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (getIntent().getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null){
|
||||||
createMinFragments();
|
switchToSearchFragment();
|
||||||
}
|
|
||||||
|
|
||||||
refreshList(true);
|
int menuId = getIntent().getIntExtra(DRAWER_MENU_ID, -1);
|
||||||
|
if (menuId != -1){
|
||||||
|
setupDrawer(menuId);
|
||||||
|
}
|
||||||
|
} else if (savedInstanceState == null) {
|
||||||
|
createMinFragments();
|
||||||
|
refreshList(true);
|
||||||
|
}
|
||||||
|
|
||||||
setIndeterminate(mSyncInProgress);
|
setIndeterminate(mSyncInProgress);
|
||||||
// always AFTER setContentView(...) in onCreate(); to work around bug in its implementation
|
// always AFTER setContentView(...) in onCreate(); to work around bug in its implementation
|
||||||
|
@ -377,6 +385,19 @@ public class FileDisplayActivity extends HookActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void switchToSearchFragment() {
|
||||||
|
OCFileListFragment listOfFiles = new OCFileListFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
|
args.putParcelable(OCFileListFragment.SEARCH_EVENT,
|
||||||
|
getIntent().getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
|
||||||
|
|
||||||
|
listOfFiles.setArguments(args);
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
transaction.add(R.id.left_fragment_container, listOfFiles, TAG_LIST_OF_FILES);
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
|
||||||
private void createMinFragments() {
|
private void createMinFragments() {
|
||||||
OCFileListFragment listOfFiles = new OCFileListFragment();
|
OCFileListFragment listOfFiles = new OCFileListFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|
|
@ -109,6 +109,17 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
new ThumbnailsCacheManager.InitDiskCacheTask().execute();
|
new ThumbnailsCacheManager.InitDiskCacheTask().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileListListAdapter(
|
||||||
|
boolean justFolders,
|
||||||
|
Context context,
|
||||||
|
ComponentsGetter transferServiceGetter,
|
||||||
|
OCFileListFragmentInterface OCFileListFragmentInterface,
|
||||||
|
FileDataStorageManager fileDataStorageManager
|
||||||
|
) {
|
||||||
|
this(justFolders, context, transferServiceGetter, OCFileListFragmentInterface);
|
||||||
|
mStorageManager = fileDataStorageManager;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areAllItemsEnabled() {
|
public boolean areAllItemsEnabled() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -467,21 +478,24 @@ public class FileListListAdapter extends BaseAdapter {
|
||||||
if (searchType.equals(ExtendedListFragment.SearchType.SHARED_FILTER)) {
|
if (searchType.equals(ExtendedListFragment.SearchType.SHARED_FILTER)) {
|
||||||
ArrayList<OCShare> shares = new ArrayList<>();
|
ArrayList<OCShare> shares = new ArrayList<>();
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
shares.add((OCShare) objects.get(i));
|
// check type before cast as of long running data fetch it is possible that old result is filled
|
||||||
|
if (objects.get(i) instanceof OCShare) {
|
||||||
|
OCShare ocShare = (OCShare) objects.get(i);
|
||||||
|
|
||||||
|
shares.add(ocShare);
|
||||||
|
|
||||||
|
OCFile ocFile = mStorageManager.getFileByPath(ocShare.getPath());
|
||||||
|
if (!mFiles.contains(ocFile)) {
|
||||||
|
mFiles.add(ocFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mStorageManager.saveShares(shares);
|
mStorageManager.saveShares(shares);
|
||||||
}
|
} else {
|
||||||
for (int i = 0; i < objects.size(); i++) {
|
for (int i = 0; i < objects.size(); i++) {
|
||||||
if (!searchType.equals(ExtendedListFragment.SearchType.SHARED_FILTER)) {
|
|
||||||
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) objects.get(i));
|
OCFile ocFile = FileStorageUtils.fillOCFile((RemoteFile) objects.get(i));
|
||||||
searchForLocalFileInDefaultPath(ocFile);
|
searchForLocalFileInDefaultPath(ocFile);
|
||||||
mFiles.add(ocFile);
|
mFiles.add(ocFile);
|
||||||
} else {
|
|
||||||
OCShare ocShare = (OCShare) objects.get(i);
|
|
||||||
OCFile ocFile = mStorageManager.getFileByPath(ocShare.getPath());
|
|
||||||
if (!mFiles.contains(ocFile)) {
|
|
||||||
mFiles.add(ocFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,20 +21,27 @@ package com.owncloud.android.ui.events;
|
||||||
|
|
||||||
import com.owncloud.android.lib.resources.files.SearchOperation;
|
import com.owncloud.android.lib.resources.files.SearchOperation;
|
||||||
|
|
||||||
|
import org.parceler.Parcel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search event
|
* Search event
|
||||||
*/
|
*/
|
||||||
|
@Parcel
|
||||||
public class SearchEvent {
|
public class SearchEvent {
|
||||||
public final String searchQuery;
|
public String searchQuery;
|
||||||
|
|
||||||
public final SearchOperation.SearchType searchType;
|
public SearchOperation.SearchType searchType;
|
||||||
|
|
||||||
public final UnsetType unsetType;
|
public UnsetType unsetType;
|
||||||
|
|
||||||
public enum UnsetType {
|
public enum UnsetType {
|
||||||
NO_UNSET,
|
NO_UNSET,
|
||||||
UNSET_DRAWER,
|
UNSET_DRAWER,
|
||||||
UNSET_BOTTOM_NAV_BAR;
|
UNSET_BOTTOM_NAV_BAR
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchEvent() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchEvent(String searchQuery, SearchOperation.SearchType searchType, UnsetType unsetType) {
|
public SearchEvent(String searchQuery, SearchOperation.SearchType searchType, UnsetType unsetType) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -61,6 +62,7 @@ import com.owncloud.android.files.FileMenuFilter;
|
||||||
import com.owncloud.android.lib.common.OwnCloudAccount;
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClient;
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
||||||
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
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.lib.resources.files.SearchOperation;
|
||||||
|
@ -116,6 +118,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL";
|
public final static String ARG_ALLOW_CONTEXTUAL_ACTIONS = MY_PACKAGE + ".ALLOW_CONTEXTUAL";
|
||||||
public final static String ARG_HIDE_FAB = MY_PACKAGE + ".HIDE_FAB";
|
public final static String ARG_HIDE_FAB = MY_PACKAGE + ".HIDE_FAB";
|
||||||
|
|
||||||
|
public static final String SEARCH_EVENT = "SEARCH_EVENT";
|
||||||
|
|
||||||
private static final String KEY_FILE = MY_PACKAGE + ".extra.FILE";
|
private static final String KEY_FILE = MY_PACKAGE + ".extra.FILE";
|
||||||
private static final String KEY_FAB_EVER_CLICKED = "FAB_EVER_CLICKED";
|
private static final String KEY_FAB_EVER_CLICKED = "FAB_EVER_CLICKED";
|
||||||
|
|
||||||
|
@ -146,6 +150,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
private BottomNavigationView bottomNavigationView;
|
private BottomNavigationView bottomNavigationView;
|
||||||
|
|
||||||
private SearchType currentSearchType;
|
private SearchType currentSearchType;
|
||||||
|
private boolean searchFragment = false;
|
||||||
|
|
||||||
private enum MenuItemAddRemove {
|
private enum MenuItemAddRemove {
|
||||||
DO_NOTHING, REMOVE_SORT, REMOVE_GRID_AND_SORT, ADD_SORT, ADD_GRID_AND_SORT, ADD_GRID_AND_SORT_WITH_SEARCH,
|
DO_NOTHING, REMOVE_SORT, REMOVE_GRID_AND_SORT, ADD_SORT, ADD_GRID_AND_SORT, ADD_GRID_AND_SORT_WITH_SEARCH,
|
||||||
|
@ -310,7 +315,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
mJustFolders,
|
mJustFolders,
|
||||||
getActivity(),
|
getActivity(),
|
||||||
mContainerActivity,
|
mContainerActivity,
|
||||||
this
|
this,
|
||||||
|
mContainerActivity.getStorageManager()
|
||||||
);
|
);
|
||||||
setListAdapter(mAdapter);
|
setListAdapter(mAdapter);
|
||||||
|
|
||||||
|
@ -334,6 +340,11 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
removeFabLabels();
|
removeFabLabels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SearchEvent searchEvent = Parcels.unwrap(getArguments().getParcelable(OCFileListFragment.SEARCH_EVENT));
|
||||||
|
if (searchEvent != null){
|
||||||
|
onMessageEvent(searchEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -940,6 +951,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshDirectory() {
|
public void refreshDirectory() {
|
||||||
|
searchFragment = false;
|
||||||
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
|
listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,56 +963,58 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
* @param directory File to be listed
|
* @param directory File to be listed
|
||||||
*/
|
*/
|
||||||
public void listDirectory(OCFile directory, boolean onlyOnDevice, boolean fromSearch) {
|
public void listDirectory(OCFile directory, boolean onlyOnDevice, boolean fromSearch) {
|
||||||
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
|
if (!searchFragment) {
|
||||||
if (storageManager != null) {
|
FileDataStorageManager storageManager = mContainerActivity.getStorageManager();
|
||||||
|
if (storageManager != null) {
|
||||||
|
|
||||||
// Check input parameters for null
|
// Check input parameters for null
|
||||||
if (directory == null) {
|
if (directory == null) {
|
||||||
if (mFile != null) {
|
if (mFile != null) {
|
||||||
directory = mFile;
|
directory = mFile;
|
||||||
} else {
|
} else {
|
||||||
directory = storageManager.getFileByPath("/");
|
directory = storageManager.getFileByPath("/");
|
||||||
if (directory == null) {
|
if (directory == null) {
|
||||||
return; // no files, wait for sync
|
return; // no files, wait for sync
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// If that's not a directory -> List its parent
|
// If that's not a directory -> List its parent
|
||||||
if (!directory.isFolder()) {
|
if (!directory.isFolder()) {
|
||||||
Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString());
|
Log_OC.w(TAG, "You see, that is not a directory -> " + directory.toString());
|
||||||
directory = storageManager.getFileById(directory.getParentId());
|
directory = storageManager.getFileById(directory.getParentId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (searchView != null && !searchView.isIconified() && !fromSearch) {
|
if (searchView != null && !searchView.isIconified() && !fromSearch) {
|
||||||
|
|
||||||
searchView.post(new Runnable() {
|
searchView.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
searchView.setQuery("", false);
|
searchView.setQuery("", false);
|
||||||
searchView.onActionViewCollapsed();
|
searchView.onActionViewCollapsed();
|
||||||
Activity activity;
|
Activity activity;
|
||||||
if ((activity = getActivity()) != null && activity instanceof FileDisplayActivity) {
|
if ((activity = getActivity()) != null && activity instanceof FileDisplayActivity) {
|
||||||
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
|
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
|
||||||
if (getCurrentFile() != null) {
|
if (getCurrentFile() != null) {
|
||||||
fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isRoot(getCurrentFile()));
|
fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isRoot(getCurrentFile()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
mAdapter.swapDirectory(directory, storageManager, onlyOnDevice);
|
||||||
|
if (mFile == null || !mFile.equals(directory)) {
|
||||||
|
mCurrentListView.setSelection(0);
|
||||||
|
}
|
||||||
|
mFile = directory;
|
||||||
|
|
||||||
|
updateLayout();
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mAdapter.swapDirectory(directory, storageManager, onlyOnDevice);
|
|
||||||
if (mFile == null || !mFile.equals(directory)) {
|
|
||||||
mCurrentListView.setSelection(0);
|
|
||||||
}
|
|
||||||
mFile = directory;
|
|
||||||
|
|
||||||
updateLayout();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1047,42 +1061,46 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateFooterText(int filesCount, int foldersCount) {
|
private String generateFooterText(int filesCount, int foldersCount) {
|
||||||
String output;
|
String output = "";
|
||||||
if (filesCount <= 0) {
|
|
||||||
if (foldersCount <= 0) {
|
|
||||||
output = "";
|
|
||||||
|
|
||||||
} else if (foldersCount == 1) {
|
if (getActivity() != null) {
|
||||||
output = getResources().getString(R.string.file_list__footer__folder);
|
if (filesCount <= 0) {
|
||||||
|
if (foldersCount <= 0) {
|
||||||
|
output = "";
|
||||||
|
|
||||||
} else { // foldersCount > 1
|
} else if (foldersCount == 1) {
|
||||||
output = getResources().getString(R.string.file_list__footer__folders, foldersCount);
|
output = getResources().getString(R.string.file_list__footer__folder);
|
||||||
}
|
|
||||||
|
|
||||||
} else if (filesCount == 1) {
|
} else { // foldersCount > 1
|
||||||
if (foldersCount <= 0) {
|
output = getResources().getString(R.string.file_list__footer__folders, foldersCount);
|
||||||
output = getResources().getString(R.string.file_list__footer__file);
|
}
|
||||||
|
|
||||||
} else if (foldersCount == 1) {
|
} else if (filesCount == 1) {
|
||||||
output = getResources().getString(R.string.file_list__footer__file_and_folder);
|
if (foldersCount <= 0) {
|
||||||
|
output = getResources().getString(R.string.file_list__footer__file);
|
||||||
|
|
||||||
} else { // foldersCount > 1
|
} else if (foldersCount == 1) {
|
||||||
output = getResources().getString(R.string.file_list__footer__file_and_folders, foldersCount);
|
output = getResources().getString(R.string.file_list__footer__file_and_folder);
|
||||||
}
|
|
||||||
} else { // filesCount > 1
|
|
||||||
if (foldersCount <= 0) {
|
|
||||||
output = getResources().getString(R.string.file_list__footer__files, filesCount);
|
|
||||||
|
|
||||||
} else if (foldersCount == 1) {
|
} else { // foldersCount > 1
|
||||||
output = getResources().getString(R.string.file_list__footer__files_and_folder, filesCount);
|
output = getResources().getString(R.string.file_list__footer__file_and_folders, foldersCount);
|
||||||
|
}
|
||||||
|
} else { // filesCount > 1
|
||||||
|
if (foldersCount <= 0) {
|
||||||
|
output = getResources().getString(R.string.file_list__footer__files, filesCount);
|
||||||
|
|
||||||
} else { // foldersCount > 1
|
} else if (foldersCount == 1) {
|
||||||
output = getResources().getString(
|
output = getResources().getString(R.string.file_list__footer__files_and_folder, filesCount);
|
||||||
R.string.file_list__footer__files_and_folders, filesCount, foldersCount
|
|
||||||
);
|
|
||||||
|
|
||||||
|
} else { // foldersCount > 1
|
||||||
|
output = getResources().getString(
|
||||||
|
R.string.file_list__footer__files_and_folders, filesCount, foldersCount
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,6 +1263,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
||||||
public void onMessageEvent(SearchEvent event) {
|
public void onMessageEvent(SearchEvent event) {
|
||||||
|
searchFragment = true;
|
||||||
setEmptyListLoadingMessage();
|
setEmptyListLoadingMessage();
|
||||||
mAdapter.setData(new ArrayList<>(), SearchType.NO_SEARCH);
|
mAdapter.setData(new ArrayList<>(), SearchType.NO_SEARCH);
|
||||||
|
|
||||||
|
@ -1284,30 +1303,35 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
|
final RemoteOperation remoteOperation;
|
||||||
|
if (!currentSearchType.equals(SearchType.SHARED_FILTER)) {
|
||||||
|
remoteOperation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
|
||||||
|
} else {
|
||||||
|
remoteOperation = new GetRemoteSharesOperation();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
final Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
|
||||||
OwnCloudAccount ocAccount = new OwnCloudAccount(
|
|
||||||
currentAccount,
|
AsyncTask task = new AsyncTask() {
|
||||||
MainApp.getAppContext()
|
@Override
|
||||||
);
|
protected Object doInBackground(Object[] params) {
|
||||||
|
RemoteOperationResult remoteOperationResult = remoteOperation.execute(currentAccount, getContext());
|
||||||
|
|
||||||
OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
|
|
||||||
getClientFor(ocAccount, MainApp.getAppContext());
|
|
||||||
if (!currentSearchType.equals(SearchType.SHARED_FILTER)) {
|
|
||||||
SearchOperation operation = new SearchOperation(event.getSearchQuery(), event.getSearchType());
|
|
||||||
RemoteOperationResult remoteOperationResult = operation.execute(mClient);
|
|
||||||
if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
|
|
||||||
mAdapter.setData(remoteOperationResult.getData(), currentSearchType);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
GetRemoteSharesOperation operation = new GetRemoteSharesOperation();
|
|
||||||
RemoteOperationResult remoteOperationResult = operation.execute(mClient);
|
|
||||||
if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
|
if (remoteOperationResult.isSuccess() && remoteOperationResult.getData() != null) {
|
||||||
mAdapter.setData(remoteOperationResult.getData(), currentSearchType);
|
mAdapter.setData(remoteOperationResult.getData(), currentSearchType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return remoteOperationResult.isSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Object o) {
|
||||||
|
mAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
task.execute(true);
|
||||||
|
|
||||||
if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
|
if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
|
||||||
setEmptyListMessage(SearchType.FILE_SEARCH);
|
setEmptyListMessage(SearchType.FILE_SEARCH);
|
||||||
|
|
||||||
|
@ -1350,18 +1374,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
|
||||||
} else {
|
} else {
|
||||||
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
|
new Handler(Looper.getMainLooper()).post(switchViewsRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
|
||||||
Log_OC.e(TAG, "Account not found", e);
|
|
||||||
} catch (AuthenticatorException e) {
|
|
||||||
Log_OC.e(TAG, "Authentication failed", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
Log_OC.e(TAG, "IO error", e);
|
|
||||||
} catch (OperationCanceledException e) {
|
|
||||||
Log_OC.e(TAG, "Operation has been canceled", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue