From 4dec0aba35f1ccbccee5db1b78731e4a816ae94b Mon Sep 17 00:00:00 2001 From: mcarare Date: Tue, 24 Sep 2019 10:41:27 +0300 Subject: [PATCH 1/2] [fenix] For https://github.com/mozilla-mobile/fenix/issues/1383 Added tab title to close button content description --- .../fenix/home/sessioncontrol/viewholders/TabViewHolder.kt | 5 +++++ app/src/main/res/layout/tab_list_row.xml | 1 - app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt index 20fad20a91..44c5a4cb9b 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TabViewHolder.kt @@ -96,6 +96,7 @@ class TabViewHolder( updateSelected(tab.selected ?: false) updatePlayPauseButton(tab.mediaState ?: MediaState.None) item_tab.transitionName = "$TAB_ITEM_TRANSITION_NAME${tab.sessionId}" + updateCloseButtonDescription(tab.title) } internal fun updatePlayPauseButton(mediaState: MediaState) { @@ -136,6 +137,10 @@ class TabViewHolder( internal fun updateSelected(selected: Boolean) { selected_border.visibility = if (selected) View.VISIBLE else View.GONE } + private fun updateCloseButtonDescription(title: String) { + close_tab_button.contentDescription = + close_tab_button.context.getString(R.string.close_tab_title, title) + } companion object { private const val TAB_ITEM_TRANSITION_NAME = "tab_item" diff --git a/app/src/main/res/layout/tab_list_row.xml b/app/src/main/res/layout/tab_list_row.xml index 3b64f9c443..5ba25a9f50 100644 --- a/app/src/main/res/layout/tab_list_row.xml +++ b/app/src/main/res/layout/tab_list_row.xml @@ -83,7 +83,6 @@ android:layout_width="48dp" android:layout_height="48dp" android:alpha="0.8" - android:contentDescription="@string/close_tab" android:src="@drawable/ic_close" android:background="?android:attr/selectableItemBackgroundBorderless" app:layout_constraintEnd_toEndOf="parent" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 05a50b51b7..f89a43276a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -355,6 +355,8 @@ Add tab Close tab + + Close tab %s Open tabs menu From 57169406def888629db6891e39420f61769ac196 Mon Sep 17 00:00:00 2001 From: mcarare Date: Tue, 8 Oct 2019 17:06:02 +0300 Subject: [PATCH 2/2] [fenix] For https://github.com/mozilla-mobile/fenix/issues/3604 Snackbar messages for closing tabs use closed instead of deleted --- .../org/mozilla/fenix/home/HomeFragment.kt | 18 ++++++++++++------ app/src/main/res/values/strings.xml | 8 ++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) 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 78341e47e5..b14bd5b075 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -386,14 +386,14 @@ class HomeFragment : Fragment() { } is TabAction.Close -> { if (pendingSessionDeletion?.deletionJob == null) { - removeTabWithUndo(action.sessionId) + removeTabWithUndo(action.sessionId, browsingModeManager.mode.isPrivate) } else { pendingSessionDeletion?.deletionJob?.let { viewLifecycleOwner.lifecycleScope.launch { it.invoke() }.invokeOnCompletion { pendingSessionDeletion = null - removeTabWithUndo(action.sessionId) + removeTabWithUndo(action.sessionId, browsingModeManager.mode.isPrivate) } } } @@ -719,9 +719,9 @@ class HomeFragment : Fragment() { deleteAllSessionsJob = deleteOperation val snackbarMessage = if (private) { - getString(R.string.snackbar_private_tabs_deleted) + getString(R.string.snackbar_private_tabs_closed) } else { - getString(R.string.snackbar_tab_deleted) + getString(R.string.snackbar_tabs_closed) } viewLifecycleOwner.lifecycleScope.allowUndo( @@ -739,7 +739,7 @@ class HomeFragment : Fragment() { ) } - private fun removeTabWithUndo(sessionId: String) { + private fun removeTabWithUndo(sessionId: String, private: Boolean) { val sessionManager = requireComponents.core.sessionManager val deleteOperation: (suspend () -> Unit) = { sessionManager.findSessionById(sessionId) @@ -751,9 +751,15 @@ class HomeFragment : Fragment() { pendingSessionDeletion = PendingSessionDeletion(deleteOperation, sessionId) + val snackbarMessage = if (private) { + getString(R.string.snackbar_private_tab_closed) + } else { + getString(R.string.snackbar_tab_closed) + } + viewLifecycleOwner.lifecycleScope.allowUndo( view!!, - getString(R.string.snackbar_tab_deleted), + snackbarMessage, getString(R.string.snackbar_deleted_undo), { pendingSessionDeletion = null emitSessionChanges() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 326f4e0e30..a55315ba9c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -637,6 +637,14 @@ Tab deleted Tabs deleted + + Tab closed + + Tabs closed + + Private tab closed + + Private tabs closed Private tabs deleted