From 512341e603b6fa8ddd1558015bfcec2a01511f10 Mon Sep 17 00:00:00 2001 From: Andrew Warrington Date: Wed, 3 Jan 2018 15:24:06 +0100 Subject: [PATCH] Steampunk: Enabled chart zoom with double-tap on bottom 1/3 of screen. --- .../androidaps/watchfaces/BaseWatchFace.java | 4 ++- .../androidaps/watchfaces/Steampunk.java | 30 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index 0084891256..c23c2930a9 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -55,7 +55,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen public ImageView mGlucoseDial, mDeltaGauge, mHourHand, mMinuteHand; public long datetime; public RelativeLayout mRelativeLayout; - public LinearLayout mLinearLayout, mLinearLayout2, mDate; + public LinearLayout mLinearLayout, mLinearLayout2, mDate, mChartTap, mMainMenuTap; public long sgvLevel = 0; public int ageLevel = 1; public int loopLevel = 1; @@ -171,6 +171,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen mDeltaGauge = (ImageView) stub.findViewById(R.id.delta_pointer); mHourHand = (ImageView) stub.findViewById(R.id.hour_hand); mMinuteHand = (ImageView) stub.findViewById(R.id.minute_hand); + mChartTap = (LinearLayout) stub.findViewById(R.id.chart_zoom_tap); + mMainMenuTap = (LinearLayout) stub.findViewById(R.id.main_menu_tap); chart = (LineChartView) stub.findViewById(R.id.chart); layoutSet = true; diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java index e28a0eeca6..651d1955ae 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Steampunk.java @@ -17,7 +17,8 @@ import info.nightscout.androidaps.interaction.menus.MainMenuActivity; public class Steampunk extends BaseWatchFace { - private long sgvTapTime = 0; + private long chartTapTime = 0; + private long mainMenuTapTime = 0; private float lastEndDegrees = 0f; private float deltaRotationAngle = 0f; @@ -33,13 +34,27 @@ public class Steampunk extends BaseWatchFace { @Override protected void onTapCommand(int tapType, int x, int y, long eventTime) { - if (tapType == TAP_TYPE_TAP) { - if (eventTime - sgvTapTime < 800) { + if (tapType == TAP_TYPE_TAP&& + x >= mChartTap.getLeft() && + x <= mChartTap.getRight()&& + y >= mChartTap.getTop() && + y <= mChartTap.getBottom()){ + if (eventTime - chartTapTime < 800){ + changeChartTimeframe(); + } + chartTapTime = eventTime; + + } else if (tapType == TAP_TYPE_TAP&& + x >= mMainMenuTap.getLeft() && + x <= mMainMenuTap.getRight()&& + y >= mMainMenuTap.getTop() && + y <= mMainMenuTap.getBottom()){ + if (eventTime - mainMenuTapTime < 800){ Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } - sgvTapTime = eventTime; + mainMenuTapTime = eventTime; } } @@ -218,4 +233,11 @@ public class Steampunk extends BaseWatchFace { mRigBattery.setTextSize(fontMedium); } } + + private void changeChartTimeframe() { + int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); + timeframe = (timeframe%5) + 1; + sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).commit(); + } + } \ No newline at end of file