Remove old code
This commit is contained in:
parent
329e5af94f
commit
f74ca3b424
2 changed files with 0 additions and 251 deletions
|
@ -11,10 +11,7 @@ import android.graphics.drawable.AnimationDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.DisplayMetrics
|
import android.util.DisplayMetrics
|
||||||
import android.view.ContextMenu
|
|
||||||
import android.view.ContextMenu.ContextMenuInfo
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.View.OnLongClickListener
|
import android.view.View.OnLongClickListener
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -183,8 +180,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
overviewMenus.setupChartMenu(overview_chartMenuButton)
|
||||||
prepareGraphs()
|
prepareGraphs()
|
||||||
|
|
||||||
//overviewMenus.setupPopupMenu(overview_apsmode, requireContext(), childFragmentManager)
|
|
||||||
//overviewMenus.setupPopupMenu(overview_activeprofile, requireContext(), childFragmentManager)
|
|
||||||
overview_activeprofile?.setOnClickListener(this)
|
overview_activeprofile?.setOnClickListener(this)
|
||||||
overview_activeprofile?.setOnLongClickListener(this)
|
overview_activeprofile?.setOnLongClickListener(this)
|
||||||
overview_temptarget?.setOnClickListener(this)
|
overview_temptarget?.setOnClickListener(this)
|
||||||
|
@ -377,7 +372,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
|
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// R.id.overview_apsmode -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { LoopDialog().show(childFragmentManager, "Overview") })}
|
|
||||||
R.id.overview_apsmode -> {
|
R.id.overview_apsmode -> {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putInt("showOkCancel", 0) // 0-> false
|
args.putInt("showOkCancel", 0) // 0-> false
|
||||||
|
@ -385,14 +379,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
pvd.arguments = args
|
pvd.arguments = args
|
||||||
pvd.show(childFragmentManager, "Overview")
|
pvd.show(childFragmentManager, "Overview")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
R.id.overview_apsmode -> {
|
|
||||||
OverviewMenus.showOKCancel = false
|
|
||||||
v.performClick()
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
R.id.overview_temptarget -> v.performClick()
|
R.id.overview_temptarget -> v.performClick()
|
||||||
R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") })}
|
R.id.overview_activeprofile -> activity?.let { activity -> protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "Overview") })}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,20 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview
|
package info.nightscout.androidaps.plugins.general.overview
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.style.ForegroundColorSpan
|
import android.text.style.ForegroundColorSpan
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.widget.PopupMenu
|
import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.fragment.app.FragmentManager
|
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import info.nightscout.androidaps.Config
|
import info.nightscout.androidaps.Config
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
|
||||||
import info.nightscout.androidaps.data.Profile
|
|
||||||
import info.nightscout.androidaps.db.Source
|
|
||||||
import info.nightscout.androidaps.db.TempTarget
|
|
||||||
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
|
||||||
import info.nightscout.androidaps.dialogs.ProfileViewerDialog
|
|
||||||
import info.nightscout.androidaps.dialogs.TempTargetDialog
|
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
|
||||||
import info.nightscout.androidaps.interfaces.CommandQueueProvider
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
|
||||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
|
||||||
import info.nightscout.androidaps.queue.Callback
|
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
|
||||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
|
||||||
import info.nightscout.androidaps.utils.ToastUtils
|
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
|
||||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -50,13 +27,7 @@ class OverviewMenus @Inject constructor(
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val rxBus: RxBusWrapper,
|
private val rxBus: RxBusWrapper,
|
||||||
private val context: Context,
|
|
||||||
private val buildHelper: BuildHelper,
|
private val buildHelper: BuildHelper,
|
||||||
private val defaultValueHelper: DefaultValueHelper,
|
|
||||||
private val activePlugin: ActivePluginProvider,
|
|
||||||
private val profileFunction: ProfileFunction,
|
|
||||||
private val commandQueue: CommandQueueProvider,
|
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin,
|
|
||||||
private val loopPlugin: LoopPlugin,
|
private val loopPlugin: LoopPlugin,
|
||||||
private val config: Config
|
private val config: Config
|
||||||
) {
|
) {
|
||||||
|
@ -75,7 +46,6 @@ class OverviewMenus @Inject constructor(
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val MAX_GRAPHS = 5 // including main
|
const val MAX_GRAPHS = 5 // including main
|
||||||
var showOKCancel = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun enabledTypes(graph: Int): String {
|
fun enabledTypes(graph: Int): String {
|
||||||
|
@ -176,211 +146,4 @@ class OverviewMenus @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setupPopupMenu(v: View, context: Context, manager: FragmentManager) {
|
|
||||||
v.setOnClickListener {
|
|
||||||
val popup = PopupMenu(v.context, v)
|
|
||||||
when (v.id) {
|
|
||||||
R.id.overview_apsmode -> {
|
|
||||||
val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription
|
|
||||||
if (profileFunction.isProfileValid("ContextMenuCreation")) {
|
|
||||||
val item = popup.menu.add(Menu.NONE,1,Menu.NONE,resourceHelper.gs(R.string.loop)) // title
|
|
||||||
val title = item.title
|
|
||||||
val s = SpannableString(title)
|
|
||||||
s.setSpan( ForegroundColorSpan(resourceHelper.gc(R.color.colorAccent)), 0, s.length, 0)
|
|
||||||
item.setTitle(s)
|
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.disableloop))
|
|
||||||
if (!loopPlugin.isSuspended) {
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor1h))
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor2h))
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor3h))
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.suspendloopfor10h))
|
|
||||||
} else {
|
|
||||||
if (!loopPlugin.isDisconnected) {
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.resume))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.enableloop))
|
|
||||||
}
|
|
||||||
if (!loopPlugin.isDisconnected) {
|
|
||||||
if (pumpDescription.tempDurationStep15mAllowed) popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor15m))
|
|
||||||
if (pumpDescription.tempDurationStep30mAllowed) popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor30m))
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor1h))
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor2h))
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.disconnectpumpfor3h))
|
|
||||||
} else {
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.reconnect))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
R.id.overview_activeprofile -> {
|
|
||||||
val item = popup.menu.add(Menu.NONE,1,Menu.NONE,resourceHelper.gs(R.string.profile)) // title
|
|
||||||
val title = item.title
|
|
||||||
val s = SpannableString(title)
|
|
||||||
s.setSpan(ForegroundColorSpan(resourceHelper.gc(R.color.colorAccent)), 0, s.length, 0)
|
|
||||||
item.setTitle(s)
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.viewprofile))
|
|
||||||
if (activePlugin.activeProfileInterface.profile != null) {
|
|
||||||
popup.menu.add(resourceHelper.gs(R.string.careportal_profileswitch))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
popup.setOnMenuItemClickListener {
|
|
||||||
if (it.itemId != 1) {
|
|
||||||
if (showOKCancel) {
|
|
||||||
when (it.title) {
|
|
||||||
resourceHelper.gs(R.string.careportal_profileswitch),
|
|
||||||
resourceHelper.gs(R.string.viewprofile) -> onItemSelected(it, manager)
|
|
||||||
|
|
||||||
else -> {
|
|
||||||
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.confirm), it.title.toString(),
|
|
||||||
Runnable {
|
|
||||||
onItemSelected(it, manager)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onItemSelected(it, manager)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return@setOnMenuItemClickListener true
|
|
||||||
}
|
|
||||||
popup.setOnDismissListener { showOKCancel = true }
|
|
||||||
popup.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onItemSelected(item: MenuItem, manager: FragmentManager): Boolean {
|
|
||||||
val profile = profileFunction.getProfile() ?: return true
|
|
||||||
when (item.title) {
|
|
||||||
resourceHelper.gs(R.string.disableloop) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: LOOP DISABLED")
|
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, false)
|
|
||||||
loopPlugin.setFragmentVisible(PluginType.LOOP, false)
|
|
||||||
configBuilderPlugin.storeSettings("DisablingLoop")
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
|
||||||
override fun run() {
|
|
||||||
if (!result.success) {
|
|
||||||
ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
loopPlugin.createOfflineEvent(24 * 60) // upload 24h, we don't know real duration
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.enableloop) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: LOOP ENABLED")
|
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true)
|
|
||||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true)
|
|
||||||
configBuilderPlugin.storeSettings("EnablingLoop")
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
loopPlugin.createOfflineEvent(0)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.resume), resourceHelper.gs(R.string.reconnect) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: RESUME")
|
|
||||||
loopPlugin.suspendTo(0L)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
commandQueue.cancelTempBasal(true, object : Callback() {
|
|
||||||
override fun run() {
|
|
||||||
if (!result.success) {
|
|
||||||
val i = Intent(context, ErrorHelperActivity::class.java)
|
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
|
||||||
i.putExtra("status", result.comment)
|
|
||||||
i.putExtra("title", resourceHelper.gs(R.string.tempbasaldeliveryerror))
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
context.startActivity(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
sp.putBoolean(R.string.key_objectiveusereconnect, true)
|
|
||||||
loopPlugin.createOfflineEvent(0)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.suspendloopfor1h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: SUSPEND 1h")
|
|
||||||
loopPlugin.suspendLoop(60)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.suspendloopfor2h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: SUSPEND 2h")
|
|
||||||
loopPlugin.suspendLoop(120)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.suspendloopfor3h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: SUSPEND 3h")
|
|
||||||
loopPlugin.suspendLoop(180)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.suspendloopfor10h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: SUSPEND 10h")
|
|
||||||
loopPlugin.suspendLoop(600)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.disconnectpumpfor15m) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: DISCONNECT 15m")
|
|
||||||
loopPlugin.disconnectPump(15, profile)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.disconnectpumpfor30m) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: DISCONNECT 30m")
|
|
||||||
loopPlugin.disconnectPump(30, profile)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.disconnectpumpfor1h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: DISCONNECT 1h")
|
|
||||||
loopPlugin.disconnectPump(60, profile)
|
|
||||||
sp.putBoolean(R.string.key_objectiveusedisconnect, true)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.disconnectpumpfor2h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: DISCONNECT 2h")
|
|
||||||
loopPlugin.disconnectPump(120, profile)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.disconnectpumpfor3h) -> {
|
|
||||||
aapsLogger.debug("USER ENTRY: DISCONNECT 3h")
|
|
||||||
loopPlugin.disconnectPump(180, profile)
|
|
||||||
rxBus.send(EventRefreshOverview("suspendmenu"))
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.careportal_profileswitch) -> {
|
|
||||||
ProfileSwitchDialog().show(manager, "Overview")
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceHelper.gs(R.string.viewprofile) -> {
|
|
||||||
val args = Bundle()
|
|
||||||
args.putLong("time", DateUtil.now())
|
|
||||||
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
|
|
||||||
val pvd = ProfileViewerDialog()
|
|
||||||
pvd.arguments = args
|
|
||||||
pvd.show(manager, "ProfileViewDialog")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue