mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 07:05:35 +03:00
PM-12297: Add accessibility service alert for autofill tile (#3931)
This commit is contained in:
parent
1c2ccd5305
commit
2721f7293c
1 changed files with 15 additions and 0 deletions
|
@ -1,14 +1,18 @@
|
|||
package com.x8bit.bitwarden.data.tiles
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.service.quicksettings.TileService
|
||||
import androidx.annotation.Keep
|
||||
import com.x8bit.bitwarden.AccessibilityActivity
|
||||
import com.x8bit.bitwarden.R
|
||||
import com.x8bit.bitwarden.data.autofill.accessibility.manager.AccessibilityAutofillManager
|
||||
import com.x8bit.bitwarden.data.autofill.accessibility.model.AccessibilityAction
|
||||
import com.x8bit.bitwarden.data.autofill.accessibility.util.isAccessibilityServiceEnabled
|
||||
import com.x8bit.bitwarden.data.platform.annotation.OmitFromCoverage
|
||||
import com.x8bit.bitwarden.data.platform.util.isBuildVersionBelow
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
@ -34,6 +38,10 @@ class BitwardenAutofillTileService : TileService() {
|
|||
|
||||
@SuppressLint("StartActivityAndCollapseDeprecated")
|
||||
private fun launchAutofill() {
|
||||
if (!applicationContext.isAccessibilityServiceEnabled) {
|
||||
showDialog(getAccessibilityServiceRequiredDialog())
|
||||
return
|
||||
}
|
||||
accessibilityAutofillManager.accessibilityAction = AccessibilityAction.AttemptParseUri
|
||||
val intent = Intent(applicationContext, AccessibilityActivity::class.java)
|
||||
if (isBuildVersionBelow(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)) {
|
||||
|
@ -50,4 +58,11 @@ class BitwardenAutofillTileService : TileService() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAccessibilityServiceRequiredDialog(): Dialog =
|
||||
AlertDialog.Builder(this)
|
||||
.setMessage(R.string.autofill_tile_accessibility_required)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.ok) { dialog, _ -> dialog.cancel() }
|
||||
.create()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue