Mario Danic пре 8 година
родитељ
комит
9f94104eed

+ 5 - 2
build.gradle

@@ -58,8 +58,8 @@ android {
         javaMaxHeapSize "4g"
     }
 
-    compileSdkVersion 24
-    buildToolsVersion "24.0.2"
+    compileSdkVersion 25
+    buildToolsVersion "25.0.2"
 
     defaultConfig {
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -185,6 +185,9 @@ dependencies {
     compile 'com.github.evernote:android-job:v1.1.7'
     compile 'org.greenrobot:eventbus:3.0.0'
 
+    compile 'org.parceler:parceler-api:1.1.6'
+    annotationProcessor 'org.parceler:parceler:1.1.6'
+
     customCompile 'com.google.firebase:firebase-core:10.2.0'
 
     /// dependencies for local unit tests

+ 3 - 4
src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java

@@ -62,6 +62,8 @@ import com.owncloud.android.ui.activity.UploadFilesActivity;
 import com.owncloud.android.ui.adapter.FileListListAdapter;
 import com.owncloud.android.ui.adapter.LocalFileListAdapter;
 
+import org.parceler.Parcel;
+
 import java.util.ArrayList;
 
 import third_parties.in.srain.cube.GridViewWithHeaderAndFooter;
@@ -127,8 +129,7 @@ public class ExtendedListFragment extends Fragment
     protected SearchView searchView;
     private Handler handler = new Handler();
 
-    protected Menu mMenu;
-
+    @Parcel
     public enum SearchType {
         NO_SEARCH,
         REGULAR_FILTER,
@@ -145,7 +146,6 @@ public class ExtendedListFragment extends Fragment
         RECENTLY_ADDED_SEARCH_FILTER
     }
 
-
     protected void setListAdapter(BaseAdapter listAdapter) {
         mAdapter = listAdapter;
         mCurrentListView.setAdapter(listAdapter);
@@ -198,7 +198,6 @@ public class ExtendedListFragment extends Fragment
 
     @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);

+ 19 - 0
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -88,6 +88,7 @@ import com.owncloud.android.utils.FileStorageUtils;
 import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
+import org.parceler.Parcels;
 
 import java.io.File;
 import java.io.IOException;
@@ -113,6 +114,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     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_CURRENT_SEARCH_TYPE = "CURRENT_SEARCH_TYPE";
+
     private static final String GRID_IS_PREFERED_PREFERENCE = "gridIsPrefered";
 
     private static final String DIALOG_CREATE_FOLDER = "DIALOG_CREATE_FOLDER";
@@ -137,6 +140,8 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
     private BottomNavigationView bottomNavigationView;
 
+    private SearchType currentSearchType;
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -180,6 +185,12 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
         View v = super.onCreateView(inflater, container, savedInstanceState);
         bottomNavigationView = (BottomNavigationView) v.findViewById(R.id.bottom_navigation_view);
 
+        if (savedInstanceState != null) {
+            currentSearchType = Parcels.unwrap(savedInstanceState.getParcelable(KEY_CURRENT_SEARCH_TYPE));
+        } else {
+            currentSearchType = SearchType.NO_SEARCH;
+        }
+
         if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
             bottomNavigationView.setVisibility(View.VISIBLE);
             prepareBottomNavigationView();
@@ -622,6 +633,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         outState.putParcelable(KEY_FILE, mFile);
+        outState.putParcelable(KEY_CURRENT_SEARCH_TYPE, Parcels.wrap(currentSearchType));
         mMultiChoiceModeListener.storeStateIn(outState);
     }
 
@@ -1094,6 +1106,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
             unsetAllMenuItems(true);
         }
 
+
         Account currentAccount = com.owncloud.android.authentication.AccountUtils.
                 getCurrentOwnCloudAccount(MainApp.getAppContext());
 
@@ -1111,18 +1124,24 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
                 if (event.getSearchType().equals(SearchOperation.SearchType.FILE_SEARCH)) {
                     setEmptyListMessage(SearchType.FILE_SEARCH);
+                    currentSearchType = SearchType.FILE_SEARCH;
                 } else if (event.getSearchType().equals(SearchOperation.SearchType.CONTENT_TYPE_SEARCH)) {
                     if (event.getSearchQuery().equals("image/%")) {
                         setEmptyListMessage(SearchType.PHOTO_SEARCH);
+                        currentSearchType = SearchType.PHOTO_SEARCH;
                     } else if (event.getSearchQuery().equals("video/%")) {
                         setEmptyListMessage(SearchType.VIDEO_SEARCH);
+                        currentSearchType = SearchType.VIDEO_SEARCH;
                     }
                 } else if (event.getSearchType().equals(SearchOperation.SearchType.FAVORITE_SEARCH)) {
                     setEmptyListMessage(SearchType.FAVORITE_SEARCH);
+                    currentSearchType = SearchType.FAVORITE_SEARCH;
                 } else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_ADDED_SEARCH)) {
                     setEmptyListMessage(SearchType.RECENTLY_ADDED_SEARCH);
+                    currentSearchType = SearchType.RECENTLY_ADDED_SEARCH;
                 } else if (event.getSearchType().equals(SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH)) {
                     setEmptyListMessage(SearchType.RECENTLY_MODIFIED_SEARCH);
+                    currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
                 }
 
                 mAdapter.setData(remoteOperationResult.getData());