forked from openedx/openedx-app-android
-
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.
feat: Notifications Preferences Screen
Fixes: LEARNER-10345
- Loading branch information
1 parent
dfc37d6
commit 8ea50d1
Showing
28 changed files
with
549 additions
and
16 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
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
7 changes: 6 additions & 1 deletion
7
notifications/src/main/java/org/openedx/notifications/data/api/APIConstants.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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
package org.openedx.notifications.data.api | ||
|
||
object APIConstants { | ||
const val NOTIFICATION_COUNT = "/api/notifications/count/" | ||
const val NOTIFICATIONS_COUNT = "/api/notifications/count/" | ||
const val NOTIFICATIONS_INBOX = "/api/notifications/" | ||
const val NOTIFICATIONS_SEEN = "/api/notifications/mark-seen/{app_name}/" | ||
const val NOTIFICATION_READ = "/api/notifications/read/" | ||
|
||
const val NOTIFICATIONS_CONFIGURATION = "/api/notifications/configurations/" | ||
const val NOTIFICATION_UPDATE_CONFIGURATION = "/api/notifications/preferences/update-all/" | ||
|
||
const val APP_NAME_DISCUSSION = "discussion" | ||
const val NOTIFICATION_TYPE = "core" | ||
const val NOTIFICATION_CHANNEL = "push" | ||
} |
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
35 changes: 35 additions & 0 deletions
35
...ications/src/main/java/org/openedx/notifications/data/model/NotificationsConfiguration.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,35 @@ | ||
package org.openedx.notifications.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import org.openedx.notifications.domain.model.NotificationsConfiguration | ||
|
||
data class NotificationsConfiguration( | ||
@SerializedName("status") val status: String, | ||
@SerializedName("message") val message: String, | ||
@SerializedName("data") val data: NotificationData, | ||
) { | ||
fun mapToDomain(): NotificationsConfiguration { | ||
return NotificationsConfiguration( | ||
discussionsPushEnabled = data.discussion | ||
.notificationTypes[CORE_NOTIFICATION_TYPE]?.push ?: false | ||
) | ||
} | ||
|
||
companion object { | ||
const val CORE_NOTIFICATION_TYPE = "core" | ||
} | ||
} | ||
|
||
data class NotificationData( | ||
@SerializedName("discussion") val discussion: NotificationCategory, | ||
) | ||
|
||
data class NotificationCategory( | ||
@SerializedName("enabled") val enabled: Boolean, | ||
@SerializedName("notification_types") val notificationTypes: Map<String, NotificationType>, | ||
@SerializedName("core_notification_types") val coreNotificationTypes: List<String>, | ||
) | ||
|
||
data class NotificationType( | ||
@SerializedName("push") val push: Boolean, | ||
) |
33 changes: 33 additions & 0 deletions
33
notifications/src/main/java/org/openedx/notifications/data/model/NotificationsUpdateBody.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,33 @@ | ||
package org.openedx.notifications.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import org.openedx.notifications.domain.model.NotificationsUpdateResponse | ||
|
||
data class NotificationsUpdateBody( | ||
@SerializedName("notification_app") val notificationApp: String, | ||
@SerializedName("notification_type") val notificationType: String, | ||
@SerializedName("notification_channel") val notificationChannel: String, | ||
@SerializedName("value") val value: Boolean, | ||
) | ||
|
||
data class NotificationsUpdateResponse( | ||
@SerializedName("status") val status: String, | ||
@SerializedName("data") val data: NotificationUpdateData, | ||
) { | ||
fun mapToDomain(): NotificationsUpdateResponse { | ||
return NotificationsUpdateResponse( | ||
status = status, | ||
updatedValue = data.updatedValue, | ||
notificationType = data.notificationType, | ||
channel = data.channel, | ||
app = data.app | ||
) | ||
} | ||
} | ||
|
||
data class NotificationUpdateData( | ||
@SerializedName("updated_value") val updatedValue: Boolean, | ||
@SerializedName("notification_type") val notificationType: String, | ||
@SerializedName("channel") val channel: String, | ||
@SerializedName("app") val app: String, | ||
) |
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
5 changes: 5 additions & 0 deletions
5
...ications/src/main/java/org/openedx/notifications/data/storage/NotificationsPreferences.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 |
---|---|---|
@@ -1,2 +1,7 @@ | ||
package org.openedx.notifications.data.storage | ||
|
||
import org.openedx.notifications.domain.model.NotificationsConfiguration | ||
|
||
interface NotificationsPreferences { | ||
var notifications: NotificationsConfiguration | ||
} |
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
11 changes: 11 additions & 0 deletions
11
...ations/src/main/java/org/openedx/notifications/domain/model/NotificationsConfiguration.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,11 @@ | ||
package org.openedx.notifications.domain.model | ||
|
||
data class NotificationsConfiguration( | ||
val discussionsPushEnabled: Boolean, | ||
) { | ||
companion object { | ||
val default = NotificationsConfiguration( | ||
discussionsPushEnabled = false, | ||
) | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
notifications/src/main/java/org/openedx/notifications/domain/model/NotificationsSettings.kt
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...tions/src/main/java/org/openedx/notifications/domain/model/NotificationsUpdateResponse.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,9 @@ | ||
package org.openedx.notifications.domain.model | ||
|
||
data class NotificationsUpdateResponse( | ||
val status: String, | ||
val updatedValue: Boolean, | ||
val notificationType: String, | ||
val channel: String, | ||
val app: String, | ||
) |
18 changes: 18 additions & 0 deletions
18
notifications/src/main/java/org/openedx/notifications/presentation/NotificationsAnalytics.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 |
---|---|---|
@@ -1,2 +1,20 @@ | ||
package org.openedx.notifications.presentation | ||
|
||
interface NotificationsAnalytics { | ||
fun logEvent(event: String, params: Map<String, Any?>) | ||
fun logScreenEvent(screenName: String, params: Map<String, Any?>) | ||
} | ||
|
||
enum class NotificationsAnalyticsEvent(val eventName: String, val biValue: String) { | ||
DISCUSSION_PERMISSION_TOGGLE( | ||
eventName = "Notification:Discussion Permission Toggle", | ||
biValue = "edx.bi.app.notification.discussion.permission.toggle" | ||
) | ||
} | ||
|
||
enum class NotificationsAnalyticsKey(val key: String) { | ||
NAME("name"), | ||
ACTION("action"), | ||
CATEGORY("category"), | ||
NOTIFICATIONS("notifications"), | ||
} |
2 changes: 0 additions & 2 deletions
2
...ons/src/main/java/org/openedx/notifications/presentation/NotificationsSettingsFragment.kt
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
...ns/src/main/java/org/openedx/notifications/presentation/NotificationsSettingsViewModel.kt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.