diff --git a/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchParameters.kt b/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchParameters.kt index df15bcb2ed..0fb78b2635 100644 --- a/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchParameters.kt +++ b/app/src/main/java/com/amaze/filemanager/asynchronous/asynctasks/searchfilesystem/SearchParameters.kt @@ -23,7 +23,6 @@ package com.amaze.filemanager.asynchronous.asynctasks.searchfilesystem import java.util.EnumSet typealias SearchParameters = EnumSet -infix fun SearchParameters.allOf(other: SearchParameters) = this.containsAll(other) infix fun SearchParameters.and(other: SearchParameter): SearchParameters = SearchParameters.of( other, *this.toTypedArray() @@ -31,10 +30,10 @@ infix fun SearchParameters.and(other: SearchParameter): SearchParameters = Searc operator fun SearchParameters.plus(other: SearchParameter): SearchParameters = this and other fun searchParametersFromBoolean( - showHiddenFiles: Boolean, - isRegexEnabled: Boolean, - isRegexMatchesEnabled: Boolean, - isRoot: Boolean + showHiddenFiles: Boolean = false, + isRegexEnabled: Boolean = false, + isRegexMatchesEnabled: Boolean = false, + isRoot: Boolean = false ): SearchParameters { val searchParameterList = mutableListOf() @@ -43,5 +42,9 @@ fun searchParametersFromBoolean( if (isRegexMatchesEnabled) searchParameterList.add(SearchParameter.REGEX_MATCHES) if (isRoot) searchParameterList.add(SearchParameter.ROOT) - return SearchParameters.copyOf(searchParameterList) + return if (searchParameterList.isEmpty()) { + SearchParameters.noneOf(SearchParameter::class.java) + } else { + SearchParameters.copyOf(searchParameterList) + } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivityViewModel.kt b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivityViewModel.kt index 51b8357f13..663f3cb6cf 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivityViewModel.kt +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/MainActivityViewModel.kt @@ -197,15 +197,11 @@ class MainActivityViewModel(val applicationContext: Application) : query: String ): MutableLiveData> { val sharedPref = PreferenceManager.getDefaultSharedPreferences(mainActivity) - val showHiddenFiles = sharedPref.getBoolean(PREFERENCE_SHOW_HIDDENFILES, false) - val isRegexEnabled = sharedPref.getBoolean(PREFERENCE_REGEX, false) - val isMatchesEnabled = sharedPref.getBoolean(PREFERENCE_REGEX_MATCHES, false) - val isRoot = mainActivity.isRootExplorer val searchParameters = searchParametersFromBoolean( - showHiddenFiles, - isRegexEnabled, - isMatchesEnabled, - isRoot + showHiddenFiles = sharedPref.getBoolean(PREFERENCE_SHOW_HIDDENFILES, false), + isRegexEnabled = sharedPref.getBoolean(PREFERENCE_REGEX, false), + isRegexMatchesEnabled = sharedPref.getBoolean(PREFERENCE_REGEX_MATCHES, false), + isRoot = mainActivity.isRootExplorer ) val path = mainActivity.currentMainFragment?.currentPath ?: ""