Merge pull request #2949 from Philoul/wear/new_custom_watchface

Wear Remove AAPS WF and include a custom version into assets
This commit is contained in:
Milos Kozak 2023-10-19 21:09:29 +02:00 committed by GitHub
commit 3ffc75bd54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 325 deletions

Binary file not shown.

View file

@ -70,31 +70,6 @@
</intent-filter>
</service>
<service
android:name=".watchfaces.AapsWatchface"
android:allowEmbedded="true"
android:exported="false"
android:label="@string/label_watchface"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/watchface_graph" />
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="watch_face_configuration_home" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
<action android:name="android.intent.action.ACTION_POWER_DISCONNECTED" />
</intent-filter>
</service>
<service
android:name=".watchfaces.AapsLargeWatchface"
android:allowEmbedded="true"
@ -576,7 +551,6 @@
<action android:name="watch_face_configuration_circle" />
<action android:name="watch_face_configuration_custom" />
<action android:name="watch_face_configuration_digitalstyle" />
<action android:name="watch_face_configuration_home" />
<action android:name="watch_face_configuration_largehome" />
<action android:name="watch_face_configuration_nochart" />

View file

@ -20,7 +20,6 @@ import app.aaps.wear.tile.QuickWizardTileService
import app.aaps.wear.tile.TempTargetTileService
import app.aaps.wear.tile.TileBase
import app.aaps.wear.watchfaces.AapsLargeWatchface
import app.aaps.wear.watchfaces.AapsWatchface
import app.aaps.wear.watchfaces.BigChartWatchface
import app.aaps.wear.watchfaces.CircleWatchface
import app.aaps.wear.watchfaces.CustomWatchface
@ -51,7 +50,6 @@ abstract class WearServicesModule {
@ContributesAndroidInjector abstract fun contributesWallpaperComplication(): WallpaperComplication
@ContributesAndroidInjector abstract fun contributesBaseWatchFace(): BaseWatchFace
@ContributesAndroidInjector abstract fun contributesAapsWatchface(): AapsWatchface
@ContributesAndroidInjector abstract fun contributesAapsLargeWatchface(): AapsLargeWatchface
@ContributesAndroidInjector abstract fun contributesDigitalStyleWatchface(): DigitalStyleWatchface
@ContributesAndroidInjector abstract fun contributesBIGChart(): BigChartWatchface

View file

@ -1,107 +0,0 @@
package app.aaps.wear.watchfaces
import android.graphics.Color
import android.view.LayoutInflater
import androidx.core.content.ContextCompat
import androidx.viewbinding.ViewBinding
import app.aaps.wear.R
import app.aaps.wear.databinding.ActivityHomeBinding
import app.aaps.wear.watchfaces.utils.BaseWatchFace
import com.ustwo.clockwise.common.WatchMode
class AapsWatchface : BaseWatchFace() {
private lateinit var binding: ActivityHomeBinding
override fun inflateLayout(inflater: LayoutInflater): ViewBinding {
binding = ActivityHomeBinding.inflate(inflater)
return binding
}
override fun setColorDark() {
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView))
binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime))
val color = when (singleBg.sgvLevel) {
1L -> R.color.dark_highColor
0L -> R.color.dark_midColor
-1L -> R.color.dark_lowColor
else -> R.color.dark_midColor
}
binding.sgv.setTextColor(ContextCompat.getColor(this, color))
binding.delta.setTextColor(ContextCompat.getColor(this, color))
binding.direction.setTextColor(ContextCompat.getColor(this, color))
val colorTime = if (ageLevel == 1) if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mTimestamp1_home else R.color.dark_TimestampOld
binding.timestamp.setTextColor(ContextCompat.getColor(this, colorTime))
val colourBat = if (status.batteryLevel == 1) if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery else R.color.dark_uploaderBatteryEmpty
binding.uploaderBattery.setTextColor(ContextCompat.getColor(this, colourBat))
binding.status.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home))
highColor = ContextCompat.getColor(this, R.color.dark_highColor)
lowColor = ContextCompat.getColor(this, R.color.dark_lowColor)
midColor = ContextCompat.getColor(this, R.color.dark_midColor)
gridColor = ContextCompat.getColor(this, R.color.dark_gridColor)
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark)
basalCenterColor = ContextCompat.getColor(this, R.color.basal_light)
pointSize = 2
setupCharts()
}
override fun setColorLowRes() {
binding.time.setTextColor(ContextCompat.getColor(this, R.color.dark_mTime))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.dark_background))
binding.sgv.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.delta.setTextColor(ContextCompat.getColor(this, R.color.dark_midColor))
binding.timestamp.setTextColor(ContextCompat.getColor(this, R.color.dark_Timestamp))
highColor = ContextCompat.getColor(this, R.color.dark_midColor)
lowColor = ContextCompat.getColor(this, R.color.dark_midColor)
midColor = ContextCompat.getColor(this, R.color.dark_midColor)
gridColor = ContextCompat.getColor(this, R.color.dark_gridColor)
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_dark_lowres)
basalCenterColor = ContextCompat.getColor(this, R.color.basal_light_lowres)
pointSize = 2
setupCharts()
}
override fun setColorBright() {
if (currentWatchMode == WatchMode.INTERACTIVE) {
binding.secondaryLayout.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.light_background else R.color.light_stripe_background))
binding.mainLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.light_background))
val color = when (singleBg.sgvLevel) {
1L -> R.color.light_highColor
0L -> R.color.light_midColor
-1L -> R.color.light_lowColor
else -> R.color.light_midColor
}
binding.sgv.setTextColor(ContextCompat.getColor(this, color))
binding.delta.setTextColor(ContextCompat.getColor(this, color))
binding.direction.setTextColor(ContextCompat.getColor(this, color))
val colorTime = if (ageLevel == 1) if (dividerMatchesBg) Color.BLACK else Color.WHITE else Color.RED
binding.timestamp.setTextColor(colorTime)
val colourBat = if (status.batteryLevel == 1) if (dividerMatchesBg) Color.BLACK else Color.WHITE else Color.RED
binding.uploaderBattery.setTextColor(colourBat)
binding.status.setTextColor(if (dividerMatchesBg) Color.BLACK else Color.WHITE)
binding.time.setTextColor(Color.BLACK)
highColor = ContextCompat.getColor(this, R.color.light_highColor)
lowColor = ContextCompat.getColor(this, R.color.light_lowColor)
midColor = ContextCompat.getColor(this, R.color.light_midColor)
gridColor = ContextCompat.getColor(this, R.color.light_gridColor)
basalBackgroundColor = ContextCompat.getColor(this, R.color.basal_light)
basalCenterColor = ContextCompat.getColor(this, R.color.basal_dark)
pointSize = 2
setupCharts()
} else {
setColorDark()
}
}
}

View file

@ -4,7 +4,6 @@ import androidx.viewbinding.ViewBinding
import app.aaps.wear.databinding.ActivityBigchartBinding
import app.aaps.wear.databinding.ActivityCustomBinding
import app.aaps.wear.databinding.ActivityDigitalstyleBinding
import app.aaps.wear.databinding.ActivityHomeBinding
import app.aaps.wear.databinding.ActivityHomeLargeBinding
import app.aaps.wear.databinding.ActivityNochartBinding
@ -14,7 +13,6 @@ import app.aaps.wear.databinding.ActivityNochartBinding
*/
class WatchfaceViewAdapter(
aL: ActivityHomeLargeBinding? = null,
aa: ActivityHomeBinding? = null,
bC: ActivityBigchartBinding? = null,
ds: ActivityDigitalstyleBinding? = null,
nC: ActivityNochartBinding? = null,
@ -22,7 +20,7 @@ class WatchfaceViewAdapter(
) {
init {
if (aL == null && aa == null && bC == null && ds == null && nC == null && cU == null) {
if (aL == null && bC == null && ds == null && nC == null && cU == null) {
throw IllegalArgumentException("Require at least on Binding parameter")
}
}
@ -31,29 +29,29 @@ class WatchfaceViewAdapter(
// Required attributes
val mainLayout =
aL?.mainLayout ?: aa?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: cU?.mainLayout
aL?.mainLayout ?: bC?.mainLayout ?: bC?.mainLayout ?: ds?.mainLayout ?: nC?.mainLayout ?: cU?.mainLayout
?: throw IllegalArgumentException(errorMessage)
val timestamp =
aL?.timestamp ?: aa?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: cU?.timestamp
aL?.timestamp ?: bC?.timestamp ?: bC?.timestamp ?: ds?.timestamp ?: nC?.timestamp ?: cU?.timestamp
?: throw IllegalArgumentException(errorMessage)
val root =
aL?.root ?: aa?.root ?: bC?.root ?: bC?.root ?: ds?.root ?: nC?.root ?: cU?.root
aL?.root ?: bC?.root ?: bC?.root ?: ds?.root ?: nC?.root ?: cU?.root
?: throw IllegalArgumentException(errorMessage)
// Optional attributes
val sgv = aL?.sgv ?: aa?.sgv ?: bC?.sgv ?: bC?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
val direction = aL?.direction ?: aa?.direction ?: ds?.direction
val sgv = aL?.sgv ?: bC?.sgv ?: bC?.sgv ?: ds?.sgv ?: nC?.sgv ?: cU?.sgv
val direction = aL?.direction ?: ds?.direction
val loop = cU?.loop
val delta = aL?.delta ?: aa?.delta ?: bC?.delta ?: bC?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
val delta = aL?.delta ?: bC?.delta ?: bC?.delta ?: ds?.delta ?: nC?.delta ?: cU?.delta
val avgDelta = bC?.avgDelta ?: bC?.avgDelta ?: ds?.avgDelta ?: nC?.avgDelta ?: cU?.avgDelta
val uploaderBattery = aL?.uploaderBattery ?: aa?.uploaderBattery ?: ds?.uploaderBattery ?: cU?.uploaderBattery
val uploaderBattery = aL?.uploaderBattery ?: ds?.uploaderBattery ?: cU?.uploaderBattery
val rigBattery = ds?.rigBattery ?: cU?.rigBattery
val basalRate = ds?.basalRate ?: cU?.basalRate
val bgi = ds?.bgi ?: cU?.bgi
val AAPSv2 = ds?.AAPSv2 ?: cU?.AAPSv2
val cob1 = ds?.cob1 ?: cU?.cob1
val cob2 = ds?.cob2 ?: cU?.cob2
val time = aL?.time ?: aa?.time ?: bC?.time ?: bC?.time ?: nC?.time ?: cU?.time
val time = aL?.time ?: bC?.time ?: bC?.time ?: nC?.time ?: cU?.time
val second = cU?.second
val minute = ds?.minute ?: cU?.minute
val hour = ds?.hour ?: cU?.hour
@ -61,8 +59,8 @@ class WatchfaceViewAdapter(
val month = ds?.month ?: cU?.month
val iob1 = ds?.iob1 ?: cU?.iob1
val iob2 = ds?.iob2 ?: cU?.iob2
val chart = aa?.chart ?: bC?.chart ?: bC?.chart ?: ds?.chart ?: cU?.chart
val status = aL?.status ?: aa?.status ?: bC?.status ?: bC?.status ?: nC?.status
val chart = bC?.chart ?: bC?.chart ?: ds?.chart ?: cU?.chart
val status = aL?.status ?: bC?.status ?: bC?.status ?: nC?.status
val timePeriod = ds?.timePeriod ?: aL?.timePeriod ?: nC?.timePeriod ?: bC?.timePeriod ?: cU?.timePeriod
val dayName = ds?.dayName ?: cU?.dayName
val mainMenuTap = ds?.mainMenuTap
@ -70,7 +68,7 @@ class WatchfaceViewAdapter(
val dateTime = ds?.dateTime
val weekNumber = ds?.weekNumber ?: cU?.weekNumber
// val minuteHand = cU?.minuteHand
// val secondaryLayout = aL?.secondaryLayout ?: aa?.secondaryLayout ?: ds?.secondaryLayout
// val secondaryLayout = aL?.secondaryLayout ?: ds?.secondaryLayout
// val hourHand = cU?.hourHand
companion object {
@ -78,11 +76,10 @@ class WatchfaceViewAdapter(
fun getBinding(bindLayout: ViewBinding): WatchfaceViewAdapter {
return when (bindLayout) {
is ActivityHomeLargeBinding -> WatchfaceViewAdapter(bindLayout)
is ActivityHomeBinding -> WatchfaceViewAdapter(null, bindLayout)
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, null, bindLayout)
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, null, bindLayout)
is ActivityBigchartBinding -> WatchfaceViewAdapter(null, bindLayout)
is ActivityDigitalstyleBinding -> WatchfaceViewAdapter(null, null, bindLayout)
is ActivityNochartBinding -> WatchfaceViewAdapter(null, null, null, bindLayout)
is ActivityCustomBinding -> WatchfaceViewAdapter(null, null, null, null, bindLayout)
else -> throw IllegalArgumentException("ViewBinding is not implement in WatchfaceViewAdapter")
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 475 KiB

View file

@ -1,135 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".watchfaces.AapsWatchface">
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/secondary_layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:id="@+id/sgv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:gravity="bottom"
android:textSize="41sp"
tools:text="---" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/direction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="25sp"
android:textStyle="bold"
tools:text="--" />
<TextView
android:id="@+id/delta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textSize="11sp"
android:textStyle="bold"
tools:text="1" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/secondary_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="?android:colorForeground"
android:gravity="center_horizontal"
android:paddingVertical="1dp"
app:layout_constraintBottom_toTopOf="@+id/time">
<TextView
android:id="@+id/timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="11sp"
android:textStyle="bold"
tools:text="@string/time_stamp_na_min_ago" />
<TextView
android:id="@+id/uploader_battery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10sp"
android:paddingEnd="0sp"
android:textAlignment="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="11sp"
android:textStyle="bold"
tools:text="@string/uploader_na" />
<TextView
android:id="@+id/raw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10sp"
android:paddingEnd="0sp"
android:textAlignment="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="11sp"
android:textStyle="bold"
tools:text="" />
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10sp"
android:paddingEnd="0sp"
android:textAlignment="center"
android:textColor="?android:textColorPrimaryInverse"
android:textSize="11sp"
android:textStyle="bold"
tools:text="@string/no_status" />
</LinearLayout>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|top"
android:textAlignment="center"
android:textSize="35sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="12:00" />
<lecho.lib.hellocharts.view.LineChartView
android:id="@+id/chart"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="-5dp"
android:paddingBottom="7dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/time" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -2,7 +2,6 @@
<resources>
<string name="app_name">AAPS</string>
<string name="label_actions_activity">AAPS</string>
<string name="label_watchface">AAPS</string>
<string name="label_watchface_large">AAPS(Large)</string>
<string name="label_watchface_big_chart">AAPS(BigChart)</string>
<string name="label_watchface_no_chart">AAPS(NoChart)</string>

View file

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<CheckBoxPreference
android:defaultValue="true"
android:key="@string/key_dark"
android:title="@string/pref_dark"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_match_divider"
android:summary="Status bar divider background matches watchface background"
android:title="@string/pref_matching_divider"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/key_vibrate_hourly"
android:title="@string/pref_vibrate_hourly"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<ListPreference
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
android:key="@string/key_simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
</PreferenceScreen>