[#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:
parent
ff70299625
commit
a7589e4758
|
@ -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)) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,6 +125,14 @@
|
|||
app:wear_iconOff="@drawable/settings_off"
|
||||
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
|
||||
android:defaultValue="3"
|
||||
android:entries="@array/chart_timeframe"
|
||||
|
|
Loading…
Reference in a new issue