Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Apr 10, 2020
1 parent 71c841f commit f45f78c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 47 deletions.
8 changes: 4 additions & 4 deletions app/metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1053,9 +1053,9 @@ tip:
identifier:
description: "The identifier of the tip the action was taken on"
bugs:
- https://github.com/mozilla-mobile/fenix/issues/TODO
- https://github.com/mozilla-mobile/fenix/issues/9328
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TODO
- https://github.com/mozilla-mobile/fenix/pull/9836
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
Expand All @@ -1067,9 +1067,9 @@ tip:
identifier:
description: "The identifier of the tip the action was taken on"
bugs:
- https://github.com/mozilla-mobile/fenix/issues/TODO
- https://github.com/mozilla-mobile/fenix/issues/9328
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/TODO
- https://github.com/mozilla-mobile/fenix/pull/9836
notification_emails:
- fenix-core@mozilla.com
expires: "2020-09-01"
Expand Down
3 changes: 0 additions & 3 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,10 @@ class HomeFragment : Fragment() {
activity?.window?.setBackgroundDrawableResource(R.drawable.private_home_background_gradient)
}
hideToolbar()
// TODO: How should I handle this?
/*
if (sharedViewModel.shouldScrollToSelectedTab) {
scrollToSelectedTab()
sharedViewModel.shouldScrollToSelectedTab = false
}
*/
}

