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 711192b
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 168 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
}
}
}
Loading

0 comments on commit 711192b

Please sign in to comment.