Skip to content

Commit

Permalink
Update Version 1.6
Browse files Browse the repository at this point in the history
New functions:
Add FoodDatabase
Add Factor Database by time
Import and export for factor db and food db
  • Loading branch information
Matze1985 committed Nov 5, 2017
1 parent 2ee19a7 commit 7827960
Show file tree
Hide file tree
Showing 25 changed files with 1,689 additions and 39 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Please check with a doctor previously!
It is not a officially approved medical application.

<b>Extra Tools:</b>
* Food database
* Factor database by time
* Converter for mg/dl and mmol/l

<a href="https://play.google.com/store/apps/details?id=de.crazyinfo.fpe_rechner"><img alt="Get it on Google Play" src="http://steverichey.github.io/google-play-badge-svg/img/en_get.svg" /></a>
Expand All @@ -16,4 +18,4 @@ It is not a officially approved medical application.
[**Donate with PayPal**](https://paypal.me/MathiasN)

## Logo
<img src="http://www.bilder-upload.eu/thumb/5ca473-1474374895.png" />
<img src="https://lh3.googleusercontent.com/pWqwcqNVEr6Bq62yDOyInSyywYPSEBf96MBEYm2MWlfd5UpG77INPvapMyJP8gOWeU2w=w150" />
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ android {
}
}
compileSdkVersion 25
buildToolsVersion "23.0.3"
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "de.crazyinfo.fpe_rechner"
minSdkVersion 15
targetSdkVersion 25
versionCode 10
versionName "1.5.2"
versionName "1.6.0"
signingConfig signingConfigs.config
}
buildTypes {
Expand All @@ -27,6 +27,6 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
}
23 changes: 23 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.crazyinfo.fpe_rechner">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar">

<activity android:name="de.crazyinfo.fpe_rechner.MainActivity">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.MAIN" />
Expand Down Expand Up @@ -36,6 +39,26 @@
android:value="de.crazyinfo.fpe_rechner.MainActivity" />
</activity>

<activity
android:name="de.crazyinfo.fpe_rechner.FoodShowActivity"
android:label="FoodShow"
android:theme="@style/Theme.AppCompat.NoActionBar">
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="de.crazyinfo.fpe_rechner.MainActivity" />
</activity>

<activity
android:name="de.crazyinfo.fpe_rechner.ManageFoodActivity"
android:label="ManageFood"
android:theme="@style/Theme.AppCompat.NoActionBar">
<!-- The meta-data element is needed for versions lower than 4.1 -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="de.crazyinfo.fpe_rechner.MainActivity" />
</activity>

<!-- ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information. -->
<meta-data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public void onClick(View v) {
}

/* Berechnungen */
Locale.setDefault(new Locale("en", "US")); // Punkt statt Komma verwenden
Locale.setDefault(new Locale("en", "US")); // Punkt statt Komma verwenden
mgdlSubResult = Math.abs(converter * 0.0555); // Teilergebnis mg/dl berechnen
String mgdlResult = String.format("%.1f", mgdlSubResult); // Ergebnis ohne Komma gerundet
mmollSubResult = Math.abs(converter * 18.0182); // Teilergebnis mmol/l berechnen
String mmollResult = String.format(Locale.ROOT, "%.0f", mmollSubResult); // Ergebnis mit Komma gerundet
String mmollResult = String.format(Locale.ROOT, "%.0f", mmollSubResult); // Ergebnis mit Komma gerundet

switch (v.getId()) {
case R.id.buttonMmoll:
Expand Down
66 changes: 66 additions & 0 deletions app/src/main/java/de/crazyinfo/fpe_rechner/FactorDatabase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package de.crazyinfo.fpe_rechner;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by l.boettcher on 28.09.2017.
*/

public class FactorDatabase extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "FactorDB.db";
private static final String TABLE_NAME = "Factor";
private static final String COL1 = "hour";
private static final String COL2 = "factor";


public FactorDatabase(Context context) {
super(context, DATABASE_NAME, null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + COL1 + " INTEGER PRIMARY KEY, " + COL2 + " REAL)");


}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {

}

public boolean addDataFactor(int Hour,String Factor){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(COL1, Hour);
contentValues.put(COL2, Factor);
long result = db.insert(TABLE_NAME, null, contentValues);

if (result == -1){
db.update(TABLE_NAME, contentValues, "hour = ?", new String[] {String.valueOf(Hour)});
return true;
} else {
return true;
}

}

public Cursor checkFactor(int Hour){
SQLiteDatabase db = this.getWritableDatabase();
Cursor res1 = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE hour = "+ Hour + ";",null);
return res1;
}

public Cursor getAllDataFactor() {
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("SELECT * FROM " + TABLE_NAME + ";", null);
return res;
}

}

70 changes: 70 additions & 0 deletions app/src/main/java/de/crazyinfo/fpe_rechner/FoodCalcDatabase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package de.crazyinfo.fpe_rechner;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
* Created by l.boettcher on 06.10.2017.
*/

