2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-02 03:40:16 +00:00
This commit is contained in:
Mihai Adrian 2020-05-05 21:22:15 +03:00 committed by GitHub
parent 168ce3b74e
commit 404e6baa72
2 changed files with 19 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import android.content.Context
import android.os.Bundle import android.os.Bundle
import android.view.Gravity import android.view.Gravity
import android.view.View import android.view.View
import android.view.accessibility.AccessibilityEvent
import androidx.core.content.res.ResourcesCompat import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
@ -16,6 +17,7 @@ import androidx.navigation.Navigation
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import kotlinx.android.synthetic.main.fragment_add_ons_management.* import kotlinx.android.synthetic.main.fragment_add_ons_management.*
import kotlinx.android.synthetic.main.fragment_add_ons_management.view.* import kotlinx.android.synthetic.main.fragment_add_ons_management.view.*
import kotlinx.android.synthetic.main.overlay_add_on_progress.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
@ -29,6 +31,7 @@ import mozilla.components.feature.addons.ui.translatedName
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getRootView import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.ext.showToolbar import org.mozilla.fenix.ext.showToolbar
import org.mozilla.fenix.theme.ThemeManager import org.mozilla.fenix.theme.ThemeManager
@ -188,6 +191,11 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management),
private val onPositiveButtonClicked: ((Addon) -> Unit) = { addon -> private val onPositiveButtonClicked: ((Addon) -> Unit) = { addon ->
addonProgressOverlay?.visibility = View.VISIBLE addonProgressOverlay?.visibility = View.VISIBLE
if (requireContext().settings().accessibilityServicesEnabled) {
announceForAccessibility(addonProgressOverlay.add_ons_overlay_text.text)
}
isInstallationInProgress = true isInstallationInProgress = true
requireContext().components.addonManager.installAddon( requireContext().components.addonManager.installAddon(
@ -224,6 +232,16 @@ class AddonsManagementFragment : Fragment(R.layout.fragment_add_ons_management),
) )
} }
private fun announceForAccessibility(announcementText: CharSequence) {
val event = AccessibilityEvent.obtain(
AccessibilityEvent.TYPE_ANNOUNCEMENT
)
addonProgressOverlay.onInitializeAccessibilityEvent(event)
event.text.add(announcementText)
event.contentDescription = null
addonProgressOverlay.parent.requestSendAccessibilityEvent(addonProgressOverlay, event)
}
companion object { companion object {
private const val PERMISSIONS_DIALOG_FRAGMENT_TAG = "ADDONS_PERMISSIONS_DIALOG_FRAGMENT" private const val PERMISSIONS_DIALOG_FRAGMENT_TAG = "ADDONS_PERMISSIONS_DIALOG_FRAGMENT"
} }

View File

@ -10,6 +10,7 @@
android:elevation="1dp"> android:elevation="1dp">
<TextView <TextView
android:id="@+id/add_ons_overlay_text"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"