-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from omer358/dev
resolves #42
- Loading branch information
Showing
20 changed files
with
277 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/rememberme/di/CoroutineModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.rememberme.di | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.coroutines.CoroutineDispatcher | ||
import kotlinx.coroutines.Dispatchers | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object CoroutineModule { | ||
|
||
@Provides | ||
@Singleton | ||
fun provideIoDispatcher(): CoroutineDispatcher = Dispatchers.IO | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...rc/main/java/com/example/rememberme/presentation/onboarding/NotificationActionReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.example.rememberme.presentation.onboarding | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.util.Log | ||
import androidx.core.app.NotificationManagerCompat | ||
import com.example.rememberme.domain.usecases.people.DeletePersonById | ||
import com.example.rememberme.utils.Constants.NOTIFICATION_ID | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.DelicateCoroutinesApi | ||
import kotlinx.coroutines.GlobalScope | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@AndroidEntryPoint | ||
class NotificationActionReceiver : BroadcastReceiver() { | ||
|
||
@Inject | ||
lateinit var deletePersonById: DeletePersonById | ||
@OptIn(DelicateCoroutinesApi::class) | ||
override fun onReceive(context: Context, intent: Intent) { | ||
val notificationManager = NotificationManagerCompat.from(context) | ||
|
||
when (intent.action) { | ||
"ACTION_OKAY" -> { | ||
// Handle the "Okay" action | ||
notificationManager.cancel(NOTIFICATION_ID) | ||
|
||
} | ||
"ACTION_DELETE" -> { | ||
val personId = intent.getLongExtra("personId",-1) | ||
GlobalScope.launch { | ||
Log.i(TAG,"Deleting the person with id: $personId") | ||
deletePersonById(personId) | ||
notificationManager.cancel(NOTIFICATION_ID) | ||
} | ||
} | ||
} | ||
} | ||
companion object{ | ||
private const val TAG = "NotificationActionRecei" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.