wear low bit mode

This commit is contained in:
AdrianLxM 2016-11-27 06:12:20 +01:00
parent 299e235f4b
commit 736c87a9cc
6 changed files with 97 additions and 50 deletions

View file

@ -31,7 +31,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.android.gms.wearable.DataMap;
import com.ustwo.clockwise.common.util.Logr;
import com.ustwo.clockwise.wearable.WatchFace;
import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchMode;
@ -59,7 +58,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public int basalBackgroundColor = Color.BLUE;
public int basalCenterColor = Color.BLUE;
public int pointSize = 2;
public boolean singleLine = false;
public boolean lowResMode = false;
public boolean layoutSet = false;
public BgGraphBuilder bgGraphBuilder;
public LineChartView chart;
@ -163,13 +162,18 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
}
protected void onWatchModeChanged(WatchMode watchMode) {
if (! sharedPrefs.getBoolean("dark", true)){
if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode
lowResMode = isLowRes(watchMode);
setColor();
} else if (! sharedPrefs.getBoolean("dark", true)){
//in bright mode: different colours if active:
setColor();
} else {
//TODO: Handle low bit ambient
}
}
private boolean isLowRes(WatchMode watchMode) {
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
}
@ -306,7 +310,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
//start animation?
// dataMap.getDataMapArrayList("entries") == null -> not on "resend data".
if (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5"))) {
if (!lowResMode && (sharedPrefs.getBoolean("animation", false) && dataMap.getDataMapArrayList("entries") == null && (sgvString.equals("100") || sgvString.equals("5.5") || sgvString.equals("5,5")))) {
startAnimation();
}
}
@ -393,7 +397,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
}
public void setColor() {
if (sharedPrefs.getBoolean("dark", true)) {
if(lowResMode){
setColorLowRes();
} else if (sharedPrefs.getBoolean("dark", true)) {
setColorDark();
} else {
setColorBright();
@ -465,8 +471,26 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
animator.start();
}
//without theme
protected void setColorLowRes() {
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
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));
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
if (chart != null) {
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
gridColour = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark_lowres);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light_lowres);
pointSize = 2;
setupCharts();
}
}
protected void setColorDark() {
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
@ -487,9 +511,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
}
if (ageLevel == 1) {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
} else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
}
if (chart != null) {
@ -499,7 +523,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
gridColour = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light);
singleLine = false;
pointSize = 2;
setupCharts();
}
@ -540,7 +563,6 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
gridColour = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark);
singleLine = false;
pointSize = 2;
setupCharts();
}
@ -560,18 +582,12 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
bgDataList = new ArrayList<BgWatchData>();
for (DataMap entry : entries) {
double sgv = entry.getDouble("sgvDouble");
double high = entry.getDouble("high");
double low = entry.getDouble("low");
double timestamp = entry.getDouble("timestamp");
final int size = bgDataList.size();
if (size > 0) {
if (bgDataList.get(size - 1).timestamp == timestamp)
continue; // Ignore duplicates.
}
bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
}
} else {
@ -600,7 +616,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
public void setupCharts() {
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (singleLine) {
if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe);
} else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, basalBackgroundColor, basalCenterColor, timeframe);

View file

@ -26,6 +26,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.google.android.gms.wearable.DataMap;
import com.ustwo.clockwise.common.WatchMode;
import com.ustwo.clockwise.wearable.WatchFace;
import com.ustwo.clockwise.common.WatchFaceTime;
import com.ustwo.clockwise.common.WatchShape;
@ -53,8 +54,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
public int gridColor = Color.WHITE;
public int basalBackgroundColor = Color.BLUE;
public int basalCenterColor = Color.BLUE;
public boolean lowResMode = false;
public int pointSize = 2;
public boolean singleLine = false;
public boolean layoutSet = false;
public int missed_readings_alert_id = 818;
public BgGraphBuilder bgGraphBuilder;
@ -312,15 +313,29 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
}
public void setColor() {
if (sharedPrefs.getBoolean("dark", true)) {
if(lowResMode){
setColorLowRes();
} else if (sharedPrefs.getBoolean("dark", true)) {
setColorDark();
} else {
setColorBright();
}
}
protected void onWatchModeChanged(WatchMode watchMode) {
if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode
lowResMode = isLowRes(watchMode);
setColor();
} else if (! sharedPrefs.getBoolean("dark", true)){
//in bright mode: different colours if active:
setColor();
}
}
private boolean isLowRes(WatchMode watchMode) {
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN) || (watchMode == WatchMode.LOW_BIT_BURN_IN);
}
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
@ -335,6 +350,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
}
protected abstract void setColorDark();
protected abstract void setColorBright();
protected abstract void setColorLowRes();
public void missedReadingAlert() {
@ -348,18 +364,12 @@ protected abstract void setColorDark();
ArrayList<DataMap> entries = dataMap.getDataMapArrayList("entries");
if (entries != null) {
bgDataList = new ArrayList<BgWatchData>();
for (DataMap entry : entries) {
double sgv = entry.getDouble("sgvDouble");
double high = entry.getDouble("high");
double low = entry.getDouble("low");
double timestamp = entry.getDouble("timestamp");
final int size = bgDataList.size();
if (size > 0) {
if (bgDataList.get(size - 1).timestamp == timestamp)
continue; // Ignore duplicates.
}
bgDataList.add(new BgWatchData(sgv, high, low, timestamp));
}
} else {
@ -388,7 +398,7 @@ protected abstract void setColorDark();
public void setupCharts() {
if(bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (singleLine) {
if (lowResMode) {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);
} else {
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, basalBackgroundColor, basalCenterColor, timeframe);

View file

@ -52,6 +52,7 @@ public class BgGraphBuilder {
public Viewport viewport;
//used for low resolution screen.
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
end_time = new Date().getTime() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
start_time = new Date().getTime() - (1000 * 60 * 60 * timespan); //timespan hours ago
@ -72,7 +73,6 @@ public class BgGraphBuilder {
this.basalBackgroundColor = basalBackgroundColor;
}
// TODO: use for ambient mode!
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, int basalBackgroundColor, int basalCenterColor, int timespan) {
end_time = new Date().getTime() + (1000 * 60 * 6 * timespan); //Now plus 30 minutes padding (for 5 hours. Less if less.)
start_time = new Date().getTime() - (1000 * 60 * 60 * timespan); //timespan hours ago

View file

@ -40,16 +40,6 @@ public class Home extends BaseWatchFace {
sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).commit();
}
protected void onWatchModeChanged(WatchMode watchMode) {
if (! sharedPrefs.getBoolean("dark", true)){
//in bright mode: different colours if active:
setColor();
} else {
//TODO: Handle low bit ambient
}
}
@Override
protected WatchFaceStyle getWatchFaceStyle(){
return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build();
@ -77,7 +67,7 @@ public class Home extends BaseWatchFace {
if (ageLevel == 1) {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home));
} else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
}
if (batteryLevel == 1) {
@ -95,12 +85,30 @@ public class Home extends BaseWatchFace {
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light);
singleLine = false;
pointSize = 2;
setupCharts();
}
}
protected void setColorLowRes() {
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));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_Timestamp));
if (chart != null) {
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark_lowres);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light_lowres);
pointSize = 2;
setupCharts();
}
}
protected void setColorBright() {
@ -142,7 +150,6 @@ public class Home extends BaseWatchFace {
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor);
basalBackgroundColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_light);
basalCenterColor = ContextCompat.getColor(getApplicationContext(), R.color.basal_dark);
singleLine = false;
pointSize = 2;
setupCharts();
}

View file

@ -16,7 +16,6 @@ public class LargeHome extends BaseWatchFace {
performViewSetup();
}
@Override
protected void setColorDark(){
mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout));
@ -39,7 +38,7 @@ public class LargeHome extends BaseWatchFace {
if (ageLevel == 1) {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp1_home));
} else {
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp));
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_TimestampOld));
}
if (batteryLevel == 1) {
@ -106,4 +105,17 @@ public class LargeHome extends BaseWatchFace {
mTime.setTextColor(Color.WHITE);
}
}
@Override
protected void setColorLowRes() {
mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), 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));
}
}

View file

@ -31,9 +31,9 @@
<color name="dark_statusView">@color/grey_50</color>
<color name="dark_background">@color/black</color>
<color name="dark_mLinearLayout">@color/grey_50</color>
<color name="dark_mTimestamp1">@color/grey_50</color>
<color name="dark_Timestamp">@color/grey_50</color>
<color name="dark_mTimestamp1_home">@color/black</color>
<color name="dark_mTimestamp">@color/red_600</color>
<color name="dark_TimestampOld">@color/red_600</color>
<color name="dark_uploaderBattery">@color/black</color>
<color name="dark_uploaderBatteryEmpty">@color/red_600</color>
<color name="dark_mStatus_home">@color/black</color>
@ -46,6 +46,8 @@
<!-- basal colors -->
<color name="basal_light">@color/blue_300</color>
<color name="basal_dark">@color/BLUE</color>
<color name="basal_light_lowres">@color/grey_300</color>
<color name="basal_dark_lowres">@color/grey_500</color>
<!-- Material Design - Color Palette -->