fix passing context
This commit is contained in:
parent
5ae6191922
commit
21c92d41c8
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.androidaps.dialogs
|
package info.nightscout.androidaps.dialogs
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.google.common.base.Joiner
|
import com.google.common.base.Joiner
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
|
@ -15,8 +15,8 @@ import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
import info.nightscout.androidaps.queue.Callback
|
import info.nightscout.androidaps.queue.Callback
|
||||||
import info.nightscout.androidaps.utils.HtmlHelper
|
import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
|
||||||
import info.nightscout.androidaps.utils.SafeParse
|
import info.nightscout.androidaps.utils.SafeParse
|
||||||
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
import info.nightscout.androidaps.utils.extensions.formatColor
|
import info.nightscout.androidaps.utils.extensions.formatColor
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import kotlinx.android.synthetic.main.dialog_extendedbolus.*
|
import kotlinx.android.synthetic.main.dialog_extendedbolus.*
|
||||||
|
@ -27,7 +27,8 @@ import javax.inject.Inject
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
|
|
||||||
class ExtendedBolusDialog : DialogFragmentWithDate() {
|
class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
|
@Inject lateinit var ctx: Context
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var constraintChecker: ConstraintChecker
|
@Inject lateinit var constraintChecker: ConstraintChecker
|
||||||
@Inject lateinit var commandQueue: CommandQueueProvider
|
@Inject lateinit var commandQueue: CommandQueueProvider
|
||||||
|
@ -77,12 +78,12 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(ctx, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
ctx.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.dialogs
|
package info.nightscout.androidaps.dialogs
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -9,7 +10,6 @@ import android.view.Window
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import dagger.android.support.DaggerDialogFragment
|
import dagger.android.support.DaggerDialogFragment
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.databinding.DialogLoopBinding
|
import info.nightscout.androidaps.databinding.DialogLoopBinding
|
||||||
|
@ -37,7 +37,7 @@ import javax.inject.Inject
|
||||||
class LoopDialog : DaggerDialogFragment() {
|
class LoopDialog : DaggerDialogFragment() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var ctx: Context
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -190,14 +190,14 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
val profileStore = activePlugin.activeProfileInterface.profile
|
val profileStore = activePlugin.activeProfileInterface.profile
|
||||||
|
|
||||||
if (profile == null || profileStore == null) {
|
if (profile == null || profileStore == null) {
|
||||||
ToastUtils.showToastInUiThread(mainApp, resourceHelper.gs(R.string.noprofile))
|
ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.noprofile))
|
||||||
dismiss()
|
dismiss()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onClickOkCancelEnabled(v: View): Boolean {
|
private fun onClickOkCancelEnabled(v: View): Boolean {
|
||||||
var description = ""
|
var description = ""
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.overview_closeloop -> description = resourceHelper.gs(R.string.closedloop)
|
R.id.overview_closeloop -> description = resourceHelper.gs(R.string.closedloop)
|
||||||
|
@ -255,7 +255,7 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
ToastUtils.showToastInUiThread(ctx, resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -280,12 +280,12 @@ class LoopDialog : DaggerDialogFragment() {
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(context, ErrorHelperActivity::class.java)
|
val i = Intent(ctx, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
context?.startActivity(i)
|
ctx.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.actions
|
package info.nightscout.androidaps.plugins.general.actions
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
|
@ -11,7 +12,6 @@ import androidx.core.content.ContextCompat
|
||||||
import dagger.android.support.DaggerFragment
|
import dagger.android.support.DaggerFragment
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.Constants
|
import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.activities.TDDStatsActivity
|
import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||||
|
@ -45,11 +45,12 @@ import java.util.*
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class ActionsFragment : DaggerFragment() {
|
class ActionsFragment : DaggerFragment() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var ctx: Context
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var statusLightHandler: StatusLightHandler
|
@Inject lateinit var statusLightHandler: StatusLightHandler
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
|
@ -94,12 +95,12 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
actions_extendedbolus.setOnClickListener {
|
actions_extendedbolus.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable {
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
|
||||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), resourceHelper.gs(R.string.ebstopsloop),
|
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.extended_bolus), resourceHelper.gs(R.string.ebstopsloop),
|
||||||
Runnable {
|
Runnable {
|
||||||
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
ExtendedBolusDialog().show(childFragmentManager, "Actions")
|
||||||
}, null)
|
}, null)
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions_extendedbolus_cancel.setOnClickListener {
|
actions_extendedbolus_cancel.setOnClickListener {
|
||||||
|
@ -108,12 +109,12 @@ class ActionsFragment : DaggerFragment() {
|
||||||
commandQueue.cancelExtended(object : Callback() {
|
commandQueue.cancelExtended(object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(ctx, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.extendedbolusdeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.extendedbolusdeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
ctx.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -128,12 +129,12 @@ class ActionsFragment : DaggerFragment() {
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
commandQueue.cancelTempBasal(true, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(mainApp, ErrorHelperActivity::class.java)
|
val i = Intent(ctx, ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
mainApp.startActivity(i)
|
ctx.startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -141,7 +142,7 @@ class ActionsFragment : DaggerFragment() {
|
||||||
}
|
}
|
||||||
actions_fill.setOnClickListener {
|
actions_fill.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable(Runnable { FillDialog().show(childFragmentManager, "FillDialog") }))
|
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { FillDialog().show(childFragmentManager, "FillDialog") })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
|
actions_historybrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
|
||||||
|
|
Loading…
Reference in a new issue