Skip to content

Commit

Permalink
Show a dialog that explains why I need aaccesibility service
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep committed Nov 17, 2021
1 parent b9c2081 commit 16f3422
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import android.util.TypedValue
import android.view.View
import android.widget.SeekBar
import androidx.browser.customtabs.CustomTabsIntent
import androidx.core.graphics.ColorUtils
import androidx.core.net.toUri
import androidx.core.view.*
import androidx.lifecycle.Observer
Expand All @@ -26,6 +25,7 @@ import com.artemchep.pocketmode.models.Proximity
import com.artemchep.pocketmode.ui.activities.base.BaseActivity
import com.artemchep.pocketmode.util.ObserverConsumer
import com.artemchep.pocketmode.viewmodels.MainViewModel
import com.google.android.material.dialog.MaterialAlertDialogBuilder


/**
Expand Down Expand Up @@ -426,7 +426,16 @@ class MainActivity : BaseActivity(),
R.id.labBtn -> mainViewModel.openLab()
R.id.moreAppsBtn -> mainViewModel.openApps()
// Permissions
R.id.accessibilityServiceBtn -> mainViewModel.grantAccessibilityService()
R.id.accessibilityServiceBtn -> MaterialAlertDialogBuilder(this)
.setTitle(R.string.access_accessibility_service_dialog_text)
.setMessage(R.string.access_accessibility_service_dialog_text)
.setNegativeButton(R.string.access_accessibility_service_dialog_no, null)
.setPositiveButton(
R.string.access_accessibility_service_dialog_yes,
) { _, _ ->
mainViewModel.grantAccessibilityService()
}
.show()
R.id.callStateBtn -> mainViewModel.grantCallState()
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

<string name="access">Permissions</string>
<string name="access_accessibility_service">Pocket Mode uses accessibility service to send the command that locks the screen. Tap to grant accessibility service privileges</string>
<string name="access_accessibility_service_dialog_title">How do we use accessibility service</string>
<string name="access_accessibility_service_dialog_text">Pocket Mode uses accessibility service to send the command that locks the screen. Without it locking the screen would require a PIN code on each unlock, ruining the user experience.</string>
<string name="access_accessibility_service_dialog_no">Close</string>
<string name="access_accessibility_service_dialog_yes">Enable accessibility service</string>
<string name="access_runtime_call_state">Pocket Mode reads call state to not turn screen off while call is active. Tap to grant call state privileges</string>
<string name="access_overlays">Pocket Mode can draw overlay on top of the user apps to show user that the proximity sensor is covered.</string>

Expand Down

0 comments on commit 16f3422

Please sign in to comment.