2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00
5507: For https://github.com/mozilla-mobile/fenix/issues/1383 Added tab title to close button content description r=ekager a=mcarare


### Pull Request checklist
<!-- Before submitting the PR, please address each item -->
- [x] **Quality**: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
- [ ] **Tests**: This PR includes thorough tests or an explanation of why it does not
- [x] **Screenshots**: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
- [x] **Accessibility**: The code in this PR follows [accessibility best practices](https://github.com/mozilla-mobile/shared-docs/blob/master/android/accessibility_guide.md) or does not include any user facing features

### After merge
- [ ] **Milestone**: Make sure issues finished by this pull request are added to the [milestone](https://github.com/mozilla-mobile/fenix/milestones) of the version currently in development.

### To download an APK when reviewing a PR:
1. click on Show All Checks,
2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
3. click on the "Fenix - assemble" task, then click "Run Artifacts".
4. the APK links should be on the left side of the screen, named for each CPU architecture

5846: For https://github.com/mozilla-mobile/fenix/issues/3604 Snackbar messages for closing tabs use closed instead of deleted r=sblatz a=mcarare


### Pull Request checklist
<!-- Before submitting the PR, please address each item -->
- [x] **Quality**: This PR builds and passes detekt/ktlint checks (A pre-push hook is recommended)
- [x] **Tests**: This PR includes thorough tests or an explanation of why it does not
- [x] **Screenshots**: This PR includes screenshots or GIFs of the changes made or an explanation of why it does not
- [x] **Accessibility**: The code in this PR follows [accessibility best practices](https://github.com/mozilla-mobile/shared-docs/blob/master/android/accessibility_guide.md) or does not include any user facing features

### After merge
- [ ] **Milestone**: Make sure issues finished by this pull request are added to the [milestone](https://github.com/mozilla-mobile/fenix/milestones) of the version currently in development.

### To download an APK when reviewing a PR:
1. click on Show All Checks,
2. click Details next to "Taskcluster (pull_request)" after it appears and then finishes with a green checkmark,
3. click on the "Fenix - assemble" task, then click "Run Artifacts".
4. the APK links should be on the left side of the screen, named for each CPU architecture

Co-authored-by: mcarare <mihai.carare.dev@gmail.com>
This commit is contained in:
MozLando 2019-10-11 16:28:36 +00:00
commit df858f2f3b
4 changed files with 27 additions and 7 deletions

View File

@ -394,14 +394,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)
}
}
}
@ -727,9 +727,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(
@ -747,7 +747,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)
@ -759,9 +759,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()

View File

@ -98,6 +98,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) {
@ -142,6 +143,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"

View File

@ -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"

View File

@ -357,6 +357,8 @@
<string name="add_tab">Add tab</string>
<!-- Content description (not visible, for screen readers etc.): Close tab button. Closes the current session when pressed -->
<string name="close_tab">Close tab</string>
<!-- Content description (not visible, for screen readers etc.): Close tab <title> button. First parameter is tab title -->
<string name="close_tab_title">Close tab %s</string>
<!-- Content description (not visible, for screen readers etc.): Opens the open tabs menu when pressed -->
<string name="open_tabs_menu">Open tabs menu</string>
<!-- Open tabs menu item to close all tabs -->
@ -641,6 +643,14 @@
<string name="snackbar_tab_deleted">Tab deleted</string>
<!-- Text shown in snackbar when user deletes all tabs -->
<string name="snackbar_tabs_deleted">Tabs deleted</string>
<!-- Text shown in snackbar when user closes a tab -->
<string name="snackbar_tab_closed">Tab closed</string>
<!-- Text shown in snackbar when user closes all tabs -->
<string name="snackbar_tabs_closed">Tabs closed</string>
<!-- Text shown in snackbar when user closes a private tab -->
<string name="snackbar_private_tab_closed">Private tab closed</string>
<!-- Text shown in snackbar when user closes all private tabs -->
<string name="snackbar_private_tabs_closed">Private tabs closed</string>
<!-- Text shown in snackbar when user deletes all private tabs -->
<string name="snackbar_private_tabs_deleted">Private tabs deleted</string>
<!-- Text for action to undo deleting a tab or collection shown in snackbar -->