Merge pull request #1432 from Andries-Smit/chore/use-binging-actions-overview-skin

Chore: use binding actions overview skin
This commit is contained in:
Milos Kozak 2022-03-14 12:49:48 +01:00 committed by GitHub
commit f29857d23b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 156 additions and 506 deletions

View file

@ -8,11 +8,8 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TableRow
import android.widget.TextView
import androidx.core.content.ContextCompat
import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.activities.HistoryBrowseActivity
@ -21,7 +18,7 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.ValueWrapper
import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.diaconn.DiaconnG8Plugin
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
import info.nightscout.androidaps.dialogs.*
import info.nightscout.androidaps.events.EventCustomActionsChanged
import info.nightscout.androidaps.events.EventExtendedBolusChange
@ -37,7 +34,6 @@ import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBus
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
import info.nightscout.androidaps.plugins.pump.omnipod.eros.OmnipodErosPumpPlugin
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.skins.SkinProvider
import info.nightscout.androidaps.utils.DateUtil
@ -82,83 +78,30 @@ class ActionsFragment : DaggerFragment() {
private val pumpCustomActions = HashMap<String, CustomAction>()
private val pumpCustomButtons = ArrayList<SingleClickButton>()
private var smallWidth = false
private var smallHeight = false
private lateinit var dm: DisplayMetrics
private var buttonsLayout: LinearLayout? = null
private var profileSwitch: SingleClickButton? = null
private var tempTarget: SingleClickButton? = null
private var extendedBolus: SingleClickButton? = null
private var extendedBolusCancel: SingleClickButton? = null
private var setTempBasal: SingleClickButton? = null
private var cancelTempBasal: SingleClickButton? = null
private var fill: SingleClickButton? = null
private var historyBrowser: SingleClickButton? = null
private var tddStats: SingleClickButton? = null
private var pumpBatteryChange: SingleClickButton? = null
private var _binding: ActionsFragmentBinding? = null
// This property is only valid between onCreateView and onDestroyView.
private val binding get() = _binding!!
private var cannulaAge: TextView? = null
private var insulinAge: TextView? = null
private var reservoirLevel: TextView? = null
private var sensorAge: TextView? = null
private var sensorLevel: TextView? = null
private var pbAge: TextView? = null
private var batteryLevel: TextView? = null
private var sensorLevelLabel: TextView? = null
private var insulinLevelLabel: TextView? = null
private var pbLevelLabel: TextView? = null
private var cannulaOrPatch: TextView? = null
private var batteryLayout: TableRow? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
//check screen width
dm = DisplayMetrics()
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
activity?.display?.getRealMetrics(dm)
else
} else {
@Suppress("DEPRECATION") activity?.windowManager?.defaultDisplay?.getMetrics(dm)
val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels
smallWidth = screenWidth <= Constants.SMALL_WIDTH
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
val landscape = screenHeight < screenWidth
return inflater.inflate(skinProvider.activeSkin().actionsLayout(landscape, smallWidth), container, false)
}
_binding = ActionsFragmentBinding.inflate(inflater, container, false)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
buttonsLayout = view.findViewById(R.id.action_buttons_layout)
profileSwitch = view.findViewById(R.id.actions_profileswitch)
tempTarget = view.findViewById(R.id.actions_temptarget)
extendedBolus = view.findViewById(R.id.actions_extendedbolus)
extendedBolusCancel = view.findViewById(R.id.actions_extendedbolus_cancel)
setTempBasal = view.findViewById(R.id.actions_settempbasal)
cancelTempBasal = view.findViewById(R.id.actions_canceltempbasal)
fill = view.findViewById(R.id.actions_fill)
historyBrowser = view.findViewById(R.id.actions_historybrowser)
tddStats = view.findViewById(R.id.actions_tddstats)
pumpBatteryChange = view.findViewById(R.id.actions_pumpbatterychange)
cannulaAge = view.findViewById(R.id.cannula_age)
insulinAge = view.findViewById(R.id.insulin_age)
reservoirLevel = view.findViewById(R.id.reservoir_level)
sensorAge = view.findViewById(R.id.sensor_age)
sensorLevel = view.findViewById(R.id.sensor_level)
pbAge = view.findViewById(R.id.pb_age)
batteryLevel = view.findViewById(R.id.battery_level)
sensorLevelLabel = view.findViewById(R.id.sensor_level_label)
insulinLevelLabel = view.findViewById(R.id.insulin_level_label)
pbLevelLabel = view.findViewById(R.id.pb_level_label)
cannulaOrPatch = view.findViewById(R.id.cannula_or_patch)
batteryLayout = view.findViewById(R.id.battery_layout)
skinProvider.activeSkin().preProcessLandscapeActionsLayout(dm, binding)
profileSwitch?.setOnClickListener {
binding.profileSwitch.setOnClickListener {
activity?.let { activity ->
protectionCheck.queryProtection(
activity,
@ -166,7 +109,7 @@ class ActionsFragment : DaggerFragment() {
UIRunnable { ProfileSwitchDialog().show(childFragmentManager, "ProfileSwitchDialog")})
}
}
tempTarget?.setOnClickListener {
binding.tempTarget.setOnClickListener {
activity?.let { activity ->
protectionCheck.queryProtection(
activity,
@ -174,7 +117,7 @@ class ActionsFragment : DaggerFragment() {
UIRunnable { TempTargetDialog().show(childFragmentManager, "Actions") })
}
}
extendedBolus?.setOnClickListener {
binding.extendedBolus.setOnClickListener {
activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable {
OKDialog.showConfirmation(
@ -186,7 +129,7 @@ class ActionsFragment : DaggerFragment() {
})
}
}
extendedBolusCancel?.setOnClickListener {
binding.extendedBolusCancel.setOnClickListener {
if (iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) {
uel.log(Action.CANCEL_EXTENDED_BOLUS, Sources.Actions)
commandQueue.cancelExtended(object : Callback() {
@ -198,7 +141,7 @@ class ActionsFragment : DaggerFragment() {
})
}
}
setTempBasal?.setOnClickListener {
binding.setTempBasal.setOnClickListener {
activity?.let { activity ->
protectionCheck.queryProtection(
activity,
@ -206,7 +149,7 @@ class ActionsFragment : DaggerFragment() {
UIRunnable { TempBasalDialog().show(childFragmentManager, "Actions") })
}
}
cancelTempBasal?.setOnClickListener {
binding.cancelTempBasal.setOnClickListener {
if (iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) != null) {
uel.log(Action.CANCEL_TEMP_BASAL, Sources.Actions)
commandQueue.cancelTempBasal(true, object : Callback() {
@ -218,32 +161,32 @@ class ActionsFragment : DaggerFragment() {
})
}
}
fill?.setOnClickListener {
binding.fill.setOnClickListener {
activity?.let { activity ->
protectionCheck.queryProtection(activity, ProtectionCheck.Protection.BOLUS, UIRunnable { FillDialog().show(childFragmentManager, "FillDialog") })
}
}
historyBrowser?.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
tddStats?.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
view.findViewById<SingleClickButton>(R.id.actions_bgcheck).setOnClickListener {
binding.historyBrowser.setOnClickListener { startActivity(Intent(context, HistoryBrowseActivity::class.java)) }
binding.tddStats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
binding.bgCheck.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.BGCHECK, R.string.careportal_bgcheck).show(childFragmentManager, "Actions")
}
view.findViewById<SingleClickButton>(R.id.actions_cgmsensorinsert).setOnClickListener {
binding.cgmSensorInsert.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.SENSOR_INSERT, R.string.careportal_cgmsensorinsert).show(childFragmentManager, "Actions")
}
pumpBatteryChange?.setOnClickListener {
binding.pumpBatteryChange.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.BATTERY_CHANGE, R.string.careportal_pumpbatterychange).show(childFragmentManager, "Actions")
}
view.findViewById<SingleClickButton>(R.id.actions_note).setOnClickListener {
binding.note.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.NOTE, R.string.careportal_note).show(childFragmentManager, "Actions")
}
view.findViewById<SingleClickButton>(R.id.actions_exercise).setOnClickListener {
binding.exercise.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.EXERCISE, R.string.careportal_exercise).show(childFragmentManager, "Actions")
}
view.findViewById<SingleClickButton>(R.id.actions_question).setOnClickListener {
binding.question.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.QUESTION, R.string.careportal_question).show(childFragmentManager, "Actions")
}
view.findViewById<SingleClickButton>(R.id.actions_announcement).setOnClickListener {
binding.announcement.setOnClickListener {
CareDialog().setOptions(CareDialog.EventType.ANNOUNCEMENT, R.string.careportal_announcement).show(childFragmentManager, "Actions")
}
@ -282,13 +225,18 @@ class ActionsFragment : DaggerFragment() {
disposable.clear()
}
override fun onDestroyView() {
super.onDestroyView()
_binding = null
}
@Synchronized
fun updateGui() {
val profile = profileFunction.getProfile()
val pump = activePlugin.activePump
profileSwitch?.visibility = (
binding.profileSwitch.visibility = (
activePlugin.activeProfileSource.profile != null &&
pump.pumpDescription.isSetBasalProfileCapable &&
pump.isInitialized() &&
@ -296,56 +244,58 @@ class ActionsFragment : DaggerFragment() {
!loop.isDisconnected).toVisibility()
if (!pump.pumpDescription.isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || loop.isDisconnected || pump.isFakingTempsByExtendedBoluses || config.NSCLIENT) {
extendedBolus?.visibility = View.GONE
extendedBolusCancel?.visibility = View.GONE
binding.extendedBolus.visibility = View.GONE
binding.extendedBolusCancel.visibility = View.GONE
} else {
val activeExtendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet()
if (activeExtendedBolus is ValueWrapper.Existing) {
extendedBolus?.visibility = View.GONE
extendedBolusCancel?.visibility = View.VISIBLE
binding.extendedBolus.visibility = View.GONE
binding.extendedBolusCancel.visibility = View.VISIBLE
@Suppress("SetTextI18n")
extendedBolusCancel?.text = rh.gs(R.string.cancel) + " " + activeExtendedBolus.value.toStringMedium(dateUtil)
binding.extendedBolusCancel.text = rh.gs(R.string.cancel) + " " + activeExtendedBolus.value.toStringMedium(dateUtil)
} else {
extendedBolus?.visibility = View.VISIBLE
extendedBolusCancel?.visibility = View.GONE
binding.extendedBolus.visibility = View.VISIBLE
binding.extendedBolusCancel.visibility = View.GONE
}
}
if (!pump.pumpDescription.isTempBasalCapable || !pump.isInitialized() || pump.isSuspended() || loop.isDisconnected || config.NSCLIENT) {
setTempBasal?.visibility = View.GONE
cancelTempBasal?.visibility = View.GONE
binding.setTempBasal.visibility = View.GONE
binding.cancelTempBasal.visibility = View.GONE
} else {
val activeTemp = iobCobCalculator.getTempBasalIncludingConvertedExtended(System.currentTimeMillis())
if (activeTemp != null) {
setTempBasal?.visibility = View.GONE
cancelTempBasal?.visibility = View.VISIBLE
binding.setTempBasal.visibility = View.GONE
binding.cancelTempBasal.visibility = View.VISIBLE
@Suppress("SetTextI18n")
cancelTempBasal?.text = rh.gs(R.string.cancel) + " " + activeTemp.toStringShort()
binding.cancelTempBasal.text = rh.gs(R.string.cancel) + " " + activeTemp.toStringShort()
} else {
setTempBasal?.visibility = View.VISIBLE
cancelTempBasal?.visibility = View.GONE
binding.setTempBasal.visibility = View.VISIBLE
binding.cancelTempBasal.visibility = View.GONE
}
}
val activeBgSource = activePlugin.activeBgSource
historyBrowser?.visibility = (profile != null).toVisibility()
fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized() && !pump.isSuspended()).toVisibility()
pumpBatteryChange?.visibility = (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()).toVisibility()
tempTarget?.visibility = (profile != null && !loop.isDisconnected).toVisibility()
tddStats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
binding.historyBrowser.visibility = (profile != null).toVisibility()
binding.fill.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized() && !pump.isSuspended()).toVisibility()
binding.pumpBatteryChange.visibility = (pump.pumpDescription.isBatteryReplaceable || pump.isBatteryChangeLoggingEnabled()).toVisibility()
binding.tempTarget.visibility = (profile != null && !loop.isDisconnected).toVisibility()
binding.tddStats.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
val isPatchPump = pump.pumpDescription.isPatchPump
cannulaOrPatch?.text = if (isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
binding.status.apply {
cannulaOrPatch.text = if (isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
val imageResource = if (isPatchPump) R.drawable.ic_patch_pump_outline else R.drawable.ic_cp_age_cannula
cannulaOrPatch?.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0)
batteryLayout?.visibility = (!isPatchPump || pump.pumpDescription.useHardwareLink).toVisibility()
cannulaOrPatch.setCompoundDrawablesWithIntrinsicBounds(imageResource, 0, 0, 0)
batteryLayout.visibility = (!isPatchPump || pump.pumpDescription.useHardwareLink).toVisibility()
if (!config.NSCLIENT) {
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel)
sensorLevelLabel?.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.careportal_level_label)
sensorLevelLabel.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.careportal_level_label)
} else {
statusLightHandler.updateStatusLights(cannulaAge, insulinAge, null, sensorAge, null, pbAge, null)
sensorLevelLabel?.text = ""
insulinLevelLabel?.text = ""
pbLevelLabel?.text = ""
sensorLevelLabel.text = ""
insulinLevelLabel.text = ""
pbLevelLabel.text = ""
}
}
checkPumpCustomActions()
@ -378,7 +328,7 @@ class ActionsFragment : DaggerFragment() {
val top = activity?.let { ContextCompat.getDrawable(it, customAction.iconResourceId) }
btn.setCompoundDrawablesWithIntrinsicBounds(null, top, null, null)
buttonsLayout?.addView(btn)
binding.buttonsLayout.addView(btn)
this.pumpCustomActions[rh.gs(customAction.name)] = customAction
this.pumpCustomButtons.add(btn)
@ -386,7 +336,7 @@ class ActionsFragment : DaggerFragment() {
}
private fun removePumpCustomActions() {
for (customButton in pumpCustomButtons) buttonsLayout?.removeView(customButton)
for (customButton in pumpCustomButtons) binding.buttonsLayout.removeView(customButton)
pumpCustomButtons.clear()
}
}

View file

@ -152,7 +152,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
_binding = it
//check screen width
dm = DisplayMetrics()
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
activity?.display?.getRealMetrics(dm)
else
@Suppress("DEPRECATION") activity?.windowManager?.defaultDisplay?.getMetrics(dm)
@ -168,7 +168,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
val landscape = screenHeight < screenWidth
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, landscape, rh.gb(R.bool.isTablet), smallHeight)
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, binding, landscape, rh.gb(R.bool.isTablet), smallHeight)
binding.nsclientLayout.visibility = config.NSCLIENT.toVisibility()
binding.notifications.setHasFixedSize(false)

View file

@ -5,6 +5,7 @@ import android.view.View
import android.widget.LinearLayout
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
import javax.inject.Inject
import javax.inject.Singleton
@ -15,8 +16,8 @@ class SkinClassic @Inject constructor(private val config: Config): SkinInterface
override val mainGraphHeight: Int get() = 200
override val secondaryGraphHeight: Int get() = 100
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
super.preProcessLandscapeOverviewLayout(dm, view, isLandscape, isTablet, isSmallHeight)
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(view as LinearLayout)
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
super.preProcessLandscapeOverviewLayout(dm, binding, isLandscape, isTablet, isSmallHeight)
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(binding.root)
}
}

View file

@ -4,11 +4,11 @@ import android.util.DisplayMetrics
import android.util.TypedValue.COMPLEX_UNIT_PX
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.LayoutRes
import androidx.annotation.StringRes
import androidx.constraintlayout.widget.ConstraintLayout
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
interface SkinInterface {
@ -17,19 +17,19 @@ interface SkinInterface {
val mainGraphHeight: Int // in dp
val secondaryGraphHeight: Int // in dp
@LayoutRes
fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int = R.layout.actions_fragment
fun preProcessLandscapeActionsLayout(dm: DisplayMetrics, binding: ActionsFragmentBinding) {
}
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
// pre-process landscape mode
val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels
val landscape = screenHeight < screenWidth
if (landscape) {
val iobLayout = view.findViewById<LinearLayout>(R.id.iob_layout)
val iobLayout = binding.infoLayout.iobLayout
val iobLayoutParams = iobLayout.layoutParams as ConstraintLayout.LayoutParams
val timeLayout = view.findViewById<LinearLayout>(R.id.time_layout)
val timeLayout = binding.infoLayout.timeLayout
iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET
iobLayoutParams.startToEnd = timeLayout.id
iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET
@ -37,43 +37,34 @@ interface SkinInterface {
val timeLayoutParams = timeLayout.layoutParams as ConstraintLayout.LayoutParams
timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET
timeLayoutParams.endToStart = iobLayout.id
val cobLayoutParams = view.findViewById<LinearLayout>(R.id.cob_layout).layoutParams as ConstraintLayout.LayoutParams
val cobLayoutParams = binding.infoLayout.cobLayout.layoutParams as ConstraintLayout.LayoutParams
cobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val basalLayoutParams = view.findViewById<LinearLayout>(R.id.basal_layout).layoutParams as ConstraintLayout.LayoutParams
val basalLayoutParams = binding.infoLayout.basalLayout.layoutParams as ConstraintLayout.LayoutParams
basalLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val extendedLayoutParams = view.findViewById<LinearLayout>(R.id.extended_layout).layoutParams as ConstraintLayout.LayoutParams
val extendedLayoutParams = binding.infoLayout.extendedLayout.layoutParams as ConstraintLayout.LayoutParams
extendedLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val asLayoutParams = view.findViewById<LinearLayout>(R.id.as_layout).layoutParams as ConstraintLayout.LayoutParams
val asLayoutParams = binding.infoLayout.asLayout.layoutParams as ConstraintLayout.LayoutParams
asLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
if (isTablet) {
for (v in listOf<TextView?>(
view.findViewById(R.id.bg),
view.findViewById(R.id.time),
view.findViewById(R.id.time_ago_short),
view.findViewById(R.id.iob),
view.findViewById(R.id.cob),
view.findViewById(R.id.base_basal),
view.findViewById(R.id.extended_bolus),
view.findViewById(R.id.sensitivity)
)) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f)
for (v in listOf<TextView?>(
view.findViewById(R.id.pump),
view.findViewById(R.id.openaps),
view.findViewById(R.id.uploader),
view.findViewById(R.id.cannula_age),
view.findViewById(R.id.insulin_age),
view.findViewById(R.id.reservoir_level),
view.findViewById(R.id.sensor_age),
view.findViewById(R.id.pb_age),
view.findViewById(R.id.battery_level)
)) v?.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
timeLayout?.orientation = LinearLayout.HORIZONTAL
view.findViewById<TextView>(R.id.time_ago_short)?.setTextSize(COMPLEX_UNIT_PX, view.findViewById<TextView>(R.id.time).textSize)
binding.infoLayout.apply {
val texts = listOf(bg, time, timeAgoShort, iob, cob, baseBasal, extendedBolus, sensitivity)
for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f)
}
binding.apply {
val texts = listOf(pump, openaps, uploader)
for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
}
binding.statusLightsLayout.apply {
val texts = listOf(cannulaAge, insulinAge, reservoirLevel, sensorAge, pbAge, batteryLevel)
for (v in texts) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
}
timeLayout.orientation = LinearLayout.HORIZONTAL
binding.infoLayout.timeAgoShort.setTextSize(COMPLEX_UNIT_PX, binding.infoLayout.time.textSize)
view.findViewById<TextView>(R.id.delta_large)?.visibility = View.VISIBLE
binding.infoLayout.deltaLarge.visibility = View.VISIBLE
} else {
view.findViewById<TextView>(R.id.delta_large)?.visibility = View.GONE
binding.infoLayout.deltaLarge.visibility = View.GONE
}
}
}
@ -84,4 +75,5 @@ interface SkinInterface {
val innerLayout = root.findViewById<LinearLayout>(R.id.inner_layout)
innerLayout.addView(buttonsLayout)
}
}

View file

@ -5,6 +5,7 @@ import android.view.View
import android.widget.LinearLayout
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
import javax.inject.Inject
import javax.inject.Singleton
@ -15,8 +16,8 @@ class SkinLargeDisplay @Inject constructor(private val config: Config): SkinInte
override val mainGraphHeight: Int get() = 400
override val secondaryGraphHeight: Int get() = 150
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
super.preProcessLandscapeOverviewLayout(dm, view, isLandscape, isTablet, isSmallHeight)
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(view as LinearLayout)
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
super.preProcessLandscapeOverviewLayout(dm, binding, isLandscape, isTablet, isSmallHeight)
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(binding.root)
}
}

View file

@ -1,10 +1,11 @@
package info.nightscout.androidaps.skins
import android.util.DisplayMetrics
import android.view.View
import android.widget.LinearLayout
import android.view.View.GONE
import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.R
import info.nightscout.androidaps.databinding.ActionsFragmentBinding
import info.nightscout.androidaps.databinding.OverviewFragmentBinding
import javax.inject.Inject
import javax.inject.Singleton
@ -15,13 +16,28 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface
override val mainGraphHeight: Int get() = 200
override val secondaryGraphHeight: Int get() = 100
override fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int =
when {
isLandscape -> R.layout.actions_fragment
else -> R.layout.actions_fragment_lowres
override fun preProcessLandscapeActionsLayout(dm: DisplayMetrics, binding: ActionsFragmentBinding) {
val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels
val isLandscape = screenHeight < screenWidth
if (!isLandscape) {
binding.status.apply {
sensorAgeLabel.visibility = GONE
sensorAgeLabel.visibility = GONE
sensorLevelLabel.visibility = GONE
insulinAgeLabel.visibility = GONE
insulinLevelLabel.visibility = GONE
cannulaAgeLabel.visibility = GONE
cannulaPlaceholder.visibility = GONE
pbAgeLabel.visibility = GONE
pbLevelLabel.visibility = GONE
}
}
}
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
if (!config.NSCLIENT && isLandscape) moveButtonsLayout(view as LinearLayout)
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
if (!config.NSCLIENT && isLandscape) moveButtonsLayout(binding.root)
}
}

View file

@ -6,7 +6,7 @@
tools:context=".plugins.general.actions.ActionsFragment">
<LinearLayout
android:id="@+id/action_buttons_layout"
android:id="@+id/buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -26,7 +26,7 @@
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_profileswitch"
android:id="@+id/profile_switch"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -41,7 +41,7 @@
app:layout_row="0" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_temptarget"
android:id="@+id/temp_target"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -56,7 +56,7 @@
app:layout_row="0" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_settempbasal"
android:id="@+id/set_temp_basal"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -71,7 +71,7 @@
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_canceltempbasal"
android:id="@+id/cancel_temp_basal"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -87,7 +87,7 @@
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_extendedbolus"
android:id="@+id/extended_bolus"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -102,7 +102,7 @@
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_extendedbolus_cancel"
android:id="@+id/extended_bolus_cancel"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -127,7 +127,7 @@
android:text="@string/careportal" />
<include
android:id="@+id/careportal_stats"
android:id="@+id/status"
layout="@layout/careportal_stats_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -140,7 +140,7 @@
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_bgcheck"
android:id="@+id/bg_check"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -155,7 +155,7 @@
app:layout_row="2" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_fill"
android:id="@+id/fill"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -170,7 +170,7 @@
app:layout_row="2" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_cgmsensorinsert"
android:id="@+id/cgm_sensor_insert"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -185,7 +185,7 @@
app:layout_row="3" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_pumpbatterychange"
android:id="@+id/pump_battery_change"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -200,7 +200,7 @@
app:layout_row="3" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_note"
android:id="@+id/note"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -215,7 +215,7 @@
app:layout_row="4" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_exercise"
android:id="@+id/exercise"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -230,7 +230,7 @@
app:layout_row="4" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_announcement"
android:id="@+id/announcement"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -245,7 +245,7 @@
app:layout_row="5" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_question"
android:id="@+id/question"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
@ -275,7 +275,7 @@
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_historybrowser"
android:id="@+id/history_browser"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -290,7 +290,7 @@
app:layout_row="6" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_tddstats"
android:id="@+id/tdd_stats"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"

View file

@ -1,311 +0,0 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".plugins.general.actions.ActionsFragment">
<LinearLayout
android:id="@+id/action_buttons_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:text="@string/actions" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_profileswitch"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_profileswitch"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_profileswitch"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_temptarget"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_temptarget_high"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_temporarytarget"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="0" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_settempbasal"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_starttempbasal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/overview_tempbasal_button"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_canceltempbasal"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_cancelbasal"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/canceltemp"
android:textSize="11sp"
android:visibility="gone"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_extendedbolus"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_startextbolus"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/overview_extendedbolus_button"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_extendedbolus_cancel"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_actions_cancelextbolus"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/overview_extendedbolus_cancel_button"
android:textSize="11sp"
android:visibility="gone"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="1" />
</androidx.gridlayout.widget.GridLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:text="@string/careportal" />
<include
android:id="@+id/careportal_stats"
layout="@layout/careportal_stats_fragment_lowres"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_bgcheck"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_bgcheck"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_bgcheck"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="2" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_fill"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_cp_pump_canula"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/primefill"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="2" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_cgmsensorinsert"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_cgm_insert"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_cgmsensorinsert"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="3" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_pumpbatterychange"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_pump_battery"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_pumpbatterychange"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="3" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_note"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_note"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_note"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="4" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_exercise"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_exercise"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_exercise"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="4" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_announcement"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_announcement"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_announcement"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="5" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_question"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:drawableTop="@drawable/ic_cp_question"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/careportal_question"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="5" />
</androidx.gridlayout.widget.GridLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:text="@string/tools" />
<androidx.gridlayout.widget.GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
app:columnCount="2">
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_historybrowser"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_pump_history"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/nav_historybrowser"
android:textSize="11sp"
app:layout_column="0"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="6" />
<info.nightscout.androidaps.utils.ui.SingleClickButton
android:id="@+id/actions_tddstats"
style="?android:attr/buttonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_cp_stats"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/tdd"
android:textSize="11sp"
app:layout_column="1"
app:layout_columnWeight="1"
app:layout_gravity="fill"
app:layout_row="6" />
</androidx.gridlayout.widget.GridLayout>
</LinearLayout>
</ScrollView>

View file

@ -192,6 +192,7 @@
android:textSize="14sp" />
<TextView
android:id="@+id/cannula_placeholder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"