Last active
December 17, 2015 16:09
-
-
Save Klowner/5637105 to your computer and use it in GitHub Desktop.
MyFitnessPal Android app patch to fix weekly caloric average graph to be consistent with iPhone app (factors in negative net daily values).
Also adds display of daily caloric average on weekly report.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- com.myfitnesspal.android-original/assets/stats_graph.html 2013-05-23 00:40:12.349331184 -0500 | |
+++ com.myfitnesspal.android/assets/stats_graph.html 2013-05-23 09:45:21.899270466 -0500 | |
@@ -51,6 +51,20 @@ | |
font-size: 0.9em; | |
} | |
+#avgCaloriesAmount { | |
+ display: inline; | |
+ font-size: 0.8em; | |
+ text-align: center; | |
+} | |
+ | |
+#avgCalorieComment { | |
+ display: inline; | |
+ color: #242424; | |
+ font-weight: normal; | |
+ text-align: center; | |
+ font-size: 0.8em; | |
+} | |
+ | |
#tooltip { | |
font-size: 20px; | |
} | |
@@ -239,6 +253,8 @@ | |
} | |
$("#netCalorieComment").css(cssObj1); | |
$("#netCaloriesAmount").css(cssObj1); | |
+ $("#avgCalorieComment").css(cssObj1); | |
+ $("#avgCaloriesAmount").css(cssObj1); | |
} | |
/** | |
@@ -274,6 +290,7 @@ | |
} | |
$("#netCaloriesAmount").html(Math.round(Math.abs(caloriesUnderGoal))); | |
+ $("#avgCaloriesAmount").html(Math.round(avg)); | |
var d2 = buildLineArray(cutOff); | |
@@ -489,6 +506,9 @@ | |
<center> | |
<div id="netCaloriesAmount">5000</div> | |
<div id="netCalorieComment">Net Calories Under Weekly Goal.</div> | |
+ <br/> | |
+ <div id="avgCaloriesAmount">1000</div> | |
+ <div id="avgCalorieComment">Daily Average.</div> | |
</center> | |
</div> | |
Only in com.myfitnesspal.android: build | |
Only in com.myfitnesspal.android: dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
net_caloric_avg_fix.patch | |
ProgressReport->valuesUsedToCalculateAverageWeeklyNetCalories() is currently | |
calculated using all DiaryDay->netCalories() values which are >0, this causes incorrect | |
results on days where netCalories < 0 due to exercise. | |
This patch changes the condition to check each DiaryDay->caloriesConsumed() > 0 and | |
then appends DiaryDay->netCalories() to the array for calculating the average weekly net calories. | |
This behavior is consistent with the iPhone version, and reflects the note at the bottom of the | |
report stating "Average daily net calories consumed calculation only includes days where atleast | |
one food item has been added to your diary." | |
display_avg_calories_on_weekly_report.patch | |
Adds average daily caloric values to bottom of weekly report for convenience. | |
Instructions: | |
Grab apk from device. | |
→ $ adb pull /data/app/com.myfitnesspal.android-2.apk ) | |
Decode apk using apktool. | |
→ $ apktool d com.myfitnesspal.android-2.apk com.myfitnesspal.android-2 | |
Apply patches | |
→ $ cd com.myfitnesspal.android-2 | |
→ $ patch -p1 < ../fixes.patch | |
Rebuild apk (I needed to manually provide the path for aapt) | |
→ $ apktool b -a /opt/android-sdk/build-tools/17.0.0/aapt | |
Generate signing keys if you don't have them. | |
→ Reference: http://developer.android.com/tools/publishing/app-signing.html | |
→ $ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 | |
Sign rebuilt apk | |
→ $ cd dist | |
→ $ jarsigner -sigalg MD5withRSA -digestalg SHA1 com.myfitnesspal.android-2.apk alias_name | |
Verify signing result (optional) | |
→ $ jarsigner -verify com.myfitnesspal.android-2.apk | |
Zipalign apk | |
→ $ zipalign -v 4 com.myfitnesspal.android-2.apk com.myfitnesspal.android-2-za.apk | |
Uninstall original app from device (signing key has changed, android dislikes this) | |
Install new apk to device | |
→ $ adb install com.myfitnesspal.android-2-za.apk | |
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- com.myfitnesspal.android-2.orig/smali/com/myfitnesspal/android/models/ProgressReport.smali 2013-05-23 17:37:35.338803978 -0500 | |
+++ com.myfitnesspal.android-2/smali/com/myfitnesspal/android/models/ProgressReport.smali 2013-05-23 23:08:57.478640821 -0500 | |
@@ -1192,7 +1192,7 @@ | |
move-result-object v4 | |
.line 207 | |
- invoke-virtual {v4}, Lcom/myfitnesspal/android/models/DiaryDay;->netCalories()F | |
+ invoke-virtual {v4}, Lcom/myfitnesspal/android/models/DiaryDay;->caloriesConsumed()F | |
move-result v0 | |
@@ -1204,6 +1204,10 @@ | |
if-lez v9, :cond_0 | |
+ .line 209 | |
+ invoke-virtual {v4}, Lcom/myfitnesspal/android/models/DiaryDay;->netCalories()F | |
+ move-result v0 | |
+ | |
.line 210 | |
iget-object v9, p0, Lcom/myfitnesspal/android/models/ProgressReport;->valuesUsedToCalculateAverageWeeklyNetCalories:Ljava/util/ArrayList; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment