diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 03c1a4dff8..a9c3d0e4d9 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -9,11 +9,15 @@
+
+
+
+
diff --git a/shared/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt b/shared/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt
index 5578a94a92..98555b846a 100644
--- a/shared/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt
+++ b/shared/src/main/java/info/nightscout/androidaps/utils/DateUtil.kt
@@ -158,11 +158,15 @@ class DateUtil @Inject constructor(private val context: Context) {
return DateTime(mills).toString(DateTimeFormat.forPattern(format))
}
- fun dayNameString(): String = minuteString(now())
+ fun amPm(): String = amPm(now())
+ fun amPm(mills: Long): String =
+ DateTime(mills).toString(DateTimeFormat.forPattern("a"))
+
+ fun dayNameString(): String = dayNameString(now())
fun dayNameString(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("E"))
- fun dayString(): String = minuteString(now())
+ fun dayString(): String = dayString(now())
fun dayString(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("dd"))
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt
index 12ea214fac..899741a872 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt
@@ -43,8 +43,6 @@ import info.nightscout.shared.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.weardata.EventData
import info.nightscout.shared.weardata.EventData.ActionResendData
-import info.nightscout.shared.weardata.EventData.SingleBg
-import info.nightscout.shared.weardata.EventData.TreatmentData
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.kotlin.plusAssign
import lecho.lib.hellocharts.view.LineChartView
@@ -73,8 +71,8 @@ abstract class BaseWatchFace : WatchFace() {
protected val singleBg get() = rawData.singleBg
protected val status get() = rawData.status
- protected val treatmentData get() = rawData.treatmentData
- protected val graphData get() = rawData.graphData
+ private val treatmentData get() = rawData.treatmentData
+ private val graphData get() = rawData.graphData
// Layout
@LayoutRes abstract fun layoutResource(): Int
@@ -98,6 +96,7 @@ abstract class BaseWatchFace : WatchFace() {
var mCOB2: TextView? = null
var mBgi: TextView? = null
var mLoop: TextView? = null
+ var mTimePeriod: TextView? = null
var mDay: TextView? = null
var mDayName: TextView? = null
var mMonth: TextView? = null
@@ -245,7 +244,7 @@ abstract class BaseWatchFace : WatchFace() {
}
private fun setupBatteryReceiver() {
- val setting = sp.getString("simplify_ui", "off")
+ val setting = sp.getString(R.string.key_simplify_ui, "off")
if ((setting == "charging" || setting == "ambient_charging") && batteryReceiver == null) {
val intentBatteryFilter = IntentFilter()
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING)
@@ -296,6 +295,7 @@ abstract class BaseWatchFace : WatchFace() {
mDay = layoutView?.findViewById(R.id.day)
mDayName = layoutView?.findViewById(R.id.dayname)
mMonth = layoutView?.findViewById(R.id.month)
+ mTimePeriod = layoutView?.findViewById(R.id.timePeriod)
mDate = layoutView?.findViewById(R.id.date_time)
mLoop = layoutView?.findViewById(R.id.loop)
mSgv = layoutView?.findViewById(R.id.sgv)
@@ -383,7 +383,7 @@ abstract class BaseWatchFace : WatchFace() {
mDirectionPaint.color = getBgColour(singleBg.sgvLevel)
val sSvg = singleBg.sgvString
val svgWidth = mSvgPaint.measureText(sSvg)
- val sDirection = " " + singleBg.sgvString + "\uFE0E"
+ val sDirection = " " + singleBg.slopeArrow + "\uFE0E"
val directionWidth = mDirectionPaint.measureText(sDirection)
val xSvg = xHalf - (svgWidth + directionWidth) / 2
canvas.drawText(sSvg, xSvg, yThird + mYOffset, mSvgPaint)
@@ -420,7 +420,7 @@ abstract class BaseWatchFace : WatchFace() {
@Suppress("DEPRECATION")
private fun checkVibrateHourly(oldTime: WatchFaceTime, newTime: WatchFaceTime) {
- val hourlyVibratePref = sp.getBoolean("vibrate_Hourly", false)
+ val hourlyVibratePref = sp.getBoolean(R.string.key_vibrate_hourly, false)
if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) {
aapsLogger.info(LTag.WEAR, "hourlyVibratePref", "true --> $newTime")
val vibrator = getSystemService(VIBRATOR_SERVICE) as Vibrator
@@ -435,8 +435,8 @@ abstract class BaseWatchFace : WatchFace() {
mSgv?.text = singleBg.sgvString
mSgv?.visibility = sp.getBoolean(R.string.key_show_bg, true).toVisibilityKeepSpace()
strikeThroughSgvIfNeeded()
- mDirection?.text = "${singleBg.sgvString}\uFE0E"
- mDirection?.visibility = sp.getBoolean("show_direction", true).toVisibility()
+ mDirection?.text = "${singleBg.slopeArrow}\uFE0E"
+ mDirection?.visibility = sp.getBoolean(R.string.key_show_direction, true).toVisibility()
mDelta?.text = singleBg.delta
mDelta?.visibility = sp.getBoolean(R.string.key_show_delta, true).toVisibility()
mAvgDelta?.text = singleBg.avgDelta
@@ -444,23 +444,23 @@ abstract class BaseWatchFace : WatchFace() {
mCOB1?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility()
mCOB2?.text = status.cob
mCOB2?.visibility = sp.getBoolean(R.string.key_show_cob, true).toVisibility()
- mIOB1?.visibility = sp.getBoolean("show_iob", true).toVisibility()
- mIOB2?.visibility = sp.getBoolean("show_iob", true).toVisibility()
- mIOB1?.text = if (sp.getBoolean("show_iob", true)) status.iobSum else getString(R.string.activity_IOB)
- mIOB2?.text = if (sp.getBoolean("show_iob", true)) status.iobDetail else status.iobSum
+ mIOB1?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility()
+ mIOB2?.visibility = sp.getBoolean(R.string.key_show_iob, true).toVisibility()
+ mIOB1?.text = if (sp.getBoolean(R.string.key_show_iob, true)) status.iobSum else getString(R.string.activity_IOB)
+ mIOB2?.text = if (sp.getBoolean(R.string.key_show_iob, true)) status.iobDetail else status.iobSum
mTimestamp?.visibility = sp.getBoolean(R.string.key_show_ago, true).toVisibility()
mTimestamp?.text = readingAge(if (isAAPSv2 != null) true else sp.getBoolean(R.string.key_show_external_status, true))
- mUploaderBattery?.visibility = sp.getBoolean("show_uploader_battery", true).toVisibility()
+ mUploaderBattery?.visibility = sp.getBoolean(R.string.key_show_uploader_battery, true).toVisibility()
mUploaderBattery?.text =
when {
isAAPSv2 != null -> status.battery + "%"
sp.getBoolean(R.string.key_show_external_status, true) -> "U: ${status.battery}%"
else -> "Uploader: ${status.battery}%"
}
- mRigBattery?.visibility = sp.getBoolean("show_rig_battery", false).toVisibility()
+ mRigBattery?.visibility = sp.getBoolean(R.string.key_show_rig_battery, false).toVisibility()
mRigBattery?.text = status.rigBattery
mBasalRate?.text = status.currentBasal
- mBasalRate?.visibility = sp.getBoolean("show_temp_basal", true).toVisibility()
+ mBasalRate?.visibility = sp.getBoolean(R.string.key_show_temp_basal, true).toVisibility()
mBgi?.text = status.bgi
mBgi?.visibility = status.showBgi.toVisibility()
mStatus?.text = status.externalStatus
@@ -499,14 +499,16 @@ abstract class BaseWatchFace : WatchFace() {
mDayName?.text = dateUtil.dayNameString()
mDay?.text = dateUtil.dayString()
mMonth?.text = dateUtil.monthString()
+ mTimePeriod?.visibility = android.text.format.DateFormat.is24HourFormat(this).not().toVisibility()
+ mTimePeriod?.text = dateUtil.amPm()
}
private fun setColor() {
- dividerMatchesBg = sp.getBoolean("match_divider", false)
+ dividerMatchesBg = sp.getBoolean(R.string.key_match_divider, false)
when {
- lowResMode -> setColorLowRes()
- sp.getBoolean("dark", true) -> setColorDark()
- else -> setColorBright()
+ lowResMode -> setColorLowRes()
+ sp.getBoolean(R.string.key_dark, true) -> setColorDark()
+ else -> setColorBright()
}
}
@@ -537,7 +539,7 @@ abstract class BaseWatchFace : WatchFace() {
private val isSimpleUi: Boolean
get() {
- val simplify = sp.getString("simplify_ui", "off")
+ val simplify = sp.getString(R.string.key_simplify_ui, "off")
return if (simplify == "off") false
else if ((simplify == "ambient" || simplify == "ambient_charging") && currentWatchMode == WatchMode.AMBIENT) true
else (simplify == "charging" || simplify == "ambient_charging") && isCharging
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.kt
index 20e9f511ce..0809275b7e 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.kt
@@ -276,35 +276,15 @@ class CircleWatchface : WatchFace() {
// defining color for dark and bright
private val lowColor: Int
- get() = if (sp.getBoolean("dark", true)) {
- Color.argb(255, 255, 120, 120)
- } else {
- Color.argb(255, 255, 80, 80)
- }
+ get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 120, 120) else Color.argb(255, 255, 80, 80)
private val inRangeColor: Int
- get() = if (sp.getBoolean("dark", true)) {
- Color.argb(255, 120, 255, 120)
- } else {
- Color.argb(255, 0, 240, 0)
- }
+ get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 120, 255, 120) else Color.argb(255, 0, 240, 0)
private val highColor: Int
- get() = if (sp.getBoolean("dark", true)) {
- Color.argb(255, 255, 255, 120)
- } else {
- Color.argb(255, 255, 200, 0)
- }
+ get() = if (sp.getBoolean(R.string.key_dark, true)) Color.argb(255, 255, 255, 120) else Color.argb(255, 255, 200, 0)
private val backgroundColor: Int
- get() = if (sp.getBoolean("dark", true)) {
- Color.BLACK
- } else {
- Color.WHITE
- }
+ get() = if (sp.getBoolean(R.string.key_dark, true)) Color.BLACK else Color.WHITE
val textColor: Int
- get() = if (sp.getBoolean("dark", true)) {
- Color.WHITE
- } else {
- Color.BLACK
- }
+ get() = if (sp.getBoolean(R.string.key_dark, true)) Color.WHITE else Color.BLACK
private fun drawOtherStuff(canvas: Canvas) {
aapsLogger.debug(LTag.WEAR, "start onDrawOtherStuff. bgDataList.size(): " + bgDataList.size)
@@ -388,7 +368,7 @@ class CircleWatchface : WatchFace() {
private fun addReadingSoft(canvas: Canvas, entry: SingleBg) {
aapsLogger.debug(LTag.WEAR, "addReadingSoft")
var color = Color.LTGRAY
- if (sp.getBoolean("dark", true)) {
+ if (sp.getBoolean(R.string.key_dark, true)) {
color = Color.DKGRAY
}
val offsetMultiplier = (displaySize.x / 2f - PADDING) / 12f
@@ -403,7 +383,7 @@ class CircleWatchface : WatchFace() {
aapsLogger.debug(LTag.WEAR, "addReading")
var color = Color.LTGRAY
var indicatorColor = Color.DKGRAY
- if (sp.getBoolean("dark", true)) {
+ if (sp.getBoolean(R.string.key_dark, true)) {
color = Color.DKGRAY
indicatorColor = Color.LTGRAY
}
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt
index e8d7ba0cf8..de808a21be 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt
@@ -67,13 +67,10 @@ class DigitalStyleWatchface : BaseWatchFace() {
val mShapesElements = layoutView?.findViewById(R.id.shapes_elements)
if (mShapesElements != null) {
val displayFormatType = if (mShapesElements.contentDescription.toString().startsWith("round")) "round" else "rect"
- val displayStyle = sp.getString("digitalstyle_frameStyle", "full")
- val displayFrameColor = sp.getString("digitalstyle_frameColor", "red")
- val displayFrameColorSaturation = sp.getString(
- "digitalstyle_frameColorSaturation",
- "500"
- )
- val displayFrameColorOpacity = sp.getString("digitalstyle_frameColorOpacity", "1")
+ val displayStyle = sp.getString(R.string.key_digital_style_frame_style, "full")
+ val displayFrameColor = sp.getString(R.string.key_digital_style_frame_color, "red")
+ val displayFrameColorSaturation = sp.getString(R.string.key_digital_style_frame_color_saturation, "500")
+ val displayFrameColorOpacity = sp.getString(R.string.key_digital_style_frame_color_opacity, "1")
// Load image with shapes
val styleDrawableName = "digitalstyle_bg_" + displayStyle + "_" + displayFormatType
diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt
index 3bc0c08ae1..fde17ae1e7 100644
--- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt
+++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt
@@ -185,7 +185,7 @@ class SteampunkWatchface : BaseWatchFace() {
}
//if both batteries are shown, make them smaller.
- if (sp.getBoolean("show_uploader_battery", true) && sp.getBoolean("show_rig_battery", false)) {
+ if (sp.getBoolean(R.string.key_show_uploader_battery, true) && sp.getBoolean(R.string.key_show_rig_battery, false)) {
mUploaderBattery?.textSize = fontSmall
mRigBattery?.textSize = fontSmall
} else {
diff --git a/wear/src/main/res/layout-notround/activity_digitalstyle.xml b/wear/src/main/res/layout-notround/activity_digitalstyle.xml
index 294d708df4..87352b783a 100644
--- a/wear/src/main/res/layout-notround/activity_digitalstyle.xml
+++ b/wear/src/main/res/layout-notround/activity_digitalstyle.xml
@@ -6,7 +6,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
- tools:context=".watchfaces.DigitalStyleWatchface"
tools:deviceIds="wear_square">
@@ -279,7 +278,7 @@
@@ -369,7 +368,7 @@
android:id="@+id/month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="5dp"
+ android:layout_marginLeft="5dp"
android:fontFamily="@font/roboto_condensed_regular"
android:text="MMM"
android:textAllCaps="true"
@@ -418,8 +417,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
- android:layout_marginStart="6sp"
- android:layout_marginTop="-2sp"
+ android:layout_marginLeft="6sp"
android:layout_marginBottom="-8sp"
android:fontFamily="@font/roboto_condensed_bold"
android:text="MI"
@@ -427,18 +425,28 @@
android:textSize="26sp"
android:textStyle="bold" />
+
+
-
-
@@ -280,7 +279,7 @@
@@ -370,7 +369,7 @@
android:id="@+id/month"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="5dp"
+ android:layout_marginLeft="5dp"
android:fontFamily="@font/roboto_condensed_regular"
android:text="MMM"
android:textAllCaps="true"
@@ -395,7 +394,7 @@
+
+
-
-
showDelta
showAvgDelta
showRingHistory
+ digital_style_frame_style
+ digital_style_frame_color
+ digital_style_frame_color_saturation
+ digital_style_frame_color_opacity
+ show_direction
+ show_iob
+ show_uploader_battery
+ show_rig_battery
+ show_temp_basal
+ vibrate_hourly
+ match_divider
+ simplify_ui
+ dark
diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml
index a719b98f78..e383787582 100644
--- a/wear/src/main/res/xml/preferences.xml
+++ b/wear/src/main/res/xml/preferences.xml
@@ -4,7 +4,7 @@
diff --git a/wear/src/main/res/xml/watch_face_configuration_bigchart.xml b/wear/src/main/res/xml/watch_face_configuration_bigchart.xml
index 93fca4db9e..1211bed170 100644
--- a/wear/src/main/res/xml/watch_face_configuration_bigchart.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_bigchart.xml
@@ -4,15 +4,14 @@
diff --git a/wear/src/main/res/xml/watch_face_configuration_circle.xml b/wear/src/main/res/xml/watch_face_configuration_circle.xml
index 556068b915..915c34c0ea 100644
--- a/wear/src/main/res/xml/watch_face_configuration_circle.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_circle.xml
@@ -4,8 +4,7 @@
@@ -44,7 +43,7 @@
diff --git a/wear/src/main/res/xml/watch_face_configuration_cockpit.xml b/wear/src/main/res/xml/watch_face_configuration_cockpit.xml
index bd87348acb..c6a75d256e 100644
--- a/wear/src/main/res/xml/watch_face_configuration_cockpit.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_cockpit.xml
@@ -4,7 +4,7 @@
@@ -13,7 +13,7 @@
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
- android:key="simplify_ui"
+ android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
diff --git a/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml b/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml
index 050bcc2c95..0c9c48ea2d 100644
--- a/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_digitalstyle.xml
@@ -6,27 +6,27 @@
android:defaultValue="full"
android:entries="@array/digitalstyle_styles_name"
android:entryValues="@array/digitalstyle_styles_values"
- android:key="digitalstyle_frameStyle"
+ android:key="@string/key_digital_style_frame_style"
android:title="@string/digitalstyle_pref_your_style" />
@@ -54,7 +54,7 @@
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
- android:key="simplify_ui"
+ android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
diff --git a/wear/src/main/res/xml/watch_face_configuration_home.xml b/wear/src/main/res/xml/watch_face_configuration_home.xml
index a471c8a816..a5e1feef89 100644
--- a/wear/src/main/res/xml/watch_face_configuration_home.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_home.xml
@@ -4,15 +4,14 @@
@@ -29,7 +28,7 @@
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
- android:key="simplify_ui"
+ android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
diff --git a/wear/src/main/res/xml/watch_face_configuration_home2.xml b/wear/src/main/res/xml/watch_face_configuration_home2.xml
index 97c7294f8e..3d86ad7cc6 100644
--- a/wear/src/main/res/xml/watch_face_configuration_home2.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_home2.xml
@@ -4,15 +4,14 @@
@@ -36,7 +35,7 @@
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
- android:key="simplify_ui"
+ android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
diff --git a/wear/src/main/res/xml/watch_face_configuration_largehome.xml b/wear/src/main/res/xml/watch_face_configuration_largehome.xml
index a471c8a816..a5e1feef89 100644
--- a/wear/src/main/res/xml/watch_face_configuration_largehome.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_largehome.xml
@@ -4,15 +4,14 @@
@@ -29,7 +28,7 @@
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
- android:key="simplify_ui"
+ android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
diff --git a/wear/src/main/res/xml/watch_face_configuration_nochart.xml b/wear/src/main/res/xml/watch_face_configuration_nochart.xml
index 93fca4db9e..1211bed170 100644
--- a/wear/src/main/res/xml/watch_face_configuration_nochart.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_nochart.xml
@@ -4,15 +4,14 @@
diff --git a/wear/src/main/res/xml/watch_face_configuration_steampunk.xml b/wear/src/main/res/xml/watch_face_configuration_steampunk.xml
index e3933b6732..08758b3f81 100644
--- a/wear/src/main/res/xml/watch_face_configuration_steampunk.xml
+++ b/wear/src/main/res/xml/watch_face_configuration_steampunk.xml
@@ -12,7 +12,7 @@
@@ -21,7 +21,7 @@
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
- android:key="simplify_ui"
+ android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />