From 9c17c075f4ea0571b6733a1bdf803656f61ed543 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 24 Apr 2022 19:38:16 +0200 Subject: [PATCH] Wear: Watchfaces unify onCreate, onTapCommand --- .../watchfaces/AapsLargeWatchface.kt | 37 +-------- .../androidaps/watchfaces/AapsV2Watchface.kt | 51 +----------- .../androidaps/watchfaces/AapsWatchface.kt | 51 +----------- .../androidaps/watchfaces/BaseWatchFace.kt | 80 ++++++++++++++++--- .../androidaps/watchfaces/CockpitWatchface.kt | 46 ++--------- .../watchfaces/DigitalStyleWatchface.kt | 26 +----- .../androidaps/watchfaces/NoChartWatchface.kt | 1 - .../watchfaces/SteampunkWatchface.kt | 49 +----------- .../layout-notround/activity_digitalstyle.xml | 2 + .../layout-round/activity_digitalstyle.xml | 2 + 10 files changed, 92 insertions(+), 253 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt index 71bf90aa78..84104d0c85 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsLargeWatchface.kt @@ -1,46 +1,13 @@ -@file:Suppress("DEPRECATION") - package info.nightscout.androidaps.watchfaces -import android.annotation.SuppressLint -import android.content.Intent import android.graphics.Color -import android.support.wearable.watchface.WatchFaceStyle -import android.view.LayoutInflater import androidx.core.content.ContextCompat import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R -import info.nightscout.androidaps.interaction.menus.MainMenuActivity class AapsLargeWatchface : BaseWatchFace() { - private var sgvTapTime: Long = 0 - - @SuppressLint("InflateParams") - override fun onCreate() { - super.onCreate() - val inflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater - layoutView = inflater.inflate(R.layout.activity_home_large, null) - performViewSetup() - } - - override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - mSgv?.let { mSgv -> - val extra = (mSgv.right - mSgv.left) / 2 - if (tapType == TAP_TYPE_TAP && x + extra >= mSgv.left && x - extra <= mSgv.right && y >= mSgv.top && y <= mSgv.bottom) { - if (eventTime - sgvTapTime < 800) { - val intent = Intent(this, MainMenuActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(intent) - } - sgvTapTime = eventTime - } - } - } - - override fun getWatchFaceStyle(): WatchFaceStyle { - return WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build() - } + override fun layoutResource(): Int = R.layout.activity_home_large override fun setColorDark() { mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_mLinearLayout)) @@ -70,7 +37,7 @@ class AapsLargeWatchface : BaseWatchFace() { if (status.batteryLevel == 1) mUploaderBattery?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_uploaderBattery)) else mUploaderBattery?.setTextColor(ContextCompat.getColor(this, R.color.dark_uploaderBatteryEmpty)) - + mStatus?.setTextColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_midColor else R.color.dark_mStatus_home)) } diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt index 438009813c..5432e3d650 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsV2Watchface.kt @@ -1,63 +1,14 @@ -@file:Suppress("DEPRECATION") - package info.nightscout.androidaps.watchfaces -import android.annotation.SuppressLint -import android.content.Intent import android.graphics.Color -import android.support.wearable.watchface.WatchFaceStyle -import android.view.LayoutInflater import androidx.annotation.ColorInt import androidx.core.content.ContextCompat import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R -import info.nightscout.androidaps.interaction.menus.MainMenuActivity class AapsV2Watchface : BaseWatchFace() { - private var chartTapTime: Long = 0 - private var sgvTapTime: Long = 0 - - @SuppressLint("InflateParams") - override fun onCreate() { - super.onCreate() - val inflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater - layoutView = inflater.inflate(R.layout.activity_home_2, null) - performViewSetup() - } - - override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - chart?.let { chart -> - if (tapType == TAP_TYPE_TAP && x >= chart.left && x <= chart.right && y >= chart.top && y <= chart.bottom) { - if (eventTime - chartTapTime < 800) { - changeChartTimeframe() - } - chartTapTime = eventTime - return - } - } - mSgv?.let { mSgv -> - val extra = (mSgv.right - mSgv.left) / 2 - if (tapType == TAP_TYPE_TAP && x + extra >= mSgv.left && x - extra <= mSgv.right && y >= mSgv.top && y <= mSgv.bottom) { - if (eventTime - sgvTapTime < 800) { - val intent = Intent(this, MainMenuActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(intent) - } - sgvTapTime = eventTime - } - } - } - - private fun changeChartTimeframe() { - var timeframe = sp.getInt(R.string.key_chart_time_frame, 3) - timeframe = timeframe % 5 + 1 - sp.putInt(R.string.key_chart_time_frame, timeframe) - } - - override fun getWatchFaceStyle(): WatchFaceStyle { - return WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build() - } + override fun layoutResource(): Int = R.layout.activity_home_2 override fun setColorDark() { @ColorInt val dividerTxtColor = if (dividerMatchesBg) ContextCompat.getColor(this, R.color.dark_midColor) else Color.BLACK diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt index 42d16e0763..a2ada7a19d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/AapsWatchface.kt @@ -1,62 +1,13 @@ -@file:Suppress("DEPRECATION") - package info.nightscout.androidaps.watchfaces -import android.annotation.SuppressLint -import android.content.Intent import android.graphics.Color -import android.support.wearable.watchface.WatchFaceStyle -import android.view.LayoutInflater import androidx.core.content.ContextCompat import com.ustwo.clockwise.common.WatchMode import info.nightscout.androidaps.R -import info.nightscout.androidaps.interaction.menus.MainMenuActivity class AapsWatchface : BaseWatchFace() { - private var chartTapTime: Long = 0 - private var sgvTapTime: Long = 0 - - @SuppressLint("InflateParams") - override fun onCreate() { - super.onCreate() - val inflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater - layoutView = inflater.inflate(R.layout.activity_home, null) - performViewSetup() - } - - override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - chart?.let { chart -> - if (tapType == TAP_TYPE_TAP && x >= chart.left && x <= chart.right && y >= chart.top && y <= chart.bottom) { - if (eventTime - chartTapTime < 800) { - changeChartTimeframe() - } - chartTapTime = eventTime - return - } - } - mSgv?.let { mSgv -> - val extra = (mSgv.right - mSgv.left) / 2 - if (tapType == TAP_TYPE_TAP && x + extra >= mSgv.left && x - extra <= mSgv.right && y >= mSgv.top && y <= mSgv.bottom) { - if (eventTime - sgvTapTime < 800) { - val intent = Intent(this, MainMenuActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(intent) - } - sgvTapTime = eventTime - } - } - } - - private fun changeChartTimeframe() { - var timeframe = sp.getInt(R.string.key_chart_time_frame, 3) - timeframe = timeframe % 5 + 1 - sp.putInt(R.string.key_chart_time_frame, timeframe) - } - - override fun getWatchFaceStyle(): WatchFaceStyle { - return WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build() - } + override fun layoutResource(): Int = R.layout.activity_home override fun setColorDark() { mLinearLayout?.setBackgroundColor(ContextCompat.getColor(this, if (dividerMatchesBg) R.color.dark_background else R.color.dark_statusView)) 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 61df905c48..aa37055b3c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.kt @@ -7,8 +7,9 @@ import android.content.Intent import android.content.IntentFilter import android.graphics.* import android.os.BatteryManager -import android.os.PowerManager import android.os.Vibrator +import android.support.wearable.watchface.WatchFaceStyle +import android.view.LayoutInflater import android.view.View import android.view.WindowInsets import android.view.WindowManager @@ -16,6 +17,7 @@ import android.widget.ImageView import android.widget.LinearLayout import android.widget.RelativeLayout import android.widget.TextView +import androidx.annotation.LayoutRes import androidx.core.content.ContextCompat import com.ustwo.clockwise.common.WatchFaceTime import com.ustwo.clockwise.common.WatchMode @@ -27,6 +29,7 @@ import info.nightscout.androidaps.events.EventWearPreferenceChange import info.nightscout.androidaps.events.EventWearToMobile import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.extensions.toVisibilityKeepSpace +import info.nightscout.androidaps.interaction.menus.MainMenuActivity import info.nightscout.androidaps.interaction.utils.Persistence import info.nightscout.androidaps.interaction.utils.WearUtil import info.nightscout.androidaps.plugins.bus.RxBus @@ -49,6 +52,7 @@ import kotlin.math.floor * Created by emmablack on 12/29/14. * Updated by andrew-warrington on 02-Jan-2018. * Refactored by dlvoy on 2019-11-2019 + * Refactored by MilosKozak 24/04/2022 */ abstract class BaseWatchFace : WatchFace() { @@ -67,6 +71,9 @@ abstract class BaseWatchFace : WatchFace() { protected var treatmentData = TreatmentData(ArrayList(), ArrayList(), ArrayList(), ArrayList()) protected var graphData = EventData.GraphData(ArrayList()) + // Layout + @LayoutRes abstract fun layoutResource(): Int + private val displaySize = Point() var mTime: TextView? = null var mHour: TextView? = null @@ -100,8 +107,10 @@ abstract class BaseWatchFace : WatchFace() { var mLinearLayout: LinearLayout? = null var mLinearLayout2: LinearLayout? = null var mDate: LinearLayout? = null - var mChartTap: LinearLayout? = null - var mMainMenuTap: LinearLayout? = null + var mChartTap: LinearLayout? = null // Steampunk only + var mMainMenuTap: LinearLayout? = null // Steampunk,Digital only + var chart: LineChartView? = null + var ageLevel = 1 var loopLevel = -1 var highColor = Color.YELLOW @@ -111,13 +120,16 @@ abstract class BaseWatchFace : WatchFace() { var basalBackgroundColor = Color.BLUE var basalCenterColor = Color.BLUE var bolusColor = Color.MAGENTA - var lowResMode = false - var layoutSet = false + private var lowResMode = false + private var layoutSet = false var bIsRound = false var dividerMatchesBg = false var pointSize = 2 - var chart: LineChartView? = null - var wakeLock: PowerManager.WakeLock? = null + + // Tapping times + private var sgvTapTime: Long = 0 + private var chartTapTime: Long = 0 + private var mainMenuTapTime: Long = 0 // related endTime manual layout var layoutView: View? = null @@ -146,7 +158,6 @@ abstract class BaseWatchFace : WatchFace() { colorDarkLow = ContextCompat.getColor(this, R.color.dark_lowColor) @Suppress("DEPRECATION") (getSystemService(WINDOW_SERVICE) as WindowManager).defaultDisplay.getSize(displaySize) - wakeLock = (getSystemService(POWER_SERVICE) as PowerManager).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AndroidAPS:BaseWatchFace") specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY) specH = if (forceSquareCanvas) specW else View.MeasureSpec.makeMeasureSpec(displaySize.y, View.MeasureSpec.EXACTLY) disposable += rxBus @@ -185,6 +196,58 @@ abstract class BaseWatchFace : WatchFace() { persistence.turnOff() setupBatteryReceiver() setupSimpleUi() + layoutView = (getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(layoutResource(), null) + performViewSetup() + rxBus.send(EventWearToMobile(ActionResendData("BaseWatchFace::onCreate"))) + } + + override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { + chart?.let { chart -> + if (tapType == TAP_TYPE_TAP && x >= chart.left && x <= chart.right && y >= chart.top && y <= chart.bottom) { + if (eventTime - chartTapTime < 800) { + changeChartTimeframe() + } + chartTapTime = eventTime + return + } + } + mSgv?.let { mSgv -> + val extra = (mSgv.right - mSgv.left) / 2 + if (tapType == TAP_TYPE_TAP && x + extra >= mSgv.left && x - extra <= mSgv.right && y >= mSgv.top && y <= mSgv.bottom) { + if (eventTime - sgvTapTime < 800) { + startActivity(Intent(this, MainMenuActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) + } + sgvTapTime = eventTime + } + } + mChartTap?.let { mChartTap -> + if (tapType == TAP_TYPE_TAP && x >= mChartTap.left && x <= mChartTap.right && y >= mChartTap.top && y <= mChartTap.bottom) { + if (eventTime - chartTapTime < 800) { + changeChartTimeframe() + } + chartTapTime = eventTime + return + } + } + mMainMenuTap?.let { mMainMenuTap -> + if (tapType == TAP_TYPE_TAP && x >= mMainMenuTap.left && x <= mMainMenuTap.right && y >= mMainMenuTap.top && y <= mMainMenuTap.bottom) { + if (eventTime - mainMenuTapTime < 800) { + startActivity(Intent(this, MainMenuActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) + } + mainMenuTapTime = eventTime + return + } + } + } + + open fun changeChartTimeframe() { + var timeframe = sp.getInt(R.string.key_chart_time_frame, 3) + timeframe = timeframe % 5 + 1 + sp.putInt(R.string.key_chart_time_frame, timeframe) + } + + override fun getWatchFaceStyle(): WatchFaceStyle { + return WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build() } private fun setupBatteryReceiver() { @@ -272,7 +335,6 @@ abstract class BaseWatchFace : WatchFace() { setupCharts() setDataFields() missedReadingAlert() - wakeLock?.acquire(50) } fun ageLevel(): Int { diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt index db8b2e0c53..ab3fab10e5 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CockpitWatchface.kt @@ -1,14 +1,7 @@ -@file:Suppress("DEPRECATION") - package info.nightscout.androidaps.watchfaces -import android.annotation.SuppressLint -import android.content.Intent -import android.support.wearable.watchface.WatchFaceStyle -import android.view.LayoutInflater import android.view.View import info.nightscout.androidaps.R -import info.nightscout.androidaps.interaction.menus.MainMenuActivity /** * Created by andrew-warrington on 18/11/2017. @@ -16,30 +9,7 @@ import info.nightscout.androidaps.interaction.menus.MainMenuActivity */ class CockpitWatchface : BaseWatchFace() { - private var sgvTapTime: Long = 0 - - @SuppressLint("InflateParams") - override fun onCreate() { - super.onCreate() - val inflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater - layoutView = inflater.inflate(R.layout.activity_cockpit, null) - performViewSetup() - } - - override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - if (tapType == TAP_TYPE_TAP) { - if (eventTime - sgvTapTime < 800) { - val intent = Intent(this, MainMenuActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(intent) - } - sgvTapTime = eventTime - } - } - - override fun getWatchFaceStyle(): WatchFaceStyle { - return WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build() - } + override fun layoutResource(): Int = R.layout.activity_cockpit override fun setColorDark() { mRelativeLayout?.setBackgroundResource(R.drawable.airplane_cockpit_outside_clouds) @@ -77,13 +47,13 @@ class CockpitWatchface : BaseWatchFace() { } private fun setTextSizes() { - if (status.detailedIob) { - if (bIsRound) mIOB2?.textSize = 10f - else mIOB2?.textSize = 9f - } else { - if (bIsRound) mIOB2?.textSize = 13f - else mIOB2?.textSize = 12f - } + if (status.detailedIob) { + if (bIsRound) mIOB2?.textSize = 10f + else mIOB2?.textSize = 9f + } else { + if (bIsRound) mIOB2?.textSize = 13f + else mIOB2?.textSize = 12f + } if (mUploaderBattery?.visibility != View.GONE && mRigBattery?.visibility != View.GONE) { if (bIsRound) { mUploaderBattery?.textSize = 12f 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 dd017cd267..7308fa0873 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/DigitalStyleWatchface.kt @@ -3,42 +3,18 @@ package info.nightscout.androidaps.watchfaces import android.annotation.SuppressLint -import android.content.Intent import android.support.wearable.watchface.WatchFaceStyle -import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout import android.widget.TextView import androidx.core.content.ContextCompat import info.nightscout.androidaps.R import info.nightscout.androidaps.extensions.toVisibility -import info.nightscout.androidaps.interaction.menus.MainMenuActivity import info.nightscout.shared.logging.LTag class DigitalStyleWatchface : BaseWatchFace() { - private var sgvTapTime: Long = 0 - - @SuppressLint("InflateParams") - override fun onCreate() { - super.onCreate() - val inflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater - layoutView = inflater.inflate(R.layout.activity_digitalstyle, null) - performViewSetup() - } - - override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - //tapType = TAP_TYPE_TAP; - aapsLogger.debug(LTag.WEAR, "onTapCommand: DeviceWidth x DeviceHeight /// x , y, TapType >> ", "$width x $height /// $x , $y , $tapType") - if (tapType == TAP_TYPE_TAP) { - if (eventTime - sgvTapTime < TIME_TAP_THRESHOLD) { - val intent = Intent(this, MainMenuActivity::class.java) - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - startActivity(intent) - } - sgvTapTime = eventTime - } - } + override fun layoutResource(): Int = R.layout.activity_digitalstyle override fun getWatchFaceStyle(): WatchFaceStyle { return WatchFaceStyle.Builder(this) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt b/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt index 52f8106741..9347951660 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/NoChartWatchface.kt @@ -10,7 +10,6 @@ import android.graphics.Point import android.graphics.Rect import android.os.PowerManager import android.support.wearable.watchface.WatchFaceStyle -import android.text.format.DateFormat import android.view.LayoutInflater import android.view.View import android.view.WindowInsets 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 776c4a8c6a..2ee0eb5142 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/SteampunkWatchface.kt @@ -1,17 +1,10 @@ -@file:Suppress("DEPRECATION") - package info.nightscout.androidaps.watchfaces -import android.annotation.SuppressLint -import android.content.Intent -import android.support.wearable.watchface.WatchFaceStyle -import android.view.LayoutInflater import android.view.animation.Animation import android.view.animation.LinearInterpolator import android.view.animation.RotateAnimation import androidx.core.content.ContextCompat import info.nightscout.androidaps.R -import info.nightscout.androidaps.interaction.menus.MainMenuActivity import info.nightscout.shared.SafeParse.stringToFloat import org.joda.time.TimeOfDay @@ -21,43 +14,14 @@ import org.joda.time.TimeOfDay */ class SteampunkWatchface : BaseWatchFace() { - private var chartTapTime: Long = 0 - private var mainMenuTapTime: Long = 0 private var lastEndDegrees = 0f private var deltaRotationAngle = 0f - @SuppressLint("InflateParams") + override fun layoutResource(): Int = R.layout.activity_steampunk + override fun onCreate() { forceSquareCanvas = true super.onCreate() - val inflater = getSystemService(LAYOUT_INFLATER_SERVICE) as LayoutInflater - layoutView = inflater.inflate(R.layout.activity_steampunk, null) - performViewSetup() - } - - override fun onTapCommand(tapType: Int, x: Int, y: Int, eventTime: Long) { - mChartTap?.let { mChartTap -> - if (tapType == TAP_TYPE_TAP && x >= mChartTap.left && x <= mChartTap.right && y >= mChartTap.top && y <= mChartTap.bottom) { - if (eventTime - chartTapTime < 800) { - changeChartTimeframe() - } - chartTapTime = eventTime - return - } - } - mMainMenuTap?.let { mMainMenuTap -> - if (tapType == TAP_TYPE_TAP && x >= mMainMenuTap.left && x <= mMainMenuTap.right && y >= mMainMenuTap.top && y <= mMainMenuTap.bottom) { - if (eventTime - mainMenuTapTime < 800) { - startActivity(Intent(this, MainMenuActivity::class.java).also { it.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) }) - } - mainMenuTapTime = eventTime - return - } - } - } - - override fun getWatchFaceStyle(): WatchFaceStyle { - return WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build() } override fun setColorDark() { @@ -241,15 +205,10 @@ class SteampunkWatchface : BaseWatchFace() { } } - private fun changeChartTimeframe() { + override fun changeChartTimeframe() { var timeframe = sp.getInt(R.string.key_chart_time_frame, 3) timeframe = timeframe % 5 + 1 - pointSize = if (timeframe < 3) { - 2 - } else { - 1 - } - setupCharts() + pointSize = if (timeframe < 3) 2 else 1 sp.putInt(R.string.key_chart_time_frame, timeframe) } } \ No newline at end of file diff --git a/wear/src/main/res/layout-notround/activity_digitalstyle.xml b/wear/src/main/res/layout-notround/activity_digitalstyle.xml index 7f9fbb28c1..294d708df4 100644 --- a/wear/src/main/res/layout-notround/activity_digitalstyle.xml +++ b/wear/src/main/res/layout-notround/activity_digitalstyle.xml @@ -28,6 +28,7 @@