larger font in tabled landscape mode

This commit is contained in:
Milos Kozak 2020-11-23 13:24:38 +01:00
parent b4fb6ebff9
commit e1a1a4228d
4 changed files with 66 additions and 27 deletions

View file

@ -185,7 +185,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
// pre-process landscape mode // pre-process landscape mode
skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, overview_iob_llayout, overview_time_llayout) skinProvider.activeSkin().preProcessLandscapeOverviewLayout(dm, view, resourceHelper.gb(R.bool.isTablet))
overview_pumpstatus?.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder)) overview_pumpstatus?.setBackgroundColor(resourceHelper.gc(R.color.colorInitializingBorder))
@ -684,7 +684,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
// Basal, TBR // Basal, TBR
val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis()) val activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis())
overview_basebasal?.text = activeTemp?.let { if (resourceHelper.shortTextMode()) "T:" + activeTemp.toStringVeryShort() else activeTemp.toStringFull() } overview_basebasal?.text = activeTemp?.let { "T:" + activeTemp.toStringVeryShort() }
?: resourceHelper.gs(R.string.pump_basebasalrate, profile.basal) ?: resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)
overview_basal_llayout?.setOnClickListener { overview_basal_llayout?.setOnClickListener {
var fullText = "${resourceHelper.gs(R.string.basebasalrate_label)}: ${resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)}" var fullText = "${resourceHelper.gs(R.string.basebasalrate_label)}: ${resourceHelper.gs(R.string.pump_basebasalrate, profile.basal)}"
@ -705,10 +705,10 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
// Extended bolus // Extended bolus
val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis()) val extendedBolus = treatmentsPlugin.getExtendedBolusFromHistory(System.currentTimeMillis())
overview_extendedbolus?.text = if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses) { overview_extendedbolus?.text =
if (resourceHelper.shortTextMode()) resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate()) if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses)
else extendedBolus.toStringMedium() resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.absoluteRate())
} else "" else ""
overview_extendedbolus?.setOnClickListener { overview_extendedbolus?.setOnClickListener {
if (extendedBolus != null) activity?.let { if (extendedBolus != null) activity?.let {
OKDialog.show(it, resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString()) OKDialog.show(it, resourceHelper.gs(R.string.extended_bolus), extendedBolus.toString())
@ -733,15 +733,8 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
treatmentsPlugin.updateTotalIOBTempBasals() treatmentsPlugin.updateTotalIOBTempBasals()
val bolusIob = treatmentsPlugin.lastCalculationTreatments.round() val bolusIob = treatmentsPlugin.lastCalculationTreatments.round()
val basalIob = treatmentsPlugin.lastCalculationTempBasals.round() val basalIob = treatmentsPlugin.lastCalculationTempBasals.round()
overview_iob?.text = when { overview_iob?.text = resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
resourceHelper.shortTextMode() ->
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob)
else ->
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob + basalIob.basaliob) + " (" +
resourceHelper.gs(R.string.formatinsulinunits, bolusIob.iob) + "/" +
resourceHelper.gs(R.string.formatinsulinunits, basalIob.basaliob) + ")"
}
overview_iob_llayout?.setOnClickListener { overview_iob_llayout?.setOnClickListener {
activity?.let { activity?.let {
OKDialog.show(it, resourceHelper.gs(R.string.iob), OKDialog.show(it, resourceHelper.gs(R.string.iob),

View file

@ -1,35 +1,73 @@
package info.nightscout.androidaps.skins package info.nightscout.androidaps.skins
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.util.TypedValue.COMPLEX_UNIT_PX
import android.view.View
import android.widget.LinearLayout import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.LayoutRes import androidx.annotation.LayoutRes
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.constraintlayout.widget.ConstraintLayout import androidx.constraintlayout.widget.ConstraintLayout
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import kotlinx.android.synthetic.main.overview_fragment_nsclient.view.*
import kotlinx.android.synthetic.main.overview_info_layout.view.*
import kotlinx.android.synthetic.main.overview_statuslights_layout.view.*
interface SkinInterface { interface SkinInterface {
@get:StringRes val description : Int
val mainGraphHeight : Int // in dp @get:StringRes val description: Int
val secondaryGraphHeight : Int // in dp
@LayoutRes fun overviewLayout(isLandscape : Boolean, isTablet : Boolean, isSmallHeight : Boolean): Int
@LayoutRes fun actionsLayout(isLandscape : Boolean, isSmallWidth : Boolean): Int = R.layout.actions_fragment
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, iobLayout: LinearLayout, timeLayout: LinearLayout) { val mainGraphHeight: Int // in dp
val secondaryGraphHeight: Int // in dp
@LayoutRes
fun overviewLayout(isLandscape: Boolean, isTablet: Boolean, isSmallHeight: Boolean): Int
@LayoutRes
fun actionsLayout(isLandscape: Boolean, isSmallWidth: Boolean): Int = R.layout.actions_fragment
fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isTablet: Boolean) {
// pre-process landscape mode // pre-process landscape mode
val screenWidth = dm.widthPixels val screenWidth = dm.widthPixels
val screenHeight = dm.heightPixels val screenHeight = dm.heightPixels
val landscape = screenHeight < screenWidth val landscape = screenHeight < screenWidth
if (landscape) { if (landscape) {
val iobLayoutParams = iobLayout.layoutParams as ConstraintLayout.LayoutParams val iobLayoutParams = view.overview_iob_llayout.layoutParams as ConstraintLayout.LayoutParams
iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET iobLayoutParams.startToStart = ConstraintLayout.LayoutParams.UNSET
iobLayoutParams.startToEnd = timeLayout.id iobLayoutParams.startToEnd = view.overview_time_llayout.id
iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET iobLayoutParams.topToBottom = ConstraintLayout.LayoutParams.UNSET
iobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID iobLayoutParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID
val timeLayoutParams = timeLayout.layoutParams as ConstraintLayout.LayoutParams val timeLayoutParams = view.overview_time_llayout.layoutParams as ConstraintLayout.LayoutParams
timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET timeLayoutParams.endToEnd = ConstraintLayout.LayoutParams.UNSET
timeLayoutParams.endToStart = iobLayout.id timeLayoutParams.endToStart = view.overview_iob_llayout.id
if (isTablet) {
for (v in listOf<TextView>(
view.overview_bg,
view.overview_time,
view.overview_timeagoshort,
view.overview_iob,
view.overview_cob,
view.overview_basebasal,
view.overview_extendedbolus,
view.overview_sensitivity
)) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.5f)
for (v in listOf<TextView>(
view.overview_pump,
view.overview_openaps,
view.overview_uploader,
view.careportal_canulaage,
view.careportal_insulinage,
view.careportal_reservoirlevel,
view.careportal_reservoirlevel,
view.careportal_sensorage,
view.careportal_pbage,
view.careportal_batterylevel
)) v.setTextSize(COMPLEX_UNIT_PX, v.textSize * 1.3f)
view.overview_time_llayout.orientation = LinearLayout.HORIZONTAL
view.overview_timeagoshort.setTextSize(COMPLEX_UNIT_PX, view.overview_time.textSize)
}
} }
} }
} }

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.skins package info.nightscout.androidaps.skins
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.widget.LinearLayout import android.view.View
import info.nightscout.androidaps.Config import info.nightscout.androidaps.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import javax.inject.Inject import javax.inject.Inject
@ -27,5 +27,5 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface
else -> R.layout.actions_fragment_lowres else -> R.layout.actions_fragment_lowres
} }
override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, iobLayout: LinearLayout, timeLayout: LinearLayout) {} override fun preProcessLandscapeOverviewLayout(dm: DisplayMetrics, view: View, isTablet: Boolean) {}
} }

View file

@ -35,6 +35,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/overview_bg"
app:layout_constraintEnd_toStartOf="@+id/overview_apsmode_llayout" app:layout_constraintEnd_toStartOf="@+id/overview_apsmode_llayout"
app:layout_constraintStart_toEndOf="@+id/overview_arrow" app:layout_constraintStart_toEndOf="@+id/overview_arrow"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -111,6 +112,7 @@
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/overview_bg"
app:layout_constraintEnd_toStartOf="@id/overview_time_llayout" app:layout_constraintEnd_toStartOf="@id/overview_time_llayout"
app:layout_constraintStart_toEndOf="@id/overview_deltas_llayout" app:layout_constraintStart_toEndOf="@id/overview_deltas_llayout"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -142,6 +144,7 @@
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="@+id/overview_bg"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/overview_apsmode_llayout" app:layout_constraintStart_toEndOf="@id/overview_apsmode_llayout"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
@ -178,6 +181,7 @@
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/overview_cob_llayout" app:layout_constraintEnd_toStartOf="@+id/overview_cob_llayout"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/overview_bg"> app:layout_constraintTop_toBottomOf="@+id/overview_bg">
@ -206,15 +210,16 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/overview_basal_llayout" app:layout_constraintEnd_toStartOf="@+id/overview_basal_llayout"
app:layout_constraintStart_toEndOf="@+id/overview_iob_llayout" app:layout_constraintStart_toEndOf="@+id/overview_iob_llayout"
app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout"> app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout">
<ImageView <ImageView
android:id="@+id/overview_carbs_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:id="@+id/overview_carbs_icon"
android:background="@drawable/anim_carbs" /> android:background="@drawable/anim_carbs" />
<TextView <TextView
@ -235,6 +240,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/overview_extended_llayout" app:layout_constraintEnd_toStartOf="@+id/overview_extended_llayout"
app:layout_constraintStart_toEndOf="@+id/overview_cob_llayout" app:layout_constraintStart_toEndOf="@+id/overview_cob_llayout"
app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout"> app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout">
@ -264,6 +270,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/overview_as_llayout" app:layout_constraintEnd_toStartOf="@+id/overview_as_llayout"
app:layout_constraintStart_toEndOf="@+id/overview_basal_llayout" app:layout_constraintStart_toEndOf="@+id/overview_basal_llayout"
app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout"> app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout">
@ -292,6 +299,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/overview_extended_llayout" app:layout_constraintStart_toEndOf="@+id/overview_extended_llayout"
app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout"> app:layout_constraintTop_toTopOf="@+id/overview_iob_llayout">