adjust ribbon style

This commit is contained in:
osodebailar 2022-04-22 19:24:28 +02:00
parent 4e0d9e25b7
commit 0d4e2c2e55
9 changed files with 82 additions and 30 deletions

View file

@ -807,31 +807,28 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
profileFunction.getProfile()?.let {
if (it is ProfileSealed.EPS) {
if (it.value.originalPercentage != 100 || it.value.originalTimeshift != 0L || it.value.originalDuration != 0L)
rh.gac(context, R.attr.ribbonWarningColor)
else rh.gac(context, R.attr.ribbonDefaultColor)
R.attr.ribbonWarningColor
else R.attr.ribbonDefaultColor
} else if (it is ProfileSealed.PS) {
rh.gac(context, R.attr.ribbonDefaultColor)
R.attr.ribbonDefaultColor
} else {
rh.gac(context, R.attr.ribbonDefaultColor)
R.attr.ribbonDefaultColor
}
} ?: rh.gac(context, R.attr.ribbonCriticalColor)
} ?: R.attr.ribbonCriticalColor
val profileTextColor =
profileFunction.getProfile()?.let {
if (it is ProfileSealed.EPS) {
if (it.value.originalPercentage != 100 || it.value.originalTimeshift != 0L || it.value.originalDuration != 0L)
rh.gac(context, R.attr.ribbonTextWarningColor)
else rh.gac(context, R.attr.ribbonTextDefaultColor)
R.attr.ribbonTextWarningColor
else R.attr.ribbonTextDefaultColor
} else if (it is ProfileSealed.PS) {
rh.gac(context, R.attr.ribbonTextDefaultColor)
R.attr.ribbonTextDefaultColor
} else {
rh.gac(context, R.attr.ribbonTextDefaultColor)
R.attr.ribbonTextDefaultColor
}
} ?: rh.gac(context, R.attr.ribbonTextDefaultColor)
binding.activeProfile.text = profileFunction.getProfileNameWithRemainingTime()
binding.activeProfile.setBackgroundColor(profileBackgroundColor)
binding.activeProfile.setTextColor(profileTextColor)
} ?: R.attr.ribbonTextDefaultColor
setRibbon(binding.activeProfile, profileTextColor, profileBackgroundColor, profileFunction.getProfileNameWithRemainingTime())
}
private fun updateTemporaryBasal() {
@ -919,9 +916,12 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
val units = profileFunction.getUnits()
val tempTarget = overviewData.temporaryTarget
if (tempTarget != null) {
binding.tempTarget.setTextColor(rh.gac(context, R.attr.ribbonTextWarningColor))
binding.tempTarget.setBackgroundColor(rh.gac(context, R.attr.ribbonWarningColor))
binding.tempTarget.text = Profile.toTargetRangeString(tempTarget.lowTarget, tempTarget.highTarget, GlucoseUnit.MGDL, units) + " " + dateUtil.untilString(tempTarget.end, rh)
setRibbon(
binding.tempTarget,
R.attr.ribbonTextWarningColor,
R.attr.ribbonWarningColor,
Profile.toTargetRangeString(tempTarget.lowTarget, tempTarget.highTarget, GlucoseUnit.MGDL, units) + " " + dateUtil.untilString(tempTarget.end, rh)
)
} else {
// If the target is not the same as set in the profile then oref has overridden it
profileFunction.getProfile()?.let { profile ->
@ -929,18 +929,33 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (targetUsed != 0.0 && abs(profile.getTargetMgdl() - targetUsed) > 0.01) {
aapsLogger.debug("Adjusted target. Profile: ${profile.getTargetMgdl()} APS: $targetUsed")
binding.tempTarget.text = Profile.toTargetRangeString(targetUsed, targetUsed, GlucoseUnit.MGDL, units)
binding.tempTarget.setTextColor(rh.gac(context, R.attr.ribbonTextWarningColor))
binding.tempTarget.setBackgroundColor(rh.gac(context, R.attr.tempTargetBackgroundColor))
setRibbon(
binding.tempTarget,
R.attr.ribbonTextWarningColor,
R.attr.tempTargetBackgroundColor,
Profile.toTargetRangeString(targetUsed, targetUsed, GlucoseUnit.MGDL, units)
)
} else {
binding.tempTarget.setTextColor(rh.gac(context, R.attr.ribbonTextDefaultColor))
binding.tempTarget.setBackgroundColor(rh.gac(context, R.attr.ribbonDefaultColor))
binding.tempTarget.text = Profile.toTargetRangeString(profile.getTargetLowMgdl(), profile.getTargetHighMgdl(), GlucoseUnit.MGDL, units)
setRibbon(
binding.tempTarget,
R.attr.ribbonTextDefaultColor,
R.attr.ribbonDefaultColor,
Profile.toTargetRangeString(profile.getTargetLowMgdl(), profile.getTargetHighMgdl(), GlucoseUnit.MGDL, units)
)
}
}
}
}
private fun setRibbon(view: TextView, attrResText: Int, attrResBack: Int, text: String) {
with(view) {
setText(text)
setBackgroundColor(rh.gac(context, attrResBack))
setTextColor(rh.gac(context, attrResText))
compoundDrawables[0]?.setTint(rh.gac(context, attrResText))
}
}
private fun updateGraph() {
_binding ?: return
val pump = activePlugin.activePump

View file

@ -70,6 +70,9 @@ class SkinLowRes @Inject constructor(private val config: Config) : SkinInterface
setMargins(0,0,0,0)
}
graphCard.layoutParams = paramGraph
activeProfile.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
tempTarget.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
}
}

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M7.225,17.939c-0.831,-0.015 -1.521,-0.876 -1.95,-2.424c-0.286,-1.031 -0.544,-2.106 -0.794,-3.147c-0.16,-0.667 -0.314,-1.309 -0.476,-1.944L3.897,9.99c-0.35,-1.411 -0.712,-2.866 -1.546,-3.011C2.229,6.958 2.123,6.89 2.052,6.789S1.954,6.565 1.975,6.444c0.039,-0.222 0.232,-0.383 0.46,-0.383c1.503,0.255 1.938,2.009 2.36,3.705l0.108,0.432c0.162,0.637 0.317,1.283 0.472,1.928c0.253,1.057 0.51,2.125 0.792,3.144c0.315,1.139 0.777,1.739 1.071,1.745c0.259,0 0.677,-0.504 1.034,-1.629c0.186,-0.588 0.346,-1.221 0.5,-1.833l0.124,-0.487c0.129,-0.504 0.251,-1.014 0.374,-1.524c0.29,-1.212 0.566,-2.366 0.906,-3.445c0.408,-1.294 1.047,-2.01 1.801,-2.017c0.765,0 1.418,0.711 1.85,2.002c0.286,0.857 0.53,1.791 0.745,2.614l0.177,0.671c0.132,0.497 0.26,1 0.387,1.503l0.043,0.171c0.239,0.953 0.487,1.938 0.766,2.869c0.221,0.74 0.564,1.09 0.79,1.102c0.001,0 0.002,0 0.004,0c0.217,0 0.509,-0.275 0.764,-0.887c0.267,-0.642 0.513,-1.39 0.75,-2.286c0.332,-1.264 0.647,-2.544 0.962,-3.825l0.439,-1.774c0.305,-1.222 0.894,-1.93 1.8,-2.165l0.03,-0.008l0.083,-0.006c0.211,0 0.396,0.142 0.449,0.345c0.064,0.249 -0.085,0.501 -0.331,0.565c-0.563,0.146 -0.912,0.605 -1.135,1.493l-0.437,1.771c-0.317,1.286 -0.634,2.571 -0.967,3.84c-0.248,0.938 -0.507,1.726 -0.791,2.407c-0.527,1.268 -1.232,1.456 -1.606,1.456c-0.763,-0.037 -1.372,-0.696 -1.691,-1.764c-0.279,-0.933 -0.527,-1.918 -0.768,-2.871c-0.148,-0.593 -0.289,-1.148 -0.435,-1.699l-0.179,-0.673c-0.211,-0.812 -0.451,-1.73 -0.727,-2.555c-0.316,-0.946 -0.712,-1.37 -0.963,-1.37c-0.249,0.002 -0.632,0.426 -0.929,1.37c-0.332,1.054 -0.603,2.188 -0.865,3.286c-0.131,0.547 -0.262,1.094 -0.4,1.633L9.669,13.78c-0.163,0.646 -0.325,1.285 -0.516,1.885c-0.479,1.51 -1.122,2.274 -1.912,2.274H7.225z"
android:fillColor="?attr/crossTargetColor"/>
<path
android:pathData="M21.569,12.709h-4.772c-0.392,0 -0.709,-0.317 -0.709,-0.709V9.177H7.927l0,2.823c0,0.392 -0.317,0.709 -0.708,0.709H2.431c-0.392,0 -0.708,-0.317 -0.708,-0.709s0.317,-0.708 0.708,-0.708H6.51l0,-2.823c0,-0.392 0.317,-0.708 0.708,-0.708h9.578c0.392,0 0.709,0.317 0.709,0.708v2.823h4.063c0.392,0 0.709,0.317 0.709,0.708S21.961,12.709 21.569,12.709z"
android:fillColor="?attr/crossTargetColor"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="22dp"
android:height="22dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M20.132,10.032c-0.141,-0.437 -0.519,-0.756 -0.975,-0.822L14.96,8.6l-1.878,-3.803c-0.406,-0.825 -1.758,-0.825 -2.164,0L9.04,8.6L4.842,9.21C4.388,9.276 4.01,9.594 3.868,10.032c-0.142,0.437 -0.024,0.917 0.305,1.237l3.038,2.96L6.495,18.41c-0.078,0.454 0.108,0.912 0.48,1.181c0.21,0.153 0.459,0.231 0.709,0.231c0.192,0 0.385,-0.047 0.561,-0.14L12,17.71l3.755,1.973c0.409,0.213 0.898,0.181 1.273,-0.091c0.371,-0.269 0.557,-0.729 0.479,-1.181l-0.717,-4.182l3.037,-2.96C20.155,10.948 20.275,10.468 20.132,10.032zM18.689,10.686l-3.16,3.081l0.746,4.35c0.014,0.087 -0.021,0.174 -0.092,0.225c-0.04,0.03 -0.087,0.044 -0.135,0.044c-0.036,0 -0.073,-0.008 -0.108,-0.027l-3.907,-2.053L8.126,18.36c-0.075,0.044 -0.17,0.036 -0.242,-0.017c-0.07,-0.051 -0.106,-0.138 -0.091,-0.225l0.746,-4.35l-3.162,-3.081c-0.063,-0.061 -0.085,-0.153 -0.058,-0.236c0.027,-0.083 0.099,-0.143 0.185,-0.156L9.874,9.66l1.954,-3.959c0.078,-0.158 0.334,-0.158 0.412,0l1.953,3.959l4.369,0.634c0.087,0.013 0.158,0.073 0.185,0.156S18.753,10.625 18.689,10.686z"
android:fillColor="?attr/profileColor"/>
</vector>

View file

@ -38,11 +38,13 @@
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:hint="active profile"
android:text="Profile"
android:textAppearance="?android:attr/textAppearanceSmall"
android:foreground="?attr/selectableItemBackgroundBorderless"
app:drawableStartCompat="@drawable/ic_ribbon_profile"
tools:ignore="HardcodedText" />
<TextView
@ -52,11 +54,13 @@
android:layout_gravity="end"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:hint="temp target"
android:text="@string/notavailable"
android:textAppearance="?android:attr/textAppearanceSmall"
android:foreground="?attr/selectableItemBackgroundBorderless"
app:drawableStartCompat="@drawable/ic_crosstarget"
tools:ignore="HardcodedText" />
</LinearLayout>

View file

@ -5,5 +5,5 @@
android:viewportHeight="24">
<path
android:pathData="M19.744,9.7c-0.135,-0.417 -0.494,-0.72 -0.928,-0.783l-3.997,-0.581L13.03,4.714c-0.387,-0.786 -1.675,-0.786 -2.061,0L9.181,8.336L5.183,8.918C4.751,8.98 4.39,9.284 4.255,9.7c-0.135,0.416 -0.023,0.873 0.291,1.178l2.894,2.819L6.757,17.68c-0.074,0.432 0.103,0.868 0.457,1.125c0.2,0.146 0.437,0.22 0.676,0.22c0.183,0 0.367,-0.044 0.535,-0.133L12,17.013l3.576,1.879c0.39,0.203 0.855,0.173 1.212,-0.087c0.353,-0.257 0.531,-0.694 0.456,-1.125l-0.683,-3.983l2.893,-2.819C19.766,10.573 19.881,10.116 19.744,9.7zM18.689,10.261l-3.16,3.081l0.746,4.35c0.014,0.087 -0.021,0.174 -0.092,0.225c-0.04,0.03 -0.087,0.044 -0.135,0.044c-0.036,0 -0.073,-0.008 -0.108,-0.027l-3.907,-2.053l-3.907,2.053c-0.075,0.044 -0.17,0.036 -0.242,-0.017c-0.07,-0.051 -0.106,-0.138 -0.091,-0.225l0.746,-4.35l-3.162,-3.081c-0.063,-0.061 -0.085,-0.153 -0.058,-0.236c0.027,-0.083 0.099,-0.143 0.185,-0.156l4.369,-0.634l1.954,-3.959c0.078,-0.158 0.334,-0.158 0.412,0l1.953,3.959l4.369,0.634c0.087,0.013 0.158,0.073 0.185,0.156S18.753,10.2 18.689,10.261z"
android:fillColor="#FFFFFF"/>
android:fillColor="?attr/profileColor"/>
</vector>

View file

@ -86,7 +86,7 @@
<!---Dialog -->
<item name="activity_title_backgroundColor">@color/activity_title_background</item>
<!---Automation -->
<item name="ribbonDefaultColor">@color/ribbonDefault</item>
<item name="ribbonDefaultColor">@color/buttonBackground</item>
<item name="ribbonWarningColor">@color/ribbonWarning</item>
<item name="ribbonCriticalColor">@color/ribbonCritical</item>
<item name="ribbonTextDefaultColor">@color/ribbonTextDefault</item>
@ -243,6 +243,9 @@
<item name="materialTimePickerStyle">@style/DatePicker</item>
<!---Nightscout client TitelColor -->
<item name="nsTitleColor">@color/defaultText</item>
<!---Icons in Loop area -->
<item name="profileColor">@color/white</item>
<item name="crossTargetColor">@color/white</item>
</style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">

View file

@ -215,4 +215,7 @@
<attr name="isNotCompletedColor" format="reference|color" />
<!---Nightscout client TitelColor -->
<attr name="nsTitleColor" format="reference|color" />
<!---Icons in Loop area -->
<attr name="profileColor" format="reference|color" />
<attr name="crossTargetColor" format="reference|color" />
</resources>

View file

@ -91,7 +91,7 @@
<!---Dialog -->
<item name="activity_title_backgroundColor">@color/dialog_title_background</item>
<!---Automation -->
<item name="ribbonDefaultColor">@color/ribbonDefault</item>
<item name="ribbonDefaultColor">@color/buttonBackground</item>
<item name="ribbonWarningColor">@color/ribbonWarning</item>
<item name="ribbonCriticalColor">@color/ribbonCritical</item>
<item name="ribbonTextDefaultColor">@color/ribbonTextDefault</item>
@ -244,6 +244,9 @@
<item name="isNotCompletedColor">@color/isNotCompleted</item>
<!---Nightscout client TitelColor -->
<item name="nsTitleColor">@color/defaultText</item>
<!---Icons in Loop area -->
<item name="profileColor">@color/white</item>
<item name="crossTargetColor">@color/white</item>
</style>
<style name="Aaps_ActionBarStyle" parent="@style/Widget.AppCompat.ActionBar">