2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00
This commit is contained in:
Sawyer Blatz 2019-04-05 15:08:55 -07:00 committed by GitHub
parent 2efa24c422
commit 0b99b7fc12
8 changed files with 147 additions and 22 deletions

View File

@ -13,5 +13,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- #1036 - Adds telemetry for Find in Page - #1036 - Adds telemetry for Find in Page
- #1049 - Add style for progress bar with gradient drawable - #1049 - Add style for progress bar with gradient drawable
- #1165 - Added doorhanger to the toolbar - #1165 - Added doorhanger to the toolbar
- #1195 - Adds telemetry for quick action sheet
### Changed ### Changed
### Removed ### Removed

View File

@ -223,6 +223,74 @@ find_in_page:
- telemetry-client-dev@mozilla.com - telemetry-client-dev@mozilla.com
expires: "2020-03-01" expires: "2020-03-01"
quick_action_sheet:
opened:
type: event
description: >
A user opened the quick action sheet UI
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- telemetry-client-dev@mozilla.com
expires: "2020-03-01"
closed:
type: event
description: >
A user closed the quick action sheet UI
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- telemetry-client-dev@mozilla.com
expires: "2020-03-01"
share_tapped:
type: event
description: >
A user tapped the share button
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- telemetry-client-dev@mozilla.com
expires: "2020-03-01"
bookmark_tapped:
type: event
description: >
A user tapped the bookmark button
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- telemetry-client-dev@mozilla.com
expires: "2020-03-01"
download_tapped:
type: event
description: >
A user tapped the download button
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- telemetry-client-dev@mozilla.com
expires: "2020-03-01"
read_tapped:
type: event
description: >
A user tapped the read button
bugs:
- 1195
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/1362#issuecomment-479668466
notification_emails:
- telemetry-client-dev@mozilla.com
expires: "2020-03-01"
metrics: metrics:
default_browser: default_browser:
type: boolean type: boolean

View File

@ -274,6 +274,7 @@ class BrowserFragment : Fragment(), BackHandler {
(activity as AppCompatActivity).supportActionBar?.hide() (activity as AppCompatActivity).supportActionBar?.hide()
} }
@Suppress("ComplexMethod")
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
getAutoDisposeObservable<SearchAction>() getAutoDisposeObservable<SearchAction>()
@ -302,14 +303,23 @@ class BrowserFragment : Fragment(), BackHandler {
getAutoDisposeObservable<QuickActionAction>() getAutoDisposeObservable<QuickActionAction>()
.subscribe { .subscribe {
when (it) { when (it) {
is QuickActionAction.Opened -> {
requireComponents.analytics.metrics.track(Event.QuickActionSheetOpened)
}
is QuickActionAction.Closed -> {
requireComponents.analytics.metrics.track(Event.QuickActionSheetClosed)
}
is QuickActionAction.SharePressed -> { is QuickActionAction.SharePressed -> {
requireComponents.analytics.metrics.track(Event.QuickActionSheetShareTapped)
requireComponents.core.sessionManager requireComponents.core.sessionManager
.selectedSession?.url?.apply { requireContext().share(this) } .selectedSession?.url?.apply { requireContext().share(this) }
} }
is QuickActionAction.DownloadsPressed -> { is QuickActionAction.DownloadsPressed -> {
requireComponents.analytics.metrics.track(Event.QuickActionSheetDownloadTapped)
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "348") ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "348")
} }
is QuickActionAction.BookmarkPressed -> { is QuickActionAction.BookmarkPressed -> {
requireComponents.analytics.metrics.track(Event.QuickActionSheetBookmarkTapped)
val session = requireComponents.core.sessionManager.selectedSession val session = requireComponents.core.sessionManager.selectedSession
CoroutineScope(IO).launch { CoroutineScope(IO).launch {
requireComponents.core.bookmarksStorage requireComponents.core.bookmarksStorage
@ -334,6 +344,7 @@ class BrowserFragment : Fragment(), BackHandler {
} }
} }
is QuickActionAction.ReadPressed -> { is QuickActionAction.ReadPressed -> {
requireComponents.analytics.metrics.track(Event.QuickActionSheetReadTapped)
ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "908") ItsNotBrokenSnack(context!!).showSnackbar(issueNumber = "908")
} }
} }

View File

@ -12,6 +12,7 @@ import org.mozilla.fenix.GleanMetrics.CrashReporter
import org.mozilla.fenix.GleanMetrics.Events import org.mozilla.fenix.GleanMetrics.Events
import org.mozilla.fenix.GleanMetrics.FindInPage import org.mozilla.fenix.GleanMetrics.FindInPage
import org.mozilla.fenix.GleanMetrics.ContextMenu import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.QuickActionSheet
import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
@ -84,6 +85,24 @@ private val Event.wrapper
{ Events.browserMenuAction }, { Events.browserMenuAction },
{ Events.browserMenuActionKeys.valueOf(it) } { Events.browserMenuActionKeys.valueOf(it) }
) )
is Event.QuickActionSheetOpened -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.opened.record(it) }
)
is Event.QuickActionSheetClosed -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.closed.record(it) }
)
is Event.QuickActionSheetShareTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.shareTapped.record(it) }
)
is Event.QuickActionSheetBookmarkTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.bookmarkTapped.record(it) }
)
is Event.QuickActionSheetDownloadTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.downloadTapped.record(it) }
)
is Event.QuickActionSheetReadTapped -> EventWrapper<NoExtraKeys>(
{ QuickActionSheet.readTapped.record(it) }
)
// Don't track other events with Glean // Don't track other events with Glean
else -> null else -> null

