瀏覽代碼

Progress on all fronts

Mario Danic 8 年之前
父節點
當前提交
b0700a38e9

+ 67 - 31
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -1,23 +1,23 @@
 /**
- *   Nextcloud Android client application
+ * Nextcloud Android client application
  *
- *   @author Andy Scherzinger
- *   Copyright (C) 2016 Andy Scherzinger
- *   Copyright (C) 2016 Nextcloud
- *   Copyright (C) 2016 ownCloud Inc.
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
- *   License as published by the Free Software Foundation; either
- *   version 3 of the License, or 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/>.
+ * @author Andy Scherzinger
+ * Copyright (C) 2016 Andy Scherzinger
+ * Copyright (C) 2016 Nextcloud
+ * Copyright (C) 2016 ownCloud Inc.
+ * <p>
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ * <p>
+ * 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.
+ * <p>
+ * 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.activity;
@@ -56,6 +56,7 @@ import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.resources.files.SearchOperation;
 import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
 import com.owncloud.android.ui.TextDrawable;
+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.utils.DisplayUtils;
@@ -294,6 +295,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         }
 
         if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
+            navigationView.getMenu().removeItem(R.id.nav_photos);
             navigationView.getMenu().removeItem(R.id.nav_all_files);
             navigationView.getMenu().removeItem(R.id.nav_settings);
             navigationView.getMenu().removeItem(R.id.nav_favorites);
@@ -339,7 +341,14 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         }
     }
 
-        private void selectNavigationItem(final MenuItem menuItem) {
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(DummyDrawerEvent event) {
+        unsetAllDrawerMenuItems();
+    }
+
+
+    private void selectNavigationItem(final MenuItem menuItem) {
+
         switch (menuItem.getItemId()) {
             case R.id.nav_all_files:
                 menuItem.setChecked(true);
@@ -349,7 +358,12 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
             case R.id.nav_favorites:
                 menuItem.setChecked(true);
                 mCheckedMenuItem = menuItem.getItemId();
-                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH));
+                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
+                        SearchEvent.UnsetType.NO_UNSET));
+                break;
+            case R.id.nav_photos:
+                EventBus.getDefault().post(new SearchEvent("image/%",
+                        SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.NO_UNSET));
                 break;
             case R.id.nav_on_device:
                 menuItem.setChecked(true);
@@ -363,7 +377,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 startActivity(uploadListIntent);
                 break;
             case R.id.nav_folder_sync:
-                Intent folderSyncIntent = new Intent(getApplicationContext(),FolderSyncActivity.class);
+                Intent folderSyncIntent = new Intent(getApplicationContext(), FolderSyncActivity.class);
                 startActivity(folderSyncIntent);
                 break;
             case R.id.nav_settings:
@@ -384,15 +398,26 @@ 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));
+                menuItem.setChecked(true);
+                mCheckedMenuItem = menuItem.getItemId();
+                EventBus.getDefault().post(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
+                        SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
                 break;
             case R.id.nav_recently_modified:
-                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH));
+                menuItem.setChecked(true);
+                mCheckedMenuItem = menuItem.getItemId();
+                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
+                        SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
                 break;
             case R.id.nav_shared:
+                menuItem.setChecked(true);
+                mCheckedMenuItem = menuItem.getItemId();
                 break;
             case R.id.nav_videos:
-                EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH));
+                menuItem.setChecked(true);
+                mCheckedMenuItem = menuItem.getItemId();
+                EventBus.getDefault().post(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
+                        SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR));
                 break;
             case Menu.NONE:
                 // account clicked
@@ -654,9 +679,9 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
     /**
      * configured the quota to be displayed.
      *
-     * @param usedSpace the used space
+     * @param usedSpace  the used space
      * @param totalSpace the total space
-     * @param relative the percentage of space already used
+     * @param relative   the percentage of space already used
      */
     private void setQuotaInformation(long usedSpace, long totalSpace, int relative) {
         mQuotaProgressBar.setProgress(relative);
@@ -670,6 +695,17 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
         showQuota(true);
     }
 
+    protected void unsetAllDrawerMenuItems() {
+        if (mNavigationView != null && mNavigationView.getMenu() != null) {
+            Menu menu = mNavigationView.getMenu();
+            for (int i = 0; i < menu.size(); i++) {
+                menu.getItem(i).setChecked(false);
+            }
+        }
+
+        mCheckedMenuItem = Menu.NONE;
+    }
+
     /**
      * checks/highlights the provided menu item if the drawer has been initialized and the menu item exists.
      *
@@ -881,10 +917,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
     @Override
     public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
         if (callContext instanceof MenuItem) {
-            MenuItem mi = (MenuItem)callContext;
+            MenuItem mi = (MenuItem) callContext;
             mi.setIcon(avatarDrawable);
         } else if (callContext instanceof ImageView) {
-            ImageView iv = (ImageView)callContext;
+            ImageView iv = (ImageView) callContext;
             iv.setImageDrawable(avatarDrawable);
         }
     }
@@ -892,10 +928,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
     @Override
     public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
         if (callContext instanceof MenuItem) {
-            MenuItem mi = (MenuItem)callContext;
+            MenuItem mi = (MenuItem) callContext;
             return String.valueOf(mi.getTitle()).equals(tag);
         } else if (callContext instanceof ImageView) {
-            ImageView iv = (ImageView)callContext;
+            ImageView iv = (ImageView) callContext;
             return String.valueOf(iv.getTag()).equals(tag);
         }
         return false;
@@ -904,7 +940,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
     /**
      * Adds other listeners to react on changes of the drawer layout.
      *
-     * @param listener      Object interested in changes of the drawer layout.
+     * @param listener Object interested in changes of the drawer layout.
      */
     public void addDrawerListener(DrawerLayout.DrawerListener listener) {
         if (mDrawerLayout != null) {

+ 13 - 30
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -81,6 +81,7 @@ import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.operations.UploadFileOperation;
 import com.owncloud.android.services.observer.FileObserverService;
 import com.owncloud.android.syncadapter.FileSyncAdapter;
+import com.owncloud.android.ui.fragment.ExtendedListFragment;
 import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.ui.fragment.FileFragment;
 import com.owncloud.android.ui.fragment.OCFileListFragment;
@@ -319,27 +320,6 @@ public class FileDisplayActivity extends HookActivity
         }
     }
 
-    @Override
-    protected void onStart() {
-        Log_OC.v(TAG, "onStart() start");
-        super.onStart();
-        Log_OC.v(TAG, "onStart() end");
-    }
-
-    @Override
-    protected void onStop() {
-        Log_OC.v(TAG, "onStop() start");
-        super.onStop();
-        Log_OC.v(TAG, "onStop() end");
-    }
-
-    @Override
-    protected void onDestroy() {
-        Log_OC.v(TAG, "onDestroy() start");
-        super.onDestroy();
-        Log_OC.v(TAG, "onDestroy() end");
-    }
-
     /**
      * Called when the ownCloud {@link Account} associated to the Activity was just updated.
      */
@@ -941,6 +921,16 @@ public class FileDisplayActivity extends HookActivity
         return (mSearchEditFrame != null && mSearchEditFrame.getVisibility() == View.VISIBLE);
     }
 
+    private void revertBottomNavigationBarToAllFiles() {
+        if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
+            BottomNavigationView bottomNavigationView = (BottomNavigationView) getListOfFilesFragment().getView()
+                    .findViewById(R.id.bottom_navigation_view);
+            if (bottomNavigationView.getMenu().findItem(R.id.nav_bar_settings).isChecked()) {
+                bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setChecked(true);
+            }
+        }
+    }
+
     @Override
     public void onBackPressed() {
         boolean isFabOpen = isFabOpen();
@@ -955,14 +945,6 @@ public class FileDisplayActivity extends HookActivity
          *    4. navigate up (only if drawer and FAB aren't open)
          */
 
-        if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
-            BottomNavigationView bottomNavigationView = (BottomNavigationView) getListOfFilesFragment().getView()
-                    .findViewById(R.id.bottom_navigation_view);
-            if (bottomNavigationView.getMenu().findItem(R.id.nav_bar_settings).isChecked()) {
-                bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setChecked(true);
-            }
-        }
-
         if (isSearchOpen && searchView != null) {
             searchView.setQuery("", true);
             searchView.onActionViewCollapsed();
@@ -1018,6 +1000,7 @@ public class FileDisplayActivity extends HookActivity
         Log_OC.v(TAG, "onResume() start");
         super.onResume();
 
+        revertBottomNavigationBarToAllFiles();
         // refresh list of files
 
         if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
@@ -1206,7 +1189,7 @@ public class FileDisplayActivity extends HookActivity
         OCFileListFragment ocFileListFragment = getListOfFilesFragment();
         if (ocFileListFragment != null) {
             if (!mSyncInProgress) {
-                    ocFileListFragment.setEmptyListMessage(false);
+                    ocFileListFragment.setEmptyListMessage(ExtendedListFragment.SearchType.NO_SEARCH);
             } else {
                 ocFileListFragment.setEmptyListLoadingMessage();
             }

+ 0 - 1
src/main/java/com/owncloud/android/ui/activity/Preferences.java

@@ -809,5 +809,4 @@ public class Preferences extends PreferenceActivity
     public void onCancelMigration() {
         // Migration was canceled so we don't do anything
     }
-
 }

+ 27 - 0
src/main/java/com/owncloud/android/ui/events/DummyDrawerEvent.java

@@ -0,0 +1,27 @@
+/**
+ * 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;
+
+/**
+ * Dummy drawer event
+ */
+
+public class DummyDrawerEvent {
+}

+ 14 - 1
src/main/java/com/owncloud/android/ui/events/SearchEvent.java

@@ -30,11 +30,24 @@ public class SearchEvent {
 
     public final SearchOperation.SearchType searchType;
 
+    public final UnsetType unsetType;
 
-    public SearchEvent(String searchQuery, SearchOperation.SearchType searchType) {
+    public enum UnsetType {
+        NO_UNSET,
+        UNSET_DRAWER,
+        UNSET_BOTTOM_NAV_BAR;
+    }
+
+    public SearchEvent(String searchQuery, SearchOperation.SearchType searchType, UnsetType unsetType) {
 
         this.searchQuery = searchQuery;
         this.searchType = searchType;
+        this.unsetType = unsetType;
+
+    }
+
+    public UnsetType getUnsetType() {
+        return unsetType;
     }
 
     public String getSearchQuery() {

+ 144 - 64
src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -1,21 +1,20 @@
 /**
- *   ownCloud Android client application
- *
- *   Copyright (C) 2012 Bartek Przybylski
- *   Copyright (C) 2012-2016 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
+ * ownCloud Android client application
+ * <p>
+ * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2016 ownCloud Inc.
+ * <p>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p>
+ * 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 General Public License for more details.
+ * <p>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 package com.owncloud.android.ui.fragment;
@@ -24,8 +23,10 @@ import android.animation.LayoutTransition;
 import android.app.Activity;
 import android.os.Bundle;
 import android.os.Handler;
+import android.os.Looper;
 import android.support.annotation.DrawableRes;
 import android.support.annotation.StringRes;
+import android.support.design.widget.BottomNavigationView;
 import android.support.v4.app.Fragment;
 import android.support.v4.view.MenuItemCompat;
 import android.support.v4.widget.SwipeRefreshLayout;
@@ -66,16 +67,28 @@ import java.util.ArrayList;
 import third_parties.in.srain.cube.GridViewWithHeaderAndFooter;
 
 import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.FAVORITE_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.FAVORITE_SEARCH_FILTER;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.FILE_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.NO_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.PHOTO_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_ADDED_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_ADDED_SEARCH_FILTER;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.RECENTLY_MODIFIED_SEARCH_FILTER;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.REGULAR_FILTER;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.VIDEO_SEARCH;
+import static com.owncloud.android.ui.fragment.ExtendedListFragment.SearchType.VIDEO_SEARCH_FILTER;
 
 public class ExtendedListFragment extends Fragment
         implements OnItemClickListener, OnEnforceableRefreshListener, SearchView.OnQueryTextListener {
 
     protected static final String TAG = ExtendedListFragment.class.getSimpleName();
 
-    protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION"; 
+    protected static final String KEY_SAVED_LIST_POSITION = "SAVED_LIST_POSITION";
 
     private static final String KEY_INDEXES = "INDEXES";
-    private static final String KEY_FIRST_POSITIONS= "FIRST_POSITIONS";
+    private static final String KEY_FIRST_POSITIONS = "FIRST_POSITIONS";
     private static final String KEY_TOPS = "TOPS";
     private static final String KEY_HEIGHT_CELL = "HEIGHT_CELL";
     private static final String KEY_EMPTY_LIST_MESSAGE = "EMPTY_LIST_MESSAGE";
@@ -114,6 +127,25 @@ public class ExtendedListFragment extends Fragment
     protected SearchView searchView;
     private Handler handler = new Handler();
 
+    protected Menu mMenu;
+
+    public enum SearchType {
+        NO_SEARCH,
+        REGULAR_FILTER,
+        FILE_SEARCH,
+        FAVORITE_SEARCH,
+        FAVORITE_SEARCH_FILTER,
+        VIDEO_SEARCH,
+        VIDEO_SEARCH_FILTER,
+        PHOTO_SEARCH,
+        PHOTOS_SEARCH_FILTER,
+        RECENTLY_MODIFIED_SEARCH,
+        RECENTLY_MODIFIED_SEARCH_FILTER,
+        RECENTLY_ADDED_SEARCH,
+        RECENTLY_ADDED_SEARCH_FILTER
+    }
+
+
     protected void setListAdapter(BaseAdapter listAdapter) {
         mAdapter = listAdapter;
         mCurrentListView.setAdapter(listAdapter);
@@ -160,12 +192,13 @@ public class ExtendedListFragment extends Fragment
         }
     }
 
-    public boolean isGridEnabled(){
+    public boolean isGridEnabled() {
         return (mCurrentListView != null && mCurrentListView.equals(mGridView));
     }
 
     @Override
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        mMenu = menu;
         final MenuItem item = menu.findItem(R.id.action_search);
         searchView = (SearchView) MenuItemCompat.getActionView(item);
         searchView.setOnQueryTextListener(this);
@@ -200,6 +233,17 @@ public class ExtendedListFragment extends Fragment
                     public void run() {
                         if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity)) {
                             setFabEnabled(!hasFocus);
+
+                            if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
+                                BottomNavigationView bottomNavigationView = (BottomNavigationView) getActivity().
+                                        findViewById(R.id.bottom_navigation_view);
+                                if (hasFocus) {
+                                    bottomNavigationView.setVisibility(View.GONE);
+                                } else {
+                                    bottomNavigationView.setVisibility(View.VISIBLE);
+                                }
+                            }
+
                         }
                     }
                 }, 100);
@@ -220,9 +264,10 @@ public class ExtendedListFragment extends Fragment
 
                 if (currentVisibility != oldVisibility) {
                     if (currentVisibility == View.VISIBLE) {
-                        setEmptyListMessage(true);
+
+                        setEmptyListMessage(SearchType.REGULAR_FILTER);
                     } else {
-                        setEmptyListMessage(false);
+                        setEmptyListMessage(NO_SEARCH);
                     }
 
                     oldVisibility = currentVisibility;
@@ -284,11 +329,11 @@ public class ExtendedListFragment extends Fragment
             if ((activity = getActivity()) != null) {
                 if (activity instanceof FileDisplayActivity) {
                     ((FileDisplayActivity) activity).refreshListOfFilesFragment(true);
-                } else if (activity instanceof UploadFilesActivity){
+                } else if (activity instanceof UploadFilesActivity) {
                     LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) mAdapter;
                     localFileListAdapter.filter(query);
                 } else if (activity instanceof FolderPickerActivity) {
-                    ((FolderPickerActivity)activity).refreshListOfFilesFragment(true);
+                    ((FolderPickerActivity) activity).refreshListOfFilesFragment(true);
                 }
 
             }
@@ -305,7 +350,7 @@ public class ExtendedListFragment extends Fragment
         View v = inflater.inflate(R.layout.list_fragment, null);
         setupEmptyList(v);
 
-        mListView = (ExtendedListView)(v.findViewById(R.id.list_root));
+        mListView = (ExtendedListView) (v.findViewById(R.id.list_root));
         mListView.setOnItemClickListener(this);
         mListFooterView = inflater.inflate(R.layout.list_footer, null, false);
 
@@ -366,23 +411,23 @@ public class ExtendedListFragment extends Fragment
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
-        
+
         if (savedInstanceState != null) {
             mIndexes = savedInstanceState.getIntegerArrayList(KEY_INDEXES);
             mFirstPositions = savedInstanceState.getIntegerArrayList(KEY_FIRST_POSITIONS);
             mTops = savedInstanceState.getIntegerArrayList(KEY_TOPS);
             mHeightCell = savedInstanceState.getInt(KEY_HEIGHT_CELL);
             setMessageForEmptyList(savedInstanceState.getString(KEY_EMPTY_LIST_MESSAGE));
-            
+
         } else {
             mIndexes = new ArrayList<>();
             mFirstPositions = new ArrayList<>();
             mTops = new ArrayList<>();
             mHeightCell = 0;
         }
-    }    
-    
-    
+    }
+
+
     @Override
     public void onSaveInstanceState(Bundle savedInstanceState) {
         super.onSaveInstanceState(savedInstanceState);
@@ -400,10 +445,10 @@ public class ExtendedListFragment extends Fragment
      * 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
      * other position.
-     * 
+     *
      * The current policy is take as a reference the visible item in the center
      * of the screen.
-     * 
+     *
      * @return The position in the list of the visible item in the center of the
      *         screen.
      */
@@ -421,25 +466,25 @@ public class ExtendedListFragment extends Fragment
      * Restore index and position
      */
     protected void restoreIndexAndTopPosition() {
-        if (mIndexes.size() > 0) {  
+        if (mIndexes.size() > 0) {
             // needs to be checked; not every browse-up had a browse-down before 
-            
+
             int index = mIndexes.remove(mIndexes.size() - 1);
-            final int firstPosition = mFirstPositions.remove(mFirstPositions.size() -1);
+            final int firstPosition = mFirstPositions.remove(mFirstPositions.size() - 1);
             int top = mTops.remove(mTops.size() - 1);
 
             Log_OC.v(TAG, "Setting selection to position: " + firstPosition + "; top: "
                     + top + "; index: " + index);
 
-            if (mCurrentListView!= null && mCurrentListView.equals(mListView)) {
-                if (mHeightCell*index <= mListView.getHeight()) {
+            if (mCurrentListView != null && mCurrentListView.equals(mListView)) {
+                if (mHeightCell * index <= mListView.getHeight()) {
                     mListView.setSelectionFromTop(firstPosition, top);
                 } else {
                     mListView.setSelectionFromTop(index, 0);
                 }
 
             } else {
-                if (mHeightCell*index <= mGridView.getHeight()) {
+                if (mHeightCell * index <= mGridView.getHeight()) {
                     mGridView.setSelection(firstPosition);
                     //mGridView.smoothScrollToPosition(firstPosition);
                 } else {
@@ -450,29 +495,29 @@ public class ExtendedListFragment extends Fragment
 
         }
     }
-    
+
     /*
      * Save index and top position
      */
     protected void saveIndexAndTopPosition(int index) {
-        
+
         mIndexes.add(index);
-        
+
         int firstPosition = mCurrentListView.getFirstVisiblePosition();
         mFirstPositions.add(firstPosition);
-        
+
         View view = mCurrentListView.getChildAt(0);
-        int top = (view == null) ? 0 : view.getTop() ;
+        int top = (view == null) ? 0 : view.getTop();
 
         mTops.add(top);
-        
+
         // Save the height of a cell
         mHeightCell = (view == null || mHeightCell != 0) ? mHeightCell : view.getHeight();
     }
-    
-    
+
+
     @Override
-    public void onItemClick (AdapterView<?> parent, View view, int position, long id) {
+    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
         // to be @overriden
     }
 
@@ -501,7 +546,7 @@ public class ExtendedListFragment extends Fragment
     public void setOnRefreshListener(OnEnforceableRefreshListener listener) {
         mOnRefreshListener = listener;
     }
-    
+
 
     /**
      * Disables swipe gesture.
@@ -526,7 +571,7 @@ public class ExtendedListFragment extends Fragment
      * @param   enabled     Desired visibility for the FAB.
      */
     public void setFabEnabled(boolean enabled) {
-        if(enabled) {
+        if (enabled) {
             mFabMain.setVisibility(View.VISIBLE);
         } else {
             mFabMain.setVisibility(View.GONE);
@@ -555,22 +600,52 @@ public class ExtendedListFragment extends Fragment
             mEmptyListMessage.setText(message);
             mEmptyListIcon.setImageResource(icon);
 
-            mEmptyListIcon.setVisibility(View.VISIBLE);
-            mEmptyListProgress.setVisibility(View.GONE);
+            new Handler(Looper.getMainLooper()).post(new Runnable() {
+                @Override
+                public void run() {
+                    mEmptyListIcon.setVisibility(View.VISIBLE);
+                    mEmptyListProgress.setVisibility(View.GONE);
+                }
+            });
         }
     }
 
-    public void setEmptyListMessage(boolean isSearch) {
-        if (isSearch) {
-            setMessageForEmptyList(R.string.file_list_empty_headline_search,
-                    R.string.file_list_empty_search, R.drawable.ic_search_light_grey);
-
-        } else {
+    public void setEmptyListMessage(SearchType searchType) {
+        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 == VIDEO_SEARCH_FILTER) {
+
+        } else if (searchType == RECENTLY_MODIFIED_SEARCH_FILTER) {
+
+        } else if (searchType == RECENTLY_ADDED_SEARCH_FILTER) {
+
         }
     }
 
@@ -582,14 +657,19 @@ public class ExtendedListFragment extends Fragment
             mEmptyListHeadline.setText(R.string.file_list_loading);
             mEmptyListMessage.setText("");
 
-            mEmptyListIcon.setVisibility(View.GONE);
-            mEmptyListProgress.setVisibility(View.VISIBLE);
+            new Handler(Looper.getMainLooper()).post(new Runnable() {
+                @Override
+                public void run() {
+                    mEmptyListIcon.setVisibility(View.GONE);
+                    mEmptyListProgress.setVisibility(View.VISIBLE);
+                }
+            });
         }
     }
 
     /**
      * Get the text of EmptyListMessage TextView.
-     * 
+     *
      * @return String empty text view text-value
      */
     public String getEmptyViewText() {
@@ -632,7 +712,7 @@ public class ExtendedListFragment extends Fragment
     protected void setFooterEnabled(boolean enabled) {
         if (enabled) {
             if (mGridView.getFooterViewCount() == 0 && mGridView.isCorrectAdapter()) {
-                if (mGridFooterView.getParent() != null ) {
+                if (mGridFooterView.getParent() != null) {
                     ((ViewGroup) mGridFooterView.getParent()).removeView(mGridFooterView);
                 }
                 mGridView.addFooterView(mGridFooterView, null, false);
@@ -640,7 +720,7 @@ public class ExtendedListFragment extends Fragment
             mGridFooterView.invalidate();
 
             if (mListView.getFooterViewsCount() == 0) {
-                if (mListFooterView.getParent() != null ) {
+                if (mListFooterView.getParent() != null) {
                     ((ViewGroup) mListFooterView.getParent()).removeView(mListFooterView);
                 }
                 mListView.addFooterView(mListFooterView, null, false);
@@ -660,8 +740,8 @@ public class ExtendedListFragment extends Fragment
      */
     protected void setFooterText(String text) {
         if (text != null && text.length() > 0) {
-            ((TextView)mListFooterView.findViewById(R.id.footerText)).setText(text);
-            ((TextView)mGridFooterView.findViewById(R.id.footerText)).setText(text);
+            ((TextView) mListFooterView.findViewById(R.id.footerText)).setText(text);
+            ((TextView) mGridFooterView.findViewById(R.id.footerText)).setText(text);
             setFooterEnabled(true);
 
         } else {

+ 119 - 76
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -1,24 +1,23 @@
 /**
- *   ownCloud Android client application
- *
- *   @author Bartek Przybylski
- *   @author masensio
- *   @author David A. Velasco
- *   Copyright (C) 2011  Bartek Przybylski
- *   Copyright (C) 2016 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   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 General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * ownCloud Android client application
  *
+ * @author Bartek Przybylski
+ * @author masensio
+ * @author David A. Velasco
+ * Copyright (C) 2011  Bartek Przybylski
+ * Copyright (C) 2016 ownCloud Inc.
+ * <p>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
+ * <p>
+ * 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 General Public License for more details.
+ * <p>
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 package com.owncloud.android.ui.fragment;
 
@@ -31,6 +30,8 @@ import android.content.Intent;
 import android.content.SharedPreferences;
 import android.os.Build;
 import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
 import android.preference.PreferenceManager;
 import android.support.annotation.NonNull;
 import android.support.design.widget.BottomNavigationView;
@@ -73,6 +74,7 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
 import com.owncloud.android.ui.dialog.CreateFolderDialogFragment;
 import com.owncloud.android.ui.dialog.RemoveFilesDialogFragment;
 import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
+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.helpers.SparseBooleanArrayParcelable;
@@ -200,28 +202,29 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
         bottomNavigationView.setOnNavigationItemSelectedListener(
                 new BottomNavigationView.OnNavigationItemSelectedListener() {
-            @Override
-            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
-                switch (item.getItemId()) {
-                    case R.id.nav_bar_files:
-                        EventBus.getDefault().post(new MenuItemClickEvent(item));
-                        break;
-                    case R.id.nav_bar_favorites:
-                        EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH));
-                        break;
-                    case R.id.nav_bar_photos:
-                        EventBus.getDefault().post(new SearchEvent("image/%",
-                                SearchOperation.SearchType.CONTENT_TYPE_SEARCH));
-                        break;
-                    case R.id.nav_bar_settings:
-                        EventBus.getDefault().post(new MenuItemClickEvent(item));
-                        break;
-                    default:
-                        break;
-                }
-                return true;
-            }
-        });
+                    @Override
+                    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
+                        switch (item.getItemId()) {
+                            case R.id.nav_bar_files:
+                                EventBus.getDefault().post(new MenuItemClickEvent(item));
+                                break;
+                            case R.id.nav_bar_favorites:
+                                EventBus.getDefault().post(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
+                                        SearchEvent.UnsetType.UNSET_DRAWER));
+                                break;
+                            case R.id.nav_bar_photos:
+                                EventBus.getDefault().post(new SearchEvent("image/%",
+                                        SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.UNSET_DRAWER));
+                                break;
+                            case R.id.nav_bar_settings:
+                                EventBus.getDefault().post(new MenuItemClickEvent(item));
+                                break;
+                            default:
+                                break;
+                        }
+                        return true;
+                    }
+                });
     }
 
     @Override
@@ -276,12 +279,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
             // detect if a mini FAB has ever been clicked
             final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
-            if(prefs.getLong(KEY_FAB_EVER_CLICKED, 0) > 0) {
+            if (prefs.getLong(KEY_FAB_EVER_CLICKED, 0) > 0) {
                 miniFabClicked = true;
             }
 
             // add labels to the min FABs when none of them has ever been clicked on
-            if(!miniFabClicked) {
+            if (!miniFabClicked) {
                 setFabLabels();
             } else {
                 removeFabLabels();
@@ -399,7 +402,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
      */
     private void recordMiniFabClick() {
         // only record if it hasn't been done already at some other time
-        if(!miniFabClicked) {
+        if (!miniFabClicked) {
             final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
             sp.edit().putLong(KEY_FAB_EVER_CLICKED, 1).apply();
             miniFabClicked = true;
@@ -435,7 +438,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
      * and closed.
      */
     private class MultiChoiceModeListener
-        implements AbsListView.MultiChoiceModeListener, DrawerLayout.DrawerListener {
+            implements AbsListView.MultiChoiceModeListener, DrawerLayout.DrawerListener {
 
         private static final String KEY_ACTION_MODE_CLOSED_BY_DRAWER = "KILLED_ACTION_MODE";
         private static final String KEY_SELECTION_WHEN_CLOSED_BY_DRAWER = "CHECKED_ITEMS";
@@ -468,12 +471,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
          */
         @Override
         public void onDrawerClosed(View drawerView) {
-            if (mSelectionWhenActionModeClosedByDrawer !=null && mActionModeClosedByDrawer) {
-                for (int i = 0; i< mSelectionWhenActionModeClosedByDrawer.size(); i++) {
+            if (mSelectionWhenActionModeClosedByDrawer != null && mActionModeClosedByDrawer) {
+                for (int i = 0; i < mSelectionWhenActionModeClosedByDrawer.size(); i++) {
                     if (mSelectionWhenActionModeClosedByDrawer.valueAt(i)) {
                         getListView().setItemChecked(
-                            mSelectionWhenActionModeClosedByDrawer.keyAt(i),
-                            true
+                                mSelectionWhenActionModeClosedByDrawer.keyAt(i),
+                                true
                         );
                     }
                 }
@@ -535,16 +538,16 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             List<OCFile> checkedFiles = mAdapter.getCheckedItems(getListView());
             final int checkedCount = checkedFiles.size();
             String title = getResources().getQuantityString(
-                R.plurals.items_selected_count,
-                checkedCount,
-                checkedCount
+                    R.plurals.items_selected_count,
+                    checkedCount,
+                    checkedCount
             );
             mode.setTitle(title);
             FileMenuFilter mf = new FileMenuFilter(
-                checkedFiles,
-                ((FileActivity) getActivity()).getAccount(),
-                mContainerActivity,
-                getActivity()
+                    checkedFiles,
+                    ((FileActivity) getActivity()).getAccount(),
+                    mContainerActivity,
+                    getActivity()
             );
             mf.filter(menu);
             return true;
@@ -570,7 +573,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             DisplayUtils.colorToolbarProgressBar(getActivity(), mProgressBarColor);
 
             // show FAB on multi selection mode exit
-            if(!mHideFab) {
+            if (!mHideFab) {
                 setFabEnabled(true);
             }
         }
@@ -580,7 +583,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             outState.putBoolean(KEY_ACTION_MODE_CLOSED_BY_DRAWER, mActionModeClosedByDrawer);
             if (mSelectionWhenActionModeClosedByDrawer != null) {
                 SparseBooleanArrayParcelable sbap = new SparseBooleanArrayParcelable(
-                    mSelectionWhenActionModeClosedByDrawer
+                        mSelectionWhenActionModeClosedByDrawer
                 );
                 outState.putParcelable(KEY_SELECTION_WHEN_CLOSED_BY_DRAWER, sbap);
             }
@@ -588,11 +591,11 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
         public void loadStateFrom(Bundle savedInstanceState) {
             mActionModeClosedByDrawer = savedInstanceState.getBoolean(
-                KEY_ACTION_MODE_CLOSED_BY_DRAWER,
-                mActionModeClosedByDrawer
+                    KEY_ACTION_MODE_CLOSED_BY_DRAWER,
+                    mActionModeClosedByDrawer
             );
             SparseBooleanArrayParcelable sbap = savedInstanceState.getParcelable(
-                KEY_SELECTION_WHEN_CLOSED_BY_DRAWER
+                    KEY_SELECTION_WHEN_CLOSED_BY_DRAWER
             );
             if (sbap != null) {
                 mSelectionWhenActionModeClosedByDrawer = sbap.getSparseBooleanArray();
@@ -609,7 +612,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             mMultiChoiceModeListener.loadStateFrom(savedInstanceState);
         }
         setMultiChoiceModeListener(mMultiChoiceModeListener);
-        ((FileActivity)getActivity()).addDrawerListener(mMultiChoiceModeListener);
+        ((FileActivity) getActivity()).addDrawerListener(mMultiChoiceModeListener);
     }
 
     /**
@@ -623,7 +626,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     }
 
     @Override
-    public void onPrepareOptionsMenu (Menu menu) {
+    public void onPrepareOptionsMenu(Menu menu) {
         changeGridIcon(menu);   // this is enough if the option stays out of the action bar
     }
 
@@ -688,9 +691,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             } else { /// Click on a file
                 if (PreviewImageFragment.canBePreviewed(file)) {
                     // preview image - it handles the download, if needed
-                    ((FileDisplayActivity)mContainerActivity).startImagePreview(file);
-                } else if (PreviewTextFragment.canBePreviewed(file)){
-                    ((FileDisplayActivity)mContainerActivity).startTextPreview(file);
+                    ((FileDisplayActivity) mContainerActivity).startImagePreview(file);
+                } else if (PreviewTextFragment.canBePreviewed(file)) {
+                    ((FileDisplayActivity) mContainerActivity).startTextPreview(file);
                 } else if (file.isDown()) {
                     if (PreviewMediaFragment.canBePreviewed(file)) {
                         // media preview
@@ -817,11 +820,11 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     /**
      * Calls {@link OCFileListFragment#listDirectory(OCFile, boolean, boolean)} with a null parameter
      */
-    public void listDirectory(boolean onlyOnDevice, boolean fromSearch){
+    public void listDirectory(boolean onlyOnDevice, boolean fromSearch) {
         listDirectory(null, onlyOnDevice, fromSearch);
     }
 
-    public void refreshDirectory(){
+    public void refreshDirectory() {
         listDirectory(getCurrentFile(), MainApp.isOnlyOnDevice(), false);
     }
 
@@ -911,7 +914,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             updateFooter();
             // decide grid vs list view
             OwnCloudVersion version = AccountUtils.getServerVersion(
-                    ((FileActivity)mContainerActivity).getAccount());
+                    ((FileActivity) mContainerActivity).getAccount());
             if (version != null && version.supportsRemoteThumbnails() &&
                     isGridViewPreferred(mFile)) {
                 switchToGridView();
@@ -923,7 +926,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     }
 
     private void invalidateActionMode() {
-        if(mActiveActionMode != null){
+        if (mActiveActionMode != null) {
             mActiveActionMode.invalidate();
         }
     }
@@ -986,7 +989,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
      * @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) {
             OCFile fileToTest = file;
             OCFile parentDir;
@@ -1034,9 +1037,9 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         }
     }
 
-    private void changeGridIcon(Menu menu){
+    private void changeGridIcon(Menu menu) {
         MenuItem menuItem = menu.findItem(R.id.action_switch_view);
-        if (isGridViewPreferred(mFile)){
+        if (isGridViewPreferred(mFile)) {
             menuItem.setTitle(getString(R.string.action_switch_list_view));
             menuItem.setIcon(R.drawable.ic_view_list);
         } else {
@@ -1055,7 +1058,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         switchToGridView();
     }
 
-    private void saveGridAsPreferred(boolean setGrid){
+    private void saveGridAsPreferred(boolean setGrid) {
         SharedPreferences setting = getActivity().getSharedPreferences(
                 GRID_IS_PREFERED_PREFERENCE, Context.MODE_PRIVATE
         );
@@ -1065,8 +1068,32 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         editor.apply();
     }
 
+    private void unsetAllMenuItems(final boolean unsetDrawer) {
+        new Handler(Looper.getMainLooper()).post(new Runnable() {
+            @Override
+            public void run() {
+                if (unsetDrawer) {
+                    EventBus.getDefault().post(new DummyDrawerEvent());
+                } else {
+                    if (bottomNavigationView != null) {
+                        bottomNavigationView.getMenu().findItem(R.id.nav_bar_files).setChecked(true);
+                    }
+                }
+            }
+        });
+
+    }
+
     @Subscribe(threadMode = ThreadMode.BACKGROUND)
     public void onMessageEvent(SearchEvent event) {
+        setEmptyListLoadingMessage();
+
+        if (event.getUnsetType().equals(SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR)) {
+            unsetAllMenuItems(false);
+        } else if (event.getUnsetType().equals(SearchEvent.UnsetType.UNSET_DRAWER)) {
+            unsetAllMenuItems(true);
+        }
+
         Account currentAccount = com.owncloud.android.authentication.AccountUtils.
                 getCurrentOwnCloudAccount(MainApp.getAppContext());
 
@@ -1081,7 +1108,25 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             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)) {
+                    setEmptyListMessage(SearchType.FILE_SEARCH);
+                } else if (event.getSearchType().equals(SearchOperation.SearchType.CONTENT_TYPE_SEARCH)) {
+                    if (event.getSearchQuery().equals("image/%")) {
+                        setEmptyListMessage(SearchType.PHOTO_SEARCH);
+                    } else if (event.getSearchQuery().equals("video/%")) {
+                        setEmptyListMessage(SearchType.VIDEO_SEARCH);
+                    }
+                } else if (event.getSearchType().equals(SearchOperation.SearchType.FAVORITE_SEARCH)) {
+                    setEmptyListMessage(SearchType.FAVORITE_SEARCH);
+                } else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_ADDED_SEARCH)) {
+                    setEmptyListMessage(SearchType.RECENTLY_ADDED_SEARCH);
+                } else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH)) {
+                    setEmptyListMessage(SearchType.RECENTLY_MODIFIED_SEARCH);
+                }
+
                 mAdapter.setData(remoteOperationResult.getData());
+
             }
         } catch (AuthenticatorException e) {
             e.printStackTrace();
@@ -1092,8 +1137,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         } catch (OperationCanceledException e) {
             e.printStackTrace();
         }
-
-
     }
 
     @Override

+ 2 - 1
src/main/java/com/owncloud/android/ui/fragment/UploadListFragment.java

@@ -66,7 +66,8 @@ public class UploadListFragment extends ExpandableListFragment {
         View v = super.onCreateView(inflater, container, savedInstanceState);
         getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
         setMessageForEmptyList(
-                R.string.upload_list_empty_headline, R.string.upload_list_empty_text, R.drawable.ic_list_empty_upload
+                R.string.upload_list_empty_headline, R.string.upload_list_empty_text_auto_upload,
+                R.drawable.ic_list_empty_upload
         );
         setOnRefreshListener(this);
         return v;

+ 9 - 5
src/main/res/menu/drawer_menu.xml

@@ -27,17 +27,16 @@
             android:orderInCategory="0"
             android:id="@+id/nav_all_files"
             android:icon="@drawable/ic_folder_open"
-            android:title="@string/drawer_item_files"/>
+            android:title="@string/drawer_item_all_files"/>
         <item
             android:orderInCategory="0"
             android:id="@+id/nav_favorites"
             android:icon="@drawable/ic_favorite"
             android:title="@string/drawer_item_favorites"/>
         <item
-            android:orderInCategory="0"
-            android:id="@+id/nav_on_device"
-            android:icon="@drawable/ic_action_available_offline"
-            android:title="@string/drawer_item_on_device"/>
+            android:id="@+id/nav_photos"
+            android:icon="@drawable/file_image"
+            android:title="@string/drawer_item_photos"/>
         <item
             android:orderInCategory="0"
             android:id="@+id/nav_recently_added"
@@ -59,6 +58,11 @@
             android:title="@string/drawer_item_videos"
             android:icon="@drawable/file_movie"
             android:visible="false"/>
+        <item
+            android:orderInCategory="0"
+            android:id="@+id/nav_on_device"
+            android:icon="@drawable/ic_action_available_offline"
+            android:title="@string/drawer_item_on_device"/>
         <item
             android:orderInCategory="0"
             android:id="@+id/nav_folder_sync"

+ 1 - 1
src/main/res/menu/navigation_bar_menu.xml

@@ -3,7 +3,7 @@
     <item
         android:id="@+id/nav_bar_files"
         android:icon="@drawable/ic_folder_open"
-        android:title="@string/drawer_item_files"/>
+        android:title="@string/drawer_item_all_files"/>
     <item
         android:id="@+id/nav_bar_favorites"
         android:icon="@drawable/ic_favorite"

+ 1 - 1
src/main/res/values/setup.xml

@@ -62,7 +62,7 @@
     <!-- Drawer options -->
     <bool name="recently_added_enabled">false</bool>
     <bool name="recently_modified_enabled">false</bool>
-    <bool name="shared_enabled">false</bool>
+    <bool name="shared_enabled">true</bool>
     <bool name="videos_enabled">false</bool>
 
     <!-- Bottom toolbar -->

+ 9 - 0
src/main/res/values/strings.xml

@@ -88,13 +88,22 @@
     <string name="file_list_seconds_ago">seconds ago</string>
     <string name="file_list_empty_headline">No files in here</string>
     <string name="file_list_empty">Upload some content or sync with your devices!</string>
+    <string name="file_list_empty_favorites">Favorite some files or sync with your devices!</string>
     <string name="file_list_loading">Loading&#8230;</string>
     <string name="file_list_no_app_for_file_type">No app found for file type!</string>
     <string name="local_file_list_empty">There are no files in this folder.</string>
     <string name="file_list_empty_headline_search">No results in this folder</string>
+    <string name="file_list_empty_headline_server_search">No results</string>
+    <string name="file_list_empty_headline_server_search_videos">No videos</string>
+    <string name="file_list_empty_headline_server_search_photos">No photos</string>
     <string name="file_list_empty_search">Try looking in another folder?</string>
+    <string name="file_list_empty_recently_modified">No recently modified files found</string>
+    <string name="file_list_empty_recently_added">No recently added files found</string>
+    <string name="file_list_empty_text_photos">Upload some photos or activate auto upload!</string>
+    <string name="file_list_empty_text_videos">Upload some videos or activate auto upload!</string>
     <string name="upload_list_empty_headline">No uploads available</string>
     <string name="upload_list_empty_text">Upload some content or activate instant upload!</string>
+    <string name="upload_list_empty_text_auto_upload">Upload some content or activate auto upload!</string>
     <string name="file_list_folder">folder</string>
     <string name="file_list_folders">folders</string>
     <string name="file_list_file">file</string>