From e7ef618119115b2c4ae26a0993f5c4f1b5d75f1e Mon Sep 17 00:00:00 2001 From: parneet-guraya Date: Thu, 29 Feb 2024 23:19:13 +0530 Subject: [PATCH 1/2] fix filter dialog Signed-off-by: parneet-guraya --- .../ConversationsListActivity.kt | 5 +-- .../ui/dialog/FilterConversationFragment.kt | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt index add7201ae9..1c6d1142e4 100644 --- a/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/conversationlist/ConversationsListActivity.kt @@ -978,10 +978,7 @@ class ConversationsListActivity : updateFilterConversationButtonColor() binding.filterConversationsButton.setOnClickListener { - val newFragment: DialogFragment = FilterConversationFragment.newInstance( - filterState, - this - ) + val newFragment = FilterConversationFragment.newInstance(filterState) newFragment.show(supportFragmentManager, FilterConversationFragment.TAG) } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt index a990a0c813..8f31c1fbf1 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt @@ -20,6 +20,7 @@ package com.nextcloud.talk.ui.dialog import android.app.Dialog +import android.os.Build import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -38,14 +39,10 @@ import com.nextcloud.talk.utils.UserIdUtils import javax.inject.Inject @AutoInjector(NextcloudTalkApplication::class) -class FilterConversationFragment( - savedFilterState: MutableMap, - conversationsListActivity: ConversationsListActivity -) : DialogFragment() { +class FilterConversationFragment : DialogFragment() { lateinit var binding: DialogFilterConversationBinding private var dialogView: View? = null - private var filterState = savedFilterState - private var conversationsList = conversationsListActivity + private lateinit var filterState: HashMap @Inject lateinit var userManager: UserManager @@ -58,7 +55,11 @@ class FilterConversationFragment( override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { binding = DialogFilterConversationBinding.inflate(LayoutInflater.from(context)) dialogView = binding.root - + filterState = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + arguments?.getSerializable(FILTER_STATE_ARG, HashMap::class.java) as HashMap + } else { + arguments?.getSerializable(FILTER_STATE_ARG) as HashMap + } return MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create() } @@ -120,15 +121,23 @@ class FilterConversationFragment( arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "") arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "") - conversationsList.filterConversation() + (requireActivity() as ConversationsListActivity).filterConversation() } companion object { + private const val FILTER_STATE_ARG = "FILTER_STATE_ARG" + @JvmStatic fun newInstance( - savedFilterState: MutableMap, - conversationsListActivity: ConversationsListActivity - ) = FilterConversationFragment(savedFilterState, conversationsListActivity) + savedFilterState: MutableMap + ): FilterConversationFragment { + 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 const val MENTION: String = "mention" const val UNREAD: String = "unread" From 3866beed924e19e77244f936ec4c225b6203a7be Mon Sep 17 00:00:00 2001 From: parneet-guraya Date: Fri, 1 Mar 2024 00:00:59 +0530 Subject: [PATCH 2/2] fix remind me later dialog Signed-off-by: parneet-guraya --- .../com/nextcloud/talk/chat/ChatActivity.kt | 7 +- .../talk/ui/dialog/DateTimePickerFragment.kt | 42 ++- .../ui/dialog/FilterConversationFragment.kt | 4 +- .../res/layout/dialog_date_time_picker.xml | 304 +++++++++--------- 4 files changed, 183 insertions(+), 174 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index ae9e06c6db..0a138b2a59 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -4259,12 +4259,7 @@ class ChatActivity : val chatApiVersion = ApiUtils.getChatApiVersion(spreedCapabilities, intArrayOf(ApiUtils.API_V1, 1)) - val newFragment: DialogFragment = DateTimePickerFragment.newInstance( - roomToken, - message!!.id, - chatViewModel, - chatApiVersion - ) + val newFragment: DialogFragment = DateTimePickerFragment.newInstance(roomToken, message!!.id, chatApiVersion) newFragment.show(supportFragmentManager, DateTimePickerFragment.TAG) } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt index 65afc1888f..209bd36906 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/DateTimePickerFragment.kt @@ -37,6 +37,7 @@ import com.google.android.material.timepicker.TimeFormat import com.nextcloud.android.common.ui.theme.utils.ColorRole import com.nextcloud.talk.R import com.nextcloud.talk.application.NextcloudTalkApplication +import com.nextcloud.talk.chat.ChatActivity import com.nextcloud.talk.chat.viewmodels.ChatViewModel import com.nextcloud.talk.databinding.DialogDateTimePickerBinding import com.nextcloud.talk.ui.theme.ViewThemeUtils @@ -47,18 +48,15 @@ import javax.inject.Inject @Suppress("TooManyFunctions") @AutoInjector(NextcloudTalkApplication::class) -class DateTimePickerFragment( - token: String, - id: String, - chatViewModel: ChatViewModel, - private val chatApiVersion: Int -) : DialogFragment() { +class DateTimePickerFragment : DialogFragment() { + lateinit var binding: DialogDateTimePickerBinding private var dialogView: View? = null - private var viewModel = chatViewModel + private lateinit var viewModel: ChatViewModel private var currentTimeStamp: Long? = null - private var roomToken = token - private var messageId = id + private lateinit var roomToken: String + private lateinit var messageId: String + private var chatApiVersion: Int = -1 private var laterTodayTimeStamp = 0L private var tomorrowTimeStamp = 0L private var weekendTimeStamp = 0L @@ -73,6 +71,12 @@ class DateTimePickerFragment( override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { binding = DialogDateTimePickerBinding.inflate(LayoutInflater.from(context)) dialogView = binding.root + viewModel = (requireActivity() as ChatActivity).chatViewModel + arguments?.let { + roomToken = it.getString(TOKEN_ARG, "") + messageId = it.getString(ID_ARG, "") + chatApiVersion = it.getInt(CHAT_API_VERSION_ARG) + } return MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create() } @@ -304,14 +308,20 @@ class DateTimePickerFragment( private const val ONE_SEC = 1000 private const val HOUR_EIGHT_AM = 8 private const val HOUR_SIX_PM = 18 + private const val TOKEN_ARG = "TOKEN_ARG" + private const val ID_ARG = "ID_ARG" + private const val CHAT_API_VERSION_ARG = "CHAT_API_VERSION_ARG" @JvmStatic - fun newInstance(token: String, id: String, chatViewModel: ChatViewModel, chatApiVersion: Int) = - DateTimePickerFragment( - token, - id, - chatViewModel, - chatApiVersion - ) + fun newInstance(token: String, id: String, chatApiVersion: Int): DateTimePickerFragment { + val args = Bundle() + args.putString(TOKEN_ARG, token) + args.putString(ID_ARG, id) + args.putInt(CHAT_API_VERSION_ARG, chatApiVersion) + + val dateTimePickerFragment = DateTimePickerFragment() + dateTimePickerFragment.arguments = args + return dateTimePickerFragment + } } } diff --git a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt index 8f31c1fbf1..d4a61f9e56 100644 --- a/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt +++ b/app/src/main/java/com/nextcloud/talk/ui/dialog/FilterConversationFragment.kt @@ -128,9 +128,7 @@ class FilterConversationFragment : DialogFragment() { private const val FILTER_STATE_ARG = "FILTER_STATE_ARG" @JvmStatic - fun newInstance( - savedFilterState: MutableMap - ): FilterConversationFragment { + fun newInstance(savedFilterState: MutableMap): FilterConversationFragment { val filterConversationFragment = FilterConversationFragment() val args = Bundle() args.putSerializable(FILTER_STATE_ARG, HashMap(savedFilterState)) diff --git a/app/src/main/res/layout/dialog_date_time_picker.xml b/app/src/main/res/layout/dialog_date_time_picker.xml index 2fd1e51a64..96d21a382d 100644 --- a/app/src/main/res/layout/dialog_date_time_picker.xml +++ b/app/src/main/res/layout/dialog_date_time_picker.xml @@ -17,202 +17,208 @@ ~ You should have received a copy of the GNU General Public License ~ along with this program. If not, see . --> - + android:orientation="vertical"> - + android:layout_margin="@dimen/standard_margin" + android:orientation="horizontal"> - + - + + - - + - + android:background="?android:attr/selectableItemBackground" + android:orientation="horizontal" + android:padding="@dimen/standard_padding"> - - + - + + - + android:background="?android:attr/selectableItemBackground" + android:orientation="horizontal" + android:padding="@dimen/standard_padding"> - - + - + + - + android:background="?android:attr/selectableItemBackground" + android:orientation="horizontal" + android:padding="@dimen/standard_padding"> - - + - + + - + android:background="?android:attr/selectableItemBackground" + android:orientation="horizontal" + android:padding="@dimen/standard_padding"> - - + - + + - + - + android:background="?android:attr/selectableItemBackground" + android:orientation="horizontal" + android:padding="@dimen/standard_padding"> - - + - + + + android:orientation="horizontal"> + + + + + + + android:text="@string/set" /> - + - + - - - - \ No newline at end of file + \ No newline at end of file