public class FoodCalcDatabase extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "FoodCalcDB.db";
private static final String TABLE_NAME = "FoodCalc";
private static final String Col1 = "name";
private static final String Col2 = "cho";
private static final String Col3 = "kcal";

public FoodCalcDatabase(Context context) {
super(context, DATABASE_NAME, null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + Col1 + " TEXT, "+Col2+" REAL, "+Col3+" REAL"+")");
}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {

}

public boolean addFoodCalc(String NAME, String CHO, String KCAL){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(Col1, NAME);
contentValues.put(Col2, CHO);
contentValues.put(Col3, KCAL);
long result = db.insert(TABLE_NAME, null, contentValues);

return result != -1;

}

public Cursor getFoodCalc(long id){
SQLiteDatabase db = this.getWritableDatabase();
Cursor res1 = db.rawQuery("SELECT rowid _id, * FROM " + TABLE_NAME + " WHERE rowid = "+ id + ";",null);
return res1;
}

public boolean removeFoodCalc(String rowId){
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(TABLE_NAME,"rowid = " + rowId + ";", null) > 0;
}

public Cursor getAllFoodCalc() {
SQLiteDatabase db = this.getWritableDatabase();
Cursor resFood = db.rawQuery("SELECT rowid _id,* FROM " + TABLE_NAME + ";", null);
return resFood;
}

public void removeAllFoodCalc(){
SQLiteDatabase db = this.getWritableDatabase();
db.delete(TABLE_NAME,null,null);
db.execSQL("delete from "+ TABLE_NAME);
db.close();
}
}
114 changes: 114 additions & 0 deletions app/src/main/java/de/crazyinfo/fpe_rechner/FoodDatabase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package de.crazyinfo.fpe_rechner;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
* Created by l.boettcher on 04.10.2017.
*/

public class FoodDatabase extends SQLiteOpenHelper {

private static final String DATABASE_NAME = "FoodDB.db";
private static final String TABLE_NAME = "Food";
private static final String Col1 = "id";
private static final String Col2 = "name";
private static final String Col3 = "cho";
private static final String Col4 = "kcal";

public FoodDatabase(Context context) {
super(context, DATABASE_NAME, null, 1);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + Col1 + " INTEGER PRIMARY KEY AUTOINCREMENT, " + Col2 + " TEXT UNIQUE, "+Col3+" REAL, "+Col4+" REAL"+")");

Cursor res = db.rawQuery("select * from " + TABLE_NAME + ";", null);
if (res.getCount() == 0) {
ContentValues contentValues = new ContentValues();
contentValues.put(Col2, "Steak \uD83D\uDC37 100g");
contentValues.put(Col3, "0");
contentValues.put(Col4, "112");
db.insert(TABLE_NAME, null, contentValues);
}
}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {

}

public boolean addDataFood(String NAME, String CHO, String KCAL){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(Col2, NAME);
contentValues.put(Col3, CHO);
contentValues.put(Col4, KCAL);
long result = db.insert(TABLE_NAME, null, contentValues);

if (result == -1){
db.update(TABLE_NAME, contentValues, "name = ?", new String[] {String.valueOf(NAME)});
return true;
} else {
return true;
}

}

public boolean addFood(String NAME, String CHO, String KCAL){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(Col2, NAME);
contentValues.put(Col3, CHO);
contentValues.put(Col4, KCAL);
long result = db.insert(TABLE_NAME, null, contentValues);
return result != -1;

}

public boolean updateFood(long id, String NAME, String CHO, String KCAL){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put(Col2, NAME);
contentValues.put(Col3, CHO);
contentValues.put(Col4, KCAL);
db.update(TABLE_NAME, contentValues, "id = ?", new String[] {String.valueOf(id)});
return true;

}

public Cursor getFood(long id){
SQLiteDatabase db = this.getWritableDatabase();
Cursor res1 = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE id = "+ id + ";",null);
return res1;
}

public Cursor checkFood(String chkname){
SQLiteDatabase db = this.getWritableDatabase();
Cursor res1 = db.rawQuery("SELECT * FROM " + TABLE_NAME + " WHERE name = '"+ chkname + "';",null);
return res1;
}

public Cursor getAllFood() {
SQLiteDatabase db = this.getWritableDatabase();
//Cursor resFood = db.rawQuery("select rowid _id,* from " + TABLE_NAME + ";", null);
Cursor resFood = db.rawQuery("SELECT rowid _id,* FROM " + TABLE_NAME + " ORDER BY name;", null);
return resFood;
}

public Cursor getAllDataFood() {
SQLiteDatabase db = this.getWritableDatabase();
Cursor res = db.rawQuery("SELECT NAME, CHO, KCAL FROM " + TABLE_NAME + ";", null);
return res;
}

public boolean removeFood(long rowId){
SQLiteDatabase db = this.getWritableDatabase();
return db.delete(TABLE_NAME,"id = " + rowId + ";", null) > 0;
}
}
Loading

0 comments on commit 7827960

Please sign in to comment.