Remove unused code

This commit is contained in:
Philoul 2020-12-23 21:46:15 +01:00
parent 4a368c554e
commit f76c6a4910
4 changed files with 4 additions and 106 deletions

View file

@ -85,23 +85,11 @@ class TempTargetDialog : DialogFragmentWithDate() {
val adapterReason = ArrayAdapter(context, R.layout.spinner_centered, reasonList)
overview_temptarget_reason.adapter = adapterReason
overview_temptarget_custom?.setOnClickListener {
overview_temptarget_temptarget.value = savedInstanceState?.getDouble("overview_temptarget_temptarget") ?: if (profileFunction.getUnits() == Constants.MMOL) Constants.MIN_TT_MMOL else Constants.MIN_TT_MGDL
overview_temptarget_duration.value = savedInstanceState?.getDouble("overview_temptarget_duration") ?: 0.0
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.manual)));
}
overview_temptarget_cancel?.setOnClickListener { shortClick(it) }
overview_temptarget_eating_soon?.setOnClickListener { shortClick(it) }
overview_temptarget_activity?.setOnClickListener { shortClick(it) }
overview_temptarget_hypo?.setOnClickListener { shortClick(it) }
/*
overview_temptarget_cancel?.setOnLongClickListener {
longClick(it)
return@setOnLongClickListener true
}
*/
overview_temptarget_eating_soon?.setOnLongClickListener {
longClick(it)
return@setOnLongClickListener true
@ -124,11 +112,6 @@ class TempTargetDialog : DialogFragmentWithDate() {
private fun longClick(v:View) {
when (v.id) {
R.id.overview_temptarget_cancel -> {
overview_temptarget_temptarget.value = 0.0
overview_temptarget_duration.value = 0.0
overview_temptarget_reason.setSelection(reasonList.indexOf(resourceHelper.gs(R.string.cancel)))
}
R.id.overview_temptarget_eating_soon -> {
overview_temptarget_temptarget.value = defaultValueHelper.determineEatingSoonTT()
overview_temptarget_duration.value = defaultValueHelper.determineEatingSoonTTDuration().toDouble()

View file

@ -185,7 +185,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overviewMenus.setupPopupMenu(overview_apsmode, requireContext(), childFragmentManager)
overviewMenus.setupPopupMenu(overview_activeprofile, requireContext(), childFragmentManager)
//overviewMenus.setupPopupMenu(overview_temptarget, requireContext(), childFragmentManager)
overview_temptarget?.setOnClickListener(this)
overview_accepttempbutton?.setOnClickListener(this)
overview_treatmentbutton?.setOnClickListener(this)
@ -358,7 +357,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
startActivity(Intent(v.context, QuickWizardListActivity::class.java))
return true
}
R.id.overview_apsmode, R.id.overview_activeprofile, R.id.overview_temptarget -> {
R.id.overview_apsmode, R.id.overview_activeprofile -> {
OverviewMenus.showOKCancel = false
v.performClick()
}

View file

@ -226,30 +226,15 @@ class OverviewMenus @Inject constructor(
popup.menu.add(resourceHelper.gs(R.string.careportal_profileswitch))
}
}
R.id.overview_temptarget -> {
val item = popup.menu.add(Menu.NONE,1,Menu.NONE,resourceHelper.gs(R.string.careportal_temporarytarget)) // 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.custom))
popup.menu.add(resourceHelper.gs(R.string.eatingsoon))
popup.menu.add(resourceHelper.gs(R.string.activity))
popup.menu.add(resourceHelper.gs(R.string.hypo))
if (activePlugin.activeTreatments.tempTargetFromHistory != null) {
popup.menu.add(resourceHelper.gs(R.string.cancel))
}
}
}
popup.setOnMenuItemClickListener {
if (it.itemId != 1) {
if (showOKCancel) {
when (it.title) {
resourceHelper.gs(R.string.careportal_profileswitch),
resourceHelper.gs(R.string.viewprofile),
resourceHelper.gs(R.string.custom) -> onItemSelected(it, manager)
resourceHelper.gs(R.string.viewprofile) -> onItemSelected(it, manager)
else -> {
else -> {
OKDialog.showConfirmation(context, resourceHelper.gs(R.string.confirm), it.title.toString(),
Runnable {
onItemSelected(it, manager)
@ -394,60 +379,6 @@ class OverviewMenus @Inject constructor(
pvd.arguments = args
pvd.show(manager, "ProfileViewDialog")
}
resourceHelper.gs(R.string.eatingsoon) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET EATING SOON")
val target = Profile.toMgdl(defaultValueHelper.determineEatingSoonTT(), profileFunction.getUnits())
val tempTarget = TempTarget()
.date(System.currentTimeMillis())
.duration(defaultValueHelper.determineEatingSoonTTDuration())
.reason(resourceHelper.gs(R.string.eatingsoon))
.source(Source.USER)
.low(target)
.high(target)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
resourceHelper.gs(R.string.activity) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET ACTIVITY")
val target = Profile.toMgdl(defaultValueHelper.determineActivityTT(), profileFunction.getUnits())
val tempTarget = TempTarget()
.date(DateUtil.now())
.duration(defaultValueHelper.determineActivityTTDuration())
.reason(resourceHelper.gs(R.string.activity))
.source(Source.USER)
.low(target)
.high(target)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
resourceHelper.gs(R.string.hypo) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET HYPO")
val target = Profile.toMgdl(defaultValueHelper.determineHypoTT(), profileFunction.getUnits())
val tempTarget = TempTarget()
.date(DateUtil.now())
.duration(defaultValueHelper.determineHypoTTDuration())
.reason(resourceHelper.gs(R.string.hypo))
.source(Source.USER)
.low(target)
.high(target)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
resourceHelper.gs(R.string.custom) -> {
TempTargetDialog().show(manager, "Overview")
}
resourceHelper.gs(R.string.cancel) -> {
aapsLogger.debug("USER ENTRY: TEMP TARGET CANCEL")
val tempTarget = TempTarget()
.source(Source.USER)
.date(DateUtil.now())
.duration(0)
.low(0.0)
.high(0.0)
activePlugin.activeTreatments.addToHistoryTempTarget(tempTarget)
}
}
return false
}

View file

@ -142,27 +142,12 @@
</LinearLayout>
<include layout="@layout/datetime" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/overview_temptarget_custom"
style="?android:attr/buttonStyle"
android:layout_width="0px"
android:layout_height="fill_parent"
android:layout_marginEnd="-4dp"
android:layout_weight="0.5"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:drawableTop="@drawable/ic_target_manual"
android:text="@string/manual"
android:textColor="@color/tempTargetConfirmation"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:visibility="gone"
android:textSize="11sp" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/overview_temptarget_cancel"
style="?android:attr/buttonStyle"