View File

@ -10,9 +10,6 @@ import mozilla.components.support.base.facts.Facts
import org.mozilla.fenix.BuildConfig import org.mozilla.fenix.BuildConfig
sealed class Event { sealed class Event {
object AddBookmark : Event()
object RemoveBookmark : Event()
object OpenedBookmark : Event()
data class OpenedApp(val source: Source) : Event() { data class OpenedApp(val source: Source) : Event() {
enum class Source { APP_ICON, LINK, CUSTOM_TAB } enum class Source { APP_ICON, LINK, CUSTOM_TAB }
@ -49,6 +46,15 @@ sealed class Event {
object DarkModeEnabled : Event() object DarkModeEnabled : Event()
object SearchShortcutMenuOpened : Event() object SearchShortcutMenuOpened : Event()
object SearchShortcutMenuClosed : Event() object SearchShortcutMenuClosed : Event()
object AddBookmark : Event()
object RemoveBookmark : Event()
object OpenedBookmark : Event()
object QuickActionSheetOpened : Event()
object QuickActionSheetClosed : Event()
object QuickActionSheetShareTapped : Event()
object QuickActionSheetBookmarkTapped : Event()
object QuickActionSheetDownloadTapped : Event()
object QuickActionSheetReadTapped : Event()
// Interaction Events // Interaction Events
data class SearchBarTapped(val source: Source) : Event() { data class SearchBarTapped(val source: Source) : Event() {

View File

@ -41,6 +41,8 @@ class QuickActionComponent(
data class QuickActionState(val readable: Boolean) : ViewState data class QuickActionState(val readable: Boolean) : ViewState
sealed class QuickActionAction : Action { sealed class QuickActionAction : Action {
object Opened : QuickActionAction()
object Closed : QuickActionAction()
object SharePressed : QuickActionAction() object SharePressed : QuickActionAction()
object DownloadsPressed : QuickActionAction() object DownloadsPressed : QuickActionAction()
object BookmarkPressed : QuickActionAction() object BookmarkPressed : QuickActionAction()

View File

@ -48,17 +48,6 @@ class QuickActionSheet @JvmOverloads constructor(
handle.setAccessibilityDelegate(HandleAccessibilityDelegate(quickActionSheetBehavior)) handle.setAccessibilityDelegate(HandleAccessibilityDelegate(quickActionSheetBehavior))
quickActionSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(v: View, state: Int) {
updateImportantForAccessibility(state)
}
override fun onSlide(p0: View, p1: Float) {
}
})
updateImportantForAccessibility(quickActionSheetBehavior.state)
val settings = Settings.getInstance(context) val settings = Settings.getInstance(context)
if (settings.shouldAutoBounceQuickActionSheet) { if (settings.shouldAutoBounceQuickActionSheet) {
settings.incrementAutomaticBounceQuickActionSheetCount() settings.incrementAutomaticBounceQuickActionSheetCount()
@ -66,14 +55,6 @@ class QuickActionSheet @JvmOverloads constructor(
} }
} }
private fun updateImportantForAccessibility(state: Int) {
findViewById<LinearLayout>(R.id.quick_action_buttons_layout).importantForAccessibility =
if (state == BottomSheetBehavior.STATE_COLLAPSED || state == BottomSheetBehavior.STATE_HIDDEN)
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
else
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
}
private fun bounceSheet( private fun bounceSheet(
quickActionSheetBehavior: QuickActionSheetBehavior, quickActionSheetBehavior: QuickActionSheetBehavior,
duration: Long = bounceAnimationLength duration: Long = bounceAnimationLength

View File

@ -7,6 +7,7 @@ package org.mozilla.fenix.quickactionsheet
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout
import androidx.core.widget.NestedScrollView import androidx.core.widget.NestedScrollView
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import io.reactivex.Observable import io.reactivex.Observable
@ -15,6 +16,8 @@ import io.reactivex.functions.Consumer
import kotlinx.android.synthetic.main.fragment_browser.* import kotlinx.android.synthetic.main.fragment_browser.*
import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.* import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.*
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.mvi.UIView import org.mozilla.fenix.mvi.UIView
class QuickActionUIView( class QuickActionUIView(
@ -31,6 +34,23 @@ class QuickActionUIView(
val quickActionSheetBehavior = val quickActionSheetBehavior =
BottomSheetBehavior.from(nestedScrollQuickAction as View) as QuickActionSheetBehavior BottomSheetBehavior.from(nestedScrollQuickAction as View) as QuickActionSheetBehavior
quickActionSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(v: View, state: Int) {
updateImportantForAccessibility(state)
if (state == BottomSheetBehavior.STATE_EXPANDED) {
actionEmitter.onNext(QuickActionAction.Opened)
} else if (state == BottomSheetBehavior.STATE_COLLAPSED) {
actionEmitter.onNext(QuickActionAction.Closed)
}
}
override fun onSlide(p0: View, p1: Float) {
}
})
updateImportantForAccessibility(quickActionSheetBehavior.state)
view.quick_action_share.setOnClickListener { view.quick_action_share.setOnClickListener {
actionEmitter.onNext(QuickActionAction.SharePressed) actionEmitter.onNext(QuickActionAction.SharePressed)
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED quickActionSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
@ -49,6 +69,23 @@ class QuickActionUIView(
} }
} }
private fun updateImportantForAccessibility(state: Int) {
view.findViewById<LinearLayout>(R.id.quick_action_buttons_layout).importantForAccessibility =
if (state == BottomSheetBehavior.STATE_COLLAPSED || state == BottomSheetBehavior.STATE_HIDDEN)
View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
else
View.IMPORTANT_FOR_ACCESSIBILITY_AUTO
}
private fun sendTelemetryEvent(state: Int) {
when (state) {
BottomSheetBehavior.STATE_EXPANDED ->
view.context.components.analytics.metrics.track(Event.QuickActionSheetOpened)
BottomSheetBehavior.STATE_COLLAPSED ->
view.context.components.analytics.metrics.track(Event.QuickActionSheetClosed)
}
}
override fun updateView() = Consumer<QuickActionState> { override fun updateView() = Consumer<QuickActionState> {
view.quick_action_read.visibility = if (it.readable) View.VISIBLE else View.GONE view.quick_action_read.visibility = if (it.readable) View.VISIBLE else View.GONE
} }