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

Commit

Permalink
For #4495 - Clean up homescreen toolbar focus and content descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ekager committed Aug 2, 2019
1 parent 7916025 commit 3ae4345
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- #4137 - Adds pagination to the history view
- #3695 - Made search suggestions for other tabs clickable
- Remove forced focus of toolbar on homescreen

## [1.1.0 and earlier] - 2019-07-23
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private fun assertHomePrivateBrowsingButton() = onView(ViewMatchers.withResource
private fun assertHomeWordmark() = onView(ViewMatchers.withResourceName("wordmark"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertHomeToolbar() = onView(ViewMatchers.withResourceName("toolbar"))
.check(matches(allOf(withEffectiveVisibility(Visibility.VISIBLE), ViewMatchers.hasFocus())))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
private fun assertOpenTabsHeader() =
onView(CoreMatchers.allOf(ViewMatchers.withText("Open tabs")))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
Expand Down
14 changes: 1 addition & 13 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.view.accessibility.AccessibilityEvent
import androidx.annotation.StringRes
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
Expand Down Expand Up @@ -240,7 +239,7 @@ class HomeFragment : Fragment(), AccountObserver {
}
view.toolbar.compoundDrawablePadding =
(toolbarPaddingDp * Resources.getSystem().displayMetrics.density).roundToInt()
view.toolbar.setOnClickListener {
view.toolbar_wrapper.setOnClickListener {
invokePendingDeleteJobs()
onboarding.finish()
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null)
Expand All @@ -253,7 +252,6 @@ class HomeFragment : Fragment(), AccountObserver {
nav(R.id.homeFragment, directions)
requireComponents.analytics.metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.HOME))
}
view.toolbar.requestFocus()

val isPrivate = (activity as HomeActivity).browsingModeManager.isPrivate

Expand Down Expand Up @@ -309,8 +307,6 @@ class HomeFragment : Fragment(), AccountObserver {
(activity as AppCompatActivity).supportActionBar?.hide()

requireComponents.backgroundServices.accountManager.register(this, owner = this)

focusToolbarForAccessibility()
}

override fun onStart() {
Expand Down Expand Up @@ -823,14 +819,6 @@ class HomeFragment : Fragment(), AccountObserver {
}
}

private fun focusToolbarForAccessibility() {
viewLifecycleOwner.lifecycleScope.launch {
delay(ACCESSIBILITY_FOCUS_DELAY)
toolbar.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
toolbar.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED)
}
}

private fun showRenamedSnackbar() {
view?.let { view ->
val string = view.context.getString(R.string.snackbar_collection_renamed)
Expand Down
50 changes: 30 additions & 20 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
<!-- 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/. -->
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.constraintlayout.motion.widget.MotionLayout
android:id="@+id/homeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?homeBackground"
app:layoutDescription="@xml/home_scene"
tools:context=".home.HomeFragment">

<ImageButton
android:id="@+id/menuButton"
android:layout_width="@dimen/glyph_button_height"
android:layout_height="@dimen/glyph_button_height"
android:layout_marginTop="12dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_menu"
android:contentDescription="@string/content_description_menu"
android:src="@drawable/ic_menu"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand All @@ -31,20 +32,23 @@
android:layout_width="@dimen/glyph_button_height"
android:layout_height="@dimen/glyph_button_height"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@drawable/private_browsing_button"
android:contentDescription="@string/content_description_private_browsing_button"
android:src="@drawable/private_browsing_button"
app:layout_constraintEnd_toStartOf="@id/menuButton"
app:layout_constraintTop_toTopOf="@id/menuButton" />

<ImageView
android:id="@+id/wordmark"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_marginTop="24dp"
android:layout_marginStart="16dp"
android:src="?fenixLogo"
android:contentDescription="@string/app_name"
android:layout_marginTop="24dp"
android:adjustViewBounds="true"
android:clickable="false"
android:contentDescription="@string/app_name"
android:focusable="false"
android:importantForAccessibility="no"
android:src="?fenixLogo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/menuButton" />

Expand All @@ -56,7 +60,9 @@
android:layout_marginTop="48dp"
android:layout_marginEnd="16dp"
android:background="@drawable/home_search_background_normal"
android:contentDescription="@string/search_hint"
android:elevation="@dimen/toolbar_elevation"
android:focusableInTouchMode="true"
android:transitionName="toolbar_wrapper_transition"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -66,18 +72,22 @@
android:id="@+id/search_engine_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_margin="12dp" />
android:layout_margin="12dp"
android:clickable="false"
android:focusable="false"
android:importantForAccessibility="no" />

<TextView
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="47dp"
android:clickable="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="12dp"
android:clickable="false"
android:focusable="false"
android:importantForAccessibility="no"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:text="@string/search_hint"
android:textColor="?primaryText"
android:textSize="15sp" />
Expand All @@ -87,23 +97,23 @@
android:id="@+id/homeDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginStart="40dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="40dp"
android:background="?neutralFaded"
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"
android:layout_marginStart="40dp"
android:layout_marginEnd="40dp"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" />

<View
android:id="@+id/homeDividerShadow"
android:layout_width="0dp"
android:layout_height="3dp"
android:alpha="0"
android:background="@drawable/home_header_shadow"
app:layout_constraintTop_toBottomOf="@id/homeDivider"
app:layout_constraintEnd_toEndOf="@+id/homeDivider"
app:layout_constraintStart_toStartOf="@+id/homeDivider"
app:layout_constraintEnd_toEndOf="@+id/homeDivider" />
app:layout_constraintTop_toBottomOf="@id/homeDivider" />

</androidx.constraintlayout.motion.widget.MotionLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 comments on commit 3ae4345

Please sign in to comment.