mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] Adding menu configuration for A/A experiment and A/B experiment (https://github.com/mozilla-mobile/fenix/pull/16692)
This commit is contained in:
parent
79f784b127
commit
d1a41ce4cf
@ -0,0 +1,21 @@
|
||||
/* 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.experiments
|
||||
|
||||
class Experiments {
|
||||
companion object {
|
||||
const val A_A_NIMBUS_VALIDATION = "fenix-nimbus-validation"
|
||||
const val BOOKMARK_ICON = "fenix-bookmark-list-icon"
|
||||
}
|
||||
}
|
||||
|
||||
class ExperimentBranch {
|
||||
companion object {
|
||||
const val TREATMENT = "treatment"
|
||||
const val CONTROL = "control"
|
||||
const val A1 = "A1"
|
||||
const val A2 = "A2"
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ import mozilla.components.concept.sync.AuthType
|
||||
import mozilla.components.concept.sync.OAuthAccount
|
||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.experiments.ExperimentBranch
|
||||
import org.mozilla.fenix.experiments.Experiments
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.theme.ThemeManager
|
||||
@ -96,17 +98,41 @@ class HomeMenu(
|
||||
onItemTapped.invoke(Item.WhatsNew)
|
||||
}
|
||||
|
||||
val experiments = context.components.analytics.experiments
|
||||
val bookmarksIcon = experiments.getExperimentBranch(Experiments.BOOKMARK_ICON)
|
||||
.let {
|
||||
when (it) {
|
||||
ExperimentBranch.TREATMENT -> R.drawable.ic_bookmark_list
|
||||
else -> R.drawable.ic_bookmark_filled
|
||||
}
|
||||
}
|
||||
|
||||
val bookmarksItem = BrowserMenuImageText(
|
||||
context.getString(R.string.library_bookmarks),
|
||||
R.drawable.ic_bookmark_filled,
|
||||
bookmarksIcon,
|
||||
primaryTextColor
|
||||
) {
|
||||
onItemTapped.invoke(Item.Bookmarks)
|
||||
}
|
||||
|
||||
// We want to validate that the Nimbus experiments library is working, from the android UI
|
||||
// all the way back to the data science backend. We're not testing the user's preference
|
||||
// or response, we're end-to-end testing the experiments platform.
|
||||
// So here, we're running multiple identical branches with the same treatment, and if the
|
||||
// user isn't targeted, then we get still get the same treatment.
|
||||
// The `let` block is degenerate here, but left here so as to document the form of how experiments
|
||||
// are implemented here.
|
||||
val historyIcon = experiments.getExperimentBranch(Experiments.A_A_NIMBUS_VALIDATION)
|
||||
.let {
|
||||
when (it) {
|
||||
ExperimentBranch.A1 -> R.drawable.ic_history
|
||||
ExperimentBranch.A2 -> R.drawable.ic_history
|
||||
else -> R.drawable.ic_history
|
||||
}
|
||||
}
|
||||
val historyItem = BrowserMenuImageText(
|
||||
context.getString(R.string.library_history),
|
||||
R.drawable.ic_history,
|
||||
historyIcon,
|
||||
primaryTextColor
|
||||
) {
|
||||
onItemTapped.invoke(Item.History)
|
||||
|
15
app/src/main/res/drawable/ic_bookmark_list.xml
Normal file
15
app/src/main/res/drawable/ic_bookmark_list.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:autoMirrored="true"
|
||||
android:layout_gravity="center"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="?primaryText"
|
||||
android:pathData="M7,15L7.7,11.2L4.8,8.5C4.4,8 4.4,7.3 4.8,6.9C5,6.7 5.2,6.6 5.5,6.6L9.3,6L11,2.6C11.3,2 12.1,1.8 12.6,2.2C12.8,2.3 12.9,2.4 13,2.6L14.7,6L18.5,6.6C19.1,6.7 19.5,7.3 19.4,7.9C19.4,8.1 19.3,8.4 19.1,8.5L16.3,11.2L17,15C17.1,15.4 16.9,15.8 16.6,16.1C16.4,16.2 16.2,16.3 15.9,16.3C15.7,16.3 15.5,16.3 15.4,16.2L12,14.4L8.6,16.2C8,16.5 7.4,16.2 7.1,15.7C7,15.4 7,15.2 7,15ZM5,16.9C4.4,16.9 4,17.3 4,17.9V18.9C4,20.6 5.3,21.9 7,21.9H17C18.7,21.9 20,20.6 20,18.9V17.9C20,17.3 19.6,16.9 19,16.9C18.4,16.9 18,17.3 18,17.9V18.9C18,19.5 17.6,19.9 17,19.9H7C6.4,19.9 6,19.5 6,18.9V17.9C6,17.3 5.6,16.9 5,16.9Z" />
|
||||
</vector>
|
Loading…
Reference in New Issue
Block a user