wear active-inactive mode
This commit is contained in:
parent
d7eacde0a4
commit
d53217dfe0
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -31,6 +31,7 @@ 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;
|
||||
|
@ -54,6 +55,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
public int highColor = Color.YELLOW;
|
||||
public int lowColor = Color.RED;
|
||||
public int midColor = Color.WHITE;
|
||||
public int gridColour = Color.WHITE;
|
||||
public int pointSize = 2;
|
||||
public boolean singleLine = false;
|
||||
public boolean layoutSet = false;
|
||||
|
@ -158,6 +160,17 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
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();
|
||||
|
@ -477,13 +490,11 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTimestamp));
|
||||
}
|
||||
|
||||
if (batteryLevel == 1) {
|
||||
} else {
|
||||
}
|
||||
if (chart != null) {
|
||||
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor);
|
||||
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor);
|
||||
midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
|
||||
gridColour = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
|
||||
singleLine = false;
|
||||
pointSize = 2;
|
||||
setupCharts();
|
||||
|
@ -522,37 +533,13 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
highColor = ContextCompat.getColor(getApplicationContext(), R.color.light_highColor);
|
||||
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor);
|
||||
midColor = ContextCompat.getColor(getApplicationContext(), R.color.light_midColor);
|
||||
gridColour = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor);
|
||||
singleLine = false;
|
||||
pointSize = 2;
|
||||
setupCharts();
|
||||
}
|
||||
} else {
|
||||
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_inter_mTime));
|
||||
mTimestamp.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_inter_mTimestamp));
|
||||
statusView.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_inter_statusView));
|
||||
mRelativeLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.light_inter_mRelativeLayout));
|
||||
if (sgvLevel == 1) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_highColor));
|
||||
} else if (sgvLevel == 0) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_midColor));
|
||||
} else if (sgvLevel == -1) {
|
||||
mSgv.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
|
||||
mDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
|
||||
mAvgDelta.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor));
|
||||
}
|
||||
|
||||
if (chart != null) {
|
||||
highColor = ContextCompat.getColor(getApplicationContext(), R.color.light_highColor_inter);
|
||||
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor_inter);
|
||||
midColor = ContextCompat.getColor(getApplicationContext(), R.color.light_midColor_inter);
|
||||
singleLine = true;
|
||||
pointSize = 2;
|
||||
setupCharts();
|
||||
}
|
||||
setColorDark();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -608,9 +595,9 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre
|
|||
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) {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColour, timeframe);
|
||||
} else {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColour, timeframe);
|
||||
}
|
||||
|
||||
chart.setLineChartData(bgGraphBuilder.lineData());
|
||||
|
|
|
@ -50,6 +50,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
public int highColor = Color.YELLOW;
|
||||
public int lowColor = Color.RED;
|
||||
public int midColor = Color.WHITE;
|
||||
public int gridColor = Color.WHITE;
|
||||
public int pointSize = 2;
|
||||
public boolean singleLine = false;
|
||||
public boolean layoutSet = false;
|
||||
|
@ -386,9 +387,9 @@ protected abstract void setColorDark();
|
|||
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) {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, midColor, gridColor, timeframe);
|
||||
} else {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, timeframe);
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), bgDataList, tempWatchDataList, basalWatchDataList, pointSize, highColor, lowColor, midColor, gridColor, timeframe);
|
||||
}
|
||||
|
||||
chart.setLineChartData(bgGraphBuilder.lineData());
|
||||
|
|
|
@ -40,6 +40,7 @@ public class BgGraphBuilder {
|
|||
public int highColor;
|
||||
public int lowColor;
|
||||
public int midColor;
|
||||
public int gridColour;
|
||||
public boolean singleLine = false;
|
||||
|
||||
private double endHour;
|
||||
|
@ -49,7 +50,7 @@ public class BgGraphBuilder {
|
|||
public Viewport viewport;
|
||||
|
||||
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int timespan) {
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aMidColor, int gridColour, 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
|
||||
this.bgDataList = aBgList;
|
||||
|
@ -64,9 +65,10 @@ public class BgGraphBuilder {
|
|||
this.timespan = timespan;
|
||||
this.tempWatchDataList = tempWatchDataList;
|
||||
this.basalWatchDataList = basalWatchDataList;
|
||||
this.gridColour = gridColour;
|
||||
}
|
||||
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int timespan) {
|
||||
public BgGraphBuilder(Context context, List<BgWatchData> aBgList, List<TempWatchData> tempWatchDataList, ArrayList<BasalWatchData> basalWatchDataList, int aPointSize, int aHighColor, int aLowColor, int aMidColor, int gridColour, 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
|
||||
this.bgDataList = aBgList;
|
||||
|
@ -80,6 +82,7 @@ public class BgGraphBuilder {
|
|||
this.timespan = timespan;
|
||||
this.tempWatchDataList = tempWatchDataList;
|
||||
this.basalWatchDataList = basalWatchDataList;
|
||||
this.gridColour = gridColour;
|
||||
}
|
||||
|
||||
public LineChartData lineData() {
|
||||
|
@ -190,7 +193,6 @@ public class BgGraphBuilder {
|
|||
Line inRangeValuesLine = new Line(inRangeValues);
|
||||
inRangeValuesLine.setColor(midColor);
|
||||
if(singleLine) {
|
||||
inRangeValuesLine.setHasLines(true);
|
||||
inRangeValuesLine.setHasLines(true);
|
||||
inRangeValuesLine.setHasPoints(false);
|
||||
inRangeValuesLine.setStrokeWidth(pointSize);
|
||||
|
@ -292,15 +294,7 @@ public class BgGraphBuilder {
|
|||
List<AxisValue> axisValues = new ArrayList<AxisValue>();
|
||||
yAxis.setValues(axisValues);
|
||||
yAxis.setHasLines(false);
|
||||
boolean themecolor = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("dark", true);
|
||||
if (themecolor) {
|
||||
yAxis.setLineColor(ContextCompat.getColor(context, R.color.yaxis_gridline_dark));
|
||||
yAxis.setTextColor(ContextCompat.getColor(context, R.color.yaxis_txt_dark));
|
||||
}
|
||||
else {
|
||||
yAxis.setLineColor(ContextCompat.getColor(context, R.color.yaxis_gridline_light));
|
||||
yAxis.setTextColor(ContextCompat.getColor(context, R.color.yaxis_txt_light));
|
||||
}
|
||||
yAxis.setLineColor(gridColour);
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
|
@ -341,15 +335,9 @@ public class BgGraphBuilder {
|
|||
xAxis.setValues(xAxisValues);
|
||||
xAxis.setTextSize(10);
|
||||
xAxis.setHasLines(true);
|
||||
boolean themecolor = PreferenceManager.getDefaultSharedPreferences(context).getBoolean("dark", true);
|
||||
if (themecolor) {
|
||||
xAxis.setLineColor(ContextCompat.getColor(context, R.color.xaxis_gridline_dark));
|
||||
xAxis.setTextColor(ContextCompat.getColor(context, R.color.xaxis_txt_dark));
|
||||
}
|
||||
else {
|
||||
xAxis.setLineColor(ContextCompat.getColor(context, R.color.xaxis_gridline_light));
|
||||
xAxis.setTextColor(ContextCompat.getColor(context, R.color.xaxis_txt_light));
|
||||
}
|
||||
xAxis.setLineColor(gridColour);
|
||||
xAxis.setTextColor(gridColour);
|
||||
|
||||
return xAxis;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,15 @@ package info.nightscout.androidaps;
|
|||
|
||||
import android.graphics.Color;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.wearable.watchface.WatchFaceStyle;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.ustwo.clockwise.common.WatchMode;
|
||||
|
||||
public class Home extends BaseWatchFace {
|
||||
|
||||
private long chartTapTime = 0;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
@ -16,6 +19,43 @@ public class Home extends BaseWatchFace {
|
|||
performViewSetup();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTapCommand(int tapType, int x, int y, long eventTime) {
|
||||
|
||||
if (tapType == TAP_TYPE_TAP&&
|
||||
x >=chart.getLeft() &&
|
||||
x <= chart.getRight()&&
|
||||
y >= chart.getTop() &&
|
||||
y <= chart.getBottom()){
|
||||
if (eventTime - chartTapTime < 800){
|
||||
changeChartTimeframe();
|
||||
}
|
||||
chartTapTime = eventTime;
|
||||
}
|
||||
}
|
||||
|
||||
private void changeChartTimeframe() {
|
||||
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
|
||||
timeframe = (timeframe%5) + 1;
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
protected void setColorDark() {
|
||||
mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_statusView));
|
||||
mTime.setTextColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mTime));
|
||||
|
@ -52,6 +92,8 @@ public class Home extends BaseWatchFace {
|
|||
highColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_highColor);
|
||||
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_lowColor);
|
||||
midColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor);
|
||||
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.dark_gridColor);
|
||||
|
||||
singleLine = false;
|
||||
pointSize = 2;
|
||||
setupCharts();
|
||||
|
@ -96,39 +138,13 @@ public class Home extends BaseWatchFace {
|
|||
highColor = ContextCompat.getColor(getApplicationContext(), R.color.light_highColor);
|
||||
lowColor = ContextCompat.getColor(getApplicationContext(), R.color.light_lowColor);
|
||||
midColor = ContextCompat.getColor(getApplicationContext(), R.color.light_midColor);
|
||||
gridColor = ContextCompat.getColor(getApplicationContext(), R.color.light_gridColor);
|
||||
singleLine = false;
|
||||
pointSize = 2;
|
||||
setupCharts();
|
||||
}
|
||||
} else {
|
||||
mRelativeLayout.setBackgroundColor(Color.BLACK);
|
||||
mLinearLayout.setBackgroundColor(Color.WHITE);
|
||||
if (sgvLevel == 1) {
|
||||
mSgv.setTextColor(Color.YELLOW);
|
||||
mDirection.setTextColor(Color.YELLOW);
|
||||
mDelta.setTextColor(Color.YELLOW);
|
||||
} else if (sgvLevel == 0) {
|
||||
mSgv.setTextColor(Color.WHITE);
|
||||
mDirection.setTextColor(Color.WHITE);
|
||||
mDelta.setTextColor(Color.WHITE);
|
||||
} else if (sgvLevel == -1) {
|
||||
mSgv.setTextColor(Color.RED);
|
||||
mDirection.setTextColor(Color.RED);
|
||||
mDelta.setTextColor(Color.RED);
|
||||
}
|
||||
mStatus.setTextColor(Color.BLACK);
|
||||
mUploaderBattery.setTextColor(Color.BLACK);
|
||||
mTimestamp.setTextColor(Color.BLACK);
|
||||
|
||||
mTime.setTextColor(Color.WHITE);
|
||||
if (chart != null) {
|
||||
highColor = Color.YELLOW;
|
||||
midColor = Color.WHITE;
|
||||
lowColor = Color.RED;
|
||||
singleLine = true;
|
||||
pointSize = 2;
|
||||
setupCharts();
|
||||
}
|
||||
setColorDark();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
<color name="light_highColor_inter">@color/yellow_700</color>
|
||||
<color name="light_lowColor_inter">@color/red_600</color>
|
||||
<color name="light_midColor_inter">@color/grey_50</color>
|
||||
<color name="light_gridColor">@color/black</color>
|
||||
|
||||
|
||||
<!-- dark colors -->
|
||||
<color name="dark_mTime">@color/grey_50</color>
|
||||
|
@ -36,19 +38,10 @@
|
|||
<color name="dark_uploaderBatteryEmpty">@color/red_600</color>
|
||||
<color name="dark_mStatus_home">@color/black</color>
|
||||
|
||||
<color name="dark_highColor">@color/yellow_700</color>
|
||||
<color name="dark_lowColor">@color/red_600</color>
|
||||
<color name="dark_highColor">@color/yellow_A200</color>
|
||||
<color name="dark_lowColor">@color/RED</color>
|
||||
<color name="dark_midColor">@color/grey_50</color>
|
||||
|
||||
<!-- graph colors -->
|
||||
<color name="xaxis_gridline_dark">@color/grey_50</color>
|
||||
<color name="xaxis_txt_dark">@color/grey_50</color>
|
||||
<color name="yaxis_gridline_dark">@color/grey_50</color>
|
||||
<color name="yaxis_txt_dark">@color/grey_50</color>
|
||||
<color name="xaxis_gridline_light">@color/black</color>
|
||||
<color name="xaxis_txt_light">@color/black</color>
|
||||
<color name="yaxis_gridline_light">@color/black</color>
|
||||
<color name="yaxis_txt_light">@color/black</color>
|
||||
<color name="dark_gridColor">@color/grey_50</color>
|
||||
|
||||
<!-- basal colors -->
|
||||
<color name="basalLine_primary">@color/blue_300</color>
|
||||
|
@ -72,6 +65,7 @@
|
|||
<color name="red_A200">#FF5252</color>
|
||||
<color name="red_A400">#FF1744</color>
|
||||
<color name="red_A700">#D50000</color>
|
||||
<color name="RED">#FF0000</color>
|
||||
<!-- Red -->
|
||||
|
||||
<!-- Pink -->
|
||||
|
|
Loading…
Reference in a new issue