Skip to content

Commit

Permalink
Added Tap on Action on Notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
MuindiStephen committed Jul 5, 2024
1 parent c318bb9 commit b7f45ec
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions app/src/main/java/com/steve_md/smartmkulima/model/GAP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,38 @@ import kotlinx.parcelize.Parcelize
data class GAP(
val nameGAP: String,
val imageGAP: String,
val gap: List<GAPtask> = listOf()
) : Parcelable {
val gap: List<GAPtask>
): Parcelable {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as GAP

if (nameGAP != other.nameGAP) return false
// Compare other properties here if necessary
if (imageGAP != other.imageGAP) return false
if (gap != other.gap) return false

return true
}

override fun hashCode(): Int {
var result = nameGAP.hashCode()
result = 31 * result + nameGAP.hashCode()
// Combine other properties into hash code if necessary
// result = 31 * result + gap.hashCode()
return result
}
}

/**
*
* if (Parcelable::class.java.isAssignableFrom(GAP::class.java)) {
* result.putParcelable("gap", this.gap as Parcelable)
* } else if (Serializable::class.java.isAssignableFrom(GAP::class.java)) {
* result.putSerializable("gap", this.gap as Serializable)
* } el
*/

@Parcelize
data class GAPtask (
val taskName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class HomeDashboardFragment : Fragment() {
Timber.i("=====Checking=======>: ${gap.nameGAP} Good Agricultural practice!")

// findNavController().navigate(
// HomeDashboardFragmentDirections.actionHomeDashboardFragment2ToDetailedGAP(gap)
// HomeDashboardFragmentDirections.actionHomeDashboardFragment2ToAllGAPHomeFragment(gap)
// )

val bundle = Bundle().apply {
Expand All @@ -168,7 +168,7 @@ class HomeDashboardFragment : Fragment() {
) {
if (response.isSuccessful) {

Timber.i("==== Viewing Good agri. practices${response.body()}=====")
Timber.i("==== Viewing Good Agri. practices${response.body()}=====")
// displaySnackBar("Viewing Available cycles")

val gaps = response.body()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import android.app.AlertDialog
import android.app.DatePickerDialog
import android.app.NotificationChannel
import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -88,12 +90,21 @@ class AutoCreateCropCycleFragment : Fragment() {

val notificationId = Random().nextInt()

val intentId = Intent(requireActivity(),AutoCreateCropCycleFragment::class.java)

val pendingIntent = PendingIntent.getActivity(
requireActivity(),notificationId,intentId,
PendingIntent.FLAG_IMMUTABLE)

val builder = NotificationCompat.Builder(requireContext(), "notification_id")
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle("Crop cycle tasks")
.setContentTitle("Farm cycle tasks")
.setContentText("Your have tasks due in $daysLater days.")
.setTicker("Exit")
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentIntent(pendingIntent)
.setAutoCancel(true)

val notification = builder.build()

Expand Down

0 comments on commit b7f45ec

Please sign in to comment.