mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-27 04:16:42 -08:00
fix: Fix NodeFilter preferences #2541
This commit is contained in:
4 files changed
+16
-28
No files matched your search
@@ -487,6 +487,7 @@ class GroupActivity : DatabaseLockActivity(),
|
||||
|
||||
lifecycleScope.launch {
|
||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
mGroupViewModel.assignPreferences()
|
||||
launch {
|
||||
mGroupViewModel.groupUIState.collect { groupUISTate ->
|
||||
// Load
|
||||
|
||||
@@ -42,9 +42,6 @@ import com.kunzisoft.keepass.credentialprovider.EntrySelectionHelper.retrieveSpe
|
||||
import com.kunzisoft.keepass.credentialprovider.SpecialMode
|
||||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.element.SortNodeEnum
|
||||
import com.kunzisoft.keepass.database.element.node.DefaultNodeFilter
|
||||
import com.kunzisoft.keepass.database.element.node.EmptyNodeFilter
|
||||
import com.kunzisoft.keepass.database.element.node.NodeFilter
|
||||
import com.kunzisoft.keepass.model.SearchGroupInfo
|
||||
import com.kunzisoft.keepass.model.SortedNodeInfo
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
@@ -63,9 +60,6 @@ class GroupFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListen
|
||||
|
||||
private var specialMode: SpecialMode = SpecialMode.DEFAULT
|
||||
|
||||
|
||||
private var mNodeFilter: NodeFilter = EmptyNodeFilter()
|
||||
|
||||
private var mRecycleViewScrollListener = object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
super.onScrollStateChanged(recyclerView, newState)
|
||||
@@ -139,13 +133,6 @@ class GroupFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListen
|
||||
mNodesRecyclerView = view.findViewById(R.id.nodes_list)
|
||||
notFoundView = view.findViewById(R.id.not_found_container)
|
||||
|
||||
context?.let {
|
||||
mNodeFilter = DefaultNodeFilter(
|
||||
showExpired = PreferencesUtil.showExpiredEntries(it),
|
||||
showTemplates = PreferencesUtil.showTemplates(it)
|
||||
)
|
||||
}
|
||||
|
||||
mLayoutManager = LinearLayoutManager(context)
|
||||
mNodesRecyclerView?.apply {
|
||||
scrollBarStyle = View.SCROLLBARS_INSIDE_INSET
|
||||
@@ -163,8 +150,7 @@ class GroupFragment : DatabaseFragment(), SortDialogFragment.SortSelectionListen
|
||||
groupUIState.children?.let { children ->
|
||||
mAdapter?.rebuildList(
|
||||
nodes = children,
|
||||
isSearch = currentGroup is SearchGroupInfo,
|
||||
nodeFilter = mNodeFilter
|
||||
isSearch = currentGroup is SearchGroupInfo
|
||||
)
|
||||
}
|
||||
// Direct action node selection after rebuild
|
||||
|
||||
@@ -40,8 +40,6 @@ import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.database.ContextualDatabase
|
||||
import com.kunzisoft.keepass.database.element.SortNodeEnum
|
||||
import com.kunzisoft.keepass.database.element.Tag
|
||||
import com.kunzisoft.keepass.database.element.node.EmptyNodeFilter
|
||||
import com.kunzisoft.keepass.database.element.node.NodeFilter
|
||||
import com.kunzisoft.keepass.database.element.node.NodeId
|
||||
import com.kunzisoft.keepass.database.element.node.NodeType
|
||||
import com.kunzisoft.keepass.database.element.template.TemplateField
|
||||
@@ -97,8 +95,6 @@ class NodesAdapter(
|
||||
private var mNodeClickCallback: NodeClickCallback? = null
|
||||
private var mClipboardHelper = ClipboardHelper(context)
|
||||
|
||||
private var mNodeFilter: NodeFilter = EmptyNodeFilter()
|
||||
|
||||
@ColorInt
|
||||
private val mColorSurfaceContainer: Int
|
||||
@ColorInt
|
||||
@@ -179,14 +175,11 @@ class NodesAdapter(
|
||||
/**
|
||||
* Rebuild the list by clear and build children from the list of [nodes]
|
||||
* @param isSearch If the list is a search list
|
||||
* @param nodeFilter Node filter to apply
|
||||
*/
|
||||
fun rebuildList(
|
||||
nodes: List<SortedNodeInfo>,
|
||||
isSearch: Boolean = false,
|
||||
nodeFilter: NodeFilter = EmptyNodeFilter()
|
||||
isSearch: Boolean = false
|
||||
) {
|
||||
mNodeFilter = nodeFilter
|
||||
mOldVirtualGroup = mVirtualGroup
|
||||
mVirtualGroup = isSearch
|
||||
assignPreferences()
|
||||
|
||||
@@ -156,13 +156,21 @@ class GroupViewModel(application: Application): AndroidViewModel(application) {
|
||||
private val _scrollTo = MutableSharedFlow<Int>(replay = 0)
|
||||
val scrollTo: SharedFlow<Int> = _scrollTo.asSharedFlow()
|
||||
|
||||
private var mDefaultSearchParameters: SearchParameters = PreferencesUtil.getDefaultSearchParameters(getApplication())
|
||||
private var mAutoFocusSearch: Boolean = PreferencesUtil.automaticallyFocusSearch(getApplication())
|
||||
private var mRecursiveNumberEntries: Boolean = PreferencesUtil.recursiveNumberEntries(getApplication())
|
||||
private var mShowExpiredEntries: Boolean = PreferencesUtil.showExpiredEntries(getApplication())
|
||||
private var mShowTemplates: Boolean = PreferencesUtil.showTemplates(getApplication())
|
||||
private var mDefaultSearchParameters: SearchParameters = SearchParameters()
|
||||
private var mAutoFocusSearch: Boolean = false
|
||||
private var mRecursiveNumberEntries: Boolean = false
|
||||
private var mShowExpiredEntries: Boolean = false
|
||||
private var mShowTemplates: Boolean = false
|
||||
private var mNodeFilter: NodeFilter = EmptyNodeFilter()
|
||||
|
||||
fun assignPreferences() {
|
||||
mDefaultSearchParameters = PreferencesUtil.getDefaultSearchParameters(getApplication())
|
||||
mAutoFocusSearch = PreferencesUtil.automaticallyFocusSearch(getApplication())
|
||||
mRecursiveNumberEntries = PreferencesUtil.recursiveNumberEntries(getApplication())
|
||||
mShowExpiredEntries = PreferencesUtil.showExpiredEntries(getApplication())
|
||||
mShowTemplates = PreferencesUtil.showTemplates(getApplication())
|
||||
}
|
||||
|
||||
fun onDatabaseLoaded(
|
||||
database: ContextualDatabase,
|
||||
recycleBinAllowed: Boolean
|
||||
|
||||
Reference in new issue
Block a user