Skip to content

Commit

Permalink
Merge branch 'feature/#14'
Browse files Browse the repository at this point in the history
  • Loading branch information
warmsound committed Mar 31, 2018
2 parents bd96567 + 3dd5994 commit 8d57010
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 10 deletions.
2 changes: 2 additions & 0 deletions resources-approachs60/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<!--listEntry value="1">@Strings.FloorsClimbed</listEntry-->
<listEntry value="2">@Strings.ActiveMinutes</listEntry>
<listEntry value="-1">@Strings.Battery</listEntry>
<listEntry value="-2">@Strings.CaloriesManualGoal</listEntry>
</settingConfig>
</setting>

Expand All @@ -15,6 +16,7 @@
<!--listEntry value="1">@Strings.FloorsClimbed</listEntry-->
<listEntry value="2">@Strings.ActiveMinutes</listEntry>
<listEntry value="-1">@Strings.Battery</listEntry>
<listEntry value="-2">@Strings.CaloriesManualGoal</listEntry>
</settingConfig>
</setting>

Expand Down
2 changes: 2 additions & 0 deletions resources-fr735xt/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<!--listEntry value="1">@Strings.FloorsClimbed</listEntry-->
<listEntry value="2">@Strings.ActiveMinutes</listEntry>
<listEntry value="-1">@Strings.Battery</listEntry>
<listEntry value="-2">@Strings.CaloriesManualGoal</listEntry>
</settingConfig>
</setting>

Expand All @@ -28,6 +29,7 @@
<!--listEntry value="1">@Strings.FloorsClimbed</listEntry-->
<listEntry value="2">@Strings.ActiveMinutes</listEntry>
<listEntry value="-1">@Strings.Battery</listEntry>
<listEntry value="-2">@Strings.CaloriesManualGoal</listEntry>
</settingConfig>
</setting>

Expand Down
2 changes: 1 addition & 1 deletion resources-small-icons/fonts/crystal-icons-small.fnt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ char id=50 x=42 y=0 width=20 height=20 xoffset=0 yoffset=0
char id=51 x=63 y=0 width=20 height=20 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15
char id=52 x=84 y=0 width=24 height=20 xoffset=0 yoffset=0 xadvance=24 page=0 chnl=15
char id=53 x=109 y=0 width=20 height=20 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15
char id=54 x=130 y=0 width=12 height=20 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=15
char id=54 x=130 y=0 width=12 height=20 xoffset=4 yoffset=0 xadvance=20 page=0 chnl=15
char id=55 x=143 y=0 width=18 height=20 xoffset=0 yoffset=0 xadvance=18 page=0 chnl=15
char id=56 x=162 y=0 width=15 height=20 xoffset=0 yoffset=0 xadvance=15 page=0 chnl=15
char id=57 x=178 y=0 width=20 height=20 xoffset=0 yoffset=0 xadvance=20 page=0 chnl=15
2 changes: 1 addition & 1 deletion resources/fonts/crystal-icons.fnt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ char id=50 x=47 y=0 width=24 height=24 xoffset=0 yoffset=0
char id=51 x=72 y=0 width=24 height=24 xoffset=0 yoffset=0 xadvance=24 page=0 chnl=15
char id=52 x=97 y=0 width=28 height=24 xoffset=0 yoffset=0 xadvance=28 page=0 chnl=15
char id=53 x=126 y=0 width=24 height=24 xoffset=0 yoffset=0 xadvance=24 page=0 chnl=15
char id=54 x=151 y=0 width=14 height=24 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=15
char id=54 x=151 y=0 width=14 height=24 xoffset=5 yoffset=0 xadvance=24 page=0 chnl=15
char id=55 x=166 y=0 width=22 height=24 xoffset=0 yoffset=0 xadvance=22 page=0 chnl=15
char id=56 x=189 y=0 width=18 height=24 xoffset=0 yoffset=0 xadvance=18 page=0 chnl=15
char id=57 x=208 y=0 width=24 height=24 xoffset=0 yoffset=0 xadvance=24 page=0 chnl=15
1 change: 1 addition & 0 deletions resources/settings/properties.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<property id="LeftGoalType" type="number">0</property>
<property id="RightGoalType" type="number">1</property>
<property id="CaloriesGoal" type="number">2000</property>

<property id="LeftFieldType" type="number">0</property>
<property id="CenterFieldType" type="number">1</property>
Expand Down
6 changes: 6 additions & 0 deletions resources/settings/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<listEntry value="1">@Strings.FloorsClimbed</listEntry>
<listEntry value="2">@Strings.ActiveMinutes</listEntry>
<listEntry value="-1">@Strings.Battery</listEntry>
<listEntry value="-2">@Strings.CaloriesManualGoal</listEntry>
</settingConfig>
</setting>

Expand All @@ -29,9 +30,14 @@
<listEntry value="1">@Strings.FloorsClimbed</listEntry>
<listEntry value="2">@Strings.ActiveMinutes</listEntry>
<listEntry value="-1">@Strings.Battery</listEntry>
<listEntry value="-2">@Strings.CaloriesManualGoal</listEntry>
</settingConfig>
</setting>

