From d0071d01771a77a3d1206c0756e6fba42394a702 Mon Sep 17 00:00:00 2001 From: ekager Date: Fri, 2 Aug 2019 09:10:35 -0700 Subject: [PATCH] For #4495 - Clean up homescreen toolbar focus and content descriptions --- CHANGELOG.md | 1 + .../fenix/ui/robots/HomeScreenRobot.kt | 2 +- .../org/mozilla/fenix/home/HomeFragment.kt | 14 +---- app/src/main/res/layout/fragment_home.xml | 52 +++++++++++-------- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33b21c8f4..bf4ae9b0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index 56b337ca7..dc92176cb 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -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))) diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 47bccc3e9..33d82d453 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -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 @@ -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) @@ -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 @@ -309,8 +307,6 @@ class HomeFragment : Fragment(), AccountObserver { (activity as AppCompatActivity).supportActionBar?.hide() requireComponents.backgroundServices.accountManager.register(this, owner = this) - - focusToolbarForAccessibility() } override fun onStart() { @@ -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) diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 25422544d..69977a9e7 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -2,12 +2,12 @@ - + + @@ -31,8 +32,8 @@ 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" /> @@ -40,11 +41,14 @@ 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" /> @@ -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" @@ -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" /> @@ -87,13 +97,13 @@ android:id="@+id/homeDivider" android:layout_width="match_parent" android:layout_height="1dp" - 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"/> + android:layout_marginTop="32dp" + android:layout_marginEnd="40dp" + android:background="?neutralFaded" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" /> + app:layout_constraintTop_toBottomOf="@id/homeDivider" /> \ No newline at end of file