fix filter dialog

Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parneet-guraya 2024-02-29 23:19:13 +05:30 committed by Marcel Hibbe
parent d863674b68
commit e7ef618119
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
2 changed files with 21 additions and 15 deletions

View file

@ -978,10 +978,7 @@ class ConversationsListActivity :
updateFilterConversationButtonColor() updateFilterConversationButtonColor()
binding.filterConversationsButton.setOnClickListener { binding.filterConversationsButton.setOnClickListener {
val newFragment: DialogFragment = FilterConversationFragment.newInstance( val newFragment = FilterConversationFragment.newInstance(filterState)
filterState,
this
)
newFragment.show(supportFragmentManager, FilterConversationFragment.TAG) newFragment.show(supportFragmentManager, FilterConversationFragment.TAG)
} }

View file

@ -20,6 +20,7 @@
package com.nextcloud.talk.ui.dialog package com.nextcloud.talk.ui.dialog
import android.app.Dialog import android.app.Dialog
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -38,14 +39,10 @@ import com.nextcloud.talk.utils.UserIdUtils
import javax.inject.Inject import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class) @AutoInjector(NextcloudTalkApplication::class)
class FilterConversationFragment( class FilterConversationFragment : DialogFragment() {
savedFilterState: MutableMap<String, Boolean>,
conversationsListActivity: ConversationsListActivity
) : DialogFragment() {
lateinit var binding: DialogFilterConversationBinding lateinit var binding: DialogFilterConversationBinding
private var dialogView: View? = null private var dialogView: View? = null
private var filterState = savedFilterState private lateinit var filterState: HashMap<String, Boolean>
private var conversationsList = conversationsListActivity
@Inject @Inject
lateinit var userManager: UserManager lateinit var userManager: UserManager
@ -58,7 +55,11 @@ class FilterConversationFragment(
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
binding = DialogFilterConversationBinding.inflate(LayoutInflater.from(context)) binding = DialogFilterConversationBinding.inflate(LayoutInflater.from(context))
dialogView = binding.root dialogView = binding.root
filterState = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
arguments?.getSerializable(FILTER_STATE_ARG, HashMap::class.java) as HashMap<String, Boolean>
} else {
arguments?.getSerializable(FILTER_STATE_ARG) as HashMap<String, Boolean>
}
return MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create() return MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create()
} }
@ -120,15 +121,23 @@ class FilterConversationFragment(
arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "") arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "")
arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "") arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "")
conversationsList.filterConversation() (requireActivity() as ConversationsListActivity).filterConversation()
} }
companion object { companion object {
private const val FILTER_STATE_ARG = "FILTER_STATE_ARG"
@JvmStatic @JvmStatic
fun newInstance( fun newInstance(
savedFilterState: MutableMap<String, Boolean>, savedFilterState: MutableMap<String, Boolean>
conversationsListActivity: ConversationsListActivity ): FilterConversationFragment {
) = FilterConversationFragment(savedFilterState, conversationsListActivity) val filterConversationFragment = FilterConversationFragment()
val args = Bundle()
args.putSerializable(FILTER_STATE_ARG, HashMap(savedFilterState))
filterConversationFragment.arguments = args
return filterConversationFragment
}
val TAG: String = FilterConversationFragment::class.java.simpleName val TAG: String = FilterConversationFragment::class.java.simpleName
const val MENTION: String = "mention" const val MENTION: String = "mention"
const val UNREAD: String = "unread" const val UNREAD: String = "unread"