[#1806] For WearOS app, added option to make white status bar match background of whole watchface and blend in, switchable on Settings -> Matching divider

This commit is contained in:
Dominik Dzienia 2019-11-05 09:32:07 +01:00 committed by Dominik Dzienia
parent ff70299625
commit a7589e4758
5 changed files with 83 additions and 45 deletions

View file

@ -71,6 +71,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public boolean lowResMode = false; public boolean lowResMode = false;
public boolean layoutSet = false; public boolean layoutSet = false;
public boolean bIsRound = false; public boolean bIsRound = false;
public boolean dividerMatchesBg = false;
public int pointSize = 2; public int pointSize = 2;
public BgGraphBuilder bgGraphBuilder; public BgGraphBuilder bgGraphBuilder;
public LineChartView chart; public LineChartView chart;
@ -533,6 +534,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
} }
public void setColor() { public void setColor() {
dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false);
if(lowResMode){ if(lowResMode){
setColorLowRes(); setColorLowRes();
} else if (sharedPrefs.getBoolean("dark", true)) { } else if (sharedPrefs.getBoolean("dark", true)) {

View file

@ -65,7 +65,8 @@ public class Home extends BaseWatchFace {
protected void setColorDark() { 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)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
if (sgvLevel == 1) { if (sgvLevel == 1) {
@ -83,18 +84,21 @@ public class Home extends BaseWatchFace {
} }
if (ageLevel == 1) { 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 { } else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
} }
if (batteryLevel == 1) { 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 { } else {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty)); 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) { if (chart != null) {
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor); highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor);
@ -131,7 +135,8 @@ public class Home extends BaseWatchFace {
protected void setColorBright() { protected void setColorBright() {
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { 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)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
if (sgvLevel == 1) { if (sgvLevel == 1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor)); mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
@ -148,17 +153,17 @@ public class Home extends BaseWatchFace {
} }
if (ageLevel == 1) { if (ageLevel == 1) {
mTimestamp.setTextColor(Color.WHITE); mTimestamp.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE);
} else { } else {
mTimestamp.setTextColor(Color.RED); mTimestamp.setTextColor(Color.RED);
} }
if (batteryLevel == 1) { if (batteryLevel == 1) {
mUploaderBattery.setTextColor(Color.WHITE); mUploaderBattery.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE);
} else { } else {
mUploaderBattery.setTextColor(Color.RED); mUploaderBattery.setTextColor(Color.RED);
} }
mStatus.setTextColor(Color.WHITE); mStatus.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE);
mTime.setTextColor(Color.BLACK); mTime.setTextColor(Color.BLACK);
if (chart != null) { if (chart != null) {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.watchfaces;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import android.support.wearable.watchface.WatchFaceStyle; import android.support.wearable.watchface.WatchFaceStyle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -64,7 +65,14 @@ public class Home2 extends BaseWatchFace {
} }
protected void setColorDark() { 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)); mLinearLayout2.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
mRelativeLayout.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)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
@ -96,15 +104,15 @@ public class Home2 extends BaseWatchFace {
} }
if (batteryLevel == 1) { if (batteryLevel == 1) {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); mUploaderBattery.setTextColor(dividerBatteryOkColor);
} else { } else {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty)); mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty));
} }
mRigBattery.setTextColor(Color.BLACK); mRigBattery.setTextColor(dividerTxtColor);
mDelta.setTextColor(Color.BLACK); mDelta.setTextColor(dividerTxtColor);
mAvgDelta.setTextColor(Color.BLACK); mAvgDelta.setTextColor(dividerTxtColor);
mBasalRate.setTextColor(Color.BLACK); mBasalRate.setTextColor(dividerTxtColor);
mBgi.setTextColor(Color.BLACK); mBgi.setTextColor(dividerTxtColor);
if (loopLevel == 1) { if (loopLevel == 1) {
mLoop.setBackgroundResource(R.drawable.loop_green_25); mLoop.setBackgroundResource(R.drawable.loop_green_25);
@ -125,7 +133,12 @@ public class Home2 extends BaseWatchFace {
} }
protected void setColorLowRes() { 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)); mLinearLayout2.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
mLoop.setBackgroundResource(R.drawable.loop_grey_25); 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)); mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mDirection.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)); mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
mDelta.setTextColor(Color.BLACK); mDelta.setTextColor(dividerTxtColor);
mAvgDelta.setTextColor(Color.BLACK); mAvgDelta.setTextColor(dividerTxtColor);
mRigBattery.setTextColor(Color.BLACK); mRigBattery.setTextColor(dividerTxtColor);
mUploaderBattery.setTextColor(Color.BLACK); mUploaderBattery.setTextColor(dividerTxtColor);
mBasalRate.setTextColor(Color.BLACK); mBasalRate.setTextColor(dividerTxtColor);
mBgi.setTextColor(Color.BLACK); mBgi.setTextColor(dividerTxtColor);
mIOB1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mIOB1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mIOB2.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)); mCOB1.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
@ -162,7 +175,13 @@ public class Home2 extends BaseWatchFace {
protected void setColorBright() { protected void setColorBright() {
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { 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)); mLinearLayout2.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
mTime.setTextColor(Color.BLACK); mTime.setTextColor(Color.BLACK);
@ -194,15 +213,15 @@ public class Home2 extends BaseWatchFace {
} }
if (batteryLevel == 1) { if (batteryLevel == 1) {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mUploaderBattery.setTextColor(dividerTxtColor);
} else { } else {
mUploaderBattery.setTextColor(Color.RED); mUploaderBattery.setTextColor(Color.RED);
} }
mRigBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mRigBattery.setTextColor(dividerTxtColor);
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mDelta.setTextColor(dividerTxtColor);
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mAvgDelta.setTextColor(dividerTxtColor);
mBasalRate.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mBasalRate.setTextColor(dividerTxtColor);
mBgi.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mBgi.setTextColor(dividerTxtColor);
if (loopLevel == 1) { if (loopLevel == 1) {
mLoop.setBackgroundResource(R.drawable.loop_green_25); mLoop.setBackgroundResource(R.drawable.loop_green_25);

View file

@ -49,7 +49,8 @@ public class LargeHome extends BaseWatchFace {
@Override @Override
protected void setColorDark(){ 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)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
if (sgvLevel == 1) { if (sgvLevel == 1) {
@ -67,24 +68,27 @@ public class LargeHome extends BaseWatchFace {
} }
if (ageLevel == 1) { 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 { } else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld)); mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
} }
if (batteryLevel == 1) { 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 { } else {
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBatteryEmpty)); 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 @Override
protected void setColorBright() { protected void setColorBright() {
if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { 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)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_background));
if (sgvLevel == 1) { if (sgvLevel == 1) {
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor)); mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
@ -101,21 +105,21 @@ public class LargeHome extends BaseWatchFace {
} }
if (ageLevel == 1) { if (ageLevel == 1) {
mTimestamp.setTextColor(Color.WHITE); mTimestamp.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE);
} else { } else {
mTimestamp.setTextColor(Color.RED); mTimestamp.setTextColor(Color.RED);
} }
if (batteryLevel == 1) { if (batteryLevel == 1) {
mUploaderBattery.setTextColor(Color.WHITE); mUploaderBattery.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE);
} else { } else {
mUploaderBattery.setTextColor(Color.RED); mUploaderBattery.setTextColor(Color.RED);
} }
mStatus.setTextColor(Color.WHITE); mStatus.setTextColor(dividerMatchesBg ? Color.BLACK : Color.WHITE);
mTime.setTextColor(Color.BLACK); mTime.setTextColor(Color.BLACK);
} else { } else {
mRelativeLayout.setBackgroundColor(Color.BLACK); mRelativeLayout.setBackgroundColor(Color.BLACK);
mLinearLayout.setBackgroundColor(Color.LTGRAY); mLinearLayout.setBackgroundColor(dividerMatchesBg ? Color.BLACK : Color.LTGRAY);
if (sgvLevel == 1) { if (sgvLevel == 1) {
mSgv.setTextColor(Color.YELLOW); mSgv.setTextColor(Color.YELLOW);
mDirection.setTextColor(Color.YELLOW); mDirection.setTextColor(Color.YELLOW);
@ -130,23 +134,23 @@ public class LargeHome extends BaseWatchFace {
mDelta.setTextColor(Color.RED); mDelta.setTextColor(Color.RED);
} }
mUploaderBattery.setTextColor(Color.BLACK); mUploaderBattery.setTextColor(dividerMatchesBg ? Color.WHITE : Color.BLACK);
mTimestamp.setTextColor(Color.BLACK); mTimestamp.setTextColor(dividerMatchesBg ? Color.WHITE : Color.BLACK);
mStatus.setTextColor(Color.BLACK); mStatus.setTextColor(dividerMatchesBg ? Color.WHITE : Color.BLACK);
mTime.setTextColor(Color.WHITE); mTime.setTextColor(Color.WHITE);
} }
} }
@Override @Override
protected void setColorLowRes() { 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)); mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background)); mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_background));
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor)); mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mDelta.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)); mDirection.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
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));
mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_uploaderBattery)); mUploaderBattery.setTextColor(ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.dark_midColor : R.color.dark_uploaderBattery));
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));
} }
} }

View file

@ -125,6 +125,14 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/> app:wear_iconOn="@drawable/settings_on"/>
<CheckBoxPreference
android:defaultValue="false"
android:key="match_divider"
android:summary="Status bar divider background matches watchface background"
android:title="Matching divider"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
<ListPreference <ListPreference
android:defaultValue="3" android:defaultValue="3"
android:entries="@array/chart_timeframe" android:entries="@array/chart_timeframe"