Fragments menu improvements
This commit is contained in:
parent
b2beb2d98e
commit
4ad9f1d428
15 changed files with 113 additions and 125 deletions
|
@ -14,7 +14,6 @@ import info.nightscout.androidaps.database.AppRepository
|
|||
import info.nightscout.androidaps.database.entities.Bolus
|
||||
import info.nightscout.androidaps.database.entities.BolusCalculatorResult
|
||||
import info.nightscout.androidaps.database.entities.Carbs
|
||||
import info.nightscout.androidaps.database.entities.UserEntry
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Action
|
||||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||
import info.nightscout.androidaps.database.entities.ValueWithUnit
|
||||
|
@ -30,6 +29,7 @@ import info.nightscout.androidaps.extensions.iobCalc
|
|||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart
|
||||
|
@ -41,7 +41,6 @@ import info.nightscout.androidaps.utils.T
|
|||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
|
@ -91,7 +90,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(true)
|
||||
|
|
|
@ -67,7 +67,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(true)
|
||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.extensions.isInProgress
|
|||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.ActionModeHelper
|
||||
|
@ -33,7 +34,6 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
|
@ -73,7 +73,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(true)
|
||||
|
@ -140,7 +140,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
|||
holder.binding.date.text = if (newDay) dateUtil.dateStringRelative(extendedBolus.timestamp, rh) else ""
|
||||
if (extendedBolus.isInProgress(dateUtil)) {
|
||||
holder.binding.time.text = dateUtil.timeString(extendedBolus.timestamp)
|
||||
holder.binding.time.setTextColor(rh.gac(context , R.attr.activeColor))
|
||||
holder.binding.time.setTextColor(rh.gac(context, R.attr.activeColor))
|
||||
} else {
|
||||
holder.binding.time.text = dateUtil.timeRangeString(extendedBolus.timestamp, extendedBolus.end)
|
||||
holder.binding.time.setTextColor(holder.binding.insulin.currentTextColor)
|
||||
|
@ -151,7 +151,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
|
|||
val iob = extendedBolus.iobCalc(System.currentTimeMillis(), profile, activePlugin.activeInsulin)
|
||||
holder.binding.iob.text = rh.gs(R.string.formatinsulinunits, iob.iob)
|
||||
holder.binding.ratio.text = rh.gs(R.string.pump_basebasalrate, extendedBolus.rate)
|
||||
if (iob.iob != 0.0) holder.binding.iob.setTextColor(rh.gac(context , R.attr.activeColor)) else holder.binding.iob.setTextColor(holder.binding.insulin.currentTextColor)
|
||||
if (iob.iob != 0.0) holder.binding.iob.setTextColor(rh.gac(context, R.attr.activeColor)) else holder.binding.iob.setTextColor(holder.binding.insulin.currentTextColor)
|
||||
holder.binding.cbRemove.visibility = (extendedBolus.isValid && actionHelper.isRemoving).toVisibility()
|
||||
if (actionHelper.isRemoving) {
|
||||
holder.binding.cbRemove.setOnCheckedChangeListener { _, value ->
|
||||
|
|
|
@ -78,7 +78,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(true)
|
||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.extensions.highValueToUnitsToString
|
|||
import info.nightscout.androidaps.extensions.lowValueToUnitsToString
|
||||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart
|
||||
|
@ -35,7 +36,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventNewHi
|
|||
import info.nightscout.androidaps.utils.*
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
|
@ -78,7 +78,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
binding.recyclerview.setHasFixedSize(true)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(true)
|
||||
|
@ -187,8 +187,8 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
|
|||
holder.binding.reason.text = translator.translate(tempTarget.reason)
|
||||
holder.binding.time.setTextColor(
|
||||
when {
|
||||
tempTarget.id == currentlyActiveTarget?.id -> rh.gac(context , R.attr.activeColor)
|
||||
tempTarget.timestamp > dateUtil.now() -> rh.gac(context , R.attr.scheduledColor)
|
||||
tempTarget.id == currentlyActiveTarget?.id -> rh.gac(context, R.attr.activeColor)
|
||||
tempTarget.timestamp > dateUtil.now() -> rh.gac(context, R.attr.scheduledColor)
|
||||
else -> holder.binding.reasonColon.currentTextColor
|
||||
}
|
||||
)
|
||||
|
|
|
@ -30,6 +30,7 @@ import info.nightscout.androidaps.extensions.toTemporaryBasal
|
|||
import info.nightscout.androidaps.extensions.toVisibility
|
||||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.ActionModeHelper
|
||||
|
@ -38,7 +39,6 @@ import info.nightscout.androidaps.utils.FabricPrivacy
|
|||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
|
@ -78,7 +78,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(true)
|
||||
|
|
|
@ -42,14 +42,11 @@ class LoopFragment : DaggerFragment() {
|
|||
// onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
setHasOptionsMenu(true)
|
||||
_binding = LoopFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
LoopFragmentBinding.inflate(inflater, container, false).also {
|
||||
_binding = it
|
||||
setHasOptionsMenu(true)
|
||||
}.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
|
|
@ -43,14 +43,11 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
// onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
setHasOptionsMenu(true)
|
||||
_binding = OpenapsamaFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
OpenapsamaFragmentBinding.inflate(inflater, container, false).also {
|
||||
_binding = it
|
||||
setHasOptionsMenu(true)
|
||||
}.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
@ -67,9 +64,11 @@ class OpenAPSAMAFragment : DaggerFragment() {
|
|||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
if (isResumed) {
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
|
|
|
@ -46,11 +46,11 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
// onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
setHasOptionsMenu(true)
|
||||
_binding = OpenapsamaFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
OpenapsamaFragmentBinding.inflate(inflater, container, false).also {
|
||||
_binding = it
|
||||
setHasOptionsMenu(true)
|
||||
}.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
@ -66,9 +66,11 @@ class OpenAPSSMBFragment : DaggerFragment() {
|
|||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
if (isResumed) {
|
||||
menu.removeItem(ID_MENU_RUN)
|
||||
menu.add(Menu.FIRST, ID_MENU_RUN, 0, rh.gs(R.string.openapsma_run)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.general.nsclient
|
||||
|
||||
import android.graphics.Paint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.*
|
||||
import android.widget.ScrollView
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.R
|
||||
|
@ -12,13 +9,13 @@ import info.nightscout.androidaps.database.entities.UserEntry.Action
|
|||
import info.nightscout.androidaps.database.entities.UserEntry.Sources
|
||||
import info.nightscout.androidaps.databinding.NsClientFragmentBinding
|
||||
import info.nightscout.androidaps.interfaces.DataSyncSelector
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.sharedPreferences.SP
|
||||
import io.reactivex.rxjava3.disposables.CompositeDisposable
|
||||
|
@ -36,6 +33,14 @@ class NSClientFragment : DaggerFragment() {
|
|||
@Inject lateinit var dataSyncSelector: DataSyncSelector
|
||||
@Inject lateinit var uel: UserEntryLogger
|
||||
|
||||
companion object {
|
||||
|
||||
const val ID_MENU_CLEAR_LOG = 6
|
||||
const val ID_MENU_RESTART = 7
|
||||
const val ID_MENU_SEND_NOW = 8
|
||||
const val ID_MENU_FULL_SYNC = 8
|
||||
}
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
|
||||
private var _binding: NsClientFragmentBinding? = null
|
||||
|
@ -45,7 +50,10 @@ class NSClientFragment : DaggerFragment() {
|
|||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
NsClientFragmentBinding.inflate(inflater, container, false).also { _binding = it }.root
|
||||
NsClientFragmentBinding.inflate(inflater, container, false).also {
|
||||
_binding = it
|
||||
setHasOptionsMenu(true)
|
||||
}.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
@ -63,23 +71,49 @@ class NSClientFragment : DaggerFragment() {
|
|||
nsClientPlugin.pause(isChecked)
|
||||
updateGui()
|
||||
}
|
||||
binding.clearLog.setOnClickListener { nsClientPlugin.clearLog() }
|
||||
binding.clearLog.paintFlags = binding.clearLog.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
binding.restart.setOnClickListener { rxBus.send(EventNSClientRestart()) }
|
||||
binding.restart.paintFlags = binding.restart.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
binding.deliverNow.setOnClickListener { nsClientPlugin.resend("GUI") }
|
||||
binding.deliverNow.paintFlags = binding.deliverNow.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
binding.fullSync.setOnClickListener {
|
||||
context?.let { context ->
|
||||
OKDialog.showConfirmation(context, rh.gs(R.string.nsclientinternal),
|
||||
rh.gs(R.string.full_sync_comment), Runnable {
|
||||
dataSyncSelector.resetToNextFullSync()
|
||||
})
|
||||
}
|
||||
}
|
||||
binding.fullSync.paintFlags = binding.fullSync.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
if (isResumed) {
|
||||
menu.add(Menu.FIRST, ID_MENU_CLEAR_LOG, 0, rh.gs(R.string.clearlog)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.add(Menu.FIRST, ID_MENU_RESTART, 0, rh.gs(R.string.restart)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.add(Menu.FIRST, ID_MENU_SEND_NOW, 0, rh.gs(R.string.deliver_now)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.add(Menu.FIRST, ID_MENU_FULL_SYNC, 0, rh.gs(R.string.full_sync)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
||||
when (item.itemId) {
|
||||
ID_MENU_CLEAR_LOG -> {
|
||||
nsClientPlugin.clearLog()
|
||||
true
|
||||
}
|
||||
|
||||
ID_MENU_RESTART -> {
|
||||
rxBus.send(EventNSClientRestart())
|
||||
true
|
||||
}
|
||||
|
||||
ID_MENU_SEND_NOW -> {
|
||||
nsClientPlugin.resend("GUI")
|
||||
true
|
||||
}
|
||||
|
||||
ID_MENU_FULL_SYNC -> {
|
||||
context?.let { context ->
|
||||
OKDialog.showConfirmation(
|
||||
context, rh.gs(R.string.nsclientinternal), rh.gs(R.string.full_sync_comment),
|
||||
Runnable { dataSyncSelector.resetToNextFullSync() }
|
||||
)
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
|
||||
@Synchronized override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += rxBus
|
||||
|
|
|
@ -125,7 +125,7 @@ class QuickWizardListActivity : DaggerAppCompatActivityWithResult(), OnStartDrag
|
|||
binding = OverviewQuickwizardlistActivityBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
actionHelper = ActionModeHelper(rh, this)
|
||||
actionHelper = ActionModeHelper(rh, this, null)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
actionHelper.enableSort = true
|
||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.extensions.valueToUnitsString
|
|||
import info.nightscout.androidaps.interfaces.ActivePlugin
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.ActionModeHelper
|
||||
|
@ -30,7 +31,6 @@ import info.nightscout.androidaps.utils.DateUtil
|
|||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||
import info.nightscout.shared.logging.AAPSLogger
|
||||
import info.nightscout.shared.logging.LTag
|
||||
|
@ -61,14 +61,16 @@ class BGSourceFragment : DaggerFragment() {
|
|||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
BgsourceFragmentBinding.inflate(inflater, container, false).also { _binding = it }.root
|
||||
BgsourceFragmentBinding.inflate(inflater, container, false).also {
|
||||
_binding = it
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { handler -> removeSelected(handler) }
|
||||
setHasOptionsMenu(true)
|
||||
}.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper.setUpdateListHandler { binding.recyclerview.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
setHasOptionsMenu(actionHelper.inMenu)
|
||||
|
||||
binding.recyclerview.setHasFixedSize(true)
|
||||
binding.recyclerview.layoutManager = LinearLayoutManager(view.context)
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:orientation="horizontal">
|
||||
|
@ -95,57 +96,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/clear_log"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/clearlog"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/actionButton"
|
||||
android:textStyle="normal|bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/restart"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/restart"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/actionButton"
|
||||
android:textStyle="normal|bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/deliver_now"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/deliver_now"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/actionButton"
|
||||
android:textStyle="normal|bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/full_sync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/full_sync"
|
||||
android:textAlignment="center"
|
||||
android:textColor="?attr/actionButton"
|
||||
android:textStyle="normal|bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/log_scrollview"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -69,7 +69,7 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener {
|
|||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
_binding = AutomationFragmentBinding.inflate(inflater, container, false)
|
||||
actionHelper = ActionModeHelper(rh, activity)
|
||||
actionHelper = ActionModeHelper(rh, activity, this)
|
||||
actionHelper.setUpdateListHandler { binding.eventListView.adapter?.notifyDataSetChanged() }
|
||||
actionHelper.setOnRemoveHandler { removeSelected(it) }
|
||||
actionHelper.enableSort = true
|
||||
|
|
|
@ -5,12 +5,13 @@ import android.view.ActionMode
|
|||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import info.nightscout.androidaps.core.R
|
||||
|
||||
import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||
|
||||
class ActionModeHelper<T>(val rh: ResourceHelper, val activity: FragmentActivity?) {
|
||||
class ActionModeHelper<T>(val rh: ResourceHelper, val activity: FragmentActivity?, val fragment: Fragment?) {
|
||||
|
||||
var enableSort = false
|
||||
private var selectedItems: SparseArray<T> = SparseArray()
|
||||
|
@ -20,7 +21,7 @@ class ActionModeHelper<T>(val rh: ResourceHelper, val activity: FragmentActivity
|
|||
private var onRemove: ((selectedItems: SparseArray<T>) -> Unit)? = null
|
||||
private var onUpdate: (() -> Unit)? = null
|
||||
|
||||
val inMenu: Boolean
|
||||
private val inSingleFragment: Boolean
|
||||
get() {
|
||||
val parentClass = this.activity?.let { it::class.simpleName }
|
||||
return parentClass == "SingleFragmentActivity"
|
||||
|
@ -67,8 +68,12 @@ class ActionModeHelper<T>(val rh: ResourceHelper, val activity: FragmentActivity
|
|||
}
|
||||
|
||||
fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
if (inMenu) {
|
||||
if (inSingleFragment) {
|
||||
inflater.inflate(R.menu.menu_actions, menu)
|
||||
} else if (fragment?.isResumed == true) {
|
||||
menu.add(Menu.FIRST, R.id.nav_remove_items, 0, rh.gs(R.string.remove_items)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.add(Menu.FIRST, R.id.nav_sort_items, 0, rh.gs(R.string.sort_items)).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER)
|
||||
menu.setGroupDividerEnabled(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue