|
@@ -89,6 +89,7 @@ import com.owncloud.android.ui.events.ChangeMenuEvent;
|
|
|
import com.owncloud.android.ui.events.DummyDrawerEvent;
|
|
|
import com.owncloud.android.ui.events.MenuItemClickEvent;
|
|
|
import com.owncloud.android.ui.events.SearchEvent;
|
|
|
+import com.owncloud.android.ui.fragment.OCFileListFragment;
|
|
|
import com.owncloud.android.ui.trashbin.TrashbinActivity;
|
|
|
import com.owncloud.android.utils.DisplayUtils;
|
|
|
import com.owncloud.android.utils.DrawerMenuUtil;
|
|
@@ -99,6 +100,7 @@ import com.owncloud.android.utils.svg.MenuSimpleTarget;
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
+import org.parceler.Parcels;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -403,12 +405,12 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
|
EventBus.getDefault().post(new ChangeMenuEvent());
|
|
|
break;
|
|
|
case R.id.nav_favorites:
|
|
|
- EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
|
|
- SearchEvent.UnsetType.NO_UNSET));
|
|
|
+ handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
|
|
|
+ SearchEvent.UnsetType.NO_UNSET), menuItem.getItemId());
|
|
|
break;
|
|
|
case R.id.nav_photos:
|
|
|
- EventBus.getDefault().post(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
|
- SearchEvent.UnsetType.NO_UNSET));
|
|
|
+ handleSearchEvents(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
|
+ SearchEvent.UnsetType.NO_UNSET), menuItem.getItemId());
|
|
|
break;
|
|
|
case R.id.nav_on_device:
|
|
|
EventBus.getDefault().post(new ChangeMenuEvent());
|
|
@@ -471,20 +473,20 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
|
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
|
|
|
break;
|
|
|
case R.id.nav_recently_added:
|
|
|
- EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
|
- SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
|
|
+ handleSearchEvents(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
|
+ SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
|
break;
|
|
|
case R.id.nav_recently_modified:
|
|
|
- EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
|
|
- SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
|
|
+ handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
|
|
|
+ SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
|
break;
|
|
|
case R.id.nav_shared:
|
|
|
- EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
|
|
- SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
|
|
+ handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
|
|
|
+ SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
|
break;
|
|
|
case R.id.nav_videos:
|
|
|
- EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
|
- SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
|
|
|
+ handleSearchEvents(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
|
|
|
+ SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
|
|
|
break;
|
|
|
case Menu.NONE:
|
|
|
// account clicked
|
|
@@ -502,6 +504,19 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void handleSearchEvents(SearchEvent searchEvent, int menuItemId) {
|
|
|
+ if (this instanceof FileDisplayActivity) {
|
|
|
+ EventBus.getDefault().post(searchEvent);
|
|
|
+ } else {
|
|
|
+ Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
+ intent.setAction(Intent.ACTION_SEARCH);
|
|
|
+ intent.putExtra(OCFileListFragment.SEARCH_EVENT, Parcels.wrap(searchEvent));
|
|
|
+ intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* show the file list to the user.
|
|
|
*
|