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

Commit

Permalink
For #6054: Adds toolbar position to core ping
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Nov 15, 2019
1 parent 2ea0128 commit 5f3d632
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NavigationToolbarRobot {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())

fun enterURLAndEnterToBrowser(url: Uri, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/toolbar")), waitingTime)
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/toolbar_bottom")), waitingTime)
urlBar().click()
awesomeBar().perform(replaceText(url.toString()), pressImeActionButton())

Expand Down Expand Up @@ -62,7 +62,7 @@ fun navigationToolbar(interact: NavigationToolbarRobot.() -> Unit): NavigationTo
}

private fun dismissOnboardingButton() = onView(ViewMatchers.withId(R.id.close_onboarding))
private fun urlBar() = onView(ViewMatchers.withId(R.id.toolbar))
private fun urlBar() = onView(ViewMatchers.withId(R.id.toolbar_bottom))
private fun awesomeBar() = onView(ViewMatchers.withId(R.id.mozac_browser_toolbar_edit_url_view))
private fun threeDotButton() = onView(ViewMatchers.withContentDescription("Menu"))
private fun newTab() = onView(ViewMatchers.withContentDescription("Add tab"))
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import org.mozilla.fenix.mvi.getManagedEmitter
* Fragment used for browsing the web within the main app.
*/
@ExperimentalCoroutinesApi
@Suppress("TooManyFunctions")
@Suppress("TooManyFunctions", "LargeClass")
class BrowserFragment : BaseBrowserFragment(), BackHandler {

private val windowFeature = ViewBoundFeatureWrapper<WindowFeature>()
Expand Down Expand Up @@ -130,11 +130,10 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {
super.onStart()
subscribeToTabCollections()
getSessionById()?.register(toolbarSessionObserver, this, autoPause = true)

updateToolbar()
updateEngineBottomMargin()
}

private fun updateToolbar() {
private fun updateEngineBottomMargin() {
val browserEngine = swipeRefresh.layoutParams as CoordinatorLayout.LayoutParams

browserEngine.bottomMargin = if (requireContext().settings().shouldUseBottomToolbar) {
Expand Down Expand Up @@ -332,7 +331,7 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {

private fun shouldShowTrackingProtectionOnboarding(session: Session) =
context?.settings()?.shouldShowTrackingProtectionOnboarding ?: false &&
session.trackerBlockingEnabled && session.trackersBlocked.isNotEmpty()
session.trackerBlockingEnabled && session.trackersBlocked.isNotEmpty()

companion object {
private const val THREE = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package org.mozilla.fenix.browser
import android.animation.ValueAnimator
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import android.view.Gravity
import android.view.View
import android.view.View.SCROLL_AXIS_VERTICAL
Expand Down Expand Up @@ -97,8 +96,6 @@ class BrowserToolbarTopBehavior(
override fun layoutDependsOn(parent: CoordinatorLayout, child: BrowserToolbar, dependency: View): Boolean {
if (dependency is Snackbar.SnackbarLayout) {
positionSnackbar(dependency)
} else {
Log.d("Sawyer", "depenedency: $dependency")
}

return super.layoutDependsOn(parent, child, dependency)
Expand All @@ -114,7 +111,7 @@ class BrowserToolbarTopBehavior(
val params = view.layoutParams as CoordinatorLayout.LayoutParams

// Position the snackbar below the toolbar so that it doesn't overlay the toolbar.
params.anchorId = R.id.toolbar
params.anchorId = R.id.toolbar_bottom
params.anchorGravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL
params.gravity = Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package org.mozilla.fenix.components.metrics

import android.content.Context
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch
import mozilla.components.service.glean.BuildConfig
import mozilla.components.service.glean.Glean
import mozilla.components.service.glean.config.Configuration
Expand Down Expand Up @@ -485,6 +485,7 @@ class GleanMetricsService(private val context: Context) : MetricsService {
mozillaProducts.set(MozillaProductDetector.getInstalledMozillaProducts(context))
adjustCampaign.set(context.settings().adjustCampaignId)
totalUriCount.set(context.settings().totalUriCount.toString())
toolbarPosition.set(context.settings().toolbarSettingString)
}

SearchDefaultEngine.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BrowserToolbarView(
.findViewById(R.id.toolbar_top_fixed)
} else {
LayoutInflater.from(container.context)
.inflate(R.layout.component_browser_bottom_toolbar, container, true)
.inflate(R.layout.component_browser_top_toolbar, container, true)
.findViewById(R.id.toolbar_top)
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import android.view.Gravity
import android.view.View
import androidx.core.view.isGone
import androidx.navigation.fragment.navArgs
import kotlinx.android.synthetic.main.component_browser_bottom_toolbar.*
import kotlinx.android.synthetic.main.component_browser_top_toolbar.*
import kotlinx.android.synthetic.main.fragment_browser.view.*
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.components.browser.session.Session
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class HomeFragment : Fragment() {
}
}
}
view.toolbar.compoundDrawablePadding =
view.toolbar_bottom.compoundDrawablePadding =
view.resources.getDimensionPixelSize(R.dimen.search_bar_search_engine_icon_padding)
view.toolbar_wrapper.setOnClickListener {
invokePendingDeleteJobs()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class ToolbarView(
} else {
if (container.context.settings().shouldUseFixedToolbar) {
LayoutInflater.from(container.context)
.inflate(R.layout.component_browser_bottom_toolbar, container, true)
.inflate(R.layout.component_browser_top_toolbar, container, true)
.findViewById(R.id.toolbar_top_fixed)
} else {
LayoutInflater.from(container.context)
.inflate(R.layout.component_browser_bottom_toolbar, container, true)
.inflate(R.layout.component_browser_top_toolbar, container, true)
.findViewById(R.id.toolbar_top)
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/org/mozilla/fenix/utils/Settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ class Settings private constructor(

val shouldUseFixedToolbar: Boolean
get() {
val accessibilityManager = appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
val accessibilityManager =
appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
return accessibilityManager?.isTouchExplorationEnabled ?: false
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
android:importantForAccessibility="no" />

<TextView
android:id="@+id/toolbar"
android:id="@+id/toolbar_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
Expand Down
3 changes: 2 additions & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ 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-03-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-03-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-03-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/6571)|<ul><li>position: A string that indicates the new position of the toolbar TOP or BOTTOM</li></ul>|2020-03-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-03-01 |
| tracking_protection.etp_setting_changed |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user changed their tracking protection level setting to either strict or standard. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)|<ul><li>etp_setting: The new setting for ETP: strict, standard</li></ul>|2020-03-01 |
| tracking_protection.etp_settings |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user opened tracking protection settings through settings. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 |
| tracking_protection.etp_shield |[event](https://mozilla.github.io/glean/book/user/metrics/event.html) |A user pressed the tracking protection shield icon in toolbar. |[1](https://github.com/mozilla-mobile/fenix/pull/5414#issuecomment-532847188)||2020-03-01 |
Expand All @@ -163,6 +163,7 @@ The following metrics are added to the ping:
| metrics.default_moz_browser |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |The name of the default browser on device if and only if it's a Mozilla owned product |[1](https://github.com/mozilla-mobile/fenix/pull/1953/), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 |
| metrics.mozilla_products |[string_list](https://mozilla.github.io/glean/book/user/metrics/string_list.html) |A list of all the Mozilla products installed on device. We currently scan for: Firefox, Firefox Beta, Firefox Aurora, Firefox Nightly, Firefox Fdroid, Firefox Lite, Reference Browser, Reference Browser Debug, Fenix, Focus, and Lockwise. |[1](https://github.com/mozilla-mobile/fenix/pull/1953/), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 |
| metrics.search_count |[labeled_counter](https://mozilla.github.io/glean/book/user/metrics/labeled_counters.html) |The labels for this counter are `<search-engine-name>.<source>`. If the search engine is bundled with Fenix `search-engine-name` will be the name of the search engine. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be `custom`. `source` will either be `action` or `suggestion` |[1](https://github.com/mozilla-mobile/fenix/pull/1677), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 |
| metrics.toolbar_position |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A string that indicates the new position of the toolbar TOP or BOTTOM |[1](https://github.com/mozilla-mobile/fenix/pull/6608)||2020-03-01 |
| metrics.total_uri_count |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |A counter of URIs visited by the user in the current session, including page reloads. This does not include background page requests and URIs from embedded pages or private browsing. |[1](https://github.com/mozilla-mobile/fenix/pull/6003)||2020-03-01 |
| search.default_engine.code |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be the search engine identifier. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be "custom" |[1](https://github.com/mozilla-mobile/fenix/pull/1606), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 |
| search.default_engine.name |[string](https://mozilla.github.io/glean/book/user/metrics/string.html) |If the search engine is pre-loaded with Fenix this value will be the search engine name. If it's a custom search engine (defined: https://github.com/mozilla-mobile/fenix/issues/1607) the value will be "custom" |[1](https://github.com/mozilla-mobile/fenix/pull/1606), [2](https://github.com/mozilla-mobile/fenix/pull/5216)||2020-03-01 |
Expand Down

0 comments on commit 5f3d632

Please sign in to comment.