Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gen/
build/
/*/build/


# Local configuration file (sdk path, etc)
local.properties

Expand All @@ -43,3 +44,13 @@ Thumbs.db
.idea/dataSources.ids

.idea

#Technical Files
caches/
/caches/
wrapper/
/wrapper/
native/
/native/
daemon/
/daemon/
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
apply plugin: 'com.android.application'

android {
signingConfigs {
release {
}
}
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private boolean unloadFields() {
if (muscle_mass_required) measurement.setConvertedMuscleMass(Float.parseFloat(((EditText)findViewById(R.id.muscle_mass)).getText().toString()));
if (daily_calorie_intake_required) measurement.setDailyCalorieIntake(Short.parseShort(((EditText)findViewById(R.id.daily_calorie_intake)).getText().toString()));
if (physique_rating_required) measurement.setPhysiqueRating(Short.parseShort(((EditText)findViewById(R.id.physique_rating)).getText().toString()));
if (visceral_fat_rating_required) measurement.setVisceralFatRating(Short.parseShort(((EditText)findViewById(R.id.visceral_fat_rating)).getText().toString()));
if (visceral_fat_rating_required) measurement.setVisceralFatRating(Float.parseFloat(((EditText)findViewById(R.id.visceral_fat_rating)).getText().toString()));
if (bone_mass_required) measurement.setConvertedBoneMass(Float.parseFloat(((EditText)findViewById(R.id.bone_mass)).getText().toString()));
if (metabolic_age_required) measurement.setMetabolicAge(Short.parseShort(((EditText)findViewById(R.id.metabolic_age)).getText().toString()));
measurement.setExported(((CheckBox)findViewById(R.id.exported)).isChecked());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void onCreate(SQLiteDatabase db) {
// Create measurements table
db.execSQL("CREATE TABLE measurements (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,"
+ "weight REAL NOT NULL, body_fat REAL, body_water REAL, muscle_mass REAL,"
+ "daily_calorie_intake INTEGER, physique_rating INTEGER, visceral_fat_rating INTEGER,"
+ "daily_calorie_intake INTEGER, physique_rating INTEGER, visceral_fat_rating REAL,"
+ "bone_mass REAL, metabolic_age INTEGER, recorded_at INTEGER, exported INTEGER NOT NULL DEFAULT 0);"
+ "CREATE INDEX idx_recorded_at on measurements (recorded_at ASC);");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class Measurement {
private Float muscle_mass;
private Short daily_calorie_intake;
private Short physique_rating;
private Short visceral_fat_rating;
private Float visceral_fat_rating;
private Float bone_mass;
private Short metabolic_age;
private GregorianCalendar recorded_at = new GregorianCalendar();
Expand All @@ -89,7 +89,7 @@ public Measurement(Context context, boolean convert_to_lb, boolean muscle_mass_i
}

public Measurement(Context context, Integer id, Float weight, Float body_fat, Float body_water, Float muscle_mass, Short daily_calorie_intake,
Short physique_rating, Short visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported) {
Short physique_rating, Float visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported) {
this(context);
setId(id);
setWeight(weight);
Expand All @@ -106,19 +106,19 @@ public Measurement(Context context, Integer id, Float weight, Float body_fat, Fl
}

public Measurement(Context context, Integer id, Float weight, Float body_fat, Float body_water, Float muscle_mass, Short daily_calorie_intake,
Short physique_rating, Short visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported, boolean convert_to_lb, boolean muscle_mass_in_percent) {
Short physique_rating, Float visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported, boolean convert_to_lb, boolean muscle_mass_in_percent) {
this(context, id, weight, body_fat, body_water, muscle_mass, daily_calorie_intake, physique_rating, visceral_fat_rating, bone_mass, metabolic_age, recorded_at, exported);
this.convert_to_lb = convert_to_lb;
this.muscle_mass_in_percent = muscle_mass_in_percent;
}

public Measurement(Context context, Float weight, Float body_fat, Float body_water, Float muscle_mass, Short daily_calorie_intake,
Short physique_rating, Short visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported) {
Short physique_rating, Float visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported) {
this(context, null, weight, body_fat, body_water, muscle_mass, daily_calorie_intake, physique_rating, visceral_fat_rating, bone_mass, metabolic_age, recorded_at, exported);
}

public Measurement(Context context, Float weight, Float body_fat, Float body_water, Float muscle_mass, Short daily_calorie_intake,
Short physique_rating, Short visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported, boolean convert_to_lb, boolean muscle_mass_in_percent) {
Short physique_rating, Float visceral_fat_rating, Float bone_mass, Short metabolic_age, Long recorded_at, boolean exported, boolean convert_to_lb, boolean muscle_mass_in_percent) {
this(context, null, weight, body_fat, body_water, muscle_mass, daily_calorie_intake, physique_rating, visceral_fat_rating, bone_mass, metabolic_age, recorded_at, exported, convert_to_lb, muscle_mass_in_percent);
}
// Getters & setters
Expand Down Expand Up @@ -271,15 +271,15 @@ public void setPhysiqueRating(Short physique_rating) {
this.physique_rating = physique_rating;
}

public Short getVisceralFatRating() {
public Float getVisceralFatRating() {
return visceral_fat_rating;
}

public String getVisceralFatRatingInfo() {
return (visceral_fat_rating <= 12) ? context.getString(R.string.vfr_healthy) : context.getString(R.string.vfr_excess);
return (visceral_fat_rating <= 12.0f) ? context.getString(R.string.vfr_healthy) : context.getString(R.string.vfr_excess);
}

public void setVisceralFatRating(Short visceral_fat_rating) {
public void setVisceralFatRating(Float visceral_fat_rating) {
this.visceral_fat_rating = visceral_fat_rating;
}

Expand Down Expand Up @@ -529,7 +529,7 @@ static private Measurement getInstanceFromCursor(Context context, Cursor cursor)
(cursor.isNull(MUSCLE_MASS)) ? null : cursor.getFloat(MUSCLE_MASS),
(cursor.isNull(DAILY_CALORY_INTAKE)) ? null : cursor.getShort(DAILY_CALORY_INTAKE),
(cursor.isNull(PHYSIQUE_RATING)) ? null : cursor.getShort(PHYSIQUE_RATING),
(cursor.isNull(VISCERAL_FAT_RATING)) ? null : cursor.getShort(VISCERAL_FAT_RATING),
(cursor.isNull(VISCERAL_FAT_RATING)) ? null : cursor.getFloat(VISCERAL_FAT_RATING),
(cursor.isNull(BONE_MASS)) ? null : cursor.getFloat(BONE_MASS),
(cursor.isNull(METABOLIC_AGE)) ? null : cursor.getShort(METABOLIC_AGE),
cursor.getLong(RECORDED_AT),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
Expand Down Expand Up @@ -221,14 +222,14 @@ public void run() {
cal.add(Calendar.DATE, -40);

for (int i=0; i<40; i++){
new Measurement(getActivity(),
new Measurement((Context) getActivity(),
(70 + (int)(Math.random() * 110)/10.0f),
(15 + (int)(Math.random() * 70)/10.0f),
(50 + (int)(Math.random() * 210)/10.0f),
(50 + (int)(Math.random() * 210)/10.0f),
(short)(1500 + (int)(Math.random() * 20000)/10),
(short)(1 + (int)(Math.random() * 90)/10),
(short)(1 + (int)(Math.random() * 200)/10),
(1 + (int)(Math.random() * 200)/10.0f),
(2 + (int)(Math.random() * 50)/10.0f),
(short)(20 + (int)(Math.random() * 410)/10),
cal.getTimeInMillis(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static String buildFitFile(Context context, LinkedList<Measurement> measu
if(measurement.getDailyCalorieIntake() != null)
wm.setActiveMet((float) measurement.getDailyCalorieIntake());
wm.setPhysiqueRating(measurement.getPhysiqueRating());
wm.setVisceralFatRating(measurement.getVisceralFatRating());
wm.setVisceralFatRating((short) Math.round(measurement.getVisceralFatRating()));
wm.setBoneMass(measurement.getBoneMass());
wm.setMetabolicAge(measurement.getMetabolicAge());
encoder.write(wm);
Expand Down Expand Up @@ -100,7 +100,7 @@ public static String buildFitFileInAppDir(Context context, LinkedList<Measuremen
if(measurement.getDailyCalorieIntake() != null)
wm.setActiveMet((float) measurement.getDailyCalorieIntake());
wm.setPhysiqueRating(measurement.getPhysiqueRating());
wm.setVisceralFatRating(measurement.getVisceralFatRating());
wm.setVisceralFatRating((short) Math.round(measurement.getVisceralFatRating()));
wm.setBoneMass(measurement.getBoneMass());
wm.setMetabolicAge(measurement.getMetabolicAge());
encoder.write(wm);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/edit_measurement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<TableRow android:id="@+id/visceral_fat_rating_row" style="@style/EditTableRow">
<ImageView android:src="@drawable/ic_visceral_fat_rating" />
<TextView android:text="@string/visceral_fat_rating" style="@style/EditTableRowText" />
<EditText android:id="@+id/visceral_fat_rating" android:inputType="number" style="@style/EditTableRowEditText" />
<EditText android:id="@+id/visceral_fat_rating" android:inputType="numberDecimal" style="@style/EditTableRowEditText" />
</TableRow>

<TableRow android:id="@+id/bone_mass_row" style="@style/EditTableRow">
Expand Down