add Window Permssion into Setup Wizard

This commit is contained in:
Tim Gunn 2021-03-04 04:39:35 +13:00
parent b0823bcfb8
commit 6688a2696e
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C

View file

@ -2,6 +2,9 @@ package info.nightscout.androidaps.setupwizard
import android.Manifest import android.Manifest
import android.content.Context import android.content.Context
import android.content.Intent
import android.net.Uri
import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
@ -111,6 +114,17 @@ class SWDefinition @Inject constructor(
.updateDelay(5) .updateDelay(5)
.label(R.string.high_mark) .label(R.string.high_mark)
.comment(R.string.high_mark_comment)) .comment(R.string.high_mark_comment))
private val screenPermissionWindow = SWScreen(injector, R.string.permission)
.skippable(false)
.add(SWInfoText(injector)
.label(resourceHelper.gs(R.string.needsystemwindowpermission)))
.add(SWBreak(injector))
.add(SWButton(injector)
.text(R.string.askforpermission)
.visibility { !Settings.canDrawOverlays(activity) }
.action { activity.startActivity(Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + activity.packageName))) })
.visibility { !Settings.canDrawOverlays(activity) }
.validator { Settings.canDrawOverlays(activity) }
private val screenPermissionBattery = SWScreen(injector, R.string.permission) private val screenPermissionBattery = SWScreen(injector, R.string.permission)
.skippable(false) .skippable(false)
.add(SWInfoText(injector) .add(SWInfoText(injector)
@ -377,6 +391,7 @@ class SWDefinition @Inject constructor(
//.add(screenLanguage) //.add(screenLanguage)
.add(screenEula) .add(screenEula)
.add(if (isRunningTest()) null else screenPermissionBattery) // cannot mock ask battery optimization .add(if (isRunningTest()) null else screenPermissionBattery) // cannot mock ask battery optimization
.add(screenPermissionWindow)
.add(screenPermissionBt) .add(screenPermissionBt)
.add(screenPermissionStore) .add(screenPermissionStore)
.add(screenMasterPassword) .add(screenMasterPassword)
@ -406,6 +421,7 @@ class SWDefinition @Inject constructor(
//.add(screenLanguage) //.add(screenLanguage)
.add(screenEula) .add(screenEula)
.add(if (isRunningTest()) null else screenPermissionBattery) // cannot mock ask battery optimization .add(if (isRunningTest()) null else screenPermissionBattery) // cannot mock ask battery optimization
.add(screenPermissionWindow)
.add(screenPermissionBt) .add(screenPermissionBt)
.add(screenPermissionStore) .add(screenPermissionStore)
.add(screenMasterPassword) .add(screenMasterPassword)
@ -430,6 +446,7 @@ class SWDefinition @Inject constructor(
//.add(screenLanguage) //.add(screenLanguage)
.add(screenEula) .add(screenEula)
.add(if (isRunningTest()) null else screenPermissionBattery) // cannot mock ask battery optimization .add(if (isRunningTest()) null else screenPermissionBattery) // cannot mock ask battery optimization
.add(screenPermissionWindow)
.add(screenPermissionStore) .add(screenPermissionStore)
.add(screenMasterPassword) .add(screenMasterPassword)
.add(screenImport) .add(screenImport)