mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
Merge pull request #4482 from nextcloud/fixNavigation
(temporary) fix for navigation issue
This commit is contained in:
commit
c9357b4c1d
5 changed files with 61 additions and 33 deletions
|
@ -405,9 +405,10 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
case R.id.nav_all_files:
|
||||
if (this instanceof FileDisplayActivity) {
|
||||
if (((FileDisplayActivity) this).getListOfFilesFragment() instanceof PhotoFragment) {
|
||||
showFiles(false);
|
||||
// showFiles(false);
|
||||
Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
||||
intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId());
|
||||
intent.setAction(FileDisplayActivity.ALL_FILES);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
} else {
|
||||
|
|
|
@ -30,7 +30,6 @@ import android.accounts.Account;
|
|||
import android.accounts.AuthenticatorException;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.SearchManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
|
@ -135,7 +134,6 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
@ -162,6 +160,8 @@ public class FileDisplayActivity extends FileActivity
|
|||
SendShareDialog.SendShareDialogDownloader, Injectable {
|
||||
|
||||
public static final String RESTART = "RESTART";
|
||||
public static final String ALL_FILES = "ALL_FILES";
|
||||
public static final String PHOTO_SEARCH = "PHOTO_SEARCH";
|
||||
|
||||
private SyncBroadcastReceiver mSyncBroadcastReceiver;
|
||||
private UploadFinishReceiver mUploadFinishReceiver;
|
||||
|
@ -194,7 +194,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
|
||||
private static final String TAG = FileDisplayActivity.class.getSimpleName();
|
||||
|
||||
private static final String TAG_LIST_OF_FILES = "LIST_OF_FILES";
|
||||
public static final String TAG_LIST_OF_FILES = "LIST_OF_FILES";
|
||||
public static final String TAG_SECOND_FRAGMENT = "SECOND_FRAGMENT";
|
||||
|
||||
public static final String TEXT_PREVIEW = "TEXT_PREVIEW";
|
||||
|
@ -563,14 +563,13 @@ public class FileDisplayActivity extends FileActivity
|
|||
startActivity(intent);
|
||||
} else // Verify the action and get the query
|
||||
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
|
||||
String query = intent.getStringExtra(SearchManager.QUERY);
|
||||
setIntent(intent);
|
||||
|
||||
SearchEvent searchEvent = Parcels.unwrap(intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
|
||||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH.equals(searchEvent.searchType)) {
|
||||
Log_OC.d(this, "Switch to photo search fragment");
|
||||
|
||||
PhotoFragment photoFragment = new PhotoFragment();
|
||||
PhotoFragment photoFragment = new PhotoFragment(true);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
||||
photoFragment.setArguments(bundle);
|
||||
|
@ -578,7 +577,15 @@ public class FileDisplayActivity extends FileActivity
|
|||
transaction.replace(R.id.left_fragment_container, photoFragment, TAG_LIST_OF_FILES);
|
||||
transaction.commit();
|
||||
} else {
|
||||
Log_OC.w(TAG, "Ignored Intent requesting to query for " + query);
|
||||
Log_OC.d(this, "Switch to oc file search fragment");
|
||||
|
||||
OCFileListFragment photoFragment = new OCFileListFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
||||
photoFragment.setArguments(bundle);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.left_fragment_container, photoFragment, TAG_LIST_OF_FILES);
|
||||
transaction.commit();
|
||||
}
|
||||
} else if (UsersAndGroupsSearchProvider.ACTION_SHARE_WITH.equals(intent.getAction())) {
|
||||
Uri data = intent.getData();
|
||||
|
@ -598,8 +605,13 @@ public class FileDisplayActivity extends FileActivity
|
|||
doShareWith(shareWith, shareType);
|
||||
}
|
||||
|
||||
} else {
|
||||
Log_OC.e(TAG, String.format(Locale.US, "Unexpected intent %s", intent));
|
||||
} else if (ALL_FILES.equals(intent.getAction())) {
|
||||
Log_OC.d(this, "Switch to oc file fragment");
|
||||
|
||||
OCFileListFragment fragment = new OCFileListFragment();
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
|
||||
transaction.commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2573,16 +2585,17 @@ public class FileDisplayActivity extends FileActivity
|
|||
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.searchType) {
|
||||
Log_OC.d(this, "Switch to photo search fragment");
|
||||
|
||||
fragment = new PhotoFragment();
|
||||
} else {
|
||||
Log_OC.d(this, "Switch to OCFileListFragment");
|
||||
|
||||
fragment = new OCFileListFragment();
|
||||
fragment = new PhotoFragment(true);
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
|
||||
transaction.commit();
|
||||
}
|
||||
// else {
|
||||
// Log_OC.d(this, "Switch to OCFileListFragment");
|
||||
//
|
||||
// fragment = new OCFileListFragment();
|
||||
// }
|
||||
|
||||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||
transaction.add(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
|
|
|
@ -882,7 +882,7 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
long currentSyncTime = System.currentTimeMillis();
|
||||
RemoteOperation refreshFolderOperation = new RefreshFolderOperation(ocFile,
|
||||
currentSyncTime,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
mStorageManager,
|
||||
account,
|
||||
|
|
|
@ -363,6 +363,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
}
|
||||
|
||||
setTitle();
|
||||
|
||||
if (searchEvent != null) {
|
||||
onMessageEvent(searchEvent);
|
||||
}
|
||||
}
|
||||
|
||||
protected void prepareCurrentSearch(SearchEvent event) {
|
||||
|
|
|
@ -52,10 +52,28 @@ public class PhotoFragment extends OCFileListFragment {
|
|||
private boolean photoSearchNoNew = false;
|
||||
private SearchRemoteOperation searchRemoteOperation;
|
||||
private AsyncTask photoSearchTask;
|
||||
private SearchEvent searchEvent;
|
||||
private boolean refresh = false;
|
||||
|
||||
public PhotoFragment() {
|
||||
|
||||
}
|
||||
|
||||
public PhotoFragment(boolean refresh) {
|
||||
this.refresh = refresh;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
searchEvent = new SearchEvent("image/%",
|
||||
SearchRemoteOperation.SearchType.PHOTO_SEARCH,
|
||||
SearchEvent.UnsetType.NO_UNSET);
|
||||
|
||||
searchRemoteOperation = new SearchRemoteOperation(searchEvent.getSearchQuery(),
|
||||
searchEvent.getSearchType(),
|
||||
false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,14 +114,15 @@ public class PhotoFragment extends OCFileListFragment {
|
|||
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
|
||||
requireActivity().invalidateOptionsMenu();
|
||||
|
||||
handleSearchEvent(searchEvent, false);
|
||||
handleSearchEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
super.onRefresh();
|
||||
|
||||
handleSearchEvent(searchEvent, true);
|
||||
refresh = true;
|
||||
handleSearchEvent();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,8 +130,8 @@ public class PhotoFragment extends OCFileListFragment {
|
|||
super.onMessageEvent(changeMenuEvent);
|
||||
}
|
||||
|
||||
private void handleSearchEvent(final SearchEvent event, boolean refresh) {
|
||||
prepareCurrentSearch(event);
|
||||
private void handleSearchEvent() {
|
||||
prepareCurrentSearch(searchEvent);
|
||||
searchFragment = true;
|
||||
setEmptyListLoadingMessage();
|
||||
|
||||
|
@ -124,6 +143,8 @@ public class PhotoFragment extends OCFileListFragment {
|
|||
mContainerActivity.getStorageManager(),
|
||||
mFile,
|
||||
true);
|
||||
|
||||
refresh = false;
|
||||
} else {
|
||||
mAdapter.showVirtuals(VirtualFolderType.PHOTOS, true, mContainerActivity.getStorageManager());
|
||||
preferences.setPhotoSearchTimestamp(System.currentTimeMillis());
|
||||
|
@ -133,17 +154,6 @@ public class PhotoFragment extends OCFileListFragment {
|
|||
|
||||
setFabVisible(false);
|
||||
|
||||
if (currentSearchType != SearchType.SHARED_FILTER) {
|
||||
boolean searchOnlyFolders = false;
|
||||
if (getArguments() != null && getArguments().getBoolean(ARG_SEARCH_ONLY_FOLDER, false)) {
|
||||
searchOnlyFolders = true;
|
||||
}
|
||||
|
||||
searchRemoteOperation = new SearchRemoteOperation(event.getSearchQuery(),
|
||||
event.getSearchType(),
|
||||
searchOnlyFolders);
|
||||
}
|
||||
|
||||
searchAndDisplay();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue