浏览代码

Fix files search icon

Mario Danic 8 年之前
父节点
当前提交
7f0fb21ae8

+ 2 - 0
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -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.ChangeMenuEvent;
 import com.owncloud.android.ui.events.DummyDrawerEvent;
 import com.owncloud.android.ui.events.MenuItemClickEvent;
 import com.owncloud.android.ui.events.SearchEvent;
@@ -376,6 +377,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
                 menuItem.setChecked(true);
                 mCheckedMenuItem = menuItem.getItemId();
                 showFiles(false);
+                EventBus.getDefault().post(new ChangeMenuEvent());
                 break;
             case R.id.nav_favorites:
                 menuItem.setChecked(true);

+ 27 - 0
src/main/java/com/owncloud/android/ui/events/ChangeMenuEvent.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;
+
+/**
+ * Currently a dummy event to restore grid view, sort, and search
+ */
+
+public class ChangeMenuEvent {
+}

+ 30 - 13
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -75,6 +75,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.ChangeMenuEvent;
 import com.owncloud.android.ui.events.DummyDrawerEvent;
 import com.owncloud.android.ui.events.FavoriteEvent;
 import com.owncloud.android.ui.events.MenuItemClickEvent;
@@ -233,7 +234,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                         switch (item.getItemId()) {
                             case R.id.nav_bar_files:
                                 EventBus.getDefault().post(new MenuItemClickEvent(item));
-                                menuItemAddRemoveValue = MenuItemAddRemove.ADD_GRID_AND_SORT;
+                                menuItemAddRemoveValue = MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH;
                                 if (getActivity() != null) {
                                     getActivity().invalidateOptionsMenu();
                                 }
@@ -665,22 +666,25 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
         changeGridIcon(menu);   // this is enough if the option stays out of the action bar
 
+        MenuItem menuItemOrig;
+
         if (menuItemAddRemoveValue.equals(MenuItemAddRemove.ADD_SORT)) {
-            if (menu.findItem(R.id.action_sort) == null && menu.findItem(R.id.action_search) != null) {
-                MenuItem menuItemOrig = mOriginalMenuItems.get(1);
+            if (menu.findItem(R.id.action_sort) == null) {
+                menuItemOrig = mOriginalMenuItems.get(1);
                 menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
                         menuItemOrig.getTitle());
-                MenuItem menuItemOrigSearch = mOriginalMenuItems.get(2);
-                menu.add(menuItemOrigSearch.getGroupId(), menuItemOrigSearch.getItemId(), menuItemOrigSearch.getOrder(),
-                        menuItemOrigSearch.getTitle());
             }
 
-        } else if (menuItemAddRemoveValue.equals(MenuItemAddRemove.ADD_GRID_AND_SORT)) {
-            if (menu.findItem(R.id.action_sort) == null && menu.findItem(R.id.action_switch_view) == null
-                    && menu.findItem(R.id.action_search) != null) {
-                MenuItem menuItemOrig = mOriginalMenuItems.get(0);
+        } else if (menuItemAddRemoveValue.equals(MenuItemAddRemove.ADD_GRID_AND_SORT))
+
+        {
+            if (menu.findItem(R.id.action_switch_view) == null) {
+                menuItemOrig = mOriginalMenuItems.get(0);
                 menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
                         menuItemOrig.getTitle());
+            }
+
+            if (menu.findItem(R.id.action_sort) == null) {
                 menuItemOrig = mOriginalMenuItems.get(1);
                 menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
                         menuItemOrig.getTitle());
@@ -688,15 +692,19 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         } else if (menuItemAddRemoveValue.equals(MenuItemAddRemove.REMOVE_SEARCH)) {
             menu.removeItem(R.id.action_search);
         } else if (menuItemAddRemoveValue.equals(MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH)) {
-            if (menu.findItem(R.id.action_sort) == null && menu.findItem(R.id.action_switch_view) == null
-                    && menu.findItem(R.id.action_search) != null) {
-                MenuItem menuItemOrig = mOriginalMenuItems.get(0);
+            if (menu.findItem(R.id.action_switch_view) == null) {
+                menuItemOrig = mOriginalMenuItems.get(0);
                 menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
                         menuItemOrig.getTitle());
+            }
+
+            if (menu.findItem(R.id.action_sort) == null) {
                 menuItemOrig = mOriginalMenuItems.get(1);
                 menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
                         menuItemOrig.getTitle());
+            }
 
+            if (menu.findItem(R.id.action_search) == null) {
                 menuItemOrig = mOriginalMenuItems.get(2);
                 menu.add(menuItemOrig.getGroupId(), menuItemOrig.getItemId(), menuItemOrig.getOrder(),
                         menuItemOrig.getTitle());
@@ -709,6 +717,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             menu.removeItem(R.id.action_switch_view);
             menu.removeItem(R.id.action_search);
         }
+
     }
 
     /**
@@ -1169,6 +1178,14 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
     }
 
+    @Subscribe(threadMode = ThreadMode.MAIN)
+    public void onMessageEvent(ChangeMenuEvent changeMenuEvent) {
+        menuItemAddRemoveValue = MenuItemAddRemove.ADD_GRID_AND_SORT_WITH_SEARCH;
+        if (getActivity() != null) {
+            getActivity().invalidateOptionsMenu();
+        }
+    }
+
     @Subscribe(threadMode = ThreadMode.BACKGROUND)
     public void onMessageEvent(FavoriteEvent event) {
         Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());