diff --git a/android_app/AndroidManifest.xml b/android_app/AndroidManifest.xml
deleted file mode 100644
index 6d6ecd49..00000000
--- a/android_app/AndroidManifest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android_app/libs/android-support-v4.jar b/android_app/libs/android-support-v4.jar
deleted file mode 100644
index f48d0dab..00000000
Binary files a/android_app/libs/android-support-v4.jar and /dev/null differ
diff --git a/android_app/libs/hellocharts-library-1.2.jar b/android_app/libs/hellocharts-library-1.2.jar
deleted file mode 100644
index f73a0c99..00000000
Binary files a/android_app/libs/hellocharts-library-1.2.jar and /dev/null differ
diff --git a/android_app/proguard-project.txt b/android_app/proguard-project.txt
deleted file mode 100644
index f2fe1559..00000000
--- a/android_app/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/android_app/project.properties b/android_app/project.properties
deleted file mode 100644
index f2abc482..00000000
--- a/android_app/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-android.library.reference.1=../appcompat_v7
-# Project target.
-target=android-21
diff --git a/android_app/res/drawable/flat_selector.xml b/android_app/res/drawable/flat_selector.xml
deleted file mode 100644
index 6e9fe6c4..00000000
--- a/android_app/res/drawable/flat_selector.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/android_app/res/drawable/ic_launcher.png b/android_app/res/drawable/ic_launcher.png
deleted file mode 100644
index ddd810cf..00000000
Binary files a/android_app/res/drawable/ic_launcher.png and /dev/null differ
diff --git a/android_app/res/drawable/rect_normal.xml b/android_app/res/drawable/rect_normal.xml
deleted file mode 100644
index 08cb20d6..00000000
--- a/android_app/res/drawable/rect_normal.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android_app/res/drawable/rect_pressed.xml b/android_app/res/drawable/rect_pressed.xml
deleted file mode 100644
index 2cc15774..00000000
--- a/android_app/res/drawable/rect_pressed.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
diff --git a/android_app/res/layout/activity_main.xml b/android_app/res/layout/activity_main.xml
deleted file mode 100644
index e12ea797..00000000
--- a/android_app/res/layout/activity_main.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
diff --git a/android_app/res/layout/activity_newentry.xml b/android_app/res/layout/activity_newentry.xml
deleted file mode 100644
index 63d45582..00000000
--- a/android_app/res/layout/activity_newentry.xml
+++ /dev/null
@@ -1,189 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android_app/res/layout/fragment_graph.xml b/android_app/res/layout/fragment_graph.xml
deleted file mode 100644
index be01e97e..00000000
--- a/android_app/res/layout/fragment_graph.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/android_app/res/layout/fragment_overview.xml b/android_app/res/layout/fragment_overview.xml
deleted file mode 100644
index 583d5aac..00000000
--- a/android_app/res/layout/fragment_overview.xml
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android_app/res/layout/fragment_table.xml b/android_app/res/layout/fragment_table.xml
deleted file mode 100644
index 443b1f21..00000000
--- a/android_app/res/layout/fragment_table.xml
+++ /dev/null
@@ -1,111 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/android_app/res/menu/main.xml b/android_app/res/menu/main.xml
deleted file mode 100644
index 1a99c9e4..00000000
--- a/android_app/res/menu/main.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
diff --git a/android_app/res/values-v14/styles.xml b/android_app/res/values-v14/styles.xml
deleted file mode 100644
index 664f4f16..00000000
--- a/android_app/res/values-v14/styles.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
diff --git a/android_app/res/values/colors.xml b/android_app/res/values/colors.xml
deleted file mode 100644
index 243b10a2..00000000
--- a/android_app/res/values/colors.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- @android:color/holo_blue_dark
- @android:color/holo_blue_light
-
diff --git a/android_app/res/values/dimens.xml b/android_app/res/values/dimens.xml
deleted file mode 100644
index 176dff25..00000000
--- a/android_app/res/values/dimens.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- 16dp
- 16dp
- 4dp
- 3dp
-
-
diff --git a/android_app/res/values/strings.xml b/android_app/res/values/strings.xml
deleted file mode 100644
index 9fba0dbd..00000000
--- a/android_app/res/values/strings.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
- openScale
- overview
- graph
- table
- Settings
-
-
diff --git a/android_app/res/values/styles.xml b/android_app/res/values/styles.xml
deleted file mode 100644
index 845fb572..00000000
--- a/android_app/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/android_app/res/xml/preferences.xml b/android_app/res/xml/preferences.xml
deleted file mode 100644
index 92449654..00000000
--- a/android_app/res/xml/preferences.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/android_app/src/com/health/openscale/core/BluetoothCommunication.java b/android_app/src/com/health/openscale/core/BluetoothCommunication.java
deleted file mode 100644
index 6d7c49d6..00000000
--- a/android_app/src/com/health/openscale/core/BluetoothCommunication.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.core;
-
-import java.io.IOException;
-import java.util.Set;
-import java.util.UUID;
-
-import android.bluetooth.BluetoothAdapter;
-import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothSocket;
-import android.os.Handler;
-import android.os.Message;
-import android.provider.SyncStateContract.Constants;
-import android.support.v4.app.FragmentActivity;
-import android.util.Log;
-
-public class BluetoothCommunication extends Thread {
- public static final int BT_MESSAGE_READ = 0;
- public static final int BT_SOCKET_CLOSED = 1;
- public static final int BT_NO_ADAPTER = 2;
- private final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb"); // Standard SerialPortService ID
-
- private BluetoothSocket btSocket;
- private BluetoothDevice btDevice;
- private BluetoothAdapter btAdapter;
- private Handler btHandler;
- private volatile boolean isCancel;
-
- public BluetoothCommunication(Handler handler) {
- btHandler = handler;
- isCancel = false;
- }
-
- void findBT(String deviceName) throws IOException {
- btAdapter = BluetoothAdapter.getDefaultAdapter();
-
- if (btAdapter == null) {
- btHandler.obtainMessage(BluetoothCommunication.BT_NO_ADAPTER).sendToTarget();
- return;
- }
-
- Set pairedDevices = btAdapter.getBondedDevices();
-
- for (BluetoothDevice device : pairedDevices) {
- // check if we can found bluetooth device name in the pairing list
- if (device.getName().equals(deviceName)) {
- btDevice = device;
-
- // Get a BluetoothSocket to connect with the given BluetoothDevice
- btSocket = btDevice.createRfcommSocketToServiceRecord(uuid);
- return;
- }
- }
-
- throw new IOException("Bluetooth device not found");
- }
-
- public void run() {
- while (!isCancel) {
- try {
- if (!btSocket.isConnected()) {
- // Connect the device through the socket. This will block
- // until it succeeds or throws an exception
- btSocket.connect();
- }
-
- // Bluetooth connection was successful
- Log.d("BluetoothCommunication", "Bluetooth connection successful established!");
- BluetoothConnectedThread btConnectThread = new BluetoothConnectedThread(btSocket, btHandler);
- btConnectThread.start();
- return;
-
- } catch (IOException connectException) {
- try {
- sleep(4000);
- } catch (InterruptedException e) {
- Log.e("BluetoothCommuncation", "Sleep error " + e.getMessage());
- }
- }
-
- }
- }
-
- public void cancel() {
- try {
- btSocket.close();
- isCancel = true;
- } catch (IOException e) { }
- }
-}
\ No newline at end of file
diff --git a/android_app/src/com/health/openscale/core/BluetoothConnectedThread.java b/android_app/src/com/health/openscale/core/BluetoothConnectedThread.java
deleted file mode 100644
index 903f1e97..00000000
--- a/android_app/src/com/health/openscale/core/BluetoothConnectedThread.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-package com.health.openscale.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import android.bluetooth.BluetoothSocket;
-import android.os.Handler;
-import android.util.Log;
-
-public class BluetoothConnectedThread extends Thread {
- private BluetoothSocket btSocket;
- private InputStream btInStream;
- private OutputStream btOutStream;
- private Handler btHandler;
-
- public BluetoothConnectedThread(BluetoothSocket socket, Handler handler) {
- btSocket = socket;
- btHandler = handler;
-
- // Get the input and output bluetooth streams
- try {
- btInStream = socket.getInputStream();
- btOutStream = socket.getOutputStream();
- } catch (IOException e) {
- Log.e("BluetoothConnectedThread", "Can't get bluetooth input or output stream " + e.getMessage());
- }
- }
-
- public void run() {
- final StringBuilder btLine = new StringBuilder();
-
- // Keep listening to the InputStream until an exception occurs (e.g. device partner goes offline)
- while (true) {
- try {
- // stream read is a blocking method
- char btChar = (char)btInStream.read();
-
- btLine.append(btChar);
-
- if (btLine.charAt(btLine.length()-1) == '\n'){
- btHandler.obtainMessage(BluetoothCommunication.BT_MESSAGE_READ, btLine.toString()).sendToTarget();
-
- btLine.setLength(0);
- }
-
- } catch (IOException e) {
- cancel();
- btHandler.obtainMessage(BluetoothCommunication.BT_SOCKET_CLOSED).sendToTarget();
- return;
- }
- }
- }
-
- public void write(byte[] bytes) {
- try {
- btOutStream.write(bytes);
- } catch (IOException e) { }
- }
-
- public void cancel() {
- try {
- btSocket.close();
- } catch (IOException e) {
- Log.e("BluetoothConnectedThread", "Error while closing bluetooth socket " + e.getMessage());
- }
- }
-}
\ No newline at end of file
diff --git a/android_app/src/com/health/openscale/core/OpenScale.java b/android_app/src/com/health/openscale/core/OpenScale.java
deleted file mode 100644
index d59db68d..00000000
--- a/android_app/src/com/health/openscale/core/OpenScale.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.core;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.Message;
-import android.util.Log;
-
-public class OpenScale {
-
- private static OpenScale instance;
-
- private ScaleDatabase scaleDB;
- private ArrayList scaleDBEntries;
-
- private BluetoothCommunication btCom;
- private String btDeviceName;
-
- private SimpleDateFormat dateTimeFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
-
- private OpenScale(Context con) {
- scaleDB = new ScaleDatabase(con);
- scaleDBEntries = scaleDB.getAllDBEntries();
- }
-
- public static OpenScale getInstance(Context con) {
- if (instance == null) {
- instance = new OpenScale(con);
- }
-
- return instance;
- }
-
- public ArrayList getScaleDBEntries() {
- return scaleDBEntries;
- }
-
- public void addScaleData(String date_time, float weight, float fat,
- float water, float muscle) {
- ScaleData scaleData = new ScaleData();
-
- try {
- scaleData.date_time = dateTimeFormat.parse(date_time);
- scaleData.weight = weight;
- scaleData.fat = fat;
- scaleData.water = water;
- scaleData.muscle = muscle;
- } catch (ParseException e) {
- Log.e("OpenScale", "Can't parse date time string while adding to the database");
- }
-
- scaleDB.insertEntry(scaleData);
-
- scaleDBEntries = scaleDB.getAllDBEntries();
- }
-
- public void importData(String filename) throws IOException {
- File file = new File(filename);
-
- FileInputStream inputStream = new FileInputStream(file);
-
- InputStreamReader inputReader = new InputStreamReader(inputStream);
- BufferedReader csvReader = new BufferedReader(inputReader);
-
- String line = csvReader.readLine();
-
- try {
- while (line != null) {
- String csvField[] = line.split(",");
-
- ScaleData newScaleData = new ScaleData();
-
- newScaleData.date_time = dateTimeFormat.parse(csvField[0]);
- newScaleData.weight = Float.parseFloat(csvField[1]);
- newScaleData.fat = Float.parseFloat(csvField[2]);
- newScaleData.water = Float.parseFloat(csvField[3]);
- newScaleData.muscle = Float.parseFloat(csvField[4]);
-
- scaleDB.insertEntry(newScaleData);
-
- line = csvReader.readLine();
- }
-
- } catch (ParseException e) {
- throw new IOException("Can't parse date format. Please set the date time format as (e.g. 31.10.2014 05:23)");
- }
-
- scaleDBEntries = scaleDB.getAllDBEntries();
-
- csvReader.close();
- inputReader.close();
- }
-
- public void exportData(String filename) throws IOException {
- File file = new File(filename);
- file.createNewFile();
-
- FileOutputStream outputStream = new FileOutputStream(file);
-
- OutputStreamWriter csvWriter = new OutputStreamWriter(outputStream);
-
- for (ScaleData scaleData : scaleDBEntries) {
- csvWriter.append(dateTimeFormat.format(scaleData.date_time) + ",");
- csvWriter.append(Float.toString(scaleData.weight) + ",");
- csvWriter.append(Float.toString(scaleData.fat) + ",");
- csvWriter.append(Float.toString(scaleData.water) + ",");
- csvWriter.append(Float.toString(scaleData.muscle));
- csvWriter.append("\n");
- }
-
- csvWriter.close();
- outputStream.close();
- }
-
- public void deleteAllDBEntries() {
- scaleDB.deleteAllEntries();
-
- scaleDBEntries = scaleDB.getAllDBEntries();
- }
-
- public void startBluetoothServer(String deviceName) {
- Log.d("OpenScale", "Bluetooth Server started! I am searching for device ...");
-
- btCom = new BluetoothCommunication(btHandler);
- btDeviceName = deviceName;
-
- try {
- btCom.findBT(btDeviceName);
- btCom.start();
- } catch (IOException e) {
- Log.e("OpenScale", "Error " + e.getMessage());
- }
- }
-
- public void stopBluetoothServer() {
- Log.d("OpenScale", "Bluetooth Server stopped!");
-
- if (btCom != null) {
- btCom.cancel();
- }
- }
-
- /**
- * The Handler that gets information back from the BluetoothChatService
- */
- private final Handler btHandler = new Handler() {
- @Override
- public void handleMessage(Message msg) {
-
- switch (msg.what) {
- case BluetoothCommunication.BT_MESSAGE_READ:
- String line = (String) msg.obj;
-
- parseBtString(line);
- break;
- case BluetoothCommunication.BT_SOCKET_CLOSED:
- scaleDBEntries = scaleDB.getAllDBEntries();
-
- Log.i("OpenScale", "Socket closed! Restarting socket ");
-
- startBluetoothServer(btDeviceName);
- break;
- case BluetoothCommunication.BT_NO_ADAPTER:
- Log.e("OpenScale", "No bluetooth adapter found!");
- break;
- }
- }
- };
-
- public void parseBtString(String btString) {
- btString = btString.substring(0, btString.length() - 1); // delete newline '\n' of the string
-
- if (btString.charAt(0) != '$' && btString.charAt(2) != '$') {
- Log.e("OpenScale", "Parse error of bluetooth string. String has not a valid format");
- return;
- }
-
- String btMsg = btString.substring(3, btString.length()); // message string
-
- switch (btString.charAt(1)) {
- case 'I':
- Log.i("OpenScale", "MCU Information: " + btMsg);
- break;
- case 'E':
- Log.e("OpenScale", "MCU Error: " + btMsg);
- break;
- case 'S':
- Log.i("OpenScale", "MCU stored data size: " + btMsg);
- break;
- case 'D':
- ScaleData scaleBtData = new ScaleData();
-
- String[] csvField = btMsg.split(",");
-
- try {
- int checksum = 0;
-
- checksum ^= Integer.parseInt(csvField[1]);
- checksum ^= Integer.parseInt(csvField[2]);
- checksum ^= Integer.parseInt(csvField[3]);
- checksum ^= Integer.parseInt(csvField[4]);
- checksum ^= Integer.parseInt(csvField[5]);
- checksum ^= (int)Float.parseFloat(csvField[6]);
- checksum ^= (int)Float.parseFloat(csvField[7]);
- checksum ^= (int)Float.parseFloat(csvField[8]);
- checksum ^= (int)Float.parseFloat(csvField[9]);
-
- int btChecksum = Integer.parseInt(csvField[10]);
-
- if (checksum == btChecksum) {
- scaleBtData.id = Long.parseLong(csvField[0]);
- String date_string = csvField[1] + "/" + csvField[2] + "/" + csvField[3] + "/" + csvField[4] + "/" + csvField[5];
- scaleBtData.date_time = new SimpleDateFormat("yyyy/MM/dd/HH/mm").parse(date_string);
-
- scaleBtData.weight = Float.parseFloat(csvField[6]);
- scaleBtData.fat = Float.parseFloat(csvField[7]);
- scaleBtData.water = Float.parseFloat(csvField[8]);
- scaleBtData.muscle = Float.parseFloat(csvField[9]);
-
- Log.i("OpenScale", "MCU Data: " + scaleBtData);
- scaleDB.insertEntry(scaleBtData);
- } else {
- Log.e("OpenScale", "Error calculated checksum (" + checksum + ") and received checksum (" + btChecksum + ") is different");
- }
- } catch (ParseException e) {
- Log.e("OpenScale", "Error while decoding bluetooth date string (" + e.getMessage() + ")");
- } catch (NumberFormatException e) {
- Log.e("OpenScale", "Error while decoding a number of bluetooth string (" + e.getMessage() + ")");
- }
- break;
- default:
- Log.e("OpenScale", "Error unknown MCU command");
- break;
- }
- }
-}
diff --git a/android_app/src/com/health/openscale/core/ScaleData.java b/android_app/src/com/health/openscale/core/ScaleData.java
deleted file mode 100644
index 43329f95..00000000
--- a/android_app/src/com/health/openscale/core/ScaleData.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.core;
-
-import java.util.Date;
-
-import android.util.Log;
-
-public class ScaleData {
- public long id;
- public Date date_time;
- public float weight;
- public float fat;
- public float water;
- public float muscle;
-
- @Override
- public String toString()
- {
- return "ID : " + id + " DATE_TIME: " + date_time.toString() + " WEIGHT: " + weight + " FAT: " + fat + " WATER: " + water + " MUSCLE: " + muscle;
- }
-}
diff --git a/android_app/src/com/health/openscale/core/ScaleDatabase.java b/android_app/src/com/health/openscale/core/ScaleDatabase.java
deleted file mode 100644
index 2384bbb1..00000000
--- a/android_app/src/com/health/openscale/core/ScaleDatabase.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.core;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Locale;
-
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-import android.database.sqlite.SQLiteDatabase.CursorFactory;
-import android.database.sqlite.SQLiteOpenHelper;
-import android.util.Log;
-
-public class ScaleDatabase extends SQLiteOpenHelper {
- private static final int DATABASE_VERSION = 1;
- private static final String DATABASE_NAME = "openScaleDatabase.db";
-
- private static final String TABLE_NAME = "scaledata";
- private static final String COLUMN_NAME_ID = "id";
- private static final String COLUMN_NAME_DATE_TIME = "date_time";
- private static final String COLUMN_NAME_WEIGHT = "weight";
- private static final String COLUMN_NAME_FAT = "fat";
- private static final String COLUMN_NAME_WATER = "water";
- private static final String COLUMN_NAME_MUSCLE = "muscle";
-
- private static final String SQL_CREATE_ENTRIES =
- "CREATE TABLE " + TABLE_NAME + " (" +
- COLUMN_NAME_ID + " INTEGER PRIMARY KEY," +
- COLUMN_NAME_DATE_TIME + " TEXT UNIQUE," +
- COLUMN_NAME_WEIGHT + " REAL," +
- COLUMN_NAME_FAT + " REAL," +
- COLUMN_NAME_WATER + " REAL," +
- COLUMN_NAME_MUSCLE + " REAL" +
- ")";
-
- private static final String SQL_DELETE_ENTRIES =
- "DROP TABLE IF EXISTS " + TABLE_NAME;
-
- private SimpleDateFormat formatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
-
- public ScaleDatabase(Context context) {
- super(context, DATABASE_NAME, null, DATABASE_VERSION);
- }
-
- @Override
- public void onCreate(SQLiteDatabase db) {
- db.execSQL(SQL_CREATE_ENTRIES);
- }
-
- @Override
- public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
- db.execSQL(SQL_DELETE_ENTRIES);
- onCreate(db);
- }
-
- public void deleteAllEntries() {
- SQLiteDatabase db = getWritableDatabase();
-
- db.delete(TABLE_NAME, null, null);
- }
-
- public void insertEntry(ScaleData scaleData) {
- SQLiteDatabase db = getWritableDatabase();
-
- // Create a new map of values, where column names are the keys
- ContentValues values = new ContentValues();
- values.put(COLUMN_NAME_DATE_TIME, formatDateTime.format(scaleData.date_time));
- values.put(COLUMN_NAME_WEIGHT, scaleData.weight);
- values.put(COLUMN_NAME_FAT, scaleData.fat);
- values.put(COLUMN_NAME_WATER, scaleData.water);
- values.put(COLUMN_NAME_MUSCLE, scaleData.muscle);
-
- // Insert the new row, returning the primary key value of the new row
- long newRowId = db.insert(TABLE_NAME, null, values);
-
- if (newRowId == -1) {
- Log.e("ScaleDatabase", "An error occured while inserting a new entry into the scale database");
- }
- }
-
- public ArrayList getAllDBEntries() {
- SQLiteDatabase db = getReadableDatabase();
- ArrayList scaleDBEntries = new ArrayList();
-
- // Define a projection that specifies which columns from the database
- // you will actually use after this query.
- String[] projection = {
- COLUMN_NAME_ID,
- COLUMN_NAME_DATE_TIME,
- COLUMN_NAME_WEIGHT,
- COLUMN_NAME_FAT,
- COLUMN_NAME_WATER,
- COLUMN_NAME_MUSCLE
- };
-
- // How you want the results sorted in the resulting Cursor
- String sortOrder = COLUMN_NAME_DATE_TIME + " DESC";
-
- Cursor cursorScaleDB = db.query(
- TABLE_NAME, // The table to query
- projection, // The columns to return
- null, // The columns for the WHERE clause
- null, // The values for the WHERE clause
- null, // don't group the rows
- null, // don't filter by row groups
- sortOrder // The sort order
- );
-
- try {
- cursorScaleDB.moveToFirst();
-
- while (!cursorScaleDB.isAfterLast()) {
- ScaleData dataEntry = new ScaleData();
-
- dataEntry.id = cursorScaleDB.getLong(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_ID));
- String date_time = cursorScaleDB.getString(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_DATE_TIME));
- dataEntry.weight = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WEIGHT));
- dataEntry.fat = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_FAT));
- dataEntry.water = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_WATER));
- dataEntry.muscle = cursorScaleDB.getFloat(cursorScaleDB.getColumnIndexOrThrow(COLUMN_NAME_MUSCLE));
-
- Date date = formatDateTime.parse(date_time);
-
- dataEntry.date_time = date;
-
- scaleDBEntries.add(dataEntry);
- //Log.d("ScaleDatabase", dataEntry.toString());
-
- cursorScaleDB.moveToNext();
- }
- } catch (ParseException ex) {
- Log.e("ScaleDatabase", "Can't parse the date time string: " + ex.getMessage());
- }
- catch ( IllegalArgumentException ex) {
- Log.e("ScaleDatabase", "Illegal argument while reading from scale database: " + ex.getMessage());
- }
-
-
- return scaleDBEntries;
- }
-}
diff --git a/android_app/src/com/health/openscale/gui/FragmentUpdateListener.java b/android_app/src/com/health/openscale/gui/FragmentUpdateListener.java
deleted file mode 100644
index f826ea62..00000000
--- a/android_app/src/com/health/openscale/gui/FragmentUpdateListener.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.gui;
-
-import java.util.ArrayList;
-
-import com.health.openscale.core.ScaleData;
-
-public interface FragmentUpdateListener {
- public void updateOnView(ArrayList scaleDBEntries);
-}
diff --git a/android_app/src/com/health/openscale/gui/GraphFragment.java b/android_app/src/com/health/openscale/gui/GraphFragment.java
deleted file mode 100644
index 81962caa..00000000
--- a/android_app/src/com/health/openscale/gui/GraphFragment.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.gui;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import lecho.lib.hellocharts.model.Axis;
-import lecho.lib.hellocharts.model.AxisValue;
-import lecho.lib.hellocharts.model.Line;
-import lecho.lib.hellocharts.model.LineChartData;
-import lecho.lib.hellocharts.model.PointValue;
-import lecho.lib.hellocharts.view.LineChartView;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import com.health.openscale.R;
-import com.health.openscale.core.ScaleData;
-
-public class GraphFragment extends Fragment implements FragmentUpdateListener {
- private View graphView;
- private LineChartView chartView;
-
- public GraphFragment() {
-
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
- graphView = inflater.inflate(R.layout.fragment_graph, container, false);
-
- chartView = (LineChartView) graphView.findViewById(R.id.data_chart);
-
- return graphView;
- }
-
- @Override
- public void updateOnView(ArrayList scaleDBEntries)
- {
- if (scaleDBEntries.isEmpty()) {
- LineChartData data = new LineChartData();
- chartView.setLineChartData(data);
-
- return;
- }
-
- List axisValues = new ArrayList();
- List valuesWeight = new ArrayList();
- List valuesFat = new ArrayList();
- List valuesWater = new ArrayList();
- List valuesMuscle = new ArrayList();
- List lines = new ArrayList();
-
-
- for(ScaleData scaleEntry: scaleDBEntries)
- {
- valuesWeight.add(new PointValue(scaleEntry.date_time.getTime(), scaleEntry.weight));
- valuesFat.add(new PointValue(scaleEntry.date_time.getTime(), scaleEntry.fat));
- valuesWater.add(new PointValue(scaleEntry.date_time.getTime(), scaleEntry.water));
- valuesMuscle.add(new PointValue(scaleEntry.date_time.getTime(), scaleEntry.muscle));
-
- axisValues.add(new AxisValue(scaleEntry.date_time.getTime(), DateFormat.getDateInstance(DateFormat.SHORT).format(scaleEntry.date_time).toCharArray()));
- }
-
- Line lineWeight = new Line(valuesWeight).setColor(Color.GREEN);
- Line lineFat = new Line(valuesFat).setColor(Color.RED);
- Line lineWater = new Line(valuesWater).setColor(Color.BLUE);
- Line lineMuscle = new Line(valuesMuscle).setColor(Color.GRAY);
-
- lines.add(lineWeight);
- lines.add(lineFat);
- lines.add(lineWater);
- lines.add(lineMuscle);
-
- lineWeight.setHasLabels(true);
- lineWeight.setHasLabelsOnlyForSelected(true);
- lineFat.setHasLabelsOnlyForSelected(true);
-
- LineChartData data = new LineChartData();
-
- Axis axisX = new Axis(axisValues);
- Axis axisY = new Axis();
-
- axisY.setHasLines(true);
-
- axisX.setName("Zeit");
- axisY.setName("Wert");
-
- axisX.setTextColor(Color.BLACK);
- axisY.setTextColor(Color.BLACK);
-
- data.setAxisXBottom(axisX);
- data.setAxisYLeft(axisY);
-
- data.setLines(lines);
-
- chartView.setLineChartData(data);
- }
-}
diff --git a/android_app/src/com/health/openscale/gui/MainActivity.java b/android_app/src/com/health/openscale/gui/MainActivity.java
deleted file mode 100644
index d76aa4af..00000000
--- a/android_app/src/com/health/openscale/gui/MainActivity.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-
-package com.health.openscale.gui;
-
-import java.util.Locale;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.app.FragmentTransaction;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.ActionBarActivity;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import com.health.openscale.R;
-import com.health.openscale.core.OpenScale;
-
-
-public class MainActivity extends ActionBarActivity implements
- ActionBar.TabListener {
-
- /**
- * The {@link android.support.v4.view.PagerAdapter} that will provide
- * fragments for each of the sections. We use a {@link FragmentPagerAdapter}
- * derivative, which will keep every loaded fragment in memory. If this
- * becomes too memory intensive, it may be best to switch to a
- * {@link android.support.v4.app.FragmentStatePagerAdapter}.
- */
- private SectionsPagerAdapter mSectionsPagerAdapter;
-
- /**
- * The {@link ViewPager} that will host the section contents.
- */
- private ViewPager mViewPager;
-
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- if(prefs.getBoolean("btEnable", true)) {
- Log.i("ASD", "BT TRZE");
- String deviceName = prefs.getString("btDeviceName", "openScale");
- OpenScale.getInstance(getApplicationContext()).startBluetoothServer(deviceName);
- }
-
- // Set up the action bar.
- final ActionBar actionBar = getSupportActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
-
- // Create the adapter that will return a fragment for each of the three
- // primary sections of the activity.
- mSectionsPagerAdapter = new SectionsPagerAdapter(
- getSupportFragmentManager(), this);
-
- // Set up the ViewPager with the sections adapter.
- mViewPager = (ViewPager) findViewById(R.id.pager);
- mViewPager.setAdapter(mSectionsPagerAdapter);
-
- // When swiping between different sections, select the corresponding
- // tab. We can also use ActionBar.Tab#select() to do this if we have
- // a reference to the Tab.
- mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
- @Override
- public void onPageSelected(int position) {
- actionBar.setSelectedNavigationItem(position);
-
- FragmentUpdateListener fragment = (FragmentUpdateListener) mSectionsPagerAdapter.instantiateItem(mViewPager, position);
- if (fragment != null) {
- fragment.updateOnView(OpenScale.getInstance(mViewPager.getContext()).getScaleDBEntries());
- }
- }
- });
-
- // For each of the sections in the app, add a tab to the action bar.
- for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
- // Create a tab with text corresponding to the page title defined by
- // the adapter. Also specify this Activity object, which implements
- // the TabListener interface, as the callback (listener) for when
- // this tab is selected.
- actionBar.addTab(actionBar.newTab()
- .setText(mSectionsPagerAdapter.getPageTitle(i))
- .setTabListener(this));
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.main, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // Handle action bar item clicks here. The action bar will
- // automatically handle clicks on the Home/Up button, so long
- // as you specify a parent activity in AndroidManifest.xml.
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- Intent intent = new Intent(this, SettingsActivity.class);
- startActivity(intent);
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- public void onTabSelected(ActionBar.Tab tab,
- FragmentTransaction fragmentTransaction) {
- // When the given tab is selected, switch to the corresponding page in
- // the ViewPager.
- mViewPager.setCurrentItem(tab.getPosition());
- }
-
- @Override
- public void onTabUnselected(ActionBar.Tab tab,
- FragmentTransaction fragmentTransaction) {
- }
-
- @Override
- public void onTabReselected(ActionBar.Tab tab,
- FragmentTransaction fragmentTransaction) {
- }
-
- /**
- * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
- * one of the sections/tabs/pages.
- */
- public class SectionsPagerAdapter extends FragmentPagerAdapter {
-
- private OverviewFragment overviewFrag;
- private GraphFragment graphFrag;
- private TableFragment tableFrag;
-
- public SectionsPagerAdapter(FragmentManager fm, Context con) {
- super(fm);
-
- overviewFrag = new OverviewFragment();
- graphFrag = new GraphFragment();
- tableFrag = new TableFragment();
- }
-
- @Override
- public Fragment getItem(int position) {
- // getItem is called to instantiate the fragment for the given page.
- // Return a PlaceholderFragment (defined as a static inner class
- // below).
-
- switch (position) {
- case 0:
- return overviewFrag;
- case 1:
- return graphFrag;
- case 2:
- return tableFrag;
- }
-
- return null;
- }
-
- @Override
- public int getCount() {
- return 3;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- Locale l = Locale.getDefault();
- switch (position) {
- case 0:
- return getString(R.string.title_overview).toUpperCase(l);
- case 1:
- return getString(R.string.title_graph).toUpperCase(l);
- case 2:
- return getString(R.string.title_frag).toUpperCase(l);
- }
- return null;
- }
- }
-}
diff --git a/android_app/src/com/health/openscale/gui/NewEntryActivity.java b/android_app/src/com/health/openscale/gui/NewEntryActivity.java
deleted file mode 100644
index 1f537282..00000000
--- a/android_app/src/com/health/openscale/gui/NewEntryActivity.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-package com.health.openscale.gui;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import android.app.Activity;
-import android.app.DatePickerDialog;
-import android.app.TimePickerDialog;
-import android.content.Context;
-import android.os.Bundle;
-import android.support.v4.app.FragmentTransaction;
-import android.view.View;
-import android.widget.Button;
-import android.widget.DatePicker;
-import android.widget.EditText;
-import android.widget.TimePicker;
-
-import com.health.openscale.R;
-import com.health.openscale.core.OpenScale;
-
-public class NewEntryActivity extends Activity {
-
- private EditText txtWeight;
- private EditText txtFat;
- private EditText txtWater;
- private EditText txtMuscle;
- private EditText txtDate;
- private EditText txtTime;
-
- private SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
- private SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm");
-
- private Context context;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_newentry);
- context = this;
-
- txtWeight = (EditText) findViewById(R.id.txtWeight);
- txtFat = (EditText) findViewById(R.id.txtFat);
- txtWater = (EditText) findViewById(R.id.txtWater);
- txtMuscle = (EditText) findViewById(R.id.txtMuscle);
- txtDate = (EditText) findViewById(R.id.txtDate);
- txtTime = (EditText) findViewById(R.id.txtTime);
- Button btnDateSet = (Button) findViewById(R.id.btnDateSet);
- Button btnTimeSet = (Button) findViewById(R.id.btnTimeSet);
-
- findViewById(R.id.btnAdd).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- btnOnClickAdd();
- }
- });
-
- findViewById(R.id.btnCancel).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- btnOnClickCancel();
- }
- });
-
- btnDateSet.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- Calendar cal = Calendar.getInstance();
- DatePickerDialog datePicker = new DatePickerDialog(context, datePickerListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
- datePicker.show();
- }
- });
-
- btnTimeSet.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- Calendar cal = Calendar.getInstance();
- TimePickerDialog timePicker = new TimePickerDialog(context, timePickerListener, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
- timePicker.show();
- }
- });
-
- txtDate.setText(dateFormat.format(new Date()));
- txtTime.setText(timeFormat.format(new Date()));
- }
-
- private boolean validateInput()
- {
- boolean validate = true;
-
- if( txtWeight.getText().toString().length() == 0 )
- {
- txtWeight.setError("Weight value ist required!");
- validate = false;
- } else if( !(Float.valueOf(txtWeight.getText().toString()) >= 0 && Float.valueOf(txtWeight.getText().toString()) <= 300) )
- {
- txtWeight.setError("Value must be in range from 0 to 300!");
- validate = false;
- }
-
- if( txtFat.getText().toString().length() == 0 )
- {
- txtFat.setError("Fat value ist required!");
- validate = false;
- } else if(!isInRange(txtFat.getText().toString()))
- {
- txtFat.setError("Value must be in range from 0 to 100");
- validate = false;
- }
-
-
- if( txtWater.getText().toString().length() == 0 )
- {
- txtWater.setError("Water value ist required!");
- validate = false;
- } else if(!isInRange(txtWater.getText().toString()))
- {
- txtWater.setError("Value must be in range from 0 to 100");
- validate = false;
- }
-
- if( txtMuscle.getText().toString().length() == 0 )
- {
- txtMuscle.setError("Muscle value ist required!");
- validate = false;
- } else if(!isInRange(txtMuscle.getText().toString()))
- {
- txtMuscle.setError("Value must be in range from 0 to 100");
- validate = false;
- }
-
- return validate;
- }
-
- private boolean isInRange(String value)
- {
- if (value.length() == 0)
- return false;
-
- float val = Float.valueOf(value);
-
- if (val >= 0 && val <= 100)
- return true;
-
- return false;
- }
-
- public void btnOnClickAdd()
- {
- if (validateInput())
- {
- OpenScale openScale = OpenScale.getInstance(context);
-
- float weight = Float.valueOf(txtWeight.getText().toString());
- float fat = Float.valueOf(txtFat.getText().toString());
- float water = Float.valueOf(txtWater.getText().toString());
- float muscle = Float.valueOf(txtMuscle.getText().toString());
-
- String date = txtDate.getText().toString();
- String time = txtTime.getText().toString();
-
- openScale.addScaleData(date + " " + time, weight, fat, water, muscle);
-
- finish();
- }
- }
-
- public void btnOnClickCancel()
- {
- finish();
- }
-
- private DatePickerDialog.OnDateSetListener datePickerListener = new DatePickerDialog.OnDateSetListener() {
- @Override
- public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) {
- txtDate.setText(String.format("%02d.%02d.%04d", selectedDay, selectedMonth+1, selectedYear));
- }
- };
-
- private TimePickerDialog.OnTimeSetListener timePickerListener = new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
- txtTime.setText(String.format("%02d:%02d", hourOfDay, minute));
- }
- };
-
-}
diff --git a/android_app/src/com/health/openscale/gui/OverviewFragment.java b/android_app/src/com/health/openscale/gui/OverviewFragment.java
deleted file mode 100644
index 5cb3ac66..00000000
--- a/android_app/src/com/health/openscale/gui/OverviewFragment.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-package com.health.openscale.gui;
-
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import lecho.lib.hellocharts.model.ArcValue;
-import lecho.lib.hellocharts.model.PieChartData;
-import lecho.lib.hellocharts.util.Utils;
-import lecho.lib.hellocharts.view.PieChartView;
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.health.openscale.R;
-import com.health.openscale.core.OpenScale;
-import com.health.openscale.core.ScaleData;
-
-public class OverviewFragment extends Fragment implements FragmentUpdateListener {
- private View overviewView;
- private PieChartView pieChart;
- private TextView txtAvgWeight;
- private TextView txtAvgFat;
- private TextView txtAvgWater;
- private TextView txtAvgMuscle;
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
- overviewView = inflater.inflate(R.layout.fragment_overview, container, false);
-
- pieChart = (PieChartView) overviewView.findViewById(R.id.data_pie_chart);
- txtAvgWeight = (TextView) overviewView.findViewById(R.id.txtAvgWeight);
- txtAvgFat = (TextView) overviewView.findViewById(R.id.txtAvgFat);
- txtAvgWater = (TextView) overviewView.findViewById(R.id.txtAvgWater);
- txtAvgMuscle = (TextView) overviewView.findViewById(R.id.txtAvgMuscle);
-
- overviewView.findViewById(R.id.btnInsertData).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- btnOnClickInsertData();
- }
- });
-
- updateOnView(OpenScale.getInstance(overviewView.getContext()).getScaleDBEntries());
-
- return overviewView;
- }
-
- @Override
- public void updateOnView(ArrayList scaleDBEntries)
- {
- List arcValues = new ArrayList();
-
- if (scaleDBEntries.isEmpty()) {
- return;
- }
-
- ScaleData lastEntry = scaleDBEntries.get(0);
-
- arcValues.add(new ArcValue((float) lastEntry.fat, Utils.COLOR_ORANGE));
- arcValues.add(new ArcValue((float) lastEntry.water, Utils.COLOR_BLUE));
- arcValues.add(new ArcValue((float) lastEntry.muscle, Utils.COLOR_GREEN));
-
- PieChartData pieChartData = new PieChartData(arcValues);
- pieChartData.setHasLabels(true);
- pieChartData.setHasCenterCircle(true);
- pieChartData.setCenterText1(Float.toString(lastEntry.weight) + " kg");
- pieChartData.setCenterText1FontSize(35);
- pieChartData.setCenterText2(new SimpleDateFormat("dd. MMM yyyy (EE)").format(lastEntry.date_time));
- pieChartData.setCenterText2FontSize(15);
-
- pieChart.setPieChartData(pieChartData);
-
- double avgWeight = 0;
- double avgFat = 0;
- double avgWater = 0;
- double avgMuscle = 0;
-
- for (ScaleData scaleData : scaleDBEntries)
- {
- avgWeight += scaleData.weight;
- avgFat += scaleData.fat;
- avgWater += scaleData.water;
- avgMuscle += scaleData.muscle;
- }
-
- avgWeight = avgWeight / scaleDBEntries.size();
- avgFat = avgFat / scaleDBEntries.size();
- avgWater = avgWater / scaleDBEntries.size();
- avgMuscle = avgMuscle / scaleDBEntries.size();
-
- txtAvgWeight.setText(String.format( "%.1f kg", avgWeight));
- txtAvgFat.setText(String.format( "%.1f %%", avgFat));
- txtAvgWater.setText(String.format( "%.1f %%", avgWater));
- txtAvgMuscle.setText(String.format( "%.1f %%", avgMuscle));
- }
-
- public void btnOnClickInsertData()
- {
- Intent intent = new Intent(overviewView.getContext(), NewEntryActivity.class);
- startActivity(intent);
- }
-
-}
diff --git a/android_app/src/com/health/openscale/gui/SettingsActivity.java b/android_app/src/com/health/openscale/gui/SettingsActivity.java
deleted file mode 100644
index 3448c14a..00000000
--- a/android_app/src/com/health/openscale/gui/SettingsActivity.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-package com.health.openscale.gui;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
-import android.os.Bundle;
-import android.preference.EditTextPreference;
-import android.preference.ListPreference;
-import android.preference.MultiSelectListPreference;
-import android.preference.Preference;
-import android.preference.PreferenceActivity;
-import android.preference.PreferenceGroup;
-import android.preference.PreferenceManager;
-import android.util.Log;
-
-import com.health.openscale.R;
-import com.health.openscale.core.OpenScale;
-
-public class SettingsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
-
-@Override
-protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- addPreferencesFromResource(R.xml.preferences);
- initSummary(getPreferenceScreen());
-}
-
-@Override
-protected void onResume() {
- super.onResume();
- // Set up a listener whenever a key changes
- getPreferenceScreen().getSharedPreferences()
- .registerOnSharedPreferenceChangeListener(this);
-}
-
-@Override
-protected void onPause() {
- super.onPause();
- // Unregister the listener whenever a key changes
- getPreferenceScreen().getSharedPreferences()
- .unregisterOnSharedPreferenceChangeListener(this);
-}
-
-@Override
-public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- updatePrefSummary(findPreference(key));
-
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
-
- if(prefs.getBoolean("btEnable", true))
- {
- String deviceName = prefs.getString("btDeviceName", "openScale");
- OpenScale.getInstance(getApplicationContext()).startBluetoothServer(deviceName);
- } else {
- OpenScale.getInstance(getApplicationContext()).stopBluetoothServer();
- }
-}
-
-private void initSummary(Preference p) {
- if (p instanceof PreferenceGroup) {
- PreferenceGroup pGrp = (PreferenceGroup) p;
- for (int i = 0; i < pGrp.getPreferenceCount(); i++) {
- initSummary(pGrp.getPreference(i));
- }
- } else {
- updatePrefSummary(p);
- }
-}
-
-private void updatePrefSummary(Preference p) {
- if (p instanceof ListPreference) {
- ListPreference listPref = (ListPreference) p;
- p.setSummary(listPref.getEntry());
- }
- if (p instanceof EditTextPreference) {
- EditTextPreference editTextPref = (EditTextPreference) p;
- if (p.getTitle().toString().contains("assword"))
- {
- p.setSummary("******");
- } else {
- p.setSummary(editTextPref.getText());
- }
- }
- if (p instanceof MultiSelectListPreference) {
- EditTextPreference editTextPref = (EditTextPreference) p;
- p.setSummary(editTextPref.getText());
- }
-
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
- if(prefs.getBoolean("btEnable", true))
- {
- findPreference("btDeviceName").setEnabled(true);
- } else {
- findPreference("btDeviceName").setEnabled(false);
- }
-}
-
-}
diff --git a/android_app/src/com/health/openscale/gui/TableFragment.java b/android_app/src/com/health/openscale/gui/TableFragment.java
deleted file mode 100644
index 72535839..00000000
--- a/android_app/src/com/health/openscale/gui/TableFragment.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/* Copyright (C) 2014 olie.xdev
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see
-*/
-package com.health.openscale.gui;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-
-import android.app.AlertDialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.os.Environment;
-import android.support.v4.app.Fragment;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.EditText;
-import android.widget.TableLayout;
-import android.widget.TableRow;
-import android.widget.TableRow.LayoutParams;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.health.openscale.R;
-import com.health.openscale.core.OpenScale;
-import com.health.openscale.core.ScaleData;
-
-public class TableFragment extends Fragment implements FragmentUpdateListener {
- private View tableView;
- private TableLayout tableDataView;
-
- public TableFragment() {
-
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
- {
- tableView = inflater.inflate(R.layout.fragment_table, container, false);
-
- tableDataView = (TableLayout) tableView.findViewById(R.id.tableDataView);
-
- tableView.findViewById(R.id.btnImportData).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- openImportDialog();
- }
- });
-
- tableView.findViewById(R.id.btnExportData).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- openExportDialog();
- }
- });
-
- tableView.findViewById(R.id.btnDeleteAll).setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- openDeleteAllDialog();
- }
- });
-
- return tableView;
- }
-
- @Override
- public void updateOnView(ArrayList scaleDBEntries)
- {
- TableRow headerRow = (TableRow) tableView.findViewById(R.id.tableHeader);
- tableDataView.removeAllViews();
- tableDataView.addView(headerRow);
-
- for(ScaleData scaleEntry: scaleDBEntries)
- {
- TableRow dataRow = new TableRow(tableView.getContext());
- dataRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
-
- TextView dateTextView = new TextView(tableView.getContext());
- dateTextView.setText(new SimpleDateFormat("dd. MMM yyyy (EE)").format(scaleEntry.date_time));
- dateTextView.setPadding(5, 5, 5, 5);
- dataRow.addView(dateTextView);
-
- TextView timeTextView = new TextView(tableView.getContext());
- timeTextView.setText(new SimpleDateFormat("HH:mm").format(scaleEntry.date_time));
- timeTextView.setPadding(5, 5, 5, 5);
- dataRow.addView(timeTextView);
-
- TextView weightView = new TextView(tableView.getContext());
- weightView.setText(Float.toString(scaleEntry.weight));
- weightView.setPadding(5, 5, 5, 5);
- dataRow.addView(weightView);
-
- TextView fatView = new TextView(tableView.getContext());
- fatView.setText(Float.toString(scaleEntry.fat));
- fatView.setPadding(5, 5, 5, 5);
- dataRow.addView(fatView);
-
- TextView waterView = new TextView(tableView.getContext());
- waterView.setText(Float.toString(scaleEntry.water));
- waterView.setPadding(5, 5, 5, 5);
- dataRow.addView(waterView);
-
- TextView muscleView = new TextView(tableView.getContext());
- muscleView.setText(Float.toString(scaleEntry.muscle));
- muscleView.setPadding(5, 5, 5, 5);
- dataRow.addView(muscleView);
-
- tableDataView.addView(dataRow, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
- }
- }
-
- public void openImportDialog()
- {
- AlertDialog.Builder filenameDialog = new AlertDialog.Builder(getActivity());
-
- filenameDialog.setTitle("Set filename on /sdcard ...");
-
- final EditText txtFilename = new EditText(tableView.getContext());
- txtFilename.setText("/openScale_data.csv");
-
- filenameDialog.setView(txtFilename);
-
- filenameDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- boolean isError = false;
-
- try {
- OpenScale.getInstance(tableView.getContext()).importData(Environment.getExternalStorageDirectory().getPath() + txtFilename.getText().toString());
- } catch (IOException e) {
- Toast.makeText(tableView.getContext(), "Error importing " + e.getMessage(), Toast.LENGTH_SHORT).show();
- isError = true;
- }
-
- if (!isError) {
- Toast.makeText(tableView.getContext(), "Data imported from /sdcard" + txtFilename.getText().toString(), Toast.LENGTH_SHORT).show();
- updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDBEntries());
- }
- }
- });
-
- filenameDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.dismiss();
- }
- });
-
-
- filenameDialog.show();
- }
-
- public void openExportDialog()
- {
- AlertDialog.Builder filenameDialog = new AlertDialog.Builder(getActivity());
-
- filenameDialog.setTitle("Set filename on /sdcard ...");
-
- final EditText txtFilename = new EditText(tableView.getContext());
- txtFilename.setText("/openScale_data.csv");
-
- filenameDialog.setView(txtFilename);
-
- filenameDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- boolean isError = false;
-
- try {
- OpenScale.getInstance(tableView.getContext()).exportData(Environment.getExternalStorageDirectory().getPath() + txtFilename.getText().toString());
- } catch (IOException e) {
- Toast.makeText(tableView.getContext(), "Error exporting " + e.getMessage(), Toast.LENGTH_SHORT).show();
- isError = true;
- }
-
- if (!isError) {
- Toast.makeText(tableView.getContext(), "Data exported to /sdcard" + txtFilename.getText().toString(), Toast.LENGTH_SHORT).show();
- }
- }
- });
-
- filenameDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.dismiss();
- }
- });
-
-
- filenameDialog.show();
- }
-
- public void openDeleteAllDialog()
- {
- AlertDialog.Builder deleteAllDialog = new AlertDialog.Builder(getActivity());
-
- deleteAllDialog.setMessage("Do you really want to delete all database entries?");
-
- deleteAllDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- OpenScale.getInstance(tableView.getContext()).deleteAllDBEntries();
-
- Toast.makeText(tableView.getContext(), "All database entries deleted!", Toast.LENGTH_SHORT).show();
- updateOnView(OpenScale.getInstance(tableView.getContext()).getScaleDBEntries());
- }
- });
-
- deleteAllDialog.setNegativeButton("No", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.dismiss();
- }
- });
-
- deleteAllDialog.show();
- }
-}