<setting propertyKey="@Properties.CaloriesGoal" title="@Strings.CaloriesGoalTitle">
<settingConfig type="numeric" min="1" max="10000" required="true"/>
</setting>

<setting propertyKey="@Properties.LeftFieldType" title="@Strings.LeftDataFieldTitle">
<settingConfig type="list">
<listEntry value="0">@Strings.HeartRate</listEntry>
Expand Down
2 changes: 2 additions & 0 deletions resources/strings/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<string id="ThemeTitle">Theme</string>
<string id="LeftGoalMeterTitle">Left Meter</string>
<string id="RightGoalMeterTitle">Right Meter</string>
<string id="CaloriesGoalTitle">Calories Goal (1-10,000kCal)</string>
<string id="AlwaysShowMoveBarTitle">Always Show Move Bar</string>
<string id="HideSecondsTitle">Hide Seconds</string>
<string id="LeftDataFieldTitle">Left Data Field</string>
Expand All @@ -28,6 +29,7 @@
<string id="Steps">Steps</string>
<string id="FloorsClimbed">Floors Climbed</string>
<string id="ActiveMinutes">Active Minutes (Weekly)</string>
<string id="CaloriesManualGoal">Calories (Manual Goal)</string>

<string id="HeartRate">Heart Rate</string>
<string id="Battery">Battery</string>
Expand Down
20 changes: 14 additions & 6 deletions source/CrystalView.mc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class CrystalView extends Ui.WatchFace {
App.GOAL_TYPE_FLOORS_CLIMBED => :GOAL_TYPE_FLOORS_CLIMBED,
App.GOAL_TYPE_ACTIVE_MINUTES => :GOAL_TYPE_ACTIVE_MINUTES,

-1 => :GOAL_TYPE_BATTERY
-1 => :GOAL_TYPE_BATTERY,
-2 => :GOAL_TYPE_CALORIES
};

private var FIELD_TYPES = {
Expand All @@ -41,6 +42,7 @@ class CrystalView extends Ui.WatchFace {
:FIELD_TYPE_BATTERY => "4",
:FIELD_TYPE_NOTIFICATIONS => "5",
:FIELD_TYPE_CALORIES => "6",
:GOAL_TYPE_CALORIES => "6", // Use calories icon for both field and goal.
:FIELD_TYPE_DISTANCE => "7",
:INDICATOR_BLUETOOTH => "8",
:GOAL_TYPE_BATTERY => "9"
Expand Down Expand Up @@ -207,8 +209,8 @@ class CrystalView extends Ui.WatchFace {
}

function fillBatteryMeter(dc, batteryIcon) {
// #8: battery returned as float. Use ceil() for optimistic values. Must match getDisplayInfoForFieldType().
var batteryLevel = Math.ceil(Sys.getSystemStats().battery);
// #8: battery returned as float. Use floor() to match native. Must match getDisplayInfoForFieldType().
var batteryLevel = Math.floor(Sys.getSystemStats().battery);
var colour;
var fillWidth, fillHeight;

Expand Down Expand Up @@ -303,8 +305,8 @@ class CrystalView extends Ui.WatchFace {
break;

case :FIELD_TYPE_BATTERY:
// #8: battery returned as float. Use ceil() for optimistic values. Must match fillBatteryMeter().
battery = Math.ceil(Sys.getSystemStats().battery);
// #8: battery returned as float. Use floor() to match native. Must match fillBatteryMeter().
battery = Math.floor(Sys.getSystemStats().battery);
value = battery.format("%d") + "%";
break;

Expand Down Expand Up @@ -443,9 +445,15 @@ class CrystalView extends Ui.WatchFace {
break;

case :GOAL_TYPE_BATTERY:
values[:current] = Math.ceil(Sys.getSystemStats().battery);
// #8: floor() battery to be consistent.
values[:current] = Math.floor(Sys.getSystemStats().battery);
values[:max] = 100;
break;

case :GOAL_TYPE_CALORIES:
values[:current] = info.calories;
values[:max] = App.getApp().getProperty("CaloriesGoal");
break;
}

return values;
Expand Down
5 changes: 3 additions & 2 deletions source/GoalMeter.mc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class GoalMeter extends Ui.Drawable {

// Draw filled segments.
clipBottom = dcHeight - top;
clipTop = clipBottom - mFillHeight - 1;
clipTop = clipBottom - mFillHeight;
clipHeight = clipBottom - clipTop;

if (clipHeight > 0) {
Expand Down Expand Up @@ -252,7 +252,7 @@ class GoalMeter extends Ui.Drawable {
totalSegmentHeight += segments[i];
}

var remainingFillHeight = Math.round((mCurrentValue * 1.0 / mMaxValue) * totalSegmentHeight); // Excluding separators.
var remainingFillHeight = Math.floor((mCurrentValue * 1.0 / mMaxValue) * totalSegmentHeight); // Excluding separators.
fillHeight = remainingFillHeight;

for (i = 0; i < segments.size(); ++i) {
Expand All @@ -264,6 +264,7 @@ class GoalMeter extends Ui.Drawable {
}
}

Sys.println("fillHeight " + fillHeight);
return fillHeight;
}

Expand Down

0 comments on commit 8d57010

Please sign in to comment.