From a7589e4758c2379cff2dffff397b189e81288080 Mon Sep 17 00:00:00 2001 From: Dominik Dzienia Date: Tue, 5 Nov 2019 09:32:07 +0100 Subject: [PATCH] [#1806] For WearOS app, added option to make white status bar match background of whole watchface and blend in, switchable on Settings -> Matching divider --- .../androidaps/watchfaces/BaseWatchFace.java | 2 + .../androidaps/watchfaces/Home.java | 21 ++++--- .../androidaps/watchfaces/Home2.java | 61 ++++++++++++------- .../androidaps/watchfaces/LargeHome.java | 36 ++++++----- wear/src/main/res/xml/preferences.xml | 8 +++ 5 files changed, 83 insertions(+), 45 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 229eb64f1b..24bb735067 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -71,6 +71,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen public boolean lowResMode = false; public boolean layoutSet = false; public boolean bIsRound = false; + public boolean dividerMatchesBg = false; public int pointSize = 2; public BgGraphBuilder bgGraphBuilder; public LineChartView chart; @@ -533,6 +534,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen } public void setColor() { + dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false); if(lowResMode){ setColorLowRes(); } else if (sharedPrefs.getBoolean("dark", true)) { diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java index 430a3feb47..786dbd8179 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java @@ -65,7 +65,8 @@ public class Home extends BaseWatchFace { protected void setColorDark() { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView)); + mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_background : R.color.dark_statusView)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); if (sgvLevel == 1) { @@ -83,18 +84,21 @@ public class Home extends BaseWatchFace { } if (ageLevel == 1) { - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_midColor : R.color.dark_mTimestamp1_home)); } else { mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); } if (batteryLevel == 1) { - mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); + mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_midColor : R.color.dark_uploaderBattery)); } else { mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty)); } - mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mStatus_home)); + mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_midColor : R.color.dark_mStatus_home)); if (chart != null) { highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor); @@ -131,7 +135,8 @@ public class Home extends BaseWatchFace { protected void setColorBright() { if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_stripe_background)); + mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.light_background : R.color.light_stripe_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background)); if (sgvLevel == 1) { mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor)); @@ -148,17 +153,17 @@ public class Home extends BaseWatchFace { } if (ageLevel == 1) { - mTimestamp.setTextColor(Color.WHITE); + mTimestamp.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE); } else { mTimestamp.setTextColor(Color.RED); } if (batteryLevel == 1) { - mUploaderBattery.setTextColor(Color.WHITE); + mUploaderBattery.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE); } else { mUploaderBattery.setTextColor(Color.RED); } - mStatus.setTextColor(Color.WHITE); + mStatus.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE); mTime.setTextColor(Color.BLACK); if (chart != null) { diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java index 41c9fd3029..64ec7e17c8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java @@ -2,6 +2,7 @@ package info.nightscout.androidaps.watchfaces; import android.content.Intent; import android.graphics.Color; +import androidx.annotation.ColorInt; import androidx.core.content.ContextCompat; import android.support.wearable.watchface.WatchFaceStyle; import android.view.LayoutInflater; @@ -64,7 +65,14 @@ public class Home2 extends BaseWatchFace { } protected void setColorDark() { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView)); + @ColorInt final int dividerTxtColor = dividerMatchesBg ? + ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor) : Color.BLACK; + @ColorInt final int dividerBatteryOkColor = ContextCompat.getColor(getApplicationContext(), + dividerMatchesBg ? R.color.dark_midColor : R.color.dark_uploaderBattery); + @ColorInt final int dividerBgColor = ContextCompat.getColor(getApplicationContext(), + dividerMatchesBg ? R.color.dark_background : R.color.dark_statusView); + + mLinearLayout.setBackgroundColor(dividerBgColor); mLinearLayout2.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); @@ -96,15 +104,15 @@ public class Home2 extends BaseWatchFace { } if (batteryLevel == 1) { - mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); + mUploaderBattery.setTextColor(dividerBatteryOkColor); } else { mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty)); } - mRigBattery.setTextColor(Color.BLACK); - mDelta.setTextColor(Color.BLACK); - mAvgDelta.setTextColor(Color.BLACK); - mBasalRate.setTextColor(Color.BLACK); - mBgi.setTextColor(Color.BLACK); + mRigBattery.setTextColor(dividerTxtColor); + mDelta.setTextColor(dividerTxtColor); + mAvgDelta.setTextColor(dividerTxtColor); + mBasalRate.setTextColor(dividerTxtColor); + mBgi.setTextColor(dividerTxtColor); if (loopLevel == 1) { mLoop.setBackgroundResource(R.drawable.loop_green_25); @@ -125,7 +133,12 @@ public class Home2 extends BaseWatchFace { } protected void setColorLowRes() { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView)); + @ColorInt final int dividerTxtColor = dividerMatchesBg ? + ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor) : Color.BLACK; + @ColorInt final int dividerBgColor = ContextCompat.getColor(getApplicationContext(), + dividerMatchesBg ? R.color.dark_background : R.color.dark_statusView); + + mLinearLayout.setBackgroundColor(dividerBgColor); mLinearLayout2.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mLoop.setBackgroundResource(R.drawable.loop_grey_25); @@ -133,12 +146,12 @@ public class Home2 extends BaseWatchFace { mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp)); - mDelta.setTextColor(Color.BLACK); - mAvgDelta.setTextColor(Color.BLACK); - mRigBattery.setTextColor(Color.BLACK); - mUploaderBattery.setTextColor(Color.BLACK); - mBasalRate.setTextColor(Color.BLACK); - mBgi.setTextColor(Color.BLACK); + mDelta.setTextColor(dividerTxtColor); + mAvgDelta.setTextColor(dividerTxtColor); + mRigBattery.setTextColor(dividerTxtColor); + mUploaderBattery.setTextColor(dividerTxtColor); + mBasalRate.setTextColor(dividerTxtColor); + mBgi.setTextColor(dividerTxtColor); mIOB1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mIOB2.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mCOB1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); @@ -162,7 +175,13 @@ public class Home2 extends BaseWatchFace { protected void setColorBright() { if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_stripe_background)); + + @ColorInt final int dividerTxtColor = dividerMatchesBg ? Color.BLACK : + ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); + @ColorInt final int dividerBgColor = ContextCompat.getColor(getApplicationContext(), + dividerMatchesBg ? R.color.light_background : R.color.light_stripe_background); + + mLinearLayout.setBackgroundColor(dividerBgColor); mLinearLayout2.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background)); mTime.setTextColor(Color.BLACK); @@ -194,15 +213,15 @@ public class Home2 extends BaseWatchFace { } if (batteryLevel == 1) { - mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mUploaderBattery.setTextColor(dividerTxtColor); } else { mUploaderBattery.setTextColor(Color.RED); } - mRigBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); - mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); - mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); - mBasalRate.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); - mBgi.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); + mRigBattery.setTextColor(dividerTxtColor); + mDelta.setTextColor(dividerTxtColor); + mAvgDelta.setTextColor(dividerTxtColor); + mBasalRate.setTextColor(dividerTxtColor); + mBgi.setTextColor(dividerTxtColor); if (loopLevel == 1) { mLoop.setBackgroundResource(R.drawable.loop_green_25); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java index ffb8dce3ad..672b95dee0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java @@ -49,7 +49,8 @@ public class LargeHome extends BaseWatchFace { @Override protected void setColorDark(){ - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout)); + mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_background : R.color.dark_mLinearLayout)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); if (sgvLevel == 1) { @@ -67,24 +68,27 @@ public class LargeHome extends BaseWatchFace { } if (ageLevel == 1) { - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_midColor : R.color.dark_mTimestamp1_home)); } else { mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); } if (batteryLevel == 1) { - mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); + mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.dark_midColor : R.color.dark_uploaderBattery)); } else { mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty)); } - mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mStatus_home)); + mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.dark_midColor : R.color.dark_mStatus_home)); } @Override protected void setColorBright() { if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_stripe_background)); + mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? + R.color.light_background : R.color.light_stripe_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background)); if (sgvLevel == 1) { mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor)); @@ -101,21 +105,21 @@ public class LargeHome extends BaseWatchFace { } if (ageLevel == 1) { - mTimestamp.setTextColor(Color.WHITE); + mTimestamp.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE); } else { mTimestamp.setTextColor(Color.RED); } if (batteryLevel == 1) { - mUploaderBattery.setTextColor(Color.WHITE); + mUploaderBattery.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE); } else { mUploaderBattery.setTextColor(Color.RED); } - mStatus.setTextColor(Color.WHITE); + mStatus.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE); mTime.setTextColor(Color.BLACK); } else { mRelativeLayout.setBackgroundColor(Color.BLACK); - mLinearLayout.setBackgroundColor(Color.LTGRAY); + mLinearLayout.setBackgroundColor(dividerMatchesBg ? Color.BLACK : Color.LTGRAY); if (sgvLevel == 1) { mSgv.setTextColor(Color.YELLOW); mDirection.setTextColor(Color.YELLOW); @@ -130,23 +134,23 @@ public class LargeHome extends BaseWatchFace { mDelta.setTextColor(Color.RED); } - mUploaderBattery.setTextColor(Color.BLACK); - mTimestamp.setTextColor(Color.BLACK); - mStatus.setTextColor(Color.BLACK); + mUploaderBattery.setTextColor(dividerMatchesBg ? Color.WHITE : Color.BLACK); + mTimestamp.setTextColor(dividerMatchesBg ? Color.WHITE : Color.BLACK); + mStatus.setTextColor(dividerMatchesBg ? Color.WHITE : Color.BLACK); mTime.setTextColor(Color.WHITE); } } @Override protected void setColorLowRes() { - mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout)); + mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.dark_background : R.color.dark_mLinearLayout)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); - mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home)); - mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); - mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mStatus_home)); + mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.dark_midColor : R.color.dark_mTimestamp1_home)); + mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.dark_midColor : R.color.dark_uploaderBattery)); + mStatus.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.dark_midColor : R.color.dark_mStatus_home)); } } diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index 0befaddfd0..f0fc4b5789 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -125,6 +125,14 @@ app:wear_iconOff="@drawable/settings_off" app:wear_iconOn="@drawable/settings_on"/> + +