... |
... |
@@ -5,15 +5,21 @@ |
5
|
5
|
package org.mozilla.fenix.components
|
6
|
6
|
|
7
|
7
|
import android.content.Context
|
|
8
|
+import android.content.Intent
|
|
9
|
+import android.net.Uri
|
8
|
10
|
import mozilla.components.service.nimbus.NimbusApi
|
9
|
11
|
import mozilla.components.service.nimbus.NimbusDisabled
|
10
|
12
|
import mozilla.components.service.nimbus.messaging.FxNimbusMessaging
|
11
|
13
|
import mozilla.components.service.nimbus.messaging.Message
|
|
14
|
+import mozilla.components.service.nimbus.messaging.Message.Metadata
|
|
15
|
+import mozilla.components.service.nimbus.messaging.MessageData
|
12
|
16
|
import mozilla.components.service.nimbus.messaging.MessageMetadataStorage
|
|
17
|
+import mozilla.components.service.nimbus.messaging.MessageSurfaceId
|
13
|
18
|
import mozilla.components.service.nimbus.messaging.NimbusMessagingController
|
14
|
19
|
import mozilla.components.service.nimbus.messaging.NimbusMessagingControllerInterface
|
15
|
20
|
import mozilla.components.service.nimbus.messaging.NimbusMessagingStorage
|
16
|
21
|
import mozilla.components.service.nimbus.messaging.OnDiskMessageMetadataStorage
|
|
22
|
+import mozilla.components.service.nimbus.messaging.StyleData
|
17
|
23
|
import org.mozilla.experiments.nimbus.NimbusEventStore
|
18
|
24
|
import org.mozilla.experiments.nimbus.NimbusMessagingHelperInterface
|
19
|
25
|
import org.mozilla.experiments.nimbus.NullNimbus
|
... |
... |
@@ -91,7 +97,7 @@ class NimbusComponents(private val context: Context) { |
91
|
97
|
* from the Nimbus Messaging component.
|
92
|
98
|
*/
|
93
|
99
|
val messaging: NimbusMessagingControllerInterface by lazyMonitored {
|
94
|
|
- NimbusMessagingController(
|
|
100
|
+ NullNimbusMessagingController(
|
95
|
101
|
messagingStorage = messagingStorage,
|
96
|
102
|
deepLinkScheme = BuildConfig.DEEP_LINK_SCHEME,
|
97
|
103
|
)
|
... |
... |
@@ -127,3 +133,110 @@ class NullMessageMetadataStorage(): MessageMetadataStorage { |
127
|
133
|
// noop
|
128
|
134
|
}
|
129
|
135
|
}
|
|
136
|
+
|
|
137
|
+class NullNimbusMessagingController(
|
|
138
|
+ messagingStorage: NimbusMessagingStorage,
|
|
139
|
+ deepLinkScheme: String,
|
|
140
|
+) : NimbusMessagingController(messagingStorage, deepLinkScheme) {
|
|
141
|
+
|
|
142
|
+ private val nullMessage: Message = Message(
|
|
143
|
+ id = "",
|
|
144
|
+ data = MessageData(),
|
|
145
|
+ action = "",
|
|
146
|
+ style = StyleData(),
|
|
147
|
+ triggerIfAll = listOf(),
|
|
148
|
+ excludeIfAny = listOf(),
|
|
149
|
+ metadata = Metadata(""),
|
|
150
|
+ )
|
|
151
|
+
|
|
152
|
+ override suspend fun onMessageDisplayed(displayedMessage: Message, bootIdentifier: String?): Message {
|
|
153
|
+ return nullMessage
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ /**
|
|
157
|
+ * Called when a message has been dismissed by the user.
|
|
158
|
+ *
|
|
159
|
+ * Records a messageDismissed event, and records that the message
|
|
160
|
+ * has been dismissed.
|
|
161
|
+ */
|
|
162
|
+ override suspend fun onMessageDismissed(message: Message) {
|
|
163
|
+ return
|
|
164
|
+ }
|
|
165
|
+
|
|
166
|
+ /**
|
|
167
|
+ * Called when a microsurvey attached to a message has been completed by the user.
|
|
168
|
+ *
|
|
169
|
+ * @param message The message containing the microsurvey that was completed.
|
|
170
|
+ * @param answer The user's response to the microsurvey question.
|
|
171
|
+ */
|
|
172
|
+ override suspend fun onMicrosurveyCompleted(message: Message, answer: String) {
|
|
173
|
+ return
|
|
174
|
+ }
|
|
175
|
+
|
|
176
|
+ /**
|
|
177
|
+ * Called once the user has clicked on a message.
|
|
178
|
+ *
|
|
179
|
+ * This records that the message has been clicked on, but does not record a
|
|
180
|
+ * glean event. That should be done via [processMessageActionToUri].
|
|
181
|
+ */
|
|
182
|
+ override suspend fun onMessageClicked(message: Message) {
|
|
183
|
+ return
|
|
184
|
+ }
|
|
185
|
+
|
|
186
|
+ /**
|
|
187
|
+ * Create and return the relevant [Intent] for the given [Message].
|
|
188
|
+ *
|
|
189
|
+ * @param message the [Message] to create the [Intent] for.
|
|
190
|
+ * @return an [Intent] using the processed [Message].
|
|
191
|
+ */
|
|
192
|
+ override fun getIntentForMessage(message: Message) = Intent()
|
|
193
|
+
|
|
194
|
+ /**
|
|
195
|
+ * Will attempt to get the [Message] for the given [id].
|
|
196
|
+ *
|
|
197
|
+ * @param id the [Message.id] of the [Message] to try to match.
|
|
198
|
+ * @return the [Message] with a matching [id], or null if no [Message] has a matching [id].
|
|
199
|
+ */
|
|
200
|
+ override suspend fun getMessage(id: String): Message? {
|
|
201
|
+ return nullMessage
|
|
202
|
+ }
|
|
203
|
+
|
|
204
|
+ /**
|
|
205
|
+ * The [message] action needs to be examined for string substitutions
|
|
206
|
+ * and any `uuid` needs to be recorded in the Glean event.
|
|
207
|
+ *
|
|
208
|
+ * We call this `process` as it has a side effect of logging a Glean event while it
|
|
209
|
+ * creates a URI string for the message action.
|
|
210
|
+ */
|
|
211
|
+ override fun processMessageActionToUri(message: Message): Uri {
|
|
212
|
+ return Uri.EMPTY
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ override fun sendDismissedMessageTelemetry(messageId: String) {
|
|
216
|
+ return
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ override fun sendShownMessageTelemetry(messageId: String) {
|
|
220
|
+ return
|
|
221
|
+ }
|
|
222
|
+
|
|
223
|
+ override fun sendExpiredMessageTelemetry(messageId: String) {
|
|
224
|
+ return
|
|
225
|
+ }
|
|
226
|
+
|
|
227
|
+ override fun sendClickedMessageTelemetry(messageId: String, uuid: String?) {
|
|
228
|
+ return
|
|
229
|
+ }
|
|
230
|
+
|
|
231
|
+ override fun sendMicrosurveyCompletedTelemetry(messageId: String, answer: String?) {
|
|
232
|
+ return
|
|
233
|
+ }
|
|
234
|
+
|
|
235
|
+ override fun convertActionIntoDeepLinkSchemeUri(action: String): Uri = Uri.EMPTY
|
|
236
|
+
|
|
237
|
+ override suspend fun getMessages(): List<Message> = listOf()
|
|
238
|
+
|
|
239
|
+ override suspend fun getNextMessage(surfaceId: MessageSurfaceId) = nullMessage
|
|
240
|
+
|
|
241
|
+ override fun getNextMessage(surfaceId: MessageSurfaceId, messages: List<Message>) = nullMessage
|
|
242
|
+} |