override fun onPause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,5 @@ fun TextView.setOnboardingIcon(@DrawableRes id: Int) {
val size = context.resources.getDimensionPixelSize(R.dimen.onboarding_header_icon_height_width)
icon?.setBounds(size)
icon?.setTint(ContextCompat.getColor(context, R.color.onboarding_card_icon))

putCompoundDrawablesRelative(start = icon)
}
62 changes: 26 additions & 36 deletions app/src/main/java/org/mozilla/fenix/home/tips/MigrationTip.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,24 @@ import org.mozilla.fenix.settings.SupportUtils
object MigrationTip {
private lateinit var context: Context

private fun firefoxPreviewMovedTip() : Tip =
private fun firefoxPreviewMovedTip(): Tip =
Tip(
identifier = getIdentifier(),
title = R.string.tip_firefox_preview_moved_header,
description = R.string.tip_firefox_preview_moved_description,
learnMoreButton = R.string.search_suggestions_onboarding_learn_more_link,
learnMoreAction = {
(context.asActivity() as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.FENIX_MOVING),
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(
SupportUtils.SumoTopic.FENIX_MOVING
),
newTab = true,
from = BrowserDirection.FromHome
)
},
button = R.string.tip_firefox_preview_moved_button,
shouldDisplay = {
true
//context.settings().shouldDisplayFenixMovingTip()
},
shouldDisplay = { context.settings().shouldDisplayFenixMovingTip() },
didClose = {
// TODO: Telemetry?
context.settings().preferences
.edit()
.putBoolean(context.getString(R.string.pref_key_migrating_tip), false)
Expand All @@ -49,26 +47,24 @@ object MigrationTip {
action = ::getFirefoxMovedButtonAction
)

private fun firefoxPreviewMovedPreviewInstalledTip() : Tip =
private fun firefoxPreviewMovedPreviewInstalledTip(): Tip =
Tip(
identifier = getIdentifier(),
title = R.string.tip_firefox_preview_moved_header_preview_installed,
description = R.string.tip_firefox_preview_moved_description_preview_installed,
learnMoreButton = R.string.search_suggestions_onboarding_learn_more_link,
learnMoreAction = {
(context.asActivity() as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.FENIX_MOVING),
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(
SupportUtils.SumoTopic.FENIX_MOVING
),
newTab = true,
from = BrowserDirection.FromHome
)
},
button = R.string.tip_firefox_preview_moved_button_preview_installed,
shouldDisplay = {
true
//context.settings().shouldDisplayFenixMovingTip()
},
shouldDisplay = { context.settings().shouldDisplayFenixMovingTip() },
didClose = {
// TODO: Telemetry?
context.settings().preferences
.edit()
.putBoolean(context.getString(R.string.pref_key_migrating_tip), false)
Expand All @@ -77,26 +73,24 @@ object MigrationTip {
action = ::getFirefoxMovedButtonAction
)

private fun firefoxPreviewMovedPreviewNotInstalledTip() : Tip =
private fun firefoxPreviewMovedPreviewNotInstalledTip(): Tip =
Tip(
identifier = getIdentifier(),
title = R.string.tip_firefox_preview_moved_header_preview_not_installed,
description = R.string.tip_firefox_preview_moved_description_preview_not_installed,
learnMoreButton = R.string.search_suggestions_onboarding_learn_more_link,
learnMoreAction = {
(context.asActivity() as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(SupportUtils.SumoTopic.FENIX_MOVING),
searchTermOrURL = SupportUtils.getGenericSumoURLForTopic(
SupportUtils.SumoTopic.FENIX_MOVING
),
newTab = true,
from = BrowserDirection.FromHome
)
},
button = R.string.tip_firefox_preview_moved_button_preview_not_installed,
shouldDisplay = {
true
//context.settings().shouldDisplayFenixMovingTip()
},
shouldDisplay = { context.settings().shouldDisplayFenixMovingTip() },
didClose = {
// TODO: Telemetry?
context.settings().preferences
.edit()
.putBoolean(context.getString(R.string.pref_key_migrating_tip), false)
Expand All @@ -108,21 +102,15 @@ object MigrationTip {
fun get(context: Context): Tip? {
this.context = context
return when (context.packageName) {
MozillaProductDetector.MozillaProducts.FENIX.productName -> firefoxPreviewMovedTip()
MozillaProductDetector.MozillaProducts.FIREFOX_NIGHTLY.productName -> {
getNightlyMigrationTip()
}
MozillaProductDetector.MozillaProducts.FENIX_NIGHTLY.productName -> {
getNightlyMigrationTip()
}
else -> {
null
}
FENIX.productName -> firefoxPreviewMovedTip()
FIREFOX_NIGHTLY.productName -> getNightlyMigrationTip()
FENIX_NIGHTLY.productName -> getNightlyMigrationTip()
else -> null
}
}

private fun getNightlyMigrationTip(): Tip? {
return if (MozillaProductDetector.packageIsInstalled(context, MozillaProductDetector.MozillaProducts.FENIX.productName)) {
return if (MozillaProductDetector.packageIsInstalled(context, FENIX.productName)) {
firefoxPreviewMovedPreviewInstalledTip()
} else {
firefoxPreviewMovedPreviewNotInstalledTip()
Expand All @@ -141,10 +129,12 @@ object MigrationTip {
}

private fun getNightlyMigrationAction() {
return if (MozillaProductDetector.packageIsInstalled(context, MozillaProductDetector.MozillaProducts.FENIX.productName)) {
// TODO: Just launch Firefox Preview?
return if (MozillaProductDetector.packageIsInstalled(context, FENIX.productName)) {
context.startActivity(context.packageManager.getLaunchIntentForPackage(FENIX.productName))
} else {
context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(SupportUtils.FIREFOX_NIGHTLY_PLAY_STORE_URL)))
context.startActivity(Intent(
Intent.ACTION_VIEW, Uri.parse(SupportUtils.FIREFOX_NIGHTLY_PLAY_STORE_URL)
))
}
}

Expand All @@ -156,4 +146,4 @@ object MigrationTip {
else -> { -1 }
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.content.Context
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes


enum class Type {
BUTTON
}
Expand Down
4 changes: 2 additions & 2 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ The following metrics are added to the ping:
| sync_auth.sign_up |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |User registered a new Firefox Account, and was signed into it |[1](https://github.com/mozilla-mobile/fenix/pull/4931#issuecomment-529740300)||2020-09-01 |
| tab.media_pause |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the pause icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-09-01 |
| tab.media_play |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the play icon on a tab from the home screen |[1](https://github.com/mozilla-mobile/fenix/pull/5266)||2020-09-01 |
| tip.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip was closed |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| tip.pressed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip's button was pressed |[1](https://github.com/mozilla-mobile/fenix/pull/TODO)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| tip.closed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip was closed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| tip.pressed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The tip's button was pressed |[1](https://github.com/mozilla-mobile/fenix/pull/9836)|<ul><li>identifier: The identifier of the tip the action was taken on</li></ul>|2020-09-01 |
| toolbar_settings.changed_position |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |The user selected a new position for the toolbar |[1](https://github.com/mozilla-mobile/fenix/pull/6608)|<ul><li>position: A string that indicates the new position of the toolbar TOP or BOTTOM</li></ul>|2020-09-01 |
| top_sites.open_in_new_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opens a new tab based on a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-09-01 |
| top_sites.open_in_private_tab |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opens a new private tab based on a top site item |[1](https://github.com/mozilla-mobile/fenix/pull/7523)||2020-09-01 |
Expand Down

0 comments on commit f45f78c

Please sign in to comment.