Skip to content

Commit

Permalink
fix remind me later dialog
Browse files Browse the repository at this point in the history
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
  • Loading branch information
parneet-guraya committed Feb 29, 2024
1 parent b8a2314 commit 07137be
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 171 deletions.
6 changes: 1 addition & 5 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4215,11 +4215,7 @@ class ChatActivity :

fun remindMeLater(message: ChatMessage?) {
Log.d(TAG, "remindMeLater called")
val newFragment: DialogFragment = DateTimePickerFragment.newInstance(
roomToken,
message!!.id,
chatViewModel
)
val newFragment = DateTimePickerFragment.newInstance(roomToken, message!!.id)
newFragment.show(supportFragmentManager, DateTimePickerFragment.TAG)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -47,17 +48,13 @@ import javax.inject.Inject

@Suppress("TooManyFunctions")
@AutoInjector(NextcloudTalkApplication::class)
class DateTimePickerFragment(
token: String,
id: String,
chatViewModel: ChatViewModel
) : 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 laterTodayTimeStamp = 0L
private var tomorrowTimeStamp = 0L
private var weekendTimeStamp = 0L
Expand All @@ -72,6 +69,11 @@ 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, "")
}
return MaterialAlertDialogBuilder(requireContext()).setView(dialogView).create()
}

Expand Down Expand Up @@ -297,13 +299,18 @@ 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"

@JvmStatic
fun newInstance(token: String, id: String, chatViewModel: ChatViewModel) =
DateTimePickerFragment(
token,
id,
chatViewModel
)
fun newInstance(token: String, id: String): DateTimePickerFragment {
val args = Bundle()
args.putString(TOKEN_ARG, token)
args.putString(ID_ARG, id)

val dateTimePickerFragment = DateTimePickerFragment()
dateTimePickerFragment.arguments = args
return dateTimePickerFragment
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ class FilterConversationFragment : DialogFragment() {
private const val FILTER_STATE_ARG = "FILTER_STATE_ARG"

@JvmStatic
fun newInstance(
savedFilterState: MutableMap<String, Boolean>
): FilterConversationFragment {
fun newInstance(savedFilterState: MutableMap<String, Boolean>): FilterConversationFragment {
val filterConversationFragment = FilterConversationFragment()
val args = Bundle()
args.putSerializable(FILTER_STATE_ARG, HashMap(savedFilterState))
Expand Down
Loading

0 comments on commit 07137be

Please sign in to comment.