VirtualPump: don't ask for BT permission
This commit is contained in:
parent
27355c18a2
commit
f519d37ac3
1 changed files with 15 additions and 13 deletions
|
@ -17,6 +17,7 @@ import app.aaps.core.interfaces.androidPermissions.AndroidPermission
|
||||||
import app.aaps.core.interfaces.configuration.Config
|
import app.aaps.core.interfaces.configuration.Config
|
||||||
import app.aaps.core.interfaces.notifications.Notification
|
import app.aaps.core.interfaces.notifications.Notification
|
||||||
import app.aaps.core.interfaces.plugin.ActivePlugin
|
import app.aaps.core.interfaces.plugin.ActivePlugin
|
||||||
|
import app.aaps.core.interfaces.pump.VirtualPump
|
||||||
import app.aaps.core.interfaces.resources.ResourceHelper
|
import app.aaps.core.interfaces.resources.ResourceHelper
|
||||||
import app.aaps.core.interfaces.smsCommunicator.SmsCommunicator
|
import app.aaps.core.interfaces.smsCommunicator.SmsCommunicator
|
||||||
import app.aaps.core.ui.dialogs.OKDialog
|
import app.aaps.core.ui.dialogs.OKDialog
|
||||||
|
@ -105,20 +106,21 @@ class AndroidPermissionImpl @Inject constructor(
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
@Synchronized
|
@Synchronized
|
||||||
override fun notifyForBtConnectPermission(activity: FragmentActivity) {
|
override fun notifyForBtConnectPermission(activity: FragmentActivity) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
if (activePlugin.activePump !is VirtualPump)
|
||||||
// Manifest.permission.BLUETOOTH_CONNECT
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
if (permissionNotGranted(activity, Manifest.permission.BLUETOOTH_CONNECT) || permissionNotGranted(activity, Manifest.permission.BLUETOOTH_SCAN))
|
// Manifest.permission.BLUETOOTH_CONNECT
|
||||||
activePlugin.activeOverview.addNotification(
|
if (permissionNotGranted(activity, Manifest.permission.BLUETOOTH_CONNECT) || permissionNotGranted(activity, Manifest.permission.BLUETOOTH_SCAN))
|
||||||
id = Notification.PERMISSION_BT,
|
activePlugin.activeOverview.addNotification(
|
||||||
text = rh.gs(app.aaps.core.ui.R.string.need_connect_permission),
|
id = Notification.PERMISSION_BT,
|
||||||
level = Notification.URGENT,
|
text = rh.gs(app.aaps.core.ui.R.string.need_connect_permission),
|
||||||
actionButtonId = R.string.request
|
level = Notification.URGENT,
|
||||||
) { askForPermission(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT)) }
|
actionButtonId = R.string.request
|
||||||
else {
|
) { askForPermission(activity, arrayOf(Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT)) }
|
||||||
activity.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE))
|
else {
|
||||||
activePlugin.activeOverview.dismissNotification(Notification.PERMISSION_BT)
|
activity.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE))
|
||||||
|
activePlugin.activeOverview.dismissNotification(Notification.PERMISSION_BT)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
|
Loading…
Reference in a new issue