Remove Redundant Context menu
This commit is contained in:
parent
28fa373d83
commit
7f9f6d3f03
2 changed files with 4 additions and 81 deletions
|
@ -235,11 +235,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
super.onPause()
|
super.onPause()
|
||||||
disposable.clear()
|
disposable.clear()
|
||||||
loopHandler.removeCallbacksAndMessages(null)
|
loopHandler.removeCallbacksAndMessages(null)
|
||||||
/* overview_apsmode_llayout?.let { unregisterForContextMenu(it) }
|
|
||||||
overview_activeprofile?.let { unregisterForContextMenu(it) }
|
|
||||||
overview_temptarget?.let { unregisterForContextMenu(it) }
|
|
||||||
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
|
@ -311,22 +306,9 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
}
|
}
|
||||||
loopHandler.postDelayed(refreshLoop, 60 * 1000L)
|
loopHandler.postDelayed(refreshLoop, 60 * 1000L)
|
||||||
|
|
||||||
/* overview_apsmode_llayout?.let { registerForContextMenu(overview_apsmode) }
|
|
||||||
overview_activeprofile?.let { registerForContextMenu(it) }
|
|
||||||
overview_temptarget?.let { registerForContextMenu(it) }
|
|
||||||
|
|
||||||
*/
|
|
||||||
updateGUI("onResume")
|
updateGUI("onResume")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateContextMenu(menu: ContextMenu, v: View, menuInfo: ContextMenuInfo?) {
|
|
||||||
super.onCreateContextMenu(menu, v, menuInfo)
|
|
||||||
overviewMenus.createContextMenu(menu, v)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onContextItemSelected(item: MenuItem): Boolean {
|
|
||||||
return if (overviewMenus.onContextItemSelected(item, childFragmentManager)) true else super.onContextItemSelected(item)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Intent
|
||||||
import android.os.Bundle
|
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.ContextMenu
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -248,17 +247,17 @@ class OverviewMenus @Inject constructor(
|
||||||
when (it.title) {
|
when (it.title) {
|
||||||
resourceHelper.gs(R.string.careportal_profileswitch),
|
resourceHelper.gs(R.string.careportal_profileswitch),
|
||||||
resourceHelper.gs(R.string.viewprofile),
|
resourceHelper.gs(R.string.viewprofile),
|
||||||
resourceHelper.gs(R.string.custom) -> onContextItemSelected(it, manager)
|
resourceHelper.gs(R.string.custom) -> onItemSelected(it, manager)
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.confirm), it.title.toString(),
|
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.confirm), it.title.toString(),
|
||||||
Runnable {
|
Runnable {
|
||||||
onContextItemSelected(it, manager)
|
onItemSelected(it, manager)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onContextItemSelected(it, manager)
|
onItemSelected(it, manager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
|
@ -268,65 +267,7 @@ class OverviewMenus @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createContextMenu(menu: ContextMenu, v: View) {
|
fun onItemSelected(item: MenuItem, manager: FragmentManager): Boolean {
|
||||||
when (v.id) {
|
|
||||||
R.id.overview_apsmode -> {
|
|
||||||
val pumpDescription: PumpDescription = activePlugin.activePump.pumpDescription
|
|
||||||
if (!profileFunction.isProfileValid("ContextMenuCreation")) return
|
|
||||||
menu.setHeaderTitle(resourceHelper.gs(R.string.loop))
|
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
menu.add(resourceHelper.gs(R.string.disableloop))
|
|
||||||
if (!loopPlugin.isSuspended) {
|
|
||||||
menu.add(resourceHelper.gs(R.string.suspendloopfor1h))
|
|
||||||
menu.add(resourceHelper.gs(R.string.suspendloopfor2h))
|
|
||||||
menu.add(resourceHelper.gs(R.string.suspendloopfor3h))
|
|
||||||
menu.add(resourceHelper.gs(R.string.suspendloopfor10h))
|
|
||||||
} else {
|
|
||||||
if (!loopPlugin.isDisconnected) {
|
|
||||||
menu.add(resourceHelper.gs(R.string.resume))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
menu.add(resourceHelper.gs(R.string.enableloop))
|
|
||||||
}
|
|
||||||
if (!loopPlugin.isDisconnected) {
|
|
||||||
showSuspendPump(menu, pumpDescription)
|
|
||||||
} else {
|
|
||||||
menu.add(resourceHelper.gs(R.string.reconnect))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
R.id.overview_activeprofile -> {
|
|
||||||
menu.setHeaderTitle(resourceHelper.gs(R.string.profile))
|
|
||||||
menu.add(resourceHelper.gs(R.string.viewprofile))
|
|
||||||
if (activePlugin.activeProfileInterface.profile != null) {
|
|
||||||
menu.add(resourceHelper.gs(R.string.careportal_profileswitch))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
R.id.overview_temptarget -> {
|
|
||||||
menu.setHeaderTitle(resourceHelper.gs(R.string.careportal_temporarytarget))
|
|
||||||
menu.add(resourceHelper.gs(R.string.custom))
|
|
||||||
menu.add(resourceHelper.gs(R.string.eatingsoon))
|
|
||||||
menu.add(resourceHelper.gs(R.string.activity))
|
|
||||||
menu.add(resourceHelper.gs(R.string.hypo))
|
|
||||||
if (activePlugin.activeTreatments.tempTargetFromHistory != null) {
|
|
||||||
menu.add(resourceHelper.gs(R.string.cancel))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showSuspendPump(menu: ContextMenu, pumpDescription: PumpDescription) {
|
|
||||||
if (pumpDescription.tempDurationStep15mAllowed) menu.add(resourceHelper.gs(R.string.disconnectpumpfor15m))
|
|
||||||
if (pumpDescription.tempDurationStep30mAllowed) menu.add(resourceHelper.gs(R.string.disconnectpumpfor30m))
|
|
||||||
menu.add(resourceHelper.gs(R.string.disconnectpumpfor1h))
|
|
||||||
menu.add(resourceHelper.gs(R.string.disconnectpumpfor2h))
|
|
||||||
menu.add(resourceHelper.gs(R.string.disconnectpumpfor3h))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onContextItemSelected(item: MenuItem, manager: FragmentManager): Boolean {
|
|
||||||
val profile = profileFunction.getProfile() ?: return true
|
val profile = profileFunction.getProfile() ?: return true
|
||||||
when (item.title) {
|
when (item.title) {
|
||||||
resourceHelper.gs(R.string.disableloop) -> {
|
resourceHelper.gs(R.string.disableloop) -> {
|
||||||
|
|
Loading…
Reference in a new issue