Draft Connect UI with messaging

This commit is contained in:
Arturo Mejia 2022-03-04 18:39:45 -05:00
parent 3e3f949fab
commit 7b2c7c4cc6
10 changed files with 141 additions and 40 deletions

View File

@ -1,37 +1,4 @@
{
"homescreen": {
"description": "The homescreen that the user goes to when they press home or new tab.",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"sections-enabled": {
"description": "This property provides a lookup table of whether or not the given section should be enabled. If the section is enabled, it should be toggleable in the settings screen, and on by default.",
"type": "json"
}
}
},
"default-browser-message": {
"description": "A small feature allowing experiments on the placement of a default browser message.",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"message-location": {
"description": "Where is the message to be put.",
"type": "string"
}
}
},
"search-term-groups": {
"description": "A feature allowing the grouping of URLs around the search term that it came from.",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"enabled": {
"description": "If true, the feature shows up on the homescreen and on the new tab screen.",
"type": "boolean"
}
}
},
"nimbus-validation": {
"description": "A feature that does not correspond to an application feature suitable for showing that Nimbus is working. This should never be used in production.",
"hasExposure": true,
@ -50,5 +17,61 @@
"type": "string"
}
}
},
"homescreen": {
"description": "The homescreen that the user goes to when they press home or new tab.",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"sections-enabled": {
"description": "This property provides a lookup table of whether or not the given section should be enabled. If the section is enabled, it should be toggleable in the settings screen, and on by default.",
"type": "json"
}
}
},
"search-term-groups": {
"description": "A feature allowing the grouping of URLs around the search term that it came from.",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"enabled": {
"description": "If true, the feature shows up on the homescreen and on the new tab screen.",
"type": "boolean"
}
}
},
"messaging": {
"description": "Configuration for the messaging system.\n\nIn practice this is a set of growable lookup tables for the\nmessage controller to piece together.\n",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"actions": {
"description": "A growable map of action URLs.",
"type": "json"
},
"messages": {
"description": "A growable collection of messages",
"type": "json"
},
"styles": {
"description": "A map of styles to configure message appearance.\n",
"type": "json"
},
"triggers": {
"description": "A collection of out the box trigger expressions. Each entry maps to a valid JEXL expression.\n",
"type": "json"
}
}
},
"default-browser-message": {
"description": "A small feature allowing experiments on the placement of a default browser message.",
"hasExposure": true,
"exposureDescription": "",
"variables": {
"message-location": {
"description": "Where is the message to be put.",
"type": "string"
}
}
}
}

View File

@ -28,6 +28,9 @@ import org.mozilla.fenix.autofill.AutofillSearchActivity
import org.mozilla.fenix.autofill.AutofillUnlockActivity
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.gleanplum.KeyPairMessageStorage
import org.mozilla.fenix.gleanplum.MessagesManager
import org.mozilla.fenix.nimbus.FxNimbus
import org.mozilla.fenix.perf.AppStartReasonProvider
import org.mozilla.fenix.perf.StartupActivityLog
import org.mozilla.fenix.perf.StartupStateProvider
@ -153,6 +156,18 @@ class Components(private val context: Context) {
)
}
val messageStorage by lazyMonitored {
KeyPairMessageStorage()
}
val messagesManager by lazyMonitored {
MessagesManager(
context,
messageStorage,
FxNimbus.features.messaging
)
}
val analytics by lazyMonitored { Analytics(context) }
val publicSuffixList by lazyMonitored { PublicSuffixList(context) }
val clipboardHandler by lazyMonitored { ClipboardHandler(context) }

View File

@ -0,0 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.gleanplum
class KeyPairMessageStorage : MessageStorage {
override fun getMetadata(): List<MessageMetadata> {
TODO("Not yet implemented")
}
override fun updateMetadata(metadata: MessageMetadata) {
TODO("Not yet implemented")
}
}

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.gleanplum
import org.mozilla.fenix.nimbus.MessageData

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.gleanplum
interface MessageController {

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.gleanplum
interface MessageStorage {

View File

@ -1,3 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.gleanplum
import android.content.Context
@ -17,6 +21,10 @@ class MessagesManager(
Comparator { message1, message2 -> message2.style.priority.compareTo(message1.style.priority) }
)
fun areMessagesAvailable(): Boolean {
return availableMessages.isNotEmpty()
}
override fun getNextMessage(): Message? {
return availableMessages.first()
}

View File

@ -258,7 +258,7 @@ class HomeFragment : Fragment() {
},
recentBookmarks = emptyList(),
showCollectionPlaceholder = components.settings.showCollectionsPlaceholderOnHome,
showSetAsDefaultBrowserCard = components.settings.shouldShowSetAsDefaultBrowserCard(),
showSetAsDefaultBrowserCard = components.messagesManager.areMessagesAvailable(),
// Provide an initial state for recent tabs to prevent re-rendering on the home screen.
// This will otherwise cause a visual jump as the section gets rendered from no state
// to some state.

View File

@ -8,7 +8,10 @@ import android.view.View
import androidx.recyclerview.widget.RecyclerView
import org.mozilla.fenix.R
import org.mozilla.fenix.databinding.ExperimentDefaultBrowserBinding
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.increaseTapArea
import org.mozilla.fenix.gleanplum.Message
import org.mozilla.fenix.gleanplum.MessagesManager
import org.mozilla.fenix.home.sessioncontrol.SessionControlInteractor
class ExperimentDefaultBrowserCardViewHolder(
@ -16,15 +19,39 @@ class ExperimentDefaultBrowserCardViewHolder(
private val interactor: SessionControlInteractor
) : RecyclerView.ViewHolder(view) {
// TODO: Address !!
private val messagesManager: MessagesManager = view.context.components.messagesManager
private val message: Message = messagesManager.getNextMessage()!!
init {
val binding = ExperimentDefaultBrowserBinding.bind(view)
binding.setDefaultBrowser.setOnClickListener {
// TODO: use interactor
messagesManager.onMessagePressed(message)
interactor.onSetDefaultBrowserClicked()
}
binding.descriptionText.text = message.data.text
binding.close.apply {
increaseTapArea(CLOSE_BUTTON_EXTRA_DPS)
setOnClickListener {
// TODO: use interactor
messagesManager.onMessageDismissed(message)
interactor.onCloseExperimentCardClicked()
}
}
binding.close.apply {
increaseTapArea(CLOSE_BUTTON_EXTRA_DPS)
setOnClickListener {
// TODO: use interactor
messagesManager.onMessagePressed(message)
interactor.onCloseExperimentCardClicked()
}
}

View File

@ -186,6 +186,7 @@ features:
"action": "OPEN_GDPR_SETTINGS",
"text": "GDPR has you covered. Firefox has GDPR covered",
"style": "irish-green",
"button-label": "Click me",
"trigger": [
"new-user",
"ireland"
@ -220,12 +221,12 @@ types:
description: "The message text displayed to the user"
# This should never be defaulted.
default: empty_string
button-label:
type: Text?
description: >
The text on the button. If no text
is present, the whole message is clickable.
default: null
button-label:
type: Text
description: >
The text on the button. If no text
is present, the whole message is clickable.
default: empty_string
style:
type: String
description: >