actions: do not show labels in low-res landscape mode
This commit is contained in:
parent
c86edb94fd
commit
6f22c5122f
|
@ -1,9 +1,7 @@
|
|||
package info.nightscout.plugins.general.actions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -59,7 +57,6 @@ class ActionsFragment : DaggerFragment() {
|
|||
@Inject lateinit var sp: SP
|
||||
@Inject lateinit var dateUtil: DateUtil
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
@Inject lateinit var ctx: Context
|
||||
@Inject lateinit var rh: ResourceHelper
|
||||
@Inject lateinit var statusLightHandler: StatusLightHandler
|
||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||
|
@ -78,31 +75,22 @@ class ActionsFragment : DaggerFragment() {
|
|||
|
||||
private val pumpCustomActions = HashMap<String, CustomAction>()
|
||||
private val pumpCustomButtons = ArrayList<SingleClickButton>()
|
||||
private lateinit var dm: DisplayMetrics
|
||||
|
||||
private var _binding: ActionsFragmentBinding? = null
|
||||
|
||||
// This property is only valid between onCreateView and onDestroyView.
|
||||
private val binding get() = _binding!!
|
||||
|
||||
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) {
|
||||
@Suppress("DEPRECATION")
|
||||
activity?.display?.getRealMetrics(dm)
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
activity?.windowManager?.defaultDisplay?.getMetrics(dm)
|
||||
}
|
||||
_binding = ActionsFragmentBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View =
|
||||
ActionsFragmentBinding.inflate(inflater, container, false).also { _binding = it }.root
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
skinProvider.activeSkin().preProcessLandscapeActionsLayout(dm, binding)
|
||||
val screenWidth = activity?.window?.decorView?.width ?: 0
|
||||
val screenHeight = activity?.window?.decorView?.height ?: 0
|
||||
val isLandscape = screenHeight < screenWidth
|
||||
skinProvider.activeSkin().preProcessLandscapeActionsLayout(isLandscape, binding)
|
||||
|
||||
binding.profileSwitch.setOnClickListener {
|
||||
activity?.let { activity ->
|
||||
|
@ -285,7 +273,7 @@ class ActionsFragment : DaggerFragment() {
|
|||
binding.tddStats.visibility = pump.pumpDescription.supportsTDDs.toVisibility()
|
||||
val isPatchPump = pump.pumpDescription.isPatchPump
|
||||
binding.status.apply {
|
||||
cannulaOrPatch.text = if (isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
|
||||
cannulaOrPatch.text = if (cannulaOrPatch.text.isEmpty()) "" else if (isPatchPump) rh.gs(R.string.patch_pump) else rh.gs(R.string.cannula)
|
||||
val imageResource = if (isPatchPump) info.nightscout.core.main.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()
|
||||
|
@ -293,7 +281,11 @@ class ActionsFragment : DaggerFragment() {
|
|||
cannulaUsage.visibility = isPatchPump.not().toVisibility()
|
||||
|
||||
if (!config.NSCLIENT) {
|
||||
statusLightHandler.updateStatusLights(cannulaAge, cannulaUsage, insulinAge, reservoirLevel, sensorAge, sensorLevel, pbAge, batteryLevel)
|
||||
statusLightHandler.updateStatusLights(
|
||||
cannulaAge, cannulaUsage, insulinAge,
|
||||
reservoirLevel, sensorAge, sensorLevel,
|
||||
pbAge, pbLevel
|
||||
)
|
||||
sensorLevelLabel.text = if (activeBgSource.sensorBatteryLevel == -1) "" else rh.gs(R.string.level_label)
|
||||
} else {
|
||||
statusLightHandler.updateStatusLights(cannulaAge, cannulaUsage, insulinAge, null, sensorAge, null, pbAge, null)
|
||||
|
|
|
@ -188,7 +188,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
|||
smallHeight = screenHeight <= Constants.SMALL_HEIGHT
|
||||
val landscape = screenHeight < screenWidth
|
||||
|
||||
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, binding, landscape, rh.gb(info.nightscout.shared.R.bool.isTablet), smallHeight)
|
||||
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(binding, landscape, rh.gb(info.nightscout.shared.R.bool.isTablet), smallHeight)
|
||||
binding.nsclientCard.visibility = config.NSCLIENT.toVisibility()
|
||||
|
||||
binding.notifications.setHasFixedSize(false)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.plugins.skins
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.databinding.OverviewFragmentBinding
|
||||
|
@ -14,8 +13,8 @@ class SkinClassic @Inject constructor(private val config: Config) : SkinInterfac
|
|||
override val mainGraphHeight: Int get() = 200
|
||||
override val secondaryGraphHeight: Int get() = 100
|
||||
|
||||
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
super.preProcessLandscapeOverviewLayout(dm, binding, isLandscape, isTablet, isSmallHeight)
|
||||
override fun preProcessLandscapeOverviewLayout(binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
super.preProcessLandscapeOverviewLayout(binding, isLandscape, isTablet, isSmallHeight)
|
||||
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(binding.root)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.plugins.skins
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.TypedValue.COMPLEX_UNIT_PX
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
|
@ -18,16 +17,11 @@ interface SkinInterface {
|
|||
val secondaryGraphHeight: Int // in dp
|
||||
|
||||
// no pre processing by default
|
||||
fun preProcessLandscapeActionsLayout(dm: DisplayMetrics, binding: ActionsFragmentBinding) {
|
||||
fun preProcessLandscapeActionsLayout(isLandscape: Boolean, binding: ActionsFragmentBinding) {
|
||||
}
|
||||
|
||||
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) {
|
||||
fun preProcessLandscapeOverviewLayout(binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
if (isLandscape) {
|
||||
val iobLayout = binding.infoLayout.iobLayout
|
||||
val iobLayoutParams = iobLayout.layoutParams as ConstraintLayout.LayoutParams
|
||||
val timeLayout = binding.infoLayout.timeLayout
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.plugins.skins
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import info.nightscout.interfaces.Config
|
||||
import info.nightscout.plugins.R
|
||||
import info.nightscout.plugins.databinding.OverviewFragmentBinding
|
||||
|
@ -14,8 +13,8 @@ class SkinLargeDisplay @Inject constructor(private val config: Config) : SkinInt
|
|||
override val mainGraphHeight: Int get() = 400
|
||||
override val secondaryGraphHeight: Int get() = 150
|
||||
|
||||
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
super.preProcessLandscapeOverviewLayout(dm, binding, isLandscape, isTablet, isSmallHeight)
|
||||
override fun preProcessLandscapeOverviewLayout(binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
super.preProcessLandscapeOverviewLayout(binding, isLandscape, isTablet, isSmallHeight)
|
||||
if (!config.NSCLIENT && (isSmallHeight || isLandscape)) moveButtonsLayout(binding.root)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.plugins.skins
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.View.GONE
|
||||
import android.view.ViewGroup
|
||||
import info.nightscout.interfaces.Config
|
||||
|
@ -17,27 +16,26 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface
|
|||
override val mainGraphHeight: Int get() = 200
|
||||
override val secondaryGraphHeight: Int get() = 100
|
||||
|
||||
override fun preProcessLandscapeActionsLayout(dm: DisplayMetrics, binding: ActionsFragmentBinding) {
|
||||
val screenWidth = dm.widthPixels
|
||||
val screenHeight = dm.heightPixels
|
||||
val isLandscape = screenHeight < screenWidth
|
||||
|
||||
override fun preProcessLandscapeActionsLayout(isLandscape: Boolean, binding: ActionsFragmentBinding) {
|
||||
if (!isLandscape) {
|
||||
binding.status.apply {
|
||||
sensorAgeLabel.visibility = GONE
|
||||
sensorLabel.text = ""
|
||||
sensorAgeLabel.visibility = GONE
|
||||
sensorLevelLabel.visibility = GONE
|
||||
insulinAgeLabel.visibility = GONE
|
||||
insulinLabel.text = ""
|
||||
insulinLevelLabel.visibility = GONE
|
||||
cannulaOrPatch.text = ""
|
||||
cannulaAgeLabel.visibility = GONE
|
||||
cannulaUsageLabel.visibility = GONE
|
||||
pbLabel.text = ""
|
||||
pbAgeLabel.visibility = GONE
|
||||
pbLevelLabel.visibility = GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
override fun preProcessLandscapeOverviewLayout(binding: OverviewFragmentBinding, isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean) {
|
||||
if (!config.NSCLIENT && isLandscape) moveButtonsLayout(binding.root)
|
||||
|
||||
binding.apply {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sensor_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:gravity="center_vertical"
|
||||
|
@ -84,6 +85,7 @@
|
|||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/insulin_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:gravity="center_vertical"
|
||||
|
@ -272,7 +274,7 @@
|
|||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/battery_level"
|
||||
android:id="@+id/pb_level"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
|
|
Loading…
Reference in